Shapeworks Studio  2.1
Shape analysis software suite
List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
Eigen::UmfPackLU< _MatrixType > Class Template Reference

A sparse LU factorization and solver based on UmfPack. More...

#include <UmfPackSupport.h>

+ Inheritance diagram for Eigen::UmfPackLU< _MatrixType >:
+ Collaboration diagram for Eigen::UmfPackLU< _MatrixType >:

Public Types

typedef _MatrixType MatrixType
 
typedef MatrixType::Scalar Scalar
 
typedef MatrixType::RealScalar RealScalar
 
typedef MatrixType::Index Index
 
typedef Matrix< Scalar, Dynamic, 1 > Vector
 
typedef Matrix< int, 1, MatrixType::ColsAtCompileTime > IntRowVectorType
 
typedef Matrix< int, MatrixType::RowsAtCompileTime, 1 > IntColVectorType
 
typedef SparseMatrix< Scalar > LUMatrixType
 
typedef SparseMatrix< Scalar, ColMajor, int > UmfpackMatrixType
 

Public Member Functions

 UmfPackLU (const MatrixType &matrix)
 
Index rows () const
 
Index cols () const
 
ComputationInfo info () const
 Reports whether previous computation was successful. More...
 
const LUMatrixTypematrixL () const
 
const LUMatrixTypematrixU () const
 
const IntColVectorTypepermutationP () const
 
const IntRowVectorTypepermutationQ () const
 
void compute (const MatrixType &matrix)
 
template<typename Rhs >
const internal::solve_retval< UmfPackLU, Rhs > solve (const MatrixBase< Rhs > &b) const
 
template<typename Rhs >
const internal::sparse_solve_retval< UmfPackLU, Rhs > solve (const SparseMatrixBase< Rhs > &b) const
 
void analyzePattern (const MatrixType &matrix)
 
void factorize (const MatrixType &matrix)
 
template<typename BDerived , typename XDerived >
bool _solve (const MatrixBase< BDerived > &b, MatrixBase< XDerived > &x) const
 
Scalar determinant () const
 
void extractData () const
 

Protected Member Functions

void init ()
 
void grapInput (const MatrixType &mat)
 

Protected Attributes

LUMatrixType m_l
 
LUMatrixType m_u
 
IntColVectorType m_p
 
IntRowVectorType m_q
 
UmfpackMatrixType m_copyMatrix
 
const Scalar * m_valuePtr
 
const int * m_outerIndexPtr
 
const int * m_innerIndexPtr
 
void * m_numeric
 
void * m_symbolic
 
ComputationInfo m_info
 
bool m_isInitialized
 
int m_factorizationIsOk
 
int m_analysisIsOk
 
bool m_extractedDataAreDirty
 

Detailed Description

template<typename _MatrixType>
class Eigen::UmfPackLU< _MatrixType >

A sparse LU factorization and solver based on UmfPack.

This class allows to solve for A.X = B sparse linear problems via a LU factorization using the UmfPack library. The sparse matrix A must be squared and full rank. The vectors or matrices X and B can be either dense or sparse.

Warning
The input matrix A should be in a compressed and column-major form. Otherwise an expensive copy will be made. You can call the inexpensive makeCompressed() to get a compressed matrix.
Template Parameters
_MatrixTypethe type of the sparse matrix A, it must be a SparseMatrix<>
See also
TutorialSparseDirectSolvers

Definition at line 124 of file UmfPackSupport.h.

Member Function Documentation

template<typename _MatrixType>
void Eigen::UmfPackLU< _MatrixType >::analyzePattern ( const MatrixType &  matrix)
inline

Performs a symbolic decomposition on the sparcity of matrix.

This function is particularly useful when solving for several problems having the same structure.

See also
factorize(), compute()

Definition at line 233 of file UmfPackSupport.h.

