ShapeOp  0.1.0
LSSolver.h
Go to the documentation of this file.
1 // This file is part of ShapeOp, a lightweight C++ library
3 // for static and dynamic geometry processing.
4 //
5 // Copyright (C) 2014 Sofien Bouaziz <sofien.bouaziz@gmail.com>
6 // Copyright (C) 2014 LGG EPFL
7 //
8 // This Source Code Form is subject to the terms of the Mozilla
9 // Public License v. 2.0. If a copy of the MPL was not distributed
10 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 #ifndef LSSOLVER_H
13 #define LSSOLVER_H
14 #include "Types.h"
16 
17 #include <iostream>
18 #include <unsupported/Eigen/src/IterativeSolvers/MINRES.h>
20 
22 namespace ShapeOp {
25 
27  public:
28  virtual ~LSSolver() {};
30  virtual void initialize(const SparseMatrix &A, unsigned int iteration = 1) = 0;
32  virtual VectorX solve(const VectorX &b, const VectorX &x0) const = 0;
34  virtual Eigen::ComputationInfo info() const = 0;
35 };
37 
39  public:
40  virtual ~SimplicialLDLTSolver() {};
42  virtual void initialize(const SparseMatrix &A, unsigned int iteration) override final;
44  virtual VectorX solve(const VectorX &b, const VectorX &x0) const override final;
46  virtual Eigen::ComputationInfo info() const override final;
47  private:
48  Eigen::SimplicialLDLT<SparseMatrix> solver_;
49 };
51 
52 class SHAPEOP_API CGSolver : public LSSolver {
53  public:
54  virtual ~CGSolver() {};
56  virtual void initialize(const SparseMatrix &A, unsigned int iteration) override final;
58  virtual VectorX solve(const VectorX &b, const VectorX &x0) const override final;
60  virtual Eigen::ComputationInfo info() const override final;
61  private:
62  Eigen::ConjugateGradient<SparseMatrix, Eigen::Lower, Eigen::IncompleteLUT<Scalar> > solver_;
63 };
65 
67  public:
68  virtual ~MINRESSolver() {};
70  virtual void initialize(const SparseMatrix &A, unsigned int iteration) override final;
72  virtual VectorX solve(const VectorX &b, const VectorX &x0) const override final;
74  virtual Eigen::ComputationInfo info() const override final;
75  private:
76  Eigen::MINRES<SparseMatrix, Eigen::Lower, Eigen::IncompleteLUT<Scalar> > solver_;
77 };
79 
80 class SHAPEOP_API SORSolver : public LSSolver {
81  public:
85  SORSolver(ShapeOp::Scalar relaxation = 1.6);
86  virtual ~SORSolver() {};
88  virtual void initialize(const SparseMatrix &A, unsigned int iteration) override final;
90  virtual VectorX solve(const VectorX &b, const VectorX &x0) const override final;
92  virtual Eigen::ComputationInfo info() const override final;
93  private:
95  ShapeOp::Scalar relaxation_;
96  unsigned int iteration_;
97 };
99 } // namespace ShapeOp
101 #ifdef SHAPEOP_HEADER_ONLY
102 #include "LSSolver.cpp"
103 #endif
104 #endif // LSSOLVER_H
106 
Sparse linear system solver based on CG. This class implements a sparse linear system solver based on...
Definition: LSSolver.h:52
Sparse linear system solver based on successive over-relaxation (SOR).
Definition: LSSolver.h:80
SparseMatrixT SparseMatrix
The default sparse matrix of Eigen.
Definition: Types.h:52
MatrixT< Eigen::Dynamic, 1 > VectorX
A nd column vector.
Definition: Types.h:47
Base class of any sparse linear system solver. This class defines the main functionalities of the Sha...
Definition: LSSolver.h:26
Namespace of the ShapeOp library.
Definition: Constraint.cpp:18
Sparse linear system solver based on MINRES. This class implements a sparse linear system solver base...
Definition: LSSolver.h:66
ShapeOpScalar Scalar
A scalar type, double or float, as defined in ShapeOpScalar in Common.h.
Definition: Types.h:32
#define SHAPEOP_API
Defines the API prefix for the current platform.
Definition: Common.h:34
Sparse linear system solver based on Cholesky. This class implements a sparse linear system solver ba...
Definition: LSSolver.h:38
Eigen::SparseMatrix< Scalar, Options > SparseMatrixT
A typedef of the sparse matrix of Eigen.
Definition: Types.h:51