30 template<
class T,
int _Rows,
int _Cols>
31 class gsAsMatrix :
public gsEigen::Map< gsEigen::Matrix<T,_Rows,_Cols> >
34 typedef gsEigen::Map< gsEigen::Matrix<T,_Rows,_Cols> > Base;
37 typedef typename gsMatrix< T, _Rows, _Cols>::FirstMinorMatrixType FirstMinorMatrixType;
40 typedef typename gsMatrix< T, _Rows, _Cols>::RowMinorMatrixType RowMinorMatrixType;
43 typedef typename gsMatrix< T, _Rows, _Cols>::ColMinorMatrixType ColMinorMatrixType;
46 typedef gsEigen::Transpose<Base> Tr;
49 typedef const gsEigen::Transpose<const Base> constTr;
53 : Base( v.data(), n, m)
59 gsAsMatrix( std::vector<T> & v)
60 : Base( v.data(), 1, v.size() )
65 gsAsMatrix( T * pt,
unsigned n,
unsigned m)
76 template <
class EigenExpr>
77 gsAsMatrix& operator= (
const EigenExpr & other)
79 this->Base::operator=(other);
83 using Base::operator=;
91 const index_t mrows = this->rows()-1,
92 mcols = this->cols()-1;
95 result.resize(mrows,mcols);
96 result.block(0,0,i,j) = this->block(0,0,i,j);
97 result.block(i,0,mrows-i,j) = this->block(i+1,0,mrows-i,j);
98 result.block(0,j,i,mcols-j) = this->block(0,j+1,i,mcols-j);
99 result.block(i,j,mrows-i,mcols-j) = this->block(i+1,j+1,mrows-i,mcols-j);
107 const index_t mrows = this->rows()-1;
109 result.resize(mrows, this->cols());
110 result.topRows(i) = this->topRows(i);
111 result.bottomRows(mrows-i) = this->bottomRows(mrows-i);
119 const index_t mcols = this->cols()-1;
120 GISMO_ASSERT( 0 <= j && j <= mcols,
"Invalid column." );
121 result.resize( this->rows(), mcols);
122 result.leftCols(j) = this->leftCols(j);
123 result.rightCols(mcols-j) = this->rightCols(mcols-j);
139 template<
class T,
int _Rows,
int _Cols>
140 class gsAsConstMatrix :
public gsEigen::Map< const gsEigen::Matrix<T,_Rows,_Cols> >
143 typedef gsEigen::Map<const gsEigen::Matrix<T,_Rows,_Cols> > Base;
146 typedef gsEigen::Transpose<Base> Tr;
149 typedef const gsEigen::Transpose<const Base> constTr;
152 typedef typename gsMatrix< T, _Rows, _Cols>::FirstMinorMatrixType FirstMinorMatrixType;
155 typedef typename gsMatrix< T, _Rows, _Cols>::RowMinorMatrixType RowMinorMatrixType;
158 typedef typename gsMatrix< T, _Rows, _Cols>::ColMinorMatrixType ColMinorMatrixType;
163 : Base( v.data(), n, m)
168 gsAsConstMatrix(
const std::vector<T> & v)
169 : Base( v.data(), 1, v.size() )
174 gsAsConstMatrix(
const T * pt,
unsigned n,
unsigned m)
175 : Base( pt, n, m) { }
177 gsAsConstMatrix(
const gsEigen::Map< gsEigen::Matrix<T,_Rows,_Cols> > & mat)
178 : Base( mat.data(), mat.rows(), mat.cols())
188 const index_t mrows = this->rows()-1,
189 mcols = this->cols()-1;
192 result.resize(mrows,mcols);
193 result.block(0,0,i,j) = this->block(0,0,i,j);
194 result.block(i,0,mrows-i,j) = this->block(i+1,0,mrows-i,j);
195 result.block(0,j,i,mcols-j) = this->block(0,j+1,i,mcols-j);
196 result.block(i,j,mrows-i,mcols-j) = this->block(i+1,j+1,mrows-i,mcols-j);
204 const index_t mrows = this->rows()-1;
206 result.resize(mrows, this->cols());
207 result.topRows(i) = this->topRows(i);
208 result.bottomRows(mrows-i) = this->bottomRows(mrows-i);
216 const index_t mcols = this->cols()-1;
217 GISMO_ASSERT( 0 <= j && j <= mcols,
"Invalid column." );
218 result.resize( this->rows(), mcols);
219 result.leftCols(j) = this->leftCols(j);
220 result.rightCols(mcols-j) = this->rightCols(mcols-j);
236 template<
class T,
int _Rows>
237 class gsAsVector :
public gsAsMatrix<T,_Rows,1>
243 typedef gsAsMatrix<T,_Rows,1> Base;
246 typedef gsEigen::PermutationMatrix<_Rows> Permutation;
249 gsAsVector( std::vector<T> & v)
250 : Base( v.data(), v.size(), 1 )
255 gsAsVector( T * pt,
unsigned n)
256 : Base( pt, n, 1) { }
259 template <
class EigenExpr>
260 gsAsVector& operator= (
const EigenExpr & other)
262 this->Base::operator=(other);
266 using Base::operator=;
282 template<
class T,
int _Rows>
284 class gsAsConstVector :
public gsAsConstMatrix<T,_Rows,1>
289 typedef gsAsConstMatrix<T,_Rows,1> Base;
293 gsAsConstVector(
const std::vector<T> & v)
294 : Base( v.data(), v.size(), 1)
299 gsAsConstVector(
const T * pt,
unsigned n)
300 : Base( pt, n, 1) { }
303 gsAsConstVector() { }
308 template<
class T,
class iterator>
312 for (
index_t i = 0; i!=n; ++i)
313 for (
index_t j = 0; j!=m; ++j)
314 result(i,j)= *(it++);
void firstMinor(index_t i, index_t j, FirstMinorMatrixType &result) const
Definition: gsAsMatrix.h:186
Creates a mapped object or data pointer to a matrix without copying data.
Definition: gsLinearAlgebra.h:126
void rowMinor(index_t i, RowMinorMatrixType &result) const
Definition: gsAsMatrix.h:202
#define index_t
Definition: gsConfig.h:32
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition: gsMatrix.h:38
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
gsMatrix< T > makeMatrix(iterator it, index_t n, index_t m)
Utility to make a matrix out of an iterator to values.
Definition: gsAsMatrix.h:309
Creates a mapped object or data pointer to a const matrix without copying data.
Definition: gsLinearAlgebra.h:127
void colMinor(index_t j, ColMinorMatrixType &result) const
Definition: gsAsMatrix.h:214
void colMinor(index_t j, ColMinorMatrixType &result) const
Definition: gsAsMatrix.h:117
void firstMinor(index_t i, index_t j, FirstMinorMatrixType &result) const
Definition: gsAsMatrix.h:89
void rowMinor(index_t i, RowMinorMatrixType &result) const
Definition: gsAsMatrix.h:105