234  {
235  if(m_symbolic)
236  umfpack_free_symbolic(&m_symbolic,Scalar());
237  if(m_numeric)
238  umfpack_free_numeric(&m_numeric,Scalar());
239 
240  grapInput(matrix);
241 
242  int errorCode = 0;
243  errorCode = umfpack_symbolic(matrix.rows(), matrix.cols(), m_outerIndexPtr, m_innerIndexPtr, m_valuePtr,
244  &m_symbolic, 0, 0);
245 
246  m_isInitialized = true;
247  m_info = errorCode ? InvalidInput : Success;
248  m_analysisIsOk = true;
249  m_factorizationIsOk = false;
250  }
Definition: math3d.h:219
template<typename _MatrixType>
void Eigen::UmfPackLU< _MatrixType >::compute ( const MatrixType &  matrix)
inline

Computes the sparse Cholesky decomposition of matrix Note that the matrix should be column-major, and in compressed format for best performance.

See also
SparseMatrix::makeCompressed().

Definition at line 195 of file UmfPackSupport.h.

196  {
198  factorize(matrix);
199  }
Definition: math3d.h:219
void analyzePattern(const MatrixType &matrix)
void factorize(const MatrixType &matrix)
template<typename _MatrixType>
void Eigen::UmfPackLU< _MatrixType >::factorize ( const MatrixType &  matrix)
inline

Performs a numeric decomposition of matrix

The given matrix must has the same sparcity than the matrix on which the pattern anylysis has been performed.

See also
analyzePattern(), compute()

Definition at line 258 of file UmfPackSupport.h.

259  {
260  eigen_assert(m_analysisIsOk && "UmfPackLU: you must first call analyzePattern()");
261  if(m_numeric)
262  umfpack_free_numeric(&m_numeric,Scalar());
263 
264  grapInput(matrix);
265 
266  int errorCode;
267  errorCode = umfpack_numeric(m_outerIndexPtr, m_innerIndexPtr, m_valuePtr,
268  m_symbolic, &m_numeric, 0, 0);
269 
270  m_info = errorCode ? NumericalIssue : Success;
271  m_factorizationIsOk = true;
272  }
Definition: math3d.h:219
template<typename _MatrixType>
ComputationInfo Eigen::UmfPackLU< _MatrixType >::info ( ) const
inline

Reports whether previous computation was successful.

Returns
Success if computation was succesful, NumericalIssue if the matrix.appears to be negative.

Definition at line 161 of file UmfPackSupport.h.

162  {
163  eigen_assert(m_isInitialized && "Decomposition is not initialized.");
164  return m_info;
165  }
template<typename _MatrixType>
template<typename Rhs >
const internal::solve_retval<UmfPackLU, Rhs> Eigen::UmfPackLU< _MatrixType >::solve ( const MatrixBase< Rhs > &  b) const
inline
Returns
the solution x of $ A x = b $ using the current decomposition of A.
See also
compute()

Definition at line 206 of file UmfPackSupport.h.

207  {
208  eigen_assert(m_isInitialized && "UmfPackLU is not initialized.");
209  eigen_assert(rows()==b.rows()
210  && "UmfPackLU::solve(): invalid number of rows of the right hand side matrix b");
211  return internal::solve_retval<UmfPackLU, Rhs>(*this, b.derived());
212  }
template<typename _MatrixType>
template<typename Rhs >
const internal::sparse_solve_retval<UmfPackLU, Rhs> Eigen::UmfPackLU< _MatrixType >::solve ( const SparseMatrixBase< Rhs > &  b) const
inline
Returns
the solution x of $ A x = b $ using the current decomposition of A.
See also
compute()

Definition at line 219 of file UmfPackSupport.h.

220  {
221  eigen_assert(m_isInitialized && "UmfPackLU is not initialized.");
222  eigen_assert(rows()==b.rows()
223  && "UmfPackLU::solve(): invalid number of rows of the right hand side matrix b");
224  return internal::sparse_solve_retval<UmfPackLU, Rhs>(*this, b.derived());
225  }

The documentation for this class was generated from the following file: