Eigen::KLU< MatrixType_ > Class Template Reference
+ Inheritance diagram for Eigen::KLU< MatrixType_ >:

Public Types

enum  {
  ColsAtCompileTime ,
  MaxColsAtCompileTime
}
 
typedef Matrix< int, MatrixType::RowsAtCompileTime, 1 > IntColVectorType
 
typedef Matrix< int, 1, MatrixType::ColsAtCompileTime > IntRowVectorType
 
typedef Ref< const KLUMatrixType, StandardCompressedFormatKLUMatrixRef
 
typedef SparseMatrix< Scalar, ColMajor, int > KLUMatrixType
 
typedef SparseMatrix< ScalarLUMatrixType
 
typedef MatrixType_ MatrixType
 
typedef MatrixType::RealScalar RealScalar
 
typedef MatrixType::Scalar Scalar
 
typedef MatrixType::StorageIndex StorageIndex
 
typedef Matrix< Scalar, Dynamic, 1 > Vector
 

Public Member Functions

template<typename BDerived , typename XDerived >
bool _solve_impl (const MatrixBase< BDerived > &b, MatrixBase< XDerived > &x) const
 
template<typename InputMatrixType >
void analyzePattern (const InputMatrixType &matrix)
 
EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
template<typename InputMatrixType >
void compute (const InputMatrixType &matrix)
 
template<typename InputMatrixType >
void factorize (const InputMatrixType &matrix)
 
ComputationInfo info () const
 Reports whether previous computation was successful. More...
 
 KLU ()
 
template<typename InputMatrixType >
 KLU (const InputMatrixType &matrix)
 
klu_common & kluCommon ()
 
const klu_common & kluCommon () const
 
EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 
 ~KLU ()
 
- Public Member Functions inherited from Eigen::SparseSolverBase< KLU< MatrixType_ > >
KLU< MatrixType_ > & derived ()
 
const KLU< MatrixType_ > & derived () const
 
const Solve< KLU< MatrixType_ >, Rhs > solve (const MatrixBase< Rhs > &b) const
 
const Solve< KLU< MatrixType_ >, Rhs > solve (const SparseMatrixBase< Rhs > &b) const
 
 SparseSolverBase ()
 
 SparseSolverBase (SparseSolverBase &&other)
 
 ~SparseSolverBase ()
 

Protected Types

typedef SparseSolverBase< KLU< MatrixType_ > > Base
 

Protected Member Functions

void analyzePattern_impl ()
 
void factorize_impl ()
 
template<typename MatrixDerived >
void grab (const EigenBase< MatrixDerived > &A)
 
void grab (const KLUMatrixRef &A)
 
void init ()
 

Protected Attributes

int m_analysisIsOk
 
klu_common m_common
 
KLUMatrixType m_dummy
 
bool m_extractedDataAreDirty
 
int m_factorizationIsOk
 
ComputationInfo m_info
 
klu_numeric * m_numeric
 
klu_symbolic * m_symbolic
 
KLUMatrixRef mp_matrix
 
- Protected Attributes inherited from Eigen::SparseSolverBase< KLU< MatrixType_ > >
bool m_isInitialized
 

Private Member Functions

 KLU (const KLU &)
 

Detailed Description

template<typename MatrixType_>
class Eigen::KLU< MatrixType_ >

Definition at line 62 of file KLUSupport.h.

Member Typedef Documentation

◆ Base

template<typename MatrixType_ >
typedef SparseSolverBase<KLU<MatrixType_> > Eigen::KLU< MatrixType_ >::Base
protected

Definition at line 65 of file KLUSupport.h.

◆ IntColVectorType

template<typename MatrixType_ >
typedef Matrix<int, MatrixType::RowsAtCompileTime, 1> Eigen::KLU< MatrixType_ >::IntColVectorType

Definition at line 75 of file KLUSupport.h.

◆ IntRowVectorType

template<typename MatrixType_ >
typedef Matrix<int, 1, MatrixType::ColsAtCompileTime> Eigen::KLU< MatrixType_ >::IntRowVectorType

Definition at line 74 of file KLUSupport.h.

◆ KLUMatrixRef

template<typename MatrixType_ >
typedef Ref<const KLUMatrixType, StandardCompressedFormat> Eigen::KLU< MatrixType_ >::KLUMatrixRef

Definition at line 78 of file KLUSupport.h.

◆ KLUMatrixType

