7 #include "imstkJacobi.h" 8 #include "imstkLinearProjectionConstraint.h" 9 #include "imstkLogger.h" 13 Jacobi::Jacobi(
const SparseMatrixd& A,
const Vectord& rhs) : Jacobi()
15 this->
setSystem(std::make_shared<LinearSystem<SparseMatrixd>>(A, rhs));
23 LOG(WARNING) <<
"Jacobi::solve: Linear system is not supplied for Gauss-Seidel solver!";
27 if (m_FixedLinearProjConstraints->size() == 0)
55 while (iterNum < this->getMaxNumIterations())
57 for (
auto k = 0; k < A.outerSize(); ++k)
60 double aggregate = 0.;
61 for (SparseMatrixd::InnerIterator it(A, k); it; ++it)
66 aggregate += it.value() * xOld[col];
73 x[k] = (b[k] - aggregate) / diagEle;
76 if ((x - xOld).norm() < 1.0e-4)
114 LOG(INFO) <<
"Solver: Jacobi";
void setTolerance(const double tolerance)
Set solver tolerance.
size_t m_maxIterations
Maximum number of iterations to be performed.
virtual void setMaxNumIterations(const size_t maxIter) override
set/get the maximum number of iterations for the iterative solver.
double m_tolerance
default tolerance
virtual void solve(Vectord &x) override
Solve the linear system using Gauss-Seidel iterations.
void setTolerance(const double tolerance)
Set solver tolerance.
virtual void setMaxNumIterations(const size_t maxIter)
Do one iteration of the method.
void print() const override
Print solver information.
Represents the linear system of the form .
double getResidual(const Vectord &x) override
Return the error calculated by the solver.
void setSystem(std::shared_ptr< LinearSystemType > newSystem) override
Sets the system. System of linear equations.
void print() const override
Print solver information.
void JacobiSolve(Vectord &x)
Do one iteration of the method.
void solve(Vectord &x) override
Solve the system of equations.
virtual void setSystem(std::shared_ptr< LinearSystemType > newSystem)
Set/get the system. Replaces/Returns the stored linear system of equations.
std::shared_ptr< LinearSystemType > m_linearSystem
Linear system of equations.