10#ifndef EIGEN_SUPERLUSUPPORT_H
11#define EIGEN_SUPERLUSUPPORT_H
14#include "./InternalHeaderCheck.h"
18#if defined(SUPERLU_MAJOR_VERSION) && (SUPERLU_MAJOR_VERSION >= 5)
19#define DECL_GSSVX(PREFIX, FLOATTYPE, KEYTYPE) \
21 extern void PREFIX##gssvx(superlu_options_t *, SuperMatrix *, int *, int *, int *, char *, FLOATTYPE *, FLOATTYPE *, \
22 SuperMatrix *, SuperMatrix *, void *, int, SuperMatrix *, SuperMatrix *, FLOATTYPE *, \
23 FLOATTYPE *, FLOATTYPE *, FLOATTYPE *, GlobalLU_t *, mem_usage_t *, SuperLUStat_t *, \
26 inline float SuperLU_gssvx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r, int *etree, \
27 char *equed, FLOATTYPE *R, FLOATTYPE *C, SuperMatrix *L, SuperMatrix *U, void *work, \
28 int lwork, SuperMatrix *B, SuperMatrix *X, FLOATTYPE *recip_pivot_growth, \
29 FLOATTYPE *rcond, FLOATTYPE *ferr, FLOATTYPE *berr, SuperLUStat_t *stats, int *info, \
31 mem_usage_t mem_usage; \
33 PREFIX##gssvx(options, A, perm_c, perm_r, etree, equed, R, C, L, U, work, lwork, B, X, recip_pivot_growth, rcond, \
34 ferr, berr, &gLU, &mem_usage, stats, info); \
35 return mem_usage.for_lu; \
38#define DECL_GSSVX(PREFIX, FLOATTYPE, KEYTYPE) \
40 extern void PREFIX##gssvx(superlu_options_t *, SuperMatrix *, int *, int *, int *, char *, FLOATTYPE *, FLOATTYPE *, \
41 SuperMatrix *, SuperMatrix *, void *, int, SuperMatrix *, SuperMatrix *, FLOATTYPE *, \
42 FLOATTYPE *, FLOATTYPE *, FLOATTYPE *, mem_usage_t *, SuperLUStat_t *, int *); \
44 inline float SuperLU_gssvx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r, int *etree, \
45 char *equed, FLOATTYPE *R, FLOATTYPE *C, SuperMatrix *L, SuperMatrix *U, void *work, \
46 int lwork, SuperMatrix *B, SuperMatrix *X, FLOATTYPE *recip_pivot_growth, \
47 FLOATTYPE *rcond, FLOATTYPE *ferr, FLOATTYPE *berr, SuperLUStat_t *stats, int *info, \
49 mem_usage_t mem_usage; \
50 PREFIX##gssvx(options, A, perm_c, perm_r, etree, equed, R, C, L, U, work, lwork, B, X, recip_pivot_growth, rcond, \
51 ferr, berr, &mem_usage, stats, info); \
52 return mem_usage.for_lu; \
56DECL_GSSVX(s,
float,
float)
57DECL_GSSVX(c,
float, std::complex<float>)
58DECL_GSSVX(d,
double,
double)
59DECL_GSSVX(z,
double, std::complex<double>)
62#define EIGEN_SUPERLU_HAS_ILU
65#ifdef EIGEN_SUPERLU_HAS_ILU
68#if defined(SUPERLU_MAJOR_VERSION) && (SUPERLU_MAJOR_VERSION >= 5)
69#define DECL_GSISX(PREFIX, FLOATTYPE, KEYTYPE) \
71 extern void PREFIX##gsisx(superlu_options_t *, SuperMatrix *, int *, int *, int *, char *, FLOATTYPE *, FLOATTYPE *, \
72 SuperMatrix *, SuperMatrix *, void *, int, SuperMatrix *, SuperMatrix *, FLOATTYPE *, \
73 FLOATTYPE *, GlobalLU_t *, mem_usage_t *, SuperLUStat_t *, int *); \
75 inline float SuperLU_gsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r, int *etree, \
76 char *equed, FLOATTYPE *R, FLOATTYPE *C, SuperMatrix *L, SuperMatrix *U, void *work, \
77 int lwork, SuperMatrix *B, SuperMatrix *X, FLOATTYPE *recip_pivot_growth, \
78 FLOATTYPE *rcond, SuperLUStat_t *stats, int *info, KEYTYPE) { \
79 mem_usage_t mem_usage; \
81 PREFIX##gsisx(options, A, perm_c, perm_r, etree, equed, R, C, L, U, work, lwork, B, X, recip_pivot_growth, rcond, \
82 &gLU, &mem_usage, stats, info); \
83 return mem_usage.for_lu; \
86#define DECL_GSISX(PREFIX, FLOATTYPE, KEYTYPE) \
88 extern void PREFIX##gsisx(superlu_options_t *, SuperMatrix *, int *, int *, int *, char *, FLOATTYPE *, FLOATTYPE *, \
89 SuperMatrix *, SuperMatrix *, void *, int, SuperMatrix *, SuperMatrix *, FLOATTYPE *, \
90 FLOATTYPE *, mem_usage_t *, SuperLUStat_t *, int *); \
92 inline float SuperLU_gsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r, int *etree, \
93 char *equed, FLOATTYPE *R, FLOATTYPE *C, SuperMatrix *L, SuperMatrix *U, void *work, \
94 int lwork, SuperMatrix *B, SuperMatrix *X, FLOATTYPE *recip_pivot_growth, \
95 FLOATTYPE *rcond, SuperLUStat_t *stats, int *info, KEYTYPE) { \
96 mem_usage_t mem_usage; \
97 PREFIX##gsisx(options, A, perm_c, perm_r, etree, equed, R, C, L, U, work, lwork, B, X, recip_pivot_growth, rcond, \
98 &mem_usage, stats, info); \
99 return mem_usage.for_lu; \
103DECL_GSISX(s,
float,
float)
104DECL_GSISX(c,
float, std::complex<float>)
105DECL_GSISX(d,
double,
double)
106DECL_GSISX(z,
double, std::complex<double>)
110template <
typename MatrixType>
111struct SluMatrixMapHelper;
120struct SluMatrix : SuperMatrix {
121 SluMatrix() { Store = &storage; }
123 SluMatrix(
const SluMatrix &other) : SuperMatrix(other) {
125 storage = other.storage;
128 SluMatrix &operator=(
const SluMatrix &other) {
129 SuperMatrix::operator=(
static_cast<const SuperMatrix &
>(other));
131 storage = other.storage;
145 void setStorageType(Stype_t t) {
147 if (t == SLU_NC || t == SLU_NR || t == SLU_DN)
150 eigen_assert(
false &&
"storage type not supported");
155 template <
typename Scalar>
156 void setScalarType() {
157 if (internal::is_same<Scalar, float>::value)
159 else if (internal::is_same<Scalar, double>::value)
161 else if (internal::is_same<Scalar, std::complex<float> >::value)
163 else if (internal::is_same<Scalar, std::complex<double> >::value)
166 eigen_assert(
false &&
"Scalar type not supported by SuperLU");
170 template <
typename MatrixType>
171 static SluMatrix Map(MatrixBase<MatrixType> &_mat) {
172 MatrixType &mat(_mat.derived());
174 "row-major dense matrices are not supported by SuperLU");
176 res.setStorageType(SLU_DN);
177 res.setScalarType<
typename MatrixType::Scalar>();
180 res.nrow = internal::convert_index<int>(mat.rows());
181 res.ncol = internal::convert_index<int>(mat.cols());
183 res.storage.lda = internal::convert_index<int>(MatrixType::IsVectorAtCompileTime ? mat.size() : mat.outerStride());
184 res.storage.values = (
void *)(mat.data());
188 template <
typename MatrixType>
189 static SluMatrix Map(SparseMatrixBase<MatrixType> &a_mat) {
190 MatrixType &mat(a_mat.derived());
193 res.setStorageType(SLU_NR);
194 res.nrow = internal::convert_index<int>(mat.cols());
195 res.ncol = internal::convert_index<int>(mat.rows());
197 res.setStorageType(SLU_NC);
198 res.nrow = internal::convert_index<int>(mat.rows());
199 res.ncol = internal::convert_index<int>(mat.cols());
204 res.storage.nnz = internal::convert_index<int>(mat.nonZeros());
205 res.storage.values = mat.valuePtr();
206 res.storage.innerInd = mat.innerIndexPtr();
207 res.storage.outerInd = mat.outerIndexPtr();
209 res.setScalarType<
typename MatrixType::Scalar>();
212 if (
int(MatrixType::Flags) &
int(
Upper)) res.Mtype = SLU_TRU;
213 if (
int(MatrixType::Flags) &
int(
Lower)) res.Mtype = SLU_TRL;
215 eigen_assert(((
int(MatrixType::Flags) &
int(
SelfAdjoint)) == 0) &&
216 "SelfAdjoint matrix shape not supported by SuperLU");
222template <
typename Scalar,
int Rows,
int Cols,
int Options,
int MRows,
int MCols>
223struct SluMatrixMapHelper<
Matrix<
Scalar, Rows, Cols, Options, MRows, MCols> > {
224 typedef Matrix<Scalar, Rows, Cols, Options, MRows, MCols> MatrixType;
225 static void run(MatrixType &mat, SluMatrix &res) {
226 eigen_assert(((Options &
RowMajor) !=
RowMajor) &&
"row-major dense matrices is not supported by SuperLU");
227 res.setStorageType(SLU_DN);
228 res.setScalarType<Scalar>();
231 res.nrow = mat.rows();
232 res.ncol = mat.cols();
234 res.storage.lda = mat.outerStride();
235 res.storage.values = mat.data();
239template <
typename Derived>
241 typedef Derived MatrixType;
242 static void run(MatrixType &mat, SluMatrix &res) {
244 res.setStorageType(SLU_NR);
245 res.nrow = mat.cols();
246 res.ncol = mat.rows();
248 res.setStorageType(SLU_NC);
249 res.nrow = mat.rows();
250 res.ncol = mat.cols();
255 res.storage.nnz = mat.nonZeros();
256 res.storage.values = mat.valuePtr();
257 res.storage.innerInd = mat.innerIndexPtr();
258 res.storage.outerInd = mat.outerIndexPtr();
260 res.setScalarType<
typename MatrixType::Scalar>();
263 if (MatrixType::Flags &
Upper) res.Mtype = SLU_TRU;
264 if (MatrixType::Flags &
Lower) res.Mtype = SLU_TRL;
266 eigen_assert(((MatrixType::Flags &
SelfAdjoint) == 0) &&
"SelfAdjoint matrix shape not supported by SuperLU");
272template <
typename MatrixType>
273SluMatrix asSluMatrix(MatrixType &mat) {
274 return SluMatrix::Map(mat);
278template <
typename Scalar,
int Flags,
typename Index>
279Map<SparseMatrix<Scalar, Flags, Index> > map_superlu(SluMatrix &sluMat) {
285 return Map<SparseMatrix<Scalar, Flags, Index> >(sluMat.nrow, sluMat.ncol, sluMat.storage.outerInd[outerSize],
286 sluMat.storage.outerInd, sluMat.storage.innerInd,
287 reinterpret_cast<Scalar *
>(sluMat.storage.values));
296template <
typename MatrixType_,
typename Derived>
301 using Base::m_isInitialized;
304 typedef MatrixType_ MatrixType;
305 typedef typename MatrixType::Scalar Scalar;
306 typedef typename MatrixType::RealScalar RealScalar;
307 typedef typename MatrixType::StorageIndex StorageIndex;
313 enum { ColsAtCompileTime = MatrixType::ColsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime };
318 ~SuperLUBase() { clearFactors(); }
320 inline Index rows()
const {
return m_matrix.rows(); }
321 inline Index cols()
const {
return m_matrix.cols(); }
324 inline superlu_options_t &
options() {
return m_sluOptions; }
332 eigen_assert(m_isInitialized &&
"Decomposition is not initialized.");
338 derived().analyzePattern(matrix);
339 derived().factorize(matrix);
349 m_isInitialized =
true;
351 m_analysisIsOk =
true;
352 m_factorizationIsOk =
false;
355 template <
typename Stream>
356 void dumpMemory(Stream & ) {}
359 void initFactorization(
const MatrixType &a) {
360 set_default_options(&this->m_sluOptions);
362 const Index size = a.rows();
365 m_sluA = internal::asSluMatrix(m_matrix);
372 m_sluEtree.resize(size);
375 m_sluB.setStorageType(SLU_DN);
376 m_sluB.setScalarType<Scalar>();
377 m_sluB.Mtype = SLU_GE;
378 m_sluB.storage.values = 0;
381 m_sluB.storage.lda = internal::convert_index<int>(size);
384 m_extractedDataAreDirty =
true;
389 m_isInitialized =
false;
394 void extractData()
const;
396 void clearFactors() {
397 if (m_sluL.Store) Destroy_SuperNode_Matrix(&m_sluL);
398 if (m_sluU.Store) Destroy_CompCol_Matrix(&m_sluU);
403 memset(&m_sluL, 0,
sizeof m_sluL);
404 memset(&m_sluU, 0,
sizeof m_sluU);
408 mutable LUMatrixType m_l;
409 mutable LUMatrixType m_u;
410 mutable IntColVectorType m_p;
411 mutable IntRowVectorType m_q;
413 mutable LUMatrixType m_matrix;
414 mutable SluMatrix m_sluA;
415 mutable SuperMatrix m_sluL, m_sluU;
416 mutable SluMatrix m_sluB, m_sluX;
417 mutable SuperLUStat_t m_sluStat;
418 mutable superlu_options_t m_sluOptions;
419 mutable std::vector<int> m_sluEtree;
420 mutable Matrix<RealScalar, Dynamic, 1> m_sluRscale, m_sluCscale;
421 mutable Matrix<RealScalar, Dynamic, 1> m_sluFerr, m_sluBerr;
422 mutable char m_sluEqued;
425 int m_factorizationIsOk;
427 mutable bool m_extractedDataAreDirty;
430 SuperLUBase(SuperLUBase &) {}
449template <
typename MatrixType_>
450class SuperLU :
public SuperLUBase<MatrixType_, SuperLU<MatrixType_> > {
452 typedef SuperLUBase<MatrixType_, SuperLU> Base;
453 typedef MatrixType_ MatrixType;
454 typedef typename Base::Scalar Scalar;
455 typedef typename Base::RealScalar RealScalar;
456 typedef typename Base::StorageIndex StorageIndex;
457 typedef typename Base::IntRowVectorType IntRowVectorType;
458 typedef typename Base::IntColVectorType IntColVectorType;
459 typedef typename Base::PermutationMap PermutationMap;
460 typedef typename Base::LUMatrixType LUMatrixType;
465 using Base::_solve_impl;
467 SuperLU() : Base() { init(); }
469 explicit SuperLU(
const MatrixType &matrix) : Base() {
484 m_isInitialized =
false;
497 template <
typename Rhs,
typename Dest>
500 inline const LMatrixType &matrixL()
const {
501 if (m_extractedDataAreDirty) this->extractData();
505 inline const UMatrixType &matrixU()
const {
506 if (m_extractedDataAreDirty) this->extractData();
510 inline const IntColVectorType &permutationP()
const {
511 if (m_extractedDataAreDirty) this->extractData();
515 inline const IntRowVectorType &permutationQ()
const {
516 if (m_extractedDataAreDirty) this->extractData();
520 Scalar determinant()
const;
524 using Base::m_matrix;
529 using Base::m_sluBerr;
530 using Base::m_sluCscale;
531 using Base::m_sluEqued;
532 using Base::m_sluEtree;
533 using Base::m_sluFerr;
535 using Base::m_sluOptions;
536 using Base::m_sluRscale;
537 using Base::m_sluStat;
542 using Base::m_analysisIsOk;
543 using Base::m_extractedDataAreDirty;
544 using Base::m_factorizationIsOk;
546 using Base::m_isInitialized;
551 set_default_options(&this->m_sluOptions);
552 m_sluOptions.PrintStat = NO;
553 m_sluOptions.ConditionNumber = NO;
554 m_sluOptions.Trans = NOTRANS;
555 m_sluOptions.ColPerm = COLAMD;
559 SuperLU(SuperLU &) {}
562template <
typename MatrixType>
564 eigen_assert(m_analysisIsOk &&
"You must first call analyzePattern()");
565 if (!m_analysisIsOk) {
570 this->initFactorization(a);
572 m_sluOptions.ColPerm = COLAMD;
574 RealScalar recip_pivot_growth, rcond;
575 RealScalar ferr, berr;
577 StatInit(&m_sluStat);
578 SuperLU_gssvx(&m_sluOptions, &m_sluA, m_q.data(), m_p.data(), &m_sluEtree[0], &m_sluEqued, &m_sluRscale[0],
579 &m_sluCscale[0], &m_sluL, &m_sluU, NULL, 0, &m_sluB, &m_sluX, &recip_pivot_growth, &rcond, &ferr, &berr,
580 &m_sluStat, &
info, Scalar());
581 StatFree(&m_sluStat);
583 m_extractedDataAreDirty =
true;
587 m_factorizationIsOk =
true;
590template <
typename MatrixType>
591template <
typename Rhs,
typename Dest>
593 eigen_assert(m_factorizationIsOk &&
594 "The decomposition is not in a valid state for solving, you must first call either compute() or "
595 "analyzePattern()/factorize()");
597 const Index rhsCols = b.cols();
598 eigen_assert(m_matrix.rows() == b.rows());
600 m_sluOptions.Trans = NOTRANS;
601 m_sluOptions.Fact = FACTORED;
602 m_sluOptions.IterRefine = NOREFINE;
604 m_sluFerr.resize(rhsCols);
605 m_sluBerr.resize(rhsCols);
610 m_sluB = SluMatrix::Map(b_ref.const_cast_derived());
611 m_sluX = SluMatrix::Map(x_ref.const_cast_derived());
613 typename Rhs::PlainObject b_cpy;
614 if (m_sluEqued !=
'N') {
616 m_sluB = SluMatrix::Map(b_cpy.const_cast_derived());
619 StatInit(&m_sluStat);
621 RealScalar recip_pivot_growth, rcond;
622 SuperLU_gssvx(&m_sluOptions, &m_sluA, m_q.data(), m_p.data(), &m_sluEtree[0], &m_sluEqued, &m_sluRscale[0],
623 &m_sluCscale[0], &m_sluL, &m_sluU, NULL, 0, &m_sluB, &m_sluX, &recip_pivot_growth, &rcond,
624 &m_sluFerr[0], &m_sluBerr[0], &m_sluStat, &info, Scalar());
625 StatFree(&m_sluStat);
627 if (x.derived().data() != x_ref.data()) x = x_ref;
639template <
typename MatrixType,
typename Derived>
640void SuperLUBase<MatrixType, Derived>::extractData()
const {
641 eigen_assert(m_factorizationIsOk &&
642 "The decomposition is not in a valid state for extracting factors, you must first call either compute() "
643 "or analyzePattern()/factorize()");
644 if (m_extractedDataAreDirty) {
646 int fsupc, istart, nsupr;
647 int lastl = 0, lastu = 0;
648 SCformat *Lstore =
static_cast<SCformat *
>(m_sluL.Store);
649 NCformat *Ustore =
static_cast<NCformat *
>(m_sluU.Store);
652 const Index size = m_matrix.rows();
653 m_l.resize(size, size);
654 m_l.resizeNonZeros(Lstore->nnz);
655 m_u.resize(size, size);
656 m_u.resizeNonZeros(Ustore->nnz);
658 int *Lcol = m_l.outerIndexPtr();
659 int *Lrow = m_l.innerIndexPtr();
660 Scalar *Lval = m_l.valuePtr();
662 int *Ucol = m_u.outerIndexPtr();
663 int *Urow = m_u.innerIndexPtr();
664 Scalar *Uval = m_u.valuePtr();
670 for (
int k = 0; k <= Lstore->nsuper; ++k) {
671 fsupc = L_FST_SUPC(k);
672 istart = L_SUB_START(fsupc);
673 nsupr = L_SUB_START(fsupc + 1) - istart;
677 for (
int j = fsupc; j < L_FST_SUPC(k + 1); ++j) {
678 SNptr = &((
Scalar *)Lstore->nzval)[L_NZ_START(j)];
681 for (
int i = U_NZ_START(j); i < U_NZ_START(j + 1); ++i) {
682 Uval[lastu] = ((
Scalar *)Ustore->nzval)[i];
684 if (Uval[lastu] != 0.0) Urow[lastu++] = U_SUB(i);
686 for (
int i = 0; i < upper; ++i) {
688 Uval[lastu] = SNptr[i];
690 if (Uval[lastu] != 0.0) Urow[lastu++] = L_SUB(istart + i);
696 Lrow[lastl++] = L_SUB(istart + upper - 1);
697 for (
int i = upper; i < nsupr; ++i) {
698 Lval[lastl] = SNptr[i];
700 if (Lval[lastl] != 0.0) Lrow[lastl++] = L_SUB(istart + i);
710 m_l.resizeNonZeros(lastl);
711 m_u.resizeNonZeros(lastu);
713 m_extractedDataAreDirty =
false;
717template <
typename MatrixType>
718typename SuperLU<MatrixType>::Scalar SuperLU<MatrixType>::determinant()
const {
719 eigen_assert(m_factorizationIsOk &&
720 "The decomposition is not in a valid state for computing the determinant, you must first call either "
721 "compute() or analyzePattern()/factorize()");
723 if (m_extractedDataAreDirty) this->extractData();
726 for (
int j = 0; j < m_u.cols(); ++j) {
727 if (m_u.outerIndexPtr()[j + 1] - m_u.outerIndexPtr()[j] > 0) {
728 int lastId = m_u.outerIndexPtr()[j + 1] - 1;
729 eigen_assert(m_u.innerIndexPtr()[lastId] <= j);
730 if (m_u.innerIndexPtr()[lastId] == j) det *= m_u.valuePtr()[lastId];
733 if (PermutationMap(m_p.data(), m_p.size()).determinant() * PermutationMap(m_q.data(), m_q.size()).determinant() < 0)
735 if (m_sluEqued !=
'N')
736 return det / m_sluRscale.prod() / m_sluCscale.prod();
741#ifdef EIGEN_PARSED_BY_DOXYGEN
742#define EIGEN_SUPERLU_HAS_ILU
745#ifdef EIGEN_SUPERLU_HAS_ILU
764template <
typename MatrixType_>
765class SuperILU :
public SuperLUBase<MatrixType_, SuperILU<MatrixType_> > {
767 typedef SuperLUBase<MatrixType_, SuperILU> Base;
768 typedef MatrixType_ MatrixType;
769 typedef typename Base::Scalar Scalar;
770 typedef typename Base::RealScalar RealScalar;
773 using Base::_solve_impl;
775 SuperILU() : Base() { init(); }
777 SuperILU(
const MatrixType &matrix) : Base() {
800#ifndef EIGEN_PARSED_BY_DOXYGEN
802 template <
typename Rhs,
typename Dest>
808 using Base::m_matrix;
813 using Base::m_sluBerr;
814 using Base::m_sluCscale;
815 using Base::m_sluEqued;
816 using Base::m_sluEtree;
817 using Base::m_sluFerr;
819 using Base::m_sluOptions;
820 using Base::m_sluRscale;
821 using Base::m_sluStat;
826 using Base::m_analysisIsOk;
827 using Base::m_extractedDataAreDirty;
828 using Base::m_factorizationIsOk;
830 using Base::m_isInitialized;
835 ilu_set_default_options(&m_sluOptions);
836 m_sluOptions.PrintStat = NO;
837 m_sluOptions.ConditionNumber = NO;
838 m_sluOptions.Trans = NOTRANS;
839 m_sluOptions.ColPerm = MMD_AT_PLUS_A;
842 m_sluOptions.ILU_MILU = SILU;
846 m_sluOptions.ILU_DropRule = DROP_BASIC;
847 m_sluOptions.ILU_DropTol = NumTraits<Scalar>::dummy_precision() * 10;
851 SuperILU(SuperILU &) {}
854template <
typename MatrixType>
856 eigen_assert(m_analysisIsOk &&
"You must first call analyzePattern()");
857 if (!m_analysisIsOk) {
862 this->initFactorization(a);
865 RealScalar recip_pivot_growth, rcond;
867 StatInit(&m_sluStat);
868 SuperLU_gsisx(&m_sluOptions, &m_sluA, m_q.data(), m_p.data(), &m_sluEtree[0], &m_sluEqued, &m_sluRscale[0],
869 &m_sluCscale[0], &m_sluL, &m_sluU, NULL, 0, &m_sluB, &m_sluX, &recip_pivot_growth, &rcond, &m_sluStat,
871 StatFree(&m_sluStat);
875 m_factorizationIsOk =
true;
878#ifndef EIGEN_PARSED_BY_DOXYGEN
879template <
typename MatrixType>
880template <
typename Rhs,
typename Dest>
882 eigen_assert(m_factorizationIsOk &&
883 "The decomposition is not in a valid state for solving, you must first call either compute() or "
884 "analyzePattern()/factorize()");
886 const int rhsCols = b.cols();
887 eigen_assert(m_matrix.rows() == b.rows());
889 m_sluOptions.Trans = NOTRANS;
890 m_sluOptions.Fact = FACTORED;
891 m_sluOptions.IterRefine = NOREFINE;
893 m_sluFerr.resize(rhsCols);
894 m_sluBerr.resize(rhsCols);
899 m_sluB = SluMatrix::Map(b_ref.const_cast_derived());
900 m_sluX = SluMatrix::Map(x_ref.const_cast_derived());
902 typename Rhs::PlainObject b_cpy;
903 if (m_sluEqued !=
'N') {
905 m_sluB = SluMatrix::Map(b_cpy.const_cast_derived());
909 RealScalar recip_pivot_growth, rcond;
911 StatInit(&m_sluStat);
912 SuperLU_gsisx(&m_sluOptions, &m_sluA, m_q.data(), m_p.data(), &m_sluEtree[0], &m_sluEqued, &m_sluRscale[0],
913 &m_sluCscale[0], &m_sluL, &m_sluU, NULL, 0, &m_sluB, &m_sluX, &recip_pivot_growth, &rcond, &m_sluStat,
915 StatFree(&m_sluStat);
917 if (x.derived().data() != x_ref.data()) x = x_ref;
A matrix or vector expression mapping an existing array of data.
Definition Map.h:96
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:52
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:186
constexpr void resize(Index rows, Index cols)
Definition PlainObjectBase.h:268
A matrix or vector expression mapping an existing expression.
Definition Ref.h:264
Base class of any sparse matrices or sparse expressions.
Definition SparseMatrixBase.h:30
A versatible sparse matrix representation.
Definition SparseMatrix.h:121
SparseSolverBase()
Definition SparseSolverBase.h:70
A sparse direct incomplete LU factorization and solver based on the SuperLU library.
Definition SuperLUSupport.h:765
void analyzePattern(const MatrixType &matrix)
Definition SuperLUSupport.h:790
void factorize(const MatrixType &matrix)
Definition SuperLUSupport.h:855
void compute(const MatrixType &matrix)
Definition SuperLUSupport.h:337
ComputationInfo info() const
Reports whether previous computation was successful.
Definition SuperLUSupport.h:331
void analyzePattern(const MatrixType &)
Definition SuperLUSupport.h:348
superlu_options_t & options()
Definition SuperLUSupport.h:324
void factorize(const MatrixType &matrix)
Definition SuperLUSupport.h:563
void analyzePattern(const MatrixType &matrix)
Definition SuperLUSupport.h:482
Expression of a triangular part in a matrix.
Definition TriangularMatrix.h:167
ComputationInfo
Definition Constants.h:438
@ SelfAdjoint
Definition Constants.h:227
@ Lower
Definition Constants.h:211
@ Upper
Definition Constants.h:213
@ NumericalIssue
Definition Constants.h:442
@ InvalidInput
Definition Constants.h:447
@ Success
Definition Constants.h:440
@ ColMajor
Definition Constants.h:318
@ RowMajor
Definition Constants.h:320
const unsigned int RowMajorBit
Definition Constants.h:70
Namespace containing all symbols from the Eigen library.
Definition B01_Experimental.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:82