10 #if defined(HAVE_EIGEN)
12 linearSystemEigen<double>::linearSystemEigen() { solverType = EigenSparseLU; }
14 bool linearSystemEigen<double>::isAllocated()
const
24 A.resize(nbRows, nbRows);
31 void linearSystemEigen<double>::clear()
38 void linearSystemEigen<double>::zeroMatrix()
45 void linearSystemEigen<double>::zeroRightHandSide() { B.fill(0.); }
47 void linearSystemEigen<double>::zeroSolution() { X.fill(0.); }
49 void linearSystemEigen<double>::setSolverType(
50 linearSystemEigenSolver solverName)
52 solverType = solverName;
55 int linearSystemEigen<double>::systemSolve()
57 if(solverType == EigenCholeskyLLT) {
58 Eigen::SimplicialLLT<Eigen::SparseMatrix<double> > solver;
60 if(solver.info() != Eigen::ComputationInfo::Success) {
61 Msg::Warning(
"Eigen: failed to solve linear system with CholeskyLLT");
65 if(solver.info() != Eigen::ComputationInfo::Success) {
66 Msg::Warning(
"Eigen: failed to solve linear system with CholeskyLLT");
70 else if(solverType == EigenCholeskyLDLT) {
71 Eigen::SimplicialLDLT<Eigen::SparseMatrix<double> > solver;
73 if(solver.info() != Eigen::ComputationInfo::Success) {
74 Msg::Warning(
"Eigen: failed to solve linear system with CholeskyLDLT");
78 if(solver.info() != Eigen::ComputationInfo::Success) {
79 Msg::Warning(
"Eigen: failed to solve linear system with CholeskyLDLT");
83 else if(solverType == EigenSparseLU) {
84 Eigen::SparseLU<Eigen::SparseMatrix<double> > solver;
86 if(solver.info() != Eigen::ComputationInfo::Success) {
87 Msg::Warning(
"Eigen: failed to solve linear system with SparseLU");
91 if(solver.info() != Eigen::ComputationInfo::Success) {
92 Msg::Warning(
"Eigen: failed to solve linear system with SparseLU");
96 else if(solverType == EigenSparseQR) {
98 Eigen::SparseQR<Eigen::SparseMatrix<double>, Eigen::NaturalOrdering<int> >
101 if(solver.info() != Eigen::ComputationInfo::Success) {
102 Msg::Warning(
"Eigen: failed to solve linear system with SparseQR");
106 if(solver.info() != Eigen::ComputationInfo::Success) {
107 Msg::Warning(
"Eigen: failed to solve linear system with SparseQR");
111 else if(solverType == EigenCG) {
112 Eigen::ConjugateGradient<Eigen::SparseMatrix<double> > solver;
114 if(solver.info() != Eigen::ComputationInfo::Success) {
116 "Eigen: failed to solve linear system with Conjugate Gradient");
120 if(solver.info() != Eigen::ComputationInfo::Success) {
122 "Eigen: failed to solve linear system with Conjugate Gradient");
126 else if(solverType == EigenCGLeastSquare) {
127 Eigen::LeastSquaresConjugateGradient<Eigen::SparseMatrix<double> > solver;
129 if(solver.info() != Eigen::ComputationInfo::Success) {
130 Msg::Warning(
"Eigen: failed to solve linear system with Least Square "
131 "Conjugate Gradient");
135 if(solver.info() != Eigen::ComputationInfo::Success) {
136 Msg::Warning(
"Eigen: failed to solve linear system with Least Square "
137 "Conjugate Gradient");
141 else if(solverType == EigenBiCGSTAB) {
142 Eigen::BiCGSTAB<Eigen::SparseMatrix<double> > solver;
144 if(solver.info() != Eigen::ComputationInfo::Success) {
145 Msg::Warning(
"Eigen: failed to solve linear system with BiCGSTAB");
149 if(solver.info() != Eigen::ComputationInfo::Success) {
150 Msg::Warning(
"Eigen: failed to solve linear system with BiCGSTAB");
157 void linearSystemEigen<double>::insertInSparsityPattern(
int row,
int col) {}
159 double linearSystemEigen<double>::normInfRightHandSide()
const
164 double linearSystemEigen<double>::normInfSolution()
const
169 void linearSystemEigen<double>::addToMatrix(
int row,
int col,
const double &val)
171 A.coeffRef(row, col) += val;
174 void linearSystemEigen<double>::getFromMatrix(
int row,
int col,
177 val = A.coeff(row, col);
180 void linearSystemEigen<double>::addToRightHandSide(
int row,
const double &val,
183 if((
int)B.size() <= row) {
192 void linearSystemEigen<double>::getFromRightHandSide(
int row,
double &val)
const
194 if((
int)B.size() <= row) val = 0.;
198 void linearSystemEigen<double>::getFromSolution(
int row,
double &val)
const
200 if((
int)X.size() <= row)
206 void linearSystemEigen<double>::addToSolution(
int row,
const double &val)
208 if((
int)X.size() <= row) {