CGAL 6.2 - CGAL and Solvers: CGAL::Eigen_solver_traits< EigenSolverT > Class Template Reference

CGAL 6.2 - CGAL and Solvers

Loading...
Searching...
No Matches
List of all members | Public Member Functions | Protected Attributes
CGAL::Eigen_solver_traits< EigenSolverT > Class Template Reference
Reference Manual » Linear Systems

`#include <CGAL/Eigen_solver_traits.h>`

## Definition

template<class EigenSolverT = Eigen::BiCGSTAB<Eigen_sparse_matrix<double>::EigenType>>
class CGAL::Eigen_solver_traits< EigenSolverT >

The class `Eigen_solver_traits` provides an interface to the sparse solvers of Eigen.

Eigen version 3.1 (or later) must be available on the system.

Is model of
  `SparseLinearAlgebraWithFactorTraits_d`
  `NormalEquationSparseLinearAlgebraTraits_d`

Template Parameters

  EigenSolverT | A sparse solver of Eigen. The default solver is the iterative bi-conjugate gradient stabilized solver `Eigen::BiCGSTAB` for `double`.

See also
  `CGAL::Eigen_sparse_matrix<T>`
  `CGAL::Eigen_sparse_symmetric_matrix<T>`
  `CGAL::Eigen_vector<T>`
  https://eigen.tuxfamily.org/index.php?title=Main_Page

Instantiation Example

The instantiation of this class assumes an Eigen sparse solver is provided. Here are few examples:

typedef CGAL::Eigen_sparse_matrix<double>::EigenType EigenMatrix;
//iterative general solver
typedef CGAL::Eigen_solver_traits< Eigen::BiCGSTAB<EigenMatrix> > Iterative_general_solver;
//iterative symmetric solver
typedef CGAL::Eigen_solver_traits< Eigen::ConjugateGradient<EigenMatrix> > Iterative_symmetric_solver;
//direct symmetric solver
typedef CGAL::Eigen_solver_traits< Eigen::SimplicialCholesky<EigenMatrix> > Direct_symmetric_solver;
CGAL::Eigen_solver_traits
The class Eigen_solver_traits provides an interface to the sparse solvers of Eigen.
Definition: Eigen_solver_traits.h:101
CGAL::Eigen_sparse_matrix::EigenType
Eigen::SparseMatrix< T > EigenType
The internal matrix type from Eigen.
Definition: Eigen_sparse_matrix.h:44

Examples
  Solver_interface/sparse_solvers.cpp.

## Public Member Functions
| Eigen_solver_traits ()
| Constructor.
bool | linear_solver (const Matrix &A, const Vector &B, Vector &X, NT &D)
| Solve the sparse linear system \( A \times X = B \).
bool | factor (const Matrix &A, NT &D)
| Factorize the sparse matrix \( A \).
bool | linear_solver (const Vector &B, Vector &X)
| Solve the sparse linear system \( A \times X = B\), with \( A \) being the matrix provided in `factor()`.
bool | linear_solver (const Matrix &B, Vector &X)
| Solve the sparse linear system \( A \times X = B\), with \( A \) being the matrix provided in `factor()`.
bool | normal_equation_factor (const Matrix &A)
| Factorize the sparse matrix \( A^t \times A\), where \( A^t \) is the transpose matrix of \( A \).
bool | normal_equation_solver (const Vector &B, Vector &X)
| Solve the sparse linear system \( A^t \times A \times X = A^t \times B \), with \( A \) being the matrix provided in `#normal_equation_factor()`, and \( A^t \) its transpose matrix.
bool | normal_equation_solver (const Matrix &A, const Vector &B, Vector &X)
| Equivalent to a call to `normal_equation_factor(A)` followed by a call to `normal_equation_solver(B, X)` .

## Protected Attributes
const Matrix::EigenType * | m_mat
std::shared_ptr< EigenSolverT > | m_solver_sptr

## Types
typedef EigenSolverT | Solver
typedef Scalar | NT
typedef CGAL::Eigen_vector< NT > | Vector
typedef Eigen::DenseIndex | Index
typedef unspecified_type | Matrix
| If `T` is `Eigen::ConjugateGradient<M>` or `Eigen::SimplicialCholesky<M>`, `Matrix` is `CGAL::Eigen_sparse_symmetric_matrix<T>`, and `CGAL::Eigen_sparse_matrix<T>` otherwise.

## Operations
EigenSolverT & | solver ()
| Returns a reference to the internal Eigen solver.

## Member Function Documentation

## ◆ factor()

template<class EigenSolverT = Eigen::BiCGSTAB<Eigen_sparse_matrix<double>::EigenType>>

bool CGAL::Eigen_solver_traits< EigenSolverT >::factor | ( | const Matrix & | A,
|  | NT & | D
| ) |  |

Factorize the sparse matrix \( A \).

This factorization is used in `linear_solver()` to solve the system for different right-hand side vectors. See `linear_solver()` for the description of \( D \).

Returns
  `true` if the factorization is successful and `false` otherwise.

## ◆ linear_solver() [1/3]

template<class EigenSolverT = Eigen::BiCGSTAB<Eigen_sparse_matrix<double>::EigenType>>

bool CGAL::Eigen_solver_traits< EigenSolverT >::linear_solver | ( | const Matrix & | A,
|  | const Vector & | B,
|  | Vector & | X,
|  | NT & | D
| ) |  |

Solve the sparse linear system \( A \times X = B \).

Return `true` on success. The solution is then \( (1/D) \times X \).

Precondition
  A.row_dimension() == B.dimension().
  A.column_dimension() == X.dimension().

## ◆ linear_solver() [2/3]

template<class EigenSolverT = Eigen::BiCGSTAB<Eigen_sparse_matrix<double>::EigenType>>

bool CGAL::Eigen_solver_traits< EigenSolverT >::linear_solver | ( | const Matrix & | B,
|  | Vector & | X
| ) |  |

Solve the sparse linear system \( A \times X = B\), with \( A \) being the matrix provided in `factor()`.

Returns
  `true` if the solver is successful and `false` otherwise.

## ◆ linear_solver() [3/3]

template<class EigenSolverT = Eigen::BiCGSTAB<Eigen_sparse_matrix<double>::EigenType>>

bool CGAL::Eigen_solver_traits< EigenSolverT >::linear_solver | ( | const Vector & | B,
|  | Vector & | X
| ) |  |

Solve the sparse linear system \( A \times X = B\), with \( A \) being the matrix provided in `factor()`.

Returns
  `true` if the solver is successful and `false` otherwise.

## ◆ normal_equation_factor()

template<class EigenSolverT = Eigen::BiCGSTAB<Eigen_sparse_matrix<double>::EigenType>>

bool CGAL::Eigen_solver_traits< EigenSolverT >::normal_equation_factor | ( | const Matrix & | A | ) |

Factorize the sparse matrix \( A^t \times A\), where \( A^t \) is the transpose matrix of \( A \).

This factorization is used in `normal_equation_solver()` to solve the system for different right-hand side vectors.

Returns
  `true` if the factorization is successful and `false` otherwise.

## ◆ normal_equation_solver()

template<class EigenSolverT = Eigen::BiCGSTAB<Eigen_sparse_matrix<double>::EigenType>>

bool CGAL::Eigen_solver_traits< EigenSolverT >::normal_equation_solver | ( | const Vector & | B,
|  | Vector & | X
| ) |  |

Solve the sparse linear system \( A^t \times A \times X = A^t \times B \), with \( A \) being the matrix provided in `#normal_equation_factor()`, and \( A^t \) its transpose matrix.

Returns
  `true` if the solver is successful and `false` otherwise.

## ◆ solver()

template<class EigenSolverT = Eigen::BiCGSTAB<Eigen_sparse_matrix<double>::EigenType>>

EigenSolverT & CGAL::Eigen_solver_traits< EigenSolverT >::solver | ( |  | ) |

Returns a reference to the internal Eigen solver.

This function can be used for example to set specific parameters of the solver.