G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsMatrix.h
Go to the documentation of this file.
1 
14 # pragma once
15 
16 
17 namespace gismo
18 {
19 
37 template<class T, int _Rows, int _Cols, int _Options>
38 class gsMatrix : public gsEigen::Matrix<T,_Rows, _Cols, _Options>
39 //i.e. gsEigen::PlainObjectBase<gsEigen::Matrix>
40 //i.e. gsEigen::EigenBase<gsEigen::Matrix>
41 {
42 public:
43  // Base is the dense matrix class of Eigen
44  typedef gsEigen::Matrix<T,_Rows, _Cols, _Options> Base;
45 
46  // Self type
48 
49  // The type of the coefficients of the matrix
50  typedef T Scalar_t;
51 
52  typedef typename gsEigen::aligned_allocator<Self> aalloc;
53 
54  // Type pointing to a block view of the matrix
56 
57  // Type pointing to a block of the matrix
58  typedef gsEigen::Block<Base> Block;
59 
60  // Type pointing to a (const) block of the matrix
61  typedef gsEigen::Block<const Base> constBlock;
62 
63  // Type pointing to a row of the matrix
64  typedef gsEigen::Block<Base, 1, _Cols, false> Row;
65 
66  // Type pointing to a (const) row of the matrix
67  typedef gsEigen::Block<const Base, 1, _Cols, false> constRow;
68 
69  // Type pointing to a set of successive rows of the matrix
70  typedef gsEigen::Block<Base, Dynamic, _Cols, false> Rows;
71 
72  // Type pointing to a a set of successive (const) rows of the matrix
73  typedef gsEigen::Block<const Base, Dynamic, _Cols, false> constRows;
74 
75  // Type pointing to a column of the matrix
76  typedef gsEigen::Block<Base, _Rows, 1, true > Column;
77 
78  // Type pointing to a (const) column of the matrix
79  typedef gsEigen::Block<const Base, _Rows, 1, true > constColumn;
80 
81  // Type pointing to a set of successive columns of the matrix
82  typedef gsEigen::Block<Base, _Rows, Dynamic, true > Columns;
83 
84  // Type pointing to a set of successive (const) columns of the matrix
85  typedef gsEigen::Block<const Base, _Rows, Dynamic, true > constColumns;
86 
87  // Type pointing to the transpose of the matrix
88  typedef gsEigen::Transpose<Base> Tr;
89 
90  // Type pointing to the (const) transpose of the matrix
91  typedef const gsEigen::Transpose<const Base> constTr;
92 
93  // Type refering to any possible Eigen type that can be copied
94  // into a gsMatrix
95  typedef gsEigen::Ref<Base> Ref;
96 
97  // Type refering to any (const) possible Eigen types that can be
98  // copied into a gsMatrix
99  typedef const gsEigen::Ref<const Base> constRef;
100 
102  typedef memory::shared_ptr<gsMatrix> Ptr;
103 
105  typedef memory::unique_ptr<gsMatrix> uPtr;
106 
107  // type of first minor matrix: rows and cols reduced by one
108  typedef gsMatrix< T, ChangeDim<_Rows, -1>::D, ChangeDim<_Cols, -1>::D>
110 
111  // type of row minor matrix: rows reduced by one
112  typedef gsMatrix< T, ChangeDim<_Rows, -1>::D, _Cols>
114 
115  // type of col minor matrix: cols reduced by one
116  typedef gsMatrix< T, _Rows, ChangeDim<_Cols, -1>::D>
118 
119  // block of fixed size 3
120  typedef gsEigen::VectorBlock<gsEigen::Block<gsEigen::Matrix<T,_Rows,_Cols>,-1,1,true>,3> Col3DType;
121  typedef gsEigen::VectorBlock<const gsEigen::Block<const gsEigen::Matrix<T,_Rows,_Cols>,-1,1,true>,3> CCol3DType;
122 
123 public: // Solvers related to gsMatrix
124  typedef typename gsEigen::EigenSolver<Base> EigenSolver;
125 
126  typedef typename gsEigen::SelfAdjointEigenSolver<Base> SelfAdjEigenSolver;
127 
128  typedef typename gsEigen::GeneralizedSelfAdjointEigenSolver<Base> GenSelfAdjEigenSolver;
129 
130  // Jacobi SVD using ColPivHouseholderQRPreconditioner
131  typedef typename gsEigen::JacobiSVD<Base> JacobiSVD;
132 
133  // Bidiagonal Divide and Conquer SVD
134  //typedef typename gsEigen::BDCSVD<Base> BDCSVD;
135 
136  //typedef typename gsEigen::CompleteOrthogonalDecomposition CODecomposition;
137 
138 public:
139 
140  gsMatrix() { }
141 
142  gsMatrix(const Base& a) ;
143 
144  // implicitly deleted in C++11
145  //gsMatrix(const gsMatrix& a) : Base(a) { }
146 
147  gsMatrix(int rows, int cols) ;
148 
150  template<typename OtherDerived>
151  gsMatrix(const gsEigen::EigenBase<OtherDerived>& other) : Base(other) { }
152 
154  template<typename OtherDerived>
155  gsMatrix(const gsEigen::MatrixBase<OtherDerived>& other) : Base(other) { }
156 
158  template<typename OtherDerived>
159  gsMatrix(const gsEigen::ReturnByValue<OtherDerived>& other) : Base(other) { }
160 
161  inline operator Ref () { return Ref(*this); }
162 
163  inline operator const constRef () { return constRef(*this); }
164 
171  {
172  uPtr m(new gsMatrix);
173  m->swap(*this);
174  return m;
175  //return uPtr(new gsMatrix<T>(give(*this)));
176  }
177 
178  void clear() { this->resize(0,0); }
179 /*
180  // Using the assignment operators of Eigen
181  // Note: using Base::operator=; is ambiguous in MSVC
182 #ifdef _MSC_VER // && !__INTEL_COMPILER
183  template <class EigenExpr>
184  gsMatrix& operator= (const EigenExpr & other)
185  {
186  this->Base::operator=(other);
187  return *this;
188  }
189 #else
190  using Base::operator=;
191 #endif
192 */
193 
194 #if !EIGEN_HAS_RVALUE_REFERENCES
195  // swap assignment operator
196  gsMatrix & operator=(typename gsEigen::internal::conditional<
197  -1==_Rows,gsMatrix, const gsMatrix &>::type other)
198  {
199  if (-1==_Rows)
200  this->swap(other);
201  else
202  this->Base::operator=(other);
203  return *this;
204  }
205 #endif
206 
207  std::pair<index_t,index_t> dim() const
208  { return std::make_pair(this->rows(), this->cols() ); }
209 
211  T at (index_t i) const { return *(this->data()+i);}
212 
214  T & at (index_t i) { return *(this->data()+i);}
215 
216  // \brief Returns the last element of the matrix (maximum row and column)
217  //T lastCoeff() { return *(this->data()+this->size()-1);}
218 
222  { return gsAsMatrix<T, Dynamic, Dynamic>(this->data(), n, m); }
223 
227  { return gsAsConstMatrix<T, Dynamic, Dynamic>(this->data(), n, m); }
228 
232  { return gsAsMatrix<T, Dynamic, Dynamic>(this->col(c).data(), n, m); }
233 
237  { return gsAsConstMatrix<T, Dynamic, Dynamic>(this->col(c).data(), n, m); }
238 
241  { return gsAsVector<T, Dynamic>(this->data(), this->rows()*this->cols() ); }
242 
244  Col3DType col3d(index_t c) { return this->col(c).template head<3>(); }
245  CCol3DType col3d(index_t c) const { return this->col(c).template head<3>(); }
246 
249  { return gsAsConstVector<T, Dynamic>(this->data(), this->rows()*this->cols() ); }
250 
254  { return gsAsMatrix<T, 1, Dynamic>(this->data(), 1, this->rows()*this->cols() ); }
255 
259  { return gsAsConstMatrix<T, 1, Dynamic>(this->data(), 1, this->rows()*this->cols() ); }
260 
263  template<class container>
264  void submatrixCols(const container & colInd, gsMatrix<T> & result) const
265  {
266  //GISMO_ASSERT(colInd.cols() == 1, "Invalid column index vector");
267  const index_t nc = colInd.size();
268  result.resize(this->rows(), nc );
269  for ( index_t i = 0; i!= nc; ++i )
270  result.col(i) = this->col( colInd[i] );
271  }
272 
275  template<class container>
276  void submatrixRows(const container & rowInd, gsMatrix<T> & result) const
277  {
278  //GISMO_ASSERT(rowInd.cols() == 1, "Invalid row index vector");
279  const index_t nr = rowInd.size();
280  result.resize(nr, this->cols() );
281  for ( index_t i = 0; i!= nr; ++i )
282  result.row(i) = this->row( rowInd[i] );
283  }
284 
287  template<class container>
288  void submatrix(const container & rowInd,
289  const container & colInd,
290  gsMatrix<T> & result) const
291  {
292  //GISMO_ASSERT(rowInd.cols() == 1 && colInd.cols() == 1, "Invalid index vector");
293  const index_t nr = rowInd.size();
294  const index_t nc = colInd.size();
295  result.resize(nr, nc );
296  for ( index_t i = 0; i!= nr; ++i )
297  for ( index_t j = 0; j!= nc; ++j )
298  result(i,j) = this->coeff(rowInd[i], colInd[j] );
299  }
300 
303  void removeCol( index_t i )
304  {
305  index_t cc= this->cols();
306  GISMO_ASSERT( i < cc, "Invalid column." );
307  for ( index_t c = i+1; c!= cc; ++c )
308  this->col(c-1) = this->col(c);
309  this->conservativeResize(this->rows(), cc-1);
310  }
311 
315  void firstMinor(index_t i, index_t j, FirstMinorMatrixType & result ) const
316  {
317  const index_t mrows = this->rows()-1,
318  mcols = this->cols()-1;
319  GISMO_ASSERT( i <= mrows, "Invalid row." );
320  GISMO_ASSERT( j <= mcols, "Invalid column." );
321  result.resize(mrows,mcols);
322  result.block(0,0,i,j) = this->block(0,0,i,j);
323  result.block(i,0,mrows-i,j) = this->block(i+1,0,mrows-i,j);
324  result.block(0,j,i,mcols-j) = this->block(0,j+1,i,mcols-j);
325  result.block(i,j,mrows-i,mcols-j) = this->block(i+1,j+1,mrows-i,mcols-j);
326  }
327 
331  void rowMinor(index_t i, RowMinorMatrixType & result ) const
332  {
333  const index_t mrows = this->rows()-1;
334  GISMO_ASSERT( i <= mrows, "Invalid row." );
335  result.resize(mrows, this->cols());
336  result.topRows(i) = this->topRows(i);
337  result.bottomRows(mrows-i) = this->bottomRows(mrows-i);
338  }
339 
343  void colMinor(index_t j, ColMinorMatrixType & result ) const
344  {
345  const index_t mcols = this->cols()-1;
346  GISMO_ASSERT( j <= mcols, "Invalid column." );
347  result.resize(this->rows(), mcols);
348  result.leftCols(j) = this->leftCols(j);
349  result.rightCols(mcols-j) = this->rightCols(mcols-j);
350  }
351 
352  void duplicateRow( index_t k )
353  {
354  this->conservativeResize(this->rows() + 1, this->cols());
355 
356  /*
357  // Test this
358  this->bottomRows(this->rows() - k ) =
359  this->middleRows(this->rows() - k, k+1 );
360 
361  this->row(k+1) = this->row(k);
362  return;
363 
364  */
365 
366  for (index_t i = this->rows() - 1; i > k+1 ; --i)
367  this->row(i).swap(this->row(i-1));
368 
369  this->row(k+1) = this->row(k);
370  }
371 
372  void removeNoise(const T tol)
373  {
374  this->noalias() = this->unaryExpr(removeNoise_helper(tol));
375  }
376 
377  // Clone function. Used to make a copy of the matrix
378  //gsMatrix * clone() const;
379 
382  const gsVector<index_t> & colSizes)
383  {
384  return BlockView(*this, rowSizes, colSizes);
385  }
386 
388  void sortByColumn(const index_t j )
389  {
390  GISMO_ASSERT( j < this->cols(), "Invalid column.");
391 
392  index_t lastSwapDone = this->rows() - 1;
393  index_t lastCheckIdx = lastSwapDone;
394 
395  bool didSwap;
396  gsMatrix<T> tmp(1, this->cols() );
397  do{ //caution! A stable sort algorithm is needed here for lexSortColumns function below
398  didSwap = false;
399  lastCheckIdx = lastSwapDone;
400 
401  for( index_t i=0; i < lastCheckIdx; i++)
402  if( this->coeff(i,j) > this->coeff(i+1,j) )
403  {
404  tmp.row(0) = this->row(i);
405  this->row(i) = this->row(i+1);
406  this->row(i+1) = tmp.row(0);
407 
408  didSwap = true;
409  lastSwapDone = i;
410  }
411  }while( didSwap );
412  }
413 
415  void lexSortRows(const std::vector<index_t> & lorder)
416  {
417  GISMO_ASSERT(lorder.size() == static_cast<size_t>(this->cols()),
418  "Error in dimensions");
419 
420  for(std::vector<index_t>::const_reverse_iterator k = lorder.rbegin();
421  k != lorder.rend(); ++k) //sort from last to first given column
422  this->sortByColumn( *k ); // stable sort wrt column
423  }
424 
426  // treated a 1 x (cols()/colBlock) block matrix, and every block
427  // of size rows() x colBlock is transposed in place
428  void blockTransposeInPlace(const index_t colBlock)
429  {
430  const index_t nc = this->cols();
431  const index_t nr = this->rows();
432 
433  GISMO_ASSERT( nc % colBlock == 0,
434  "The blocksize is not compatible with number of columns.");
435 
436  if (nr == 1 || colBlock == 1)
437  {
438  this->resize(colBlock, this->size()/colBlock);
439  }
440  else if ( nr == colBlock )
441  {
442  for (index_t j = 0; j!= nc; j+=colBlock)
443  this->middleCols(j,colBlock).transposeInPlace();
444  }
445  else
446  {
447  gsEigen::Map<Base> m(this->data(), nr, nc);
448  this->resize(colBlock, this->size()/colBlock);
449 
450  index_t i = 0;
451  for (index_t j = 0; j!= nc; j+=colBlock, i+=nr)
452  this->middleCols(i,nr) = m.middleCols(j,colBlock).transpose().eval();
453  }
454  }
455 
457  void rrefInPlace() { rref_impl(*this); }
458 
460  void rcefInPlace() { rref_impl(this->transpose()); }
461 
463  void refInPlace() { ref_impl(*this); }
464 
466  void cefInPlace() { ref_impl(this->transpose()); }
467 
468  std::string printSparsity() const
469  {
470  std::ostringstream os;
471  os <<", sparsity: "<< std::fixed << std::setprecision(2)<<"nnz: "<<this->size()
472  <<(double)100*(this->array() != 0).count()/this->size() <<'%'<<"\n";
473  for (index_t i = 0; i!=this->rows(); ++i)
474  {
475  for (index_t j = 0; j!=this->cols(); ++j)
476  os<< ( 0 == this->coeff(i,j) ? "\u00B7" : "x");
477  os<<" "<<(this->row(i).array()!=0).count()<<"\n";
478  }
479  return os.str();
480  }
481 
483  template<typename OtherDerived>
484  gsMatrix kron(const gsEigen::MatrixBase<OtherDerived>& other) const
485  {
486  const index_t r = this->rows(), c = this->cols();
487  const index_t ro = other.rows(), co = other.cols();
488  gsMatrix result(r*ro, c*co);
489  for (index_t i = 0; i != r; ++i) // for all rows
490  for (index_t j = 0; j != c; ++j) // for all cols
491  result.block(i*ro, j*co, ro, co) = this->coeff(i,j) * other;
492  return result;
493  }
494 
496  template<typename OtherDerived>
497  gsMatrix khatriRao(const gsEigen::MatrixBase<OtherDerived>& other) const
498  {
499  const index_t r = this->rows(), c = this->cols();
500  const index_t ro = other.rows();
501  GISMO_ASSERT(c==other.cols(), "Column sizes do not match.");
502  gsMatrix result(r*ro, c);
503  for (index_t j = 0; j != c; ++j) // for all cols
504  for (index_t i = 0; i != ro; ++i) // for all rows
505  result.block(i*r, j, r, 1) = this->coeff(i,j) * other.col(j);
506  return result;
507  }
508 
509 private:
510 
511  // Implementation of (inplace) Reduced Row Echelon Form computation
512  template <typename Derived>
513  static void rref_impl(const gsEigen::MatrixBase<Derived>& Mat)
514  {
515  // todo: const T tol = 0
516  gsEigen::MatrixBase<Derived> & M = const_cast<gsEigen::MatrixBase<Derived>& >(Mat);
517  index_t i, piv = 0;
518  const index_t nr = M.rows();
519  const index_t nc = M.cols();
520  for (index_t r=0; r!=nr; ++r)
521  {
522  if (nc <= piv) return;
523  i = r;
524  while (0 == M(i, piv)) //~
525  {
526  ++i;
527  if (nr == i)
528  {
529  i = r;
530  ++piv;
531  if (nc == piv) return;
532  }
533  }
534 
535  if (i != r) M.row(i).swap(M.row(r));
536  const index_t br = nr-r-1;
537  const index_t bc = nc-piv-1;
538 
539  // pivot row
540  M.row(r).tail(bc).array() /= M(r, piv);
541  M(r, piv) = (T)(1);
542 
543  // upper block
544  M.block(0, piv+1, r, bc).noalias() -=
545  M.col(piv).head(r) * M.row(r).tail(bc);
546  M.col(piv).head(r).setZero();
547 
548  // lower block
549  M.block(r+1, piv+1, br, bc).noalias() -= M.col(piv).tail(br) * M.row(r).tail(bc);
550  M.col(piv).tail(br).setZero();
551 
552  ++piv;
553  }
554  }
555 
556  // Implementation of (inplace) Row Echelon Form computation
557  template <typename Derived>
558  static void ref_impl(const gsEigen::MatrixBase<Derived>& Mat)
559  {
560  // todo: const T tol = 0
561  gsEigen::MatrixBase<Derived> & M = const_cast<gsEigen::MatrixBase<Derived>& >(Mat);
562  index_t i, piv = 0;
563  const index_t nr = M.rows();
564  const index_t nc = M.cols();
565  for (index_t r=0; r!=nr; ++r)
566  {
567  if (nc <= piv) return;
568  i = r;
569  while (0 == M(i, piv)) //~
570  {
571  ++i;
572  if (nr == i)
573  {
574  i = r;
575  ++piv;
576  if (nc == piv) return;
577  }
578  }
579 
580  if (i != r) M.row(i).swap(M.row(r));
581  const index_t br = nr-r-1;
582  const index_t bc = nc-piv-1;
583 
584  // lower block
585  M.block(r+1, piv+1, br, bc).noalias() -=
586  M.col(piv).tail(br) * M.row(r).tail(bc) / M(r, piv);
587  M.col(piv).tail(br).setZero();
588 
589  ++piv;
590  }
591  }
592 
593  struct removeNoise_helper
594  {
595  removeNoise_helper(const T & tol)
596  : m_tol(tol) { }
597 
598  inline const T operator() (const T & val) const
599  { return ( math::abs(val) < m_tol ? 0 : val ); }
600 
601  const T & m_tol;
602  };
603 
604 }; // class gsMatrix
605 
606 
607 /*
608 template<class T, int _Rows, int _Cols, int _Options> inline
609 gsMatrix<T,_Rows, _Cols, _Options>::gsMatrix() { }
610 */
611 
612 template<class T, int _Rows, int _Cols, int _Options> inline
613 gsMatrix<T,_Rows, _Cols, _Options>::gsMatrix(const Base& a) : Base(a) { }
614 
615 template<class T, int _Rows, int _Cols, int _Options> inline
616 gsMatrix<T,_Rows, _Cols, _Options>::gsMatrix(int rows, int cols) : Base(rows,cols) { }
617 
618 // template<class T, int _Rows, int _Cols, int _Options>
619 // template<typename OtherDerived>
620 // gsMatrix<T,_Rows, _Cols, _Options>::gsMatrix(const gsEigen::MatrixBase<OtherDerived>& other) : Base(other) { }
621 
622 /* Clone function. Used to make a copy of the matrix
623 template<class T, int _Rows, int _Cols, int _Options> inline
624 gsMatrix<T,_Rows, _Cols, _Options> * gsMatrix<T,_Rows, _Cols, _Options>::clone() const
625 { return new gsMatrix<T,_Rows, _Cols, _Options>(*this); }
626 */
627 
628 
629 #ifdef GISMO_WITH_PYBIND11
630 
634  namespace py = pybind11;
635 
636  template<typename T>
637  void pybind11_init_gsMatrix(pybind11::module &m, const std::string & typestr)
638  {
639  using Class = gsMatrix<T>;
640  std::string pyclass_name = std::string("gsMatrix") + typestr;
641  py::class_<Class>(m, pyclass_name.c_str(), py::buffer_protocol(), py::dynamic_attr())
642  // Constructors
643  .def(py::init<>())
644  .def(py::init<index_t, index_t>())
645  // Member functions
646  .def("size", &Class::size)
647  .def("rows", &Class::rows)
648  .def("cols", &Class::cols)
649  // .def("transpose", &Class::transpose)
650  ;
651  }
652 
653 #endif // GISMO_WITH_PYBIND11
654 
655 
656 } // namespace gismo
657 
658 
659 namespace gsEigen { namespace internal {
660 template<class T, int _Rows, int _Cols, int _Options>
661 struct traits<gismo::gsMatrix<T,_Rows,_Cols,_Options> > :
662 gsEigen::internal::traits<gsEigen::Matrix<T,_Rows,_Cols,_Options> > { };
663 } }
gsMatrix(const gsEigen::ReturnByValue< OtherDerived > &other)
This constructor allows constructing a gsMatrix from Eigen expressions.
Definition: gsMatrix.h:159
void rowMinor(index_t i, RowMinorMatrixType &result) const
Definition: gsMatrix.h:331
gsAsConstMatrix< T, 1, Dynamic > asRowVector() const
Definition: gsMatrix.h:258
Creates a mapped object or data pointer to a matrix without copying data.
Definition: gsLinearAlgebra.h:126
gsAsConstVector< T, Dynamic > asVector() const
Returns the entries of the matrix resized to a (const) n*m vector column-wise.
Definition: gsMatrix.h:248
gsMatrix kron(const gsEigen::MatrixBase< OtherDerived > &other) const
Returns the Kronecker product of this with other.
Definition: gsMatrix.h:484
Col3DType col3d(index_t c)
Returns column c as a fixed-size 3D vector.
Definition: gsMatrix.h:244
void lexSortRows(const std::vector< index_t > &lorder)
Sorts rows of matrix by columns in vector lorder.
Definition: gsMatrix.h:415
memory::shared_ptr< gsMatrix > Ptr
Shared pointer for gsMatrix.
Definition: gsMatrix.h:102
gsMatrix khatriRao(const gsEigen::MatrixBase< OtherDerived > &other) const
Returns the Khatri-Rao product of this with other.
Definition: gsMatrix.h:497
#define index_t
Definition: gsConfig.h:32
void colMinor(index_t j, ColMinorMatrixType &result) const
Definition: gsMatrix.h:343
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition: gsMatrix.h:38
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
void rrefInPlace()
Converts the matrix to its Reduced Row Echelon Form (RREF)
Definition: gsMatrix.h:457
memory::unique_ptr< gsMatrix > uPtr
Unique pointer for gsMatrix.
Definition: gsMatrix.h:105
gsAsMatrix< T, Dynamic, Dynamic > reshape(index_t n, index_t m)
Returns the matrix resized to n x m matrix (data is not copied) This function assumes that the matrix...
Definition: gsMatrix.h:221
void submatrixCols(const container &colInd, gsMatrix< T > &result) const
Definition: gsMatrix.h:264
T at(index_t i) const
Returns the i-th element of the vectorization of the matrix.
Definition: gsMatrix.h:211
Creates a mapped object or data pointer to a vector without copying data.
Definition: gsLinearAlgebra.h:129
void removeCol(index_t i)
Definition: gsMatrix.h:303
gsAsConstMatrix< T, Dynamic, Dynamic > reshape(index_t n, index_t m) const
Returns the matrix resized to n x m matrix (data is not copied) This function assumes that the matrix...
Definition: gsMatrix.h:226
void blockTransposeInPlace(const index_t colBlock)
Transposes in place the matrix block-wise. The matrix is.
Definition: gsMatrix.h:428
gsAsMatrix< T, Dynamic, Dynamic > reshapeCol(index_t c, index_t n, index_t m)
Returns column c of the matrix resized to n x m matrix This function assumes that the matrix is size ...
Definition: gsMatrix.h:231
Creates a mapped object or data pointer to a const matrix without copying data.
Definition: gsLinearAlgebra.h:127
void cefInPlace()
Converts the matrix to a Column Echelon Form (CEF)
Definition: gsMatrix.h:466
void rcefInPlace()
Converts the matrix to its Reduced Column Echelon Form (RCEF)
Definition: gsMatrix.h:460
gsMatrix(const gsEigen::EigenBase< OtherDerived > &other)
This constructor allows constructing a gsMatrix from Eigen expressions.
Definition: gsMatrix.h:151
void submatrixRows(const container &rowInd, gsMatrix< T > &result) const
Definition: gsMatrix.h:276
gsAsConstMatrix< T, Dynamic, Dynamic > reshapeCol(index_t c, index_t n, index_t m) const
Returns column c of the matrix resized to n x m matrix This function assumes that the matrix is size ...
Definition: gsMatrix.h:236
Represents a block-view of the given matrix.
Definition: gsMatrixBlockView.h:31
BlockView blockView(const gsVector< index_t > &rowSizes, const gsVector< index_t > &colSizes)
Return a block view of the matrix with rowSizes and colSizes.
Definition: gsMatrix.h:381
uPtr moveToPtr()
This function returns a smart pointer to the matrix. After calling it, the matrix object becomes empt...
Definition: gsMatrix.h:170
Creates a mapped object or data pointer to a const vector without copying data.
Definition: gsLinearAlgebra.h:130
void refInPlace()
Converts the matrix to a Row Echelon Form (REF)
Definition: gsMatrix.h:463
EIGEN_STRONG_INLINE abs_expr< E > abs(const E &u)
Absolute value.
Definition: gsExpressions.h:4486
gsAsVector< T, Dynamic > asVector()
Returns the entries of the matrix resized to a n*m vector column-wise.
Definition: gsMatrix.h:240
T & at(index_t i)
Returns the i-th element of the vectorization of the matrix.
Definition: gsMatrix.h:214
gsAsMatrix< T, 1, Dynamic > asRowVector()
Definition: gsMatrix.h:253
void firstMinor(index_t i, index_t j, FirstMinorMatrixType &result) const
Definition: gsMatrix.h:315
void submatrix(const container &rowInd, const container &colInd, gsMatrix< T > &result) const
Definition: gsMatrix.h:288
void sortByColumn(const index_t j)
Sorts rows of matrix by column j.
Definition: gsMatrix.h:388
gsMatrix(const gsEigen::MatrixBase< OtherDerived > &other)
This constructor allows constructing a gsMatrix from Eigen expressions.
Definition: gsMatrix.h:155