template<typename MatrixType_ >
typedef SparseMatrix<Scalar,ColMajor,int> Eigen::KLU< MatrixType_ >::KLUMatrixType

Definition at line 77 of file KLUSupport.h.

◆ LUMatrixType

template<typename MatrixType_ >
typedef SparseMatrix<Scalar> Eigen::KLU< MatrixType_ >::LUMatrixType

Definition at line 76 of file KLUSupport.h.

◆ MatrixType

template<typename MatrixType_ >
typedef MatrixType_ Eigen::KLU< MatrixType_ >::MatrixType

Definition at line 69 of file KLUSupport.h.

◆ RealScalar

template<typename MatrixType_ >
typedef MatrixType::RealScalar Eigen::KLU< MatrixType_ >::RealScalar

Definition at line 71 of file KLUSupport.h.

◆ Scalar

template<typename MatrixType_ >
typedef MatrixType::Scalar Eigen::KLU< MatrixType_ >::Scalar

Definition at line 70 of file KLUSupport.h.

◆ StorageIndex

template<typename MatrixType_ >
typedef MatrixType::StorageIndex Eigen::KLU< MatrixType_ >::StorageIndex

Definition at line 72 of file KLUSupport.h.

◆ Vector

template<typename MatrixType_ >
typedef Matrix<Scalar,Dynamic,1> Eigen::KLU< MatrixType_ >::Vector

Definition at line 73 of file KLUSupport.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename MatrixType_ >
anonymous enum
Enumerator
ColsAtCompileTime 
MaxColsAtCompileTime 

Definition at line 79 of file KLUSupport.h.

79  {
80  ColsAtCompileTime = MatrixType::ColsAtCompileTime,
81  MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
82  };
@ ColsAtCompileTime
Definition: KLUSupport.h:80
@ MaxColsAtCompileTime
Definition: KLUSupport.h:81

Constructor & Destructor Documentation

◆ KLU() [1/3]

template<typename MatrixType_ >
Eigen::KLU< MatrixType_ >::KLU ( )
inline

Definition at line 86 of file KLUSupport.h.

87  : m_dummy(0,0), mp_matrix(m_dummy)
88  {
89  init();
90  }
KLUMatrixRef mp_matrix
Definition: KLUSupport.h:290
KLUMatrixType m_dummy
Definition: KLUSupport.h:289
void init()
Definition: KLUSupport.h:226

◆ KLU() [2/3]

template<typename MatrixType_ >
template<typename InputMatrixType >
Eigen::KLU< MatrixType_ >::KLU ( const InputMatrixType &  matrix)
inlineexplicit

Definition at line 93 of file KLUSupport.h.

94  : mp_matrix(matrix)
95  {
96  init();
97  compute(matrix);
98  }
void compute(const InputMatrixType &matrix)
Definition: KLUSupport.h:149

◆ ~KLU()

template<typename MatrixType_ >
Eigen::KLU< MatrixType_ >::~KLU ( )
inline

Definition at line 100 of file KLUSupport.h.

101  {
102  if(m_symbolic) klu_free_symbolic(&m_symbolic,&m_common);
103  if(m_numeric) klu_free_numeric(&m_numeric,&m_common);
104  }
klu_symbolic * m_symbolic
Definition: KLUSupport.h:293
klu_numeric * m_numeric
Definition: KLUSupport.h:292
klu_common m_common
Definition: KLUSupport.h:294

◆ KLU() [3/3]

template<typename MatrixType_ >
Eigen::KLU< MatrixType_ >::KLU ( const KLU< MatrixType_ > &  )
inlineprivate

Definition at line 301 of file KLUSupport.h.

301 { }

Member Function Documentation

◆ _solve_impl()

template<typename MatrixType >
template<typename BDerived , typename XDerived >
bool Eigen::KLU< MatrixType >::_solve_impl ( const MatrixBase< BDerived > &  b,
MatrixBase< XDerived > &  x 
) const

Definition at line 345 of file KLUSupport.h.

