11 #ifndef EIGEN_INCOMPLETE_CHOlESKY_H
12 #define EIGEN_INCOMPLETE_CHOlESKY_H
45 template <
typename Scalar,
int UpLo_ = Lower,
typename OrderingType_ = AMDOrdering<
int> >
60 typedef std::vector<std::list<StorageIndex> >
VectorList;
78 template<
typename MatrixType>
111 template<
typename MatrixType>
116 ord(
mat.template selfadjointView<UpLo>(), pinv);
117 if(pinv.size()>0)
m_perm = pinv.inverse();
132 template<
typename MatrixType>
141 template<
typename MatrixType>
149 template<
typename Rhs,
typename Dest>
156 x =
m_L.template triangularView<Lower>().solve(
x);
157 x =
m_L.
adjoint().template triangularView<Upper>().solve(
x);
189 template<
typename Scalar,
int UpLo_,
typename OrderingType>
190 template<
typename MatrixType_>
194 eigen_assert(m_analysisIsOk &&
"analyzePattern() should be called first");
199 if (m_perm.rows() ==
mat.
rows() )
203 tmp =
mat.template selfadjointView<UpLo_>().twistedBy(m_perm);
204 m_L.template selfadjointView<Lower>() = tmp.template selfadjointView<Lower>();
208 m_L.template selfadjointView<Lower>() =
mat.template selfadjointView<UpLo_>();
212 Index nnz = m_L.nonZeros();
221 col_pattern.fill(-1);
229 for (
Index k = colPtr[
j]; k < colPtr[
j+1]; k++)
236 m_scale = m_scale.cwiseSqrt().cwiseSqrt();
250 for (
Index k = colPtr[
j]; k < colPtr[
j+1]; k++)
251 vals[k] *= (m_scale(
j)*m_scale(rowIdx[k]));
252 eigen_internal_assert(rowIdx[colPtr[
j]]==
j &&
"IncompleteCholesky: only the lower triangular part must be stored");
260 shift = m_initialShift - mindiag;
270 vals[colPtr[
j]] += shift;
278 Scalar diag = vals[colPtr[
j]];
280 for (
Index i = colPtr[
j] + 1;
i < colPtr[
j+1];
i++)
283 col_vals(col_nnz) = vals[
i];
284 col_irow(col_nnz) = l;
285 col_pattern(l) = col_nnz;
289 typename std::list<StorageIndex>::iterator k;
291 for(k = listCol[
j].begin(); k != listCol[
j].end(); k++)
293 Index jk = firstElt(*k);
298 for (
Index i = jk;
i < colPtr[*k+1];
i++)
303 col_vals(col_nnz) = vals[
i] * v_j_jk;
304 col_irow[col_nnz] = l;
305 col_pattern(l) = col_nnz;
309 col_vals(col_pattern[l]) -= vals[
i] * v_j_jk;
311 updateList(colPtr,rowIdx,vals, *k, jk, firstElt, listCol);
327 col_pattern.fill(-1);
335 vals[colPtr[
j]] = rdiag;
336 for (
Index k = 0; k<col_nnz; ++k)
340 col_vals(k) /= rdiag;
346 Index p = colPtr[
j+1] - colPtr[
j] - 1 ;
352 for (
Index i = colPtr[
j]+1;
i < colPtr[
j+1];
i++)
354 vals[
i] = col_vals(cpt);
355 rowIdx[
i] = col_irow(cpt);
357 col_pattern(col_irow(cpt)) = -1;
362 updateList(colPtr,rowIdx,vals,
j,jk,firstElt,listCol);
367 m_factorizationIsOk =
true;
373 template<
typename Scalar,
int UpLo_,
typename OrderingType>
376 if (jk < colPtr(
col+1) )
380 rowIdx.segment(jk,
p).minCoeff(&minpos);
382 if (rowIdx(minpos) != rowIdx(jk))
388 firstElt(
col) = internal::convert_index<StorageIndex,Index>(jk);
389 listCol[rowIdx(jk)].push_back(internal::convert_index<StorageIndex,Index>(
col));
const SqrtReturnType sqrt() const
ColXpr col(Index i)
This is the const version of col().
RealReturnType real() const
Array< double, 1, 3 > e(1./3., 0.5, 2.)
#define eigen_internal_assert(x)
Matrix< float, 1, Dynamic > MatrixType
Modified Incomplete Cholesky with dual threshold.
ComputationInfo info() const
Reports whether previous computation was successful.
void updateList(Ref< const VectorIx > colPtr, Ref< VectorIx > rowIdx, Ref< VectorSx > vals, const Index &col, const Index &jk, VectorIx &firstElt, VectorList &listCol)
IncompleteCholesky(const MatrixType &matrix)
std::vector< std::list< StorageIndex > > VectorList
SparseMatrix< Scalar, ColMajor, StorageIndex > FactorType
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Matrix< RealScalar, Dynamic, 1 > VectorRx
void factorize(const MatrixType &mat)
Performs the numerical factorization of the input matrix mat.
const VectorRx & scalingS() const
OrderingType_ OrderingType
const PermutationType & permutationP() const
void _solve_impl(const Rhs &b, Dest &x) const
Matrix< StorageIndex, Dynamic, 1 > VectorIx
OrderingType::PermutationType PermutationType
SparseSolverBase< IncompleteCholesky< Scalar, UpLo_, OrderingType_ > > Base
void compute(const MatrixType &mat)
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
const FactorType & matrixL() const
void analyzePattern(const MatrixType &mat)
Computes the fill reducing permutation vector using the sparsity pattern of mat.
RealScalar m_initialShift
Matrix< Scalar, Dynamic, 1 > VectorSx
PermutationType::StorageIndex StorageIndex
NumTraits< Scalar >::Real RealScalar
void setInitialShift(RealScalar shift)
Set the initial shift parameter .
A matrix or vector expression mapping an existing array of data.
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
constexpr void resize(Index rows, Index cols)
A matrix or vector expression mapping an existing expression.
const AdjointReturnType adjoint() const
const Scalar * valuePtr() const
void resize(Index rows, Index cols)
const StorageIndex * outerIndexPtr() const
const StorageIndex * innerIndexPtr() const
A base class for sparse solvers.
bfloat16() min(const bfloat16 &a, const bfloat16 &b)
Index QuickSplit(VectorV &row, VectorI &ind, Index ncut)
void swap(scoped_array< T > &a, scoped_array< T > &b)
EIGEN_ALWAYS_INLINE T maxi(const T &x, const T &y)
EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_conjugate_op< typename Derived::Scalar >, const Derived > conj(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sqrt_op< typename Derived::Scalar >, const Derived > sqrt(const Eigen::ArrayBase< Derived > &x)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.