G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsLinearAlgebra.h
Go to the documentation of this file.
1
15# pragma once
16
17#include <gsCore/gsMath.h>
18
19// Eigen linear algebra library (http://eigen.tuxfamily.org)
20
21#define Eigen gsEigen
22// Make Eigen use GISMO_ASSERT which throws exceptions
23//
24// Must be defined before including Eigen headers
25// http://eigen.tuxfamily.org/dox-3.2/TopicPreprocessorDirectives.html
26#define eigen_assert( cond ) GISMO_ASSERT( cond, "" )
27
28// Plugin provides extra members
29#define EIGEN_MATRIXBASE_PLUGIN <gsMatrix/gsMatrixAddons.h>
30#define EIGEN_PLAINOBJECTBASE_PLUGIN <gsMatrix/gsPlainObjectBaseAddons.h>
32
33#include <gsEigen/Core>
34
35#if defined(gsMpfr_ENABLED)
36#include <unsupported/Eigen/MPRealSupport>
37#endif
38
39#if defined(gsGmp_ENABLED)
40#include <unsupported/Eigen/MPQClassSupport>
41#endif
42
43#include <gsEigen/Dense>
44#include <gsEigen/Sparse>
45#include <gsEigen/StdVector>
46#include <gsEigen/Geometry>
47
48// Extra Eigen code
49#include <gsMatrix/Adjugate.h>
50#include <gsMatrix/BlockDiag.h>
52//#include <gsMatrix/RowSelection.h>
53
54#ifdef GISMO_WITH_SUPERLU
55#include <gsEigen/SuperLUSupport>
56#endif
57
58#ifdef GISMO_WITH_PARDISO
59#include <gsEigen/PardisoSupport>
60#endif
61
62#ifdef GISMO_WITH_PASTIX
63#include <gsEigen/PaStiXSupport>
64#endif
65
66// sparsesuite
67//#include <gsEigen/UmfPackSupport>
68//#include <gsEigen/SPQRSupport>
69//#include <gsEigen/CholmodSupport>
70
71// METIS
72//#include <gsEigen/MetisSupport>
73
74// PaStiX
75//#include <gsEigen/PaStiXSupport>
76
77#ifdef GISMO_WITH_PYBIND11
78#include <pybind11/eigen.h>
79#endif
80
81#undef Eigen
82#undef eigen_assert
83#undef EIGEN_MATRIXBASE_PLUGIN
84#undef EIGEN_PLAINOBJECTBASE_PLUGIN
85
86
87namespace gismo
88{
89
90using gsEigen::internal::cast; // from Core/MathFunctions.h
91
99template<typename Derived>
100inline bool (isnumber)(const gsEigen::MatrixBase<Derived>& x)
101{ return ((x.array() == x.array())).all(); }
102
108template<typename Derived>
109inline bool isfinite(const gsEigen::MatrixBase<Derived>& x)
110{ return ( (x - x).array() == (x - x).array()).all(); }
111
112
113
114//Constantss related to gsMatrix
115//( see also external/Eigen/src/Core/util/Constants.h )
116using gsEigen::Dynamic ;//=-1
117
118using gsEigen::Lower;//=1
119using gsEigen::Upper;//=2
120
121// Values for matrix align options
122using gsEigen::RowMajor;//=0
123using gsEigen::ColMajor;//=1
124using gsEigen::AutoAlign;//=0
125
126template<class T, int _Rows, int _Cols> class gsAsMatrix ;
127template<class T, int _Rows, int _Cols> class gsAsConstMatrix ;
128
129template<class T, int _Rows> class gsAsVector ;
130template<class T, int _Rows> class gsAsConstVector ;
131
132// helper template for changing the dimension of a matrix
133template <int Dim, int Change>
134struct ChangeDim
135{
136 enum { D = Change+Dim<0 ? 0 : Dim + Change };
137};
138template <int Change>
139struct ChangeDim<Dynamic, Change>
140{
141 enum { D = Dynamic };
142};
143
144
148template<typename T>
150{
151public:
152 // Note: IncompleteILU is not compatible with
153 // gsEigen::ConjugateGradient because this preconditionner does not
154 // preserve symmetry.
155
157 typedef gsEigen::ConjugateGradient<gsEigen::SparseMatrix<T,0,index_t>,
158 gsEigen::Lower|gsEigen::Upper, gsEigen::IdentityPreconditioner> CGIdentity;
159
161 typedef gsEigen::ConjugateGradient<gsEigen::SparseMatrix<T,0,index_t>,
162 gsEigen::Lower|gsEigen::Upper, gsEigen::DiagonalPreconditioner<T> > CGDiagonal;
163
165 typedef gsEigen::BiCGSTAB<gsEigen::SparseMatrix<T,0,index_t>,
166 gsEigen::IncompleteLUT<T, index_t> > BiCGSTABILUT;
167
169 typedef gsEigen::BiCGSTAB<gsEigen::SparseMatrix<T,0,index_t>,
170 gsEigen::DiagonalPreconditioner<T> > BiCGSTABDiagonal;
171
173 typedef gsEigen::BiCGSTAB<gsEigen::SparseMatrix<T,0,index_t>,
174 gsEigen::IdentityPreconditioner > BiCGSTABIdentity;
175
177 typedef gsEigen::SimplicialLDLT<gsEigen::SparseMatrix<T,0,index_t> > SimplicialLDLT;
178
180 typedef gsEigen::SimplicialLLT<gsEigen::SparseMatrix<T,0,index_t> > SimplicialLLT;
181
183 typedef gsEigen::SparseLU<gsEigen::SparseMatrix<T,0,index_t>,
184 gsEigen::COLAMDOrdering<index_t> > SparseLU;
185
187 typedef gsEigen::SparseQR<gsEigen::SparseMatrix<T,0,index_t>,
188 gsEigen::COLAMDOrdering<index_t> > SparseQR;
189
190 #ifdef GISMO_WITH_SUPERLU
192 typedef gsEigen::SuperLU<gsEigen::SparseMatrix<T,0,index_t> > SuperLU;
193 #endif
194
195 #ifdef GISMO_WITH_PARDISO
197 typedef gsEigen::PardisoLDLT<gsEigen::SparseMatrix<T,0,int> > PardisoLDLT;
198 typedef gsEigen::PardisoLLT <gsEigen::SparseMatrix<T,0,int> > PardisoLLT;
199 typedef gsEigen::PardisoLU <gsEigen::SparseMatrix<T,0,int> > PardisoLU;
200 #endif
201
202};
203
204} // namespace gismo
205
206
208#include <gsMatrix/gsMatrix.h>
209#include <gsMatrix/gsVector.h>
210#include <gsMatrix/gsAsMatrix.h>
214#include <gsMatrix/gsPoint.h>
Adjugate extension for Eigen matrix objects.
BlockDiag extension for Eigen matrix objects.
BlockTranspose extension for Eigen matrix objects.
Wraps pointers as matrix objects.
Extra forward declarations related to the Eigen library.
Mathematical functions for use in G+Smo.
Wraps a matrix and attaches a block structure to it.
Provides declaration of Matrix class.
Provides declaration of Point class.
Provides declaration of the gsSparseMatrix class.
abstract interfaces for solvers and wrapper around Eigen solvers
Provides declaration of SparseVector class (wrapping Eigen)
Provides declaration of Vector class.
The G+Smo namespace, containing all definitions for the library.
bool() isnumber(const gsEigen::MatrixBase< Derived > &x)
Check if all the entires if the matrix x are not NAN (not a number)
Definition gsLinearAlgebra.h:100
bool isfinite(const gsEigen::MatrixBase< Derived > &x)
Check if all the entires if the matrix x are not INF (infinite)
Definition gsLinearAlgebra.h:109
Adaptor for Eigen types.
Definition gsLinearAlgebra.h:150
gsEigen::SimplicialLDLT< gsEigen::SparseMatrix< T, 0, index_t > > SimplicialLDLT
Direct LDLt factorization.
Definition gsLinearAlgebra.h:177
gsEigen::ConjugateGradient< gsEigen::SparseMatrix< T, 0, index_t >, gsEigen::Lower|gsEigen::Upper, gsEigen::IdentityPreconditioner > CGIdentity
Congugate gradient without preconditioner (identity as preconditioner)
Definition gsLinearAlgebra.h:158
gsEigen::SparseLU< gsEigen::SparseMatrix< T, 0, index_t >, gsEigen::COLAMDOrdering< index_t > > SparseLU
Sparse LU solver.
Definition gsLinearAlgebra.h:184
gsEigen::SimplicialLLT< gsEigen::SparseMatrix< T, 0, index_t > > SimplicialLLT
Direct LLt factorization.
Definition gsLinearAlgebra.h:180
gsEigen::ConjugateGradient< gsEigen::SparseMatrix< T, 0, index_t >, gsEigen::Lower|gsEigen::Upper, gsEigen::DiagonalPreconditioner< T > > CGDiagonal
Congugate gradient with diagonal (Jacobi) preconditioner.
Definition gsLinearAlgebra.h:162
gsEigen::BiCGSTAB< gsEigen::SparseMatrix< T, 0, index_t >, gsEigen::IdentityPreconditioner > BiCGSTABIdentity
BiCGSTAB without preconditioner (identity as preconditioner)
Definition gsLinearAlgebra.h:174
gsEigen::BiCGSTAB< gsEigen::SparseMatrix< T, 0, index_t >, gsEigen::DiagonalPreconditioner< T > > BiCGSTABDiagonal
BiCGSTAB with Diagonal (Jacobi) preconditioner.
Definition gsLinearAlgebra.h:170
gsEigen::BiCGSTAB< gsEigen::SparseMatrix< T, 0, index_t >, gsEigen::IncompleteLUT< T, index_t > > BiCGSTABILUT
BiCGSTAB with Incomplete LU factorization with dual-threshold strategy.
Definition gsLinearAlgebra.h:166
gsEigen::SparseQR< gsEigen::SparseMatrix< T, 0, index_t >, gsEigen::COLAMDOrdering< index_t > > SparseQR
Sparse QR solver.
Definition gsLinearAlgebra.h:188