346 {
347  Index rhsCols = b.cols();
348  EIGEN_STATIC_ASSERT((XDerived::Flags&RowMajorBit)==0, THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
349  eigen_assert(m_factorizationIsOk && "The decomposition is not in a valid state for solving, you must first call either compute() or analyzePattern()/factorize()");
350 
351  x = b;
352  int info = klu_solve(m_symbolic, m_numeric, b.rows(), rhsCols, x.const_cast_derived().data(), const_cast<klu_common*>(&m_common), Scalar());
353 
355  return true;
356 }
Array< int, 3, 1 > b
#define eigen_assert(x)
Definition: Macros.h:902
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
ComputationInfo info() const
Reports whether previous computation was successful.
Definition: KLUSupport.h:114
int m_factorizationIsOk
Definition: KLUSupport.h:296
ComputationInfo m_info
Definition: KLUSupport.h:295
MatrixType::Scalar Scalar
Definition: KLUSupport.h:70
int klu_solve(klu_symbolic *Symbolic, klu_numeric *Numeric, Index ldim, Index nrhs, double B[], klu_common *Common, double)
A sparse LU factorization and solver based on KLU.
Definition: KLUSupport.h:36
@ NumericalIssue
Definition: Constants.h:448
@ Success
Definition: Constants.h:446
const unsigned int RowMajorBit
Definition: Constants.h:68
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82

◆ analyzePattern()

template<typename MatrixType_ >
template<typename InputMatrixType >
void Eigen::KLU< MatrixType_ >::analyzePattern ( const InputMatrixType &  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 165 of file KLUSupport.h.

166  {
167  if(m_symbolic) klu_free_symbolic(&m_symbolic, &m_common);
168  if(m_numeric) klu_free_numeric(&m_numeric, &m_common);
169 
170  grab(matrix.derived());
171 
173  }
void grab(const EigenBase< MatrixDerived > &A)
Definition: KLUSupport.h:266
void analyzePattern_impl()
Definition: KLUSupport.h:237

◆ analyzePattern_impl()

template<typename MatrixType_ >
void Eigen::KLU< MatrixType_ >::analyzePattern_impl ( )
inlineprotected

Definition at line 237 of file KLUSupport.h.

238  {
240  m_analysisIsOk = false;
241  m_factorizationIsOk = false;
242  m_symbolic = klu_analyze(internal::convert_index<int>(mp_matrix.rows()),
243  const_cast<StorageIndex*>(mp_matrix.outerIndexPtr()), const_cast<StorageIndex*>(mp_matrix.innerIndexPtr()),
244  &m_common);
245  if (m_symbolic) {
246  m_isInitialized = true;
247  m_info = Success;
248  m_analysisIsOk = true;
250  }
251  }
int m_analysisIsOk
Definition: KLUSupport.h:297
MatrixType::StorageIndex StorageIndex
Definition: KLUSupport.h:72
bool m_extractedDataAreDirty
Definition: KLUSupport.h:298
@ InvalidInput
Definition: Constants.h:453

◆ cols()

template<typename MatrixType_ >
EIGEN_CONSTEXPR Index Eigen::KLU< MatrixType_ >::cols ( void  ) const
inline

Definition at line 107 of file KLUSupport.h.

107 { return mp_matrix.cols(); }

◆ compute()

template<typename MatrixType_ >
template<typename InputMatrixType >
void Eigen::KLU< MatrixType_ >::compute ( const InputMatrixType &  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 149 of file KLUSupport.h.

150  {
151  if(m_symbolic) klu_free_symbolic(&m_symbolic, &m_common);
152  if(m_numeric) klu_free_numeric(&m_numeric, &m_common);
153  grab(matrix.derived());
155  factorize_impl();
156  }
void factorize_impl()
Definition: KLUSupport.h:253

◆ factorize()

template<typename MatrixType_ >
template<typename InputMatrixType >
void Eigen::KLU< MatrixType_ >::factorize ( const InputMatrixType &  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 203 of file KLUSupport.h.

204  {
205  eigen_assert(m_analysisIsOk && "KLU: you must first call analyzePattern()");
206  if(m_numeric)
207  klu_free_numeric(&m_numeric,&m_common);
208 
209  grab(matrix.derived());
210 
211  factorize_impl();
212  }

◆ factorize_impl()

template<typename MatrixType_ >
void Eigen::KLU< MatrixType_ >::factorize_impl ( )
inlineprotected

Definition at line 253 of file KLUSupport.h.

254  {
255 
256  m_numeric = klu_factor(const_cast<StorageIndex*>(mp_matrix.outerIndexPtr()), const_cast<StorageIndex*>(mp_matrix.innerIndexPtr()), const_cast<Scalar*>(mp_matrix.valuePtr()),
257  m_symbolic, &m_common, Scalar());
258 
259 
261  m_factorizationIsOk = m_numeric ? 1 : 0;
263  }
klu_numeric * klu_factor(int Ap[], int Ai[], double Ax[], klu_symbolic *Symbolic, klu_common *Common, double)
Definition: KLUSupport.h:52

◆ grab() [1/2]

template<typename MatrixType_ >
template<typename MatrixDerived >
void Eigen::KLU< MatrixType_ >::grab ( const EigenBase< MatrixDerived > &  A)
inlineprotected

Definition at line 266 of file KLUSupport.h.

267  {
269  internal::construct_at(&mp_matrix, A.derived());
270  }
MatrixXcf A
void destroy_at(T *p)
Definition: Memory.h:1264
T * construct_at(T *p, Args &&... args)
Definition: Memory.h:1248

◆ grab() [2/2]

template<typename MatrixType_ >
void Eigen::KLU< MatrixType_ >::grab ( const KLUMatrixRef A)
inlineprotected

Definition at line 272 of file KLUSupport.h.

273  {
274  if(&(A.derived()) != &mp_matrix)
275  {
278  }
279  }

◆ info()

template<typename MatrixType_ >
ComputationInfo Eigen::KLU< MatrixType_ >::info ( ) const
inline

Reports whether previous computation was successful.

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

Definition at line 114 of file KLUSupport.h.

115  {
116  eigen_assert(m_isInitialized && "Decomposition is not initialized.");
117  return m_info;
118  }

◆ init()

template<typename MatrixType_ >
void Eigen::KLU< MatrixType_ >::init ( )
inlineprotected

Definition at line 226 of file KLUSupport.h.

227  {
229  m_isInitialized = false;
230  m_numeric = 0;
231  m_symbolic = 0;
233 
234  klu_defaults(&m_common);
235  }

◆ kluCommon() [1/2]

template<typename MatrixType_ >
klu_common& Eigen::KLU< MatrixType_ >::kluCommon ( )
inline

Provides access to the control settings array used by UmfPack.

If this array contains NaN's, the default values are used.

See KLU documentation for details.

Definition at line 191 of file KLUSupport.h.

192  {
193  return m_common;
194  }

◆ kluCommon() [2/2]

template<typename MatrixType_ >
const klu_common& Eigen::KLU< MatrixType_ >::kluCommon ( ) const
inline

Provides access to the control settings array used by KLU.

See KLU documentation for details.

Definition at line 180 of file KLUSupport.h.

181  {
182  return m_common;
183  }

◆ rows()

template<typename MatrixType_ >
EIGEN_CONSTEXPR Index Eigen::KLU< MatrixType_ >::rows ( void  ) const
inline

Definition at line 106 of file KLUSupport.h.

106 { return mp_matrix.rows(); }

Member Data Documentation

◆ m_analysisIsOk

template<typename MatrixType_ >
int Eigen::KLU< MatrixType_ >::m_analysisIsOk
protected

Definition at line 297 of file KLUSupport.h.

◆ m_common

template<typename MatrixType_ >
klu_common Eigen::KLU< MatrixType_ >::m_common
protected

Definition at line 294 of file KLUSupport.h.

◆ m_dummy

template<typename MatrixType_ >
KLUMatrixType Eigen::KLU< MatrixType_ >::m_dummy
protected

Definition at line 289 of file KLUSupport.h.

◆ m_extractedDataAreDirty

template<typename MatrixType_ >
bool Eigen::KLU< MatrixType_ >::m_extractedDataAreDirty
mutableprotected

Definition at line 298 of file KLUSupport.h.

◆ m_factorizationIsOk

template<typename MatrixType_ >
int Eigen::KLU< MatrixType_ >::m_factorizationIsOk
protected

Definition at line 296 of file KLUSupport.h.

◆ m_info

template<typename MatrixType_ >
ComputationInfo Eigen::KLU< MatrixType_ >::m_info
mutableprotected

Definition at line 295 of file KLUSupport.h.

◆ m_numeric

template<typename MatrixType_ >
klu_numeric* Eigen::KLU< MatrixType_ >::m_numeric
protected

Definition at line 292 of file KLUSupport.h.

◆ m_symbolic

template<typename MatrixType_ >
klu_symbolic* Eigen::KLU< MatrixType_ >::m_symbolic
protected

Definition at line 293 of file KLUSupport.h.

◆ mp_matrix

template<typename MatrixType_ >
KLUMatrixRef Eigen::KLU< MatrixType_ >::mp_matrix
protected

Definition at line 290 of file KLUSupport.h.


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