G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsMatrix.h
Go to the documentation of this file.
1
14# pragma once
15
16
17namespace gismo
18{
19
37template<class T, int _Rows, int _Cols, int _Options>
38class gsMatrix : public gsEigen::Matrix<T,_Rows, _Cols, _Options>
39//i.e. gsEigen::PlainObjectBase<gsEigen::Matrix>
40//i.e. gsEigen::EigenBase<gsEigen::Matrix>
41{
42public:
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
123public: // 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
138public:
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
223
228
233
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
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 std::vector<index_t> idxByColumn(const index_t j )
416 {
417 std::vector<index_t> permutation;
418 GISMO_ASSERT( j < this->cols(), "Invalid column.");
419
420 index_t lastSwapDone = this->rows() - 1;
421 index_t lastCheckIdx = lastSwapDone;
422
423 for( index_t i=0; i < this->rows(); i++)
424 permutation.push_back(i);
425
426 bool didSwap;
427 gsMatrix<T> tmp(1, this->cols() );
428
429 do{ //caution! A stable sort algorithm is needed here for lexSortColumns function below
430 didSwap = false;
431 lastCheckIdx = lastSwapDone;
432
433 for( index_t i=0; i < lastCheckIdx; i++)
434 if( this->coeff(i,j) > this->coeff(i+1,j) )
435 {
436 // gsInfo << this->coeff(i,j) << " > " << this->coeff(i+1,j) << "\n";
437
438 tmp.row(0) = this->row(i);
439 index_t tdx = permutation[i];
440
441 this->row(i) = this->row(i+1);
442 permutation[i] = permutation[i+1];
443
444 this->row(i+1) = tmp.row(0);
445 permutation[i+1] = tdx;
446
447 didSwap = true;
448 lastSwapDone = i;
449 }
450 }while( didSwap );
451 return permutation;
452 }
453
455 void lexSortRows(const std::vector<index_t> & lorder)
456 {
457 GISMO_ASSERT(lorder.size() == static_cast<size_t>(this->cols()),
458 "Error in dimensions");
459
460 for(std::vector<index_t>::const_reverse_iterator k = lorder.rbegin();
461 k != lorder.rend(); ++k) //sort from last to first given column
462 this->sortByColumn( *k ); // stable sort wrt column
463 }
464
466 // treated a 1 x (cols()/colBlock) block matrix, and every block
467 // of size rows() x colBlock is transposed in place
468 void blockTransposeInPlace(const index_t colBlock)
469 {
470 const index_t nc = this->cols();
471 const index_t nr = this->rows();
472
473 GISMO_ASSERT( nc % colBlock == 0,
474 "The blocksize is not compatible with number of columns.");
475
476 if (nr == 1 || colBlock == 1)
477 {
478 this->resize(colBlock, this->size()/colBlock);
479 }
480 else if ( nr == colBlock )
481 {
482 for (index_t j = 0; j!= nc; j+=colBlock)
483 this->middleCols(j,colBlock).transposeInPlace();
484 }
485 else
486 {
487 gsEigen::Map<Base> m(this->data(), nr, nc);
488 this->resize(colBlock, this->size()/colBlock);
489
490 index_t i = 0;
491 for (index_t j = 0; j!= nc; j+=colBlock, i+=nr)
492 this->middleCols(i,nr) = m.middleCols(j,colBlock).transpose().eval();
493 }
494 }
495
497 void rrefInPlace() { rref_impl(*this); }
498
500 void rcefInPlace() { rref_impl(this->transpose()); }
501
503 void refInPlace() { ref_impl(*this); }
504
506 void cefInPlace() { ref_impl(this->transpose()); }
507
508 std::string printSparsity() const
509 {
510 std::ostringstream os;
511 os <<", sparsity: "<< std::fixed << std::setprecision(2)<<"nnz: "<<this->size()
512 <<(double)100*(this->array() != 0).count()/this->size() <<'%'<<"\n";
513 for (index_t i = 0; i!=this->rows(); ++i)
514 {
515 for (index_t j = 0; j!=this->cols(); ++j)
516 os<< ( 0 == this->coeff(i,j) ? "\u00B7" : "x");
517 os<<" "<<(this->row(i).array()!=0).count()<<"\n";
518 }
519 return os.str();
520 }
521
523 template<typename OtherDerived>
524 gsMatrix kron(const gsEigen::MatrixBase<OtherDerived>& other) const
525 {
526 const index_t r = this->rows(), c = this->cols();
527 const index_t ro = other.rows(), co = other.cols();
528 gsMatrix result(r*ro, c*co);
529 for (index_t i = 0; i != r; ++i) // for all rows
530 for (index_t j = 0; j != c; ++j) // for all cols
531 result.block(i*ro, j*co, ro, co) = this->coeff(i,j) * other;
532 return result;
533 }
534
536 template<typename OtherDerived>
537 gsMatrix khatriRao(const gsEigen::MatrixBase<OtherDerived>& other) const
538 {
539 const index_t r = this->rows(), c = this->cols();
540 const index_t ro = other.rows();
541 GISMO_ASSERT(c==other.cols(), "Column sizes do not match.");
542 gsMatrix result(r*ro, c);
543 for (index_t j = 0; j != c; ++j) // for all cols
544 for (index_t i = 0; i != ro; ++i) // for all rows
545 result.block(i*r, j, r, 1) = this->coeff(i,j) * other.col(j);
546 return result;
547 }
548
549private:
550
551 // Implementation of (inplace) Reduced Row Echelon Form computation
552 template <typename Derived>
553 static void rref_impl(const gsEigen::MatrixBase<Derived>& Mat)
554 {
555 // todo: const T tol = 0
556 gsEigen::MatrixBase<Derived> & M = const_cast<gsEigen::MatrixBase<Derived>& >(Mat);
557 index_t i, piv = 0;
558 const index_t nr = M.rows();
559 const index_t nc = M.cols();
560 for (index_t r=0; r!=nr; ++r)
561 {
562 if (nc <= piv) return;
563 i = r;
564 while (0 == M(i, piv)) //~
565 {
566 ++i;
567 if (nr == i)
568 {
569 i = r;
570 ++piv;
571 if (nc == piv) return;
572 }
573 }
574
575 if (i != r) M.row(i).swap(M.row(r));
576 const index_t br = nr-r-1;
577 const index_t bc = nc-piv-1;
578
579 // pivot row
580 M.row(r).tail(bc).array() /= M(r, piv);
581 M(r, piv) = (T)(1);
582
583 // upper block
584 M.block(0, piv+1, r, bc).noalias() -=
585 M.col(piv).head(r) * M.row(r).tail(bc);
586 M.col(piv).head(r).setZero();
587
588 // lower block
589 M.block(r+1, piv+1, br, bc).noalias() -= M.col(piv).tail(br) * M.row(r).tail(bc);
590 M.col(piv).tail(br).setZero();
591
592 ++piv;
593 }
594 }
595
596 // Implementation of (inplace) Row Echelon Form computation
597 template <typename Derived>
598 static void ref_impl(const gsEigen::MatrixBase<Derived>& Mat)
599 {
600 // todo: const T tol = 0
601 gsEigen::MatrixBase<Derived> & M = const_cast<gsEigen::MatrixBase<Derived>& >(Mat);
602 index_t i, piv = 0;
603 const index_t nr = M.rows();
604 const index_t nc = M.cols();
605 for (index_t r=0; r!=nr; ++r)
606 {
607 if (nc <= piv) return;
608 i = r;
609 while (0 == M(i, piv)) //~
610 {
611 ++i;
612 if (nr == i)
613 {
614 i = r;
615 ++piv;
616 if (nc == piv) return;
617 }
618 }
619
620 if (i != r) M.row(i).swap(M.row(r));
621 const index_t br = nr-r-1;
622 const index_t bc = nc-piv-1;
623
624 // lower block
625 M.block(r+1, piv+1, br, bc).noalias() -=
626 M.col(piv).tail(br) * M.row(r).tail(bc) / M(r, piv);
627 M.col(piv).tail(br).setZero();
628
629 ++piv;
630 }
631 }
632
633 struct removeNoise_helper
634 {
635 removeNoise_helper(const T & tol)
636 : m_tol(tol) { }
637
638 inline const T operator() (const T & val) const
639 { return ( math::abs(val) < m_tol ? 0 : val ); }
640
641 const T & m_tol;
642 };
643
644}; // class gsMatrix
645
646
647/*
648template<class T, int _Rows, int _Cols, int _Options> inline
649gsMatrix<T,_Rows, _Cols, _Options>::gsMatrix() { }
650*/
651
652template<class T, int _Rows, int _Cols, int _Options> inline
653gsMatrix<T,_Rows, _Cols, _Options>::gsMatrix(const Base& a) : Base(a) { }
654
655template<class T, int _Rows, int _Cols, int _Options> inline
656gsMatrix<T,_Rows, _Cols, _Options>::gsMatrix(int rows, int cols) : Base(rows,cols) { }
657
658// template<class T, int _Rows, int _Cols, int _Options>
659// template<typename OtherDerived>
660// gsMatrix<T,_Rows, _Cols, _Options>::gsMatrix(const gsEigen::MatrixBase<OtherDerived>& other) : Base(other) { }
661
662/* Clone function. Used to make a copy of the matrix
663template<class T, int _Rows, int _Cols, int _Options> inline
664gsMatrix<T,_Rows, _Cols, _Options> * gsMatrix<T,_Rows, _Cols, _Options>::clone() const
665{ return new gsMatrix<T,_Rows, _Cols, _Options>(*this); }
666*/
667
668
669#ifdef GISMO_WITH_PYBIND11
670
674 template<typename T>
675 void pybind11_init_gsMatrix(pybind11::module &m, const std::string & typestr)
676 {
677 using Class = gsMatrix<T>;
678 std::string pyclass_name = std::string("gsMatrix") + typestr;
679 pybind11::class_<Class>(m, pyclass_name.c_str(), pybind11::buffer_protocol(), pybind11::dynamic_attr())
680 // Constructors
681 .def(pybind11::init<>())
682 .def(pybind11::init<index_t, index_t>())
683 // Member functions
684 .def("size", &Class::size)
685 .def("rows", &Class::rows)
686 .def("cols", &Class::cols)
687 // .def("transpose", &Class::transpose)
688 ;
689 }
690
691#endif // GISMO_WITH_PYBIND11
692
693
694} // namespace gismo
695
696
697namespace gsEigen { namespace internal {
698template<class T, int _Rows, int _Cols, int _Options>
699struct traits<gismo::gsMatrix<T,_Rows,_Cols,_Options> > :
700gsEigen::internal::traits<gsEigen::Matrix<T,_Rows,_Cols,_Options> > { };
701} }
Creates a mapped object or data pointer to a const matrix without copying data.
Definition gsAsMatrix.h:141
Creates a mapped object or data pointer to a const vector without copying data.
Definition gsAsMatrix.h:285
Creates a mapped object or data pointer to a matrix without copying data.
Definition gsAsMatrix.h:32
Creates a mapped object or data pointer to a vector without copying data.
Definition gsAsMatrix.h:239
Represents a block-view of the given matrix.
Definition gsMatrixBlockView.h:32
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
void colMinor(index_t j, ColMinorMatrixType &result) const
Definition gsMatrix.h:343
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
uPtr moveToPtr()
This function returns a smart pointer to the matrix. After calling it, the matrix object becomes empt...
Definition gsMatrix.h:170
memory::unique_ptr< gsMatrix > uPtr
Unique pointer for gsMatrix.
Definition gsMatrix.h:105
gsMatrix(const gsEigen::EigenBase< OtherDerived > &other)
This constructor allows constructing a gsMatrix from Eigen expressions.
Definition gsMatrix.h:151
void firstMinor(index_t i, index_t j, FirstMinorMatrixType &result) const
Definition gsMatrix.h:315
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
Col3DType col3d(index_t c)
Returns column c as a fixed-size 3D vector.
Definition gsMatrix.h:244
void rcefInPlace()
Converts the matrix to its Reduced Column Echelon Form (RCEF)
Definition gsMatrix.h:500
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 removeCol(index_t i)
Definition gsMatrix.h:303
void refInPlace()
Converts the matrix to a Row Echelon Form (REF)
Definition gsMatrix.h:503
T at(index_t i) const
Returns the i-th element of the vectorization of the matrix.
Definition gsMatrix.h:211
gsMatrix khatriRao(const gsEigen::MatrixBase< OtherDerived > &other) const
Returns the Khatri-Rao product of this with other.
Definition gsMatrix.h:537
gsAsConstMatrix< T, 1, Dynamic > asRowVector() const
Definition gsMatrix.h:258
void cefInPlace()
Converts the matrix to a Column Echelon Form (CEF)
Definition gsMatrix.h:506
T & at(index_t i)
Returns the i-th element of the vectorization of the matrix.
Definition gsMatrix.h:214
gsAsVector< T, Dynamic > asVector()
Returns the entries of the matrix resized to a n*m vector column-wise.
Definition gsMatrix.h:240
void rowMinor(index_t i, RowMinorMatrixType &result) const
Definition gsMatrix.h:331
memory::shared_ptr< gsMatrix > Ptr
Shared pointer for gsMatrix.
Definition gsMatrix.h:102
void sortByColumn(const index_t j)
Sorts rows of matrix by column j.
Definition gsMatrix.h:388
std::vector< index_t > idxByColumn(const index_t j)
Returns the vector permutation of the rows of the matrix by column j.
Definition gsMatrix.h:415
void submatrixCols(const container &colInd, gsMatrix< T > &result) const
Definition gsMatrix.h:264
void lexSortRows(const std::vector< index_t > &lorder)
Sorts rows of matrix by columns in vector lorder.
Definition gsMatrix.h:455
gsAsConstVector< T, Dynamic > asVector() const
Returns the entries of the matrix resized to a (const) n*m vector column-wise.
Definition gsMatrix.h:248
void rrefInPlace()
Converts the matrix to its Reduced Row Echelon Form (RREF)
Definition gsMatrix.h:497
void submatrix(const container &rowInd, const container &colInd, gsMatrix< T > &result) const
Definition gsMatrix.h:288
void blockTransposeInPlace(const index_t colBlock)
Transposes in place the matrix block-wise. The matrix is.
Definition gsMatrix.h:468
void submatrixRows(const container &rowInd, gsMatrix< T > &result) const
Definition gsMatrix.h:276
gsMatrix(const gsEigen::MatrixBase< OtherDerived > &other)
This constructor allows constructing a gsMatrix from Eigen expressions.
Definition gsMatrix.h:155
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
gsMatrix(const gsEigen::ReturnByValue< OtherDerived > &other)
This constructor allows constructing a gsMatrix from Eigen expressions.
Definition gsMatrix.h:159
gsAsMatrix< T, 1, Dynamic > asRowVector()
Definition gsMatrix.h:253
gsMatrix kron(const gsEigen::MatrixBase< OtherDerived > &other) const
Returns the Kronecker product of this with other.
Definition gsMatrix.h:524
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
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
#define index_t
Definition gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
The G+Smo namespace, containing all definitions for the library.