Eigen::KLU< MatrixType_ > Class Template Reference

#include <KLUSupport.h>

+ Inheritance diagram for Eigen::KLU< MatrixType_ >:

Public Types

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

Public Member Functions

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

Protected Types

typedef SparseSolverBase< KLU< MatrixType_ > > Base
 

Protected Member Functions

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

Protected Attributes

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

Private Member Functions

 KLU (const KLU &)
 

Member Typedef Documentation

◆ Base

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

◆ IntColVectorType

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

◆ IntRowVectorType

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

◆ KLUMatrixRef

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

◆ KLUMatrixType

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

◆ LUMatrixType

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

◆ MatrixType

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

◆ RealScalar

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

◆ Scalar

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

◆ StorageIndex

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

◆ Vector

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

Member Enumeration Documentation

◆ anonymous enum

template<typename MatrixType_ >
anonymous enum
Enumerator
ColsAtCompileTime 
MaxColsAtCompileTime 
87 { ColsAtCompileTime = MatrixType::ColsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime };
@ ColsAtCompileTime
Definition: KLUSupport.h:87
@ MaxColsAtCompileTime
Definition: KLUSupport.h:87

Constructor & Destructor Documentation

◆ KLU() [1/3]

template<typename MatrixType_ >
Eigen::KLU< MatrixType_ >::KLU ( )
inline
90 : m_dummy(0, 0), mp_matrix(m_dummy) { init(); }
KLUMatrixRef mp_matrix
Definition: KLUSupport.h:267
KLUMatrixType m_dummy
Definition: KLUSupport.h:266
void init()
Definition: KLUSupport.h:210

References Eigen::KLU< MatrixType_ >::init().

◆ KLU() [2/3]

template<typename MatrixType_ >
template<typename InputMatrixType >
Eigen::KLU< MatrixType_ >::KLU ( const InputMatrixType &  matrix)
inlineexplicit
93  : mp_matrix(matrix) {
94  init();
95  compute(matrix);
96  }
void compute(const InputMatrixType &matrix)
Definition: KLUSupport.h:145
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor >, 0, Eigen::OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: common.h:85

References Eigen::KLU< MatrixType_ >::compute(), Eigen::KLU< MatrixType_ >::init(), and matrix().

◆ ~KLU()

template<typename MatrixType_ >
Eigen::KLU< MatrixType_ >::~KLU ( )
inline
98  {
99  if (m_symbolic) klu_free_symbolic(&m_symbolic, &m_common);
100  if (m_numeric) klu_free_numeric(&m_numeric, &m_common);
101  }
klu_symbolic * m_symbolic
Definition: KLUSupport.h:270
klu_numeric * m_numeric
Definition: KLUSupport.h:269
klu_common m_common
Definition: KLUSupport.h:271

References Eigen::KLU< MatrixType_ >::m_common, Eigen::KLU< MatrixType_ >::m_numeric, and Eigen::KLU< MatrixType_ >::m_symbolic.

◆ KLU() [3/3]

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

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
322  {
323  Index rhsCols = b.cols();
324  EIGEN_STATIC_ASSERT((XDerived::Flags & RowMajorBit) == 0, THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
326  "The decomposition is not in a valid state for solving, you must first call either compute() or "
327  "analyzePattern()/factorize()");
328 
329  x = b;
330  int info = klu_solve(m_symbolic, m_numeric, b.rows(), rhsCols, x.const_cast_derived().data(),
331  const_cast<klu_common *>(&m_common), Scalar());
332 
333  m_info = info != 0 ? Success : NumericalIssue;
334  return true;
335 }
#define eigen_assert(x)
Definition: Macros.h:910
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
Scalar * b
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
ComputationInfo info() const
Reports whether previous computation was successful.
Definition: KLUSupport.h:111
int m_factorizationIsOk
Definition: KLUSupport.h:273
ComputationInfo m_info
Definition: KLUSupport.h:272
@ NumericalIssue
Definition: Constants.h:442
@ Success
Definition: Constants.h:440
const unsigned int RowMajorBit
Definition: Constants.h:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
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
list x
Definition: plotDoE.py:28

References b, eigen_assert, EIGEN_STATIC_ASSERT, info, Eigen::klu_solve(), Eigen::NumericalIssue, Eigen::RowMajorBit, Eigen::Success, and plotDoE::x.

◆ 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()
160  {
161  if (m_symbolic) klu_free_symbolic(&m_symbolic, &m_common);
162  if (m_numeric) klu_free_numeric(&m_numeric, &m_common);
163 
164  grab(matrix.derived());
165 
167  }
void grab(const EigenBase< MatrixDerived > &A)
Definition: KLUSupport.h:246
void analyzePattern_impl()
Definition: KLUSupport.h:220

References Eigen::KLU< MatrixType_ >::analyzePattern_impl(), Eigen::KLU< MatrixType_ >::grab(), Eigen::KLU< MatrixType_ >::m_common, Eigen::KLU< MatrixType_ >::m_numeric, Eigen::KLU< MatrixType_ >::m_symbolic, and matrix().

◆ analyzePattern_impl()

template<typename MatrixType_ >
void Eigen::KLU< MatrixType_ >::analyzePattern_impl ( )
inlineprotected
220  {
222  m_analysisIsOk = false;
223  m_factorizationIsOk = false;
224  m_symbolic = klu_analyze(internal::convert_index<int>(mp_matrix.rows()),
225  const_cast<StorageIndex *>(mp_matrix.outerIndexPtr()),
226  const_cast<StorageIndex *>(mp_matrix.innerIndexPtr()), &m_common);
227  if (m_symbolic) {
228  m_isInitialized = true;
229  m_info = Success;
230  m_analysisIsOk = true;
232  }
233  }
int m_analysisIsOk
Definition: KLUSupport.h:274
MatrixType::StorageIndex StorageIndex
Definition: KLUSupport.h:80
bool m_extractedDataAreDirty
Definition: KLUSupport.h:275
bool m_isInitialized
Definition: SparseSolverBase.h:110
@ InvalidInput
Definition: Constants.h:447

References Eigen::InvalidInput, Eigen::KLU< MatrixType_ >::m_analysisIsOk, Eigen::KLU< MatrixType_ >::m_common, Eigen::KLU< MatrixType_ >::m_extractedDataAreDirty, Eigen::KLU< MatrixType_ >::m_factorizationIsOk, Eigen::KLU< MatrixType_ >::m_info, Eigen::SparseSolverBase< KLU< MatrixType_ > >::m_isInitialized, Eigen::KLU< MatrixType_ >::m_symbolic, Eigen::KLU< MatrixType_ >::mp_matrix, and Eigen::Success.

Referenced by Eigen::KLU< MatrixType_ >::analyzePattern(), and Eigen::KLU< MatrixType_ >::compute().

◆ 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().
145  {
146  if (m_symbolic) klu_free_symbolic(&m_symbolic, &m_common);
147  if (m_numeric) klu_free_numeric(&m_numeric, &m_common);
148  grab(matrix.derived());
150  factorize_impl();
151  }
void factorize_impl()
Definition: KLUSupport.h:235

References Eigen::KLU< MatrixType_ >::analyzePattern_impl(), Eigen::KLU< MatrixType_ >::factorize_impl(), Eigen::KLU< MatrixType_ >::grab(), Eigen::KLU< MatrixType_ >::m_common, Eigen::KLU< MatrixType_ >::m_numeric, Eigen::KLU< MatrixType_ >::m_symbolic, and matrix().

Referenced by Eigen::KLU< MatrixType_ >::KLU().

◆ 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()
190  {
191  eigen_assert(m_analysisIsOk && "KLU: you must first call analyzePattern()");
192  if (m_numeric) klu_free_numeric(&m_numeric, &m_common);
193 
194  grab(matrix.derived());
195 
196  factorize_impl();
197  }

References eigen_assert, Eigen::KLU< MatrixType_ >::factorize_impl(), Eigen::KLU< MatrixType_ >::grab(), Eigen::KLU< MatrixType_ >::m_analysisIsOk, Eigen::KLU< MatrixType_ >::m_common, Eigen::KLU< MatrixType_ >::m_numeric, and matrix().

◆ factorize_impl()

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

◆ grab() [1/2]

template<typename MatrixType_ >
template<typename MatrixDerived >
void Eigen::KLU< MatrixType_ >::grab ( const EigenBase< MatrixDerived > &  A)
inlineprotected
246  {
248  internal::construct_at(&mp_matrix, A.derived());
249  }
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47
EIGEN_DEVICE_FUNC T * construct_at(T *p, Args &&... args)
Definition: Memory.h:1321
EIGEN_DEVICE_FUNC void destroy_at(T *p)
Definition: Memory.h:1335

References Eigen::internal::construct_at(), Eigen::internal::destroy_at(), and Eigen::KLU< MatrixType_ >::mp_matrix.

Referenced by Eigen::KLU< MatrixType_ >::analyzePattern(), Eigen::KLU< MatrixType_ >::compute(), and Eigen::KLU< MatrixType_ >::factorize().

◆ grab() [2/2]

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

◆ 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.
111  {
112  eigen_assert(m_isInitialized && "Decomposition is not initialized.");
113  return m_info;
114  }

References eigen_assert, Eigen::KLU< MatrixType_ >::m_info, and Eigen::SparseSolverBase< KLU< MatrixType_ > >::m_isInitialized.

◆ init()

◆ 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.

181 { return m_common; }

References Eigen::KLU< MatrixType_ >::m_common.

◆ 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.

173 { return m_common; }

References Eigen::KLU< MatrixType_ >::m_common.

◆ rows()

Member Data Documentation

◆ m_analysisIsOk

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

◆ m_common

◆ m_dummy

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

◆ m_extractedDataAreDirty

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

◆ m_factorizationIsOk

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

◆ m_info

◆ m_numeric

◆ m_symbolic

◆ mp_matrix


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