CGAL 6.3 - CGAL and Solvers
Loading...
Searching...
No Matches
CGAL::Eigen_sparse_matrix< T > Struct Template Reference

#include <CGAL/Eigen_sparse_matrix.h>

Inherited by CGAL::Eigen_sparse_symmetric_matrix< T >.

Definition

template<class T>
struct CGAL::Eigen_sparse_matrix< T >

The class Eigen_sparse_matrix is a wrapper around Eigen matrix type Eigen::SparseMatrix that represents general matrices, be they symmetric or not.

Is model of
SparseLinearAlgebraTraits_d::Matrix
Template Parameters
TNumber type.
See also
CGAL::Eigen_vector<T>
CGAL::Eigen_matrix<T>
CGAL::Eigen_sparse_symmetric_matrix<T>

Public Member Functions

 Eigen_sparse_matrix (const EigenType &et)
 Eigen_sparse_matrix ()
 Eigen_sparse_matrix (std::size_t dim, bool is_symmetric=false)
 Create a square matrix initialized with zeros.
 Eigen_sparse_matrix (int dim, bool is_symmetric=false)
 Create a square matrix initialized with zeros.
 Eigen_sparse_matrix (std::size_t rows, std::size_t columns, bool is_symmetric=false)
 Create a rectangular matrix initialized with zeros.
void swap (Eigen_sparse_matrix &other)
 ~Eigen_sparse_matrix ()
 Delete this object and the wrapped matrix.
 Eigen_sparse_matrix (int rows, int columns, bool is_symmetric=false)
 Create a rectangular matrix initialized with zeros.
int row_dimension () const
 Return the matrix number of rows.
int column_dimension () const
 Return the matrix number of columns.
void set_coef (std::size_t i_, std::size_t j_, T val, bool new_coef=false)
 Write access to a matrix coefficient: a_ij <- val.
void add_coef (std::size_t i_, std::size_t j_, T val)
 Write access to a matrix coefficient: a_ij <- a_ij + val.
NT get_coef (std::size_t i_, std::size_t j_) const
 Read access to a matrix coefficient.
const EigenTypeeigen_object () const
 Return the internal matrix, with type EigenType.
EigenTypeeigen_object ()
 Return the internal matrix, with type EigenType.

Types

typedef Eigen::SparseMatrix< T > EigenType
 The internal matrix type from Eigen.
typedef T NT

Constructor & Destructor Documentation

◆ Eigen_sparse_matrix() [1/4]

template<class T>
CGAL::Eigen_sparse_matrix< T >::Eigen_sparse_matrix ( std::size_t dim,
bool is_symmetric = false )

Create a square matrix initialized with zeros.

Parameters
dimMatrix dimension.
is_symmetricSymmetric/hermitian?

◆ Eigen_sparse_matrix() [2/4]

template<class T>
CGAL::Eigen_sparse_matrix< T >::Eigen_sparse_matrix ( int dim,
bool is_symmetric = false )

Create a square matrix initialized with zeros.

Parameters
dimMatrix dimension.
is_symmetricSymmetric/hermitian?

◆ Eigen_sparse_matrix() [3/4]

template<class T>
CGAL::Eigen_sparse_matrix< T >::Eigen_sparse_matrix ( std::size_t rows,
std::size_t columns,
bool is_symmetric = false )

Create a rectangular matrix initialized with zeros.

Precondition
rows == columns if is_symmetric is true.
Parameters
rowsNumber of rows.
columnsNumber of columns.
is_symmetricSymmetric/hermitian?

◆ Eigen_sparse_matrix() [4/4]

template<class T>
CGAL::Eigen_sparse_matrix< T >::Eigen_sparse_matrix ( int rows,
int columns,
bool is_symmetric = false )

Create a rectangular matrix initialized with zeros.

Precondition
rows == columns if is_symmetric is true.
Parameters
rowsNumber of rows.
columnsNumber of columns.
is_symmetricSymmetric/hermitian?

Member Function Documentation

◆ add_coef()

template<class T>
void CGAL::Eigen_sparse_matrix< T >::add_coef ( std::size_t i_,
std::size_t j_,
T val )

Write access to a matrix coefficient: a_ij <- a_ij + val.

Warning
For symmetric matrices, Eigen_sparse_matrix only stores the lower triangle add_coef() does nothing if (i, j) belongs to the upper triangle.
Precondition
0 <= i < row_dimension().
0 <= j < column_dimension().

◆ get_coef()

template<class T>
NT CGAL::Eigen_sparse_matrix< T >::get_coef ( std::size_t i_,
std::size_t j_ ) const

Read access to a matrix coefficient.

Warning
Complexity:
  • \(O(log(n))\) if the matrix is already built.
  • \(O(n)\) if the matrix is not built. n being the number of entries in the matrix.
Precondition
0 <= i < row_dimension().
0 <= j < column_dimension().

◆ set_coef()

template<class T>
void CGAL::Eigen_sparse_matrix< T >::set_coef ( std::size_t i_,
std::size_t j_,
T val,
bool new_coef = false )

Write access to a matrix coefficient: a_ij <- val.

Users can optimize calls to this function by setting 'new_coef' to true if the coefficient does not already exist in the matrix.

Warning
For symmetric matrices, Eigen_sparse_matrix only stores the lower triangle and set_coef() does nothing if (i, j) belongs to the upper triangle.
Precondition
0 <= i < row_dimension().
0 <= j < column_dimension().