454 using internal::emptyIdxLU;
455 eigen_assert(m_analysisIsOk &&
"analyzePattern() should be called first");
456 eigen_assert((
matrix.rows() ==
matrix.cols()) &&
"Only for squared matrices");
458 typedef typename IndexVector::Scalar Index;
468 const Index * outerIndexPtr;
469 if (
matrix.isCompressed()) outerIndexPtr =
matrix.outerIndexPtr();
472 Index* outerIndexPtr_t =
new Index[
matrix.cols()+1];
474 outerIndexPtr = outerIndexPtr_t;
476 for (Index i = 0; i <
matrix.cols(); i++)
481 if(!
matrix.isCompressed())
delete[] outerIndexPtr;
486 for(Index i = 0; i <
matrix.cols(); ++i) m_perm_c.
indices()(i) = i;
489 Index m = m_mat.
rows();
490 Index n = m_mat.
cols();
492 Index maxpanel = m_perfv.panel_size * m;
495 Index
info =
Base::memInit(m, n, nnz, lwork, m_perfv.fillfactor, m_perfv.panel_size, m_glu);
498 m_lastError =
"UNABLE TO ALLOCATE WORKING MEMORY\n\n" ;
499 m_factorizationIsOk =
false;
504 IndexVector segrep(m); segrep.setZero();
505 IndexVector parent(m); parent.setZero();
506 IndexVector xplore(m); xplore.setZero();
507 IndexVector repfnz(maxpanel);
508 IndexVector panel_lsub(maxpanel);
509 IndexVector xprune(n); xprune.setZero();
510 IndexVector marker(m*internal::LUNoMarker); marker.setZero();
512 repfnz.setConstant(-1);
513 panel_lsub.setConstant(-1);
519 tempv.
setZero(internal::LUnumTempV(m, m_perfv.panel_size, m_perfv.maxsuper, m) );
522 PermutationType iperm_c(m_perm_c.
inverse());
525 IndexVector relax_end(n);
526 if ( m_symmetricmode ==
true )
533 m_perm_r.
indices().setConstant(-1);
534 marker.setConstant(-1);
537 m_glu.supno(0) = emptyIdxLU; m_glu.xsup.
setConstant(0);
538 m_glu.xsup(0) = m_glu.xlsub(0) = m_glu.xusub(0) = m_glu.xlusup(0) = Index(0);
544 IndexVector panel_histo(n);
550 for (jcol = 0; jcol < n; )
553 Index panel_size = m_perfv.panel_size;
554 for (k = jcol + 1; k < (std::min)(jcol+panel_size, n); k++)
556 if (relax_end(k) != emptyIdxLU)
558 panel_size = k - jcol;
563 panel_size = n - jcol;
566 Base::panel_dfs(m, panel_size, jcol, m_mat, m_perm_r.
indices(), nseg1, dense, panel_lsub, segrep, repfnz, xprune, marker, parent, xplore, m_glu);
569 Base::panel_bmod(m, panel_size, jcol, nseg1, dense, tempv, segrep, repfnz, m_glu);
572 for ( jj = jcol; jj< jcol + panel_size; jj++)
578 VectorBlock<IndexVector> panel_lsubk(panel_lsub, k, m);
579 VectorBlock<IndexVector> repfnz_k(repfnz, k, m);
580 info =
Base::column_dfs(m, jj, m_perm_r.
indices(), m_perfv.maxsuper, nseg, panel_lsubk, segrep, repfnz_k, xprune, marker, parent, xplore, m_glu);
583 m_lastError =
"UNABLE TO EXPAND MEMORY IN COLUMN_DFS() ";
585 m_factorizationIsOk =
false;
589 VectorBlock<ScalarVector> dense_k(dense, k, m);
590 VectorBlock<IndexVector> segrep_k(segrep, nseg1, m-nseg1);
591 info =
Base::column_bmod(jj, (nseg - nseg1), dense_k, tempv, segrep_k, repfnz_k, jcol, m_glu);
594 m_lastError =
"UNABLE TO EXPAND MEMORY IN COLUMN_BMOD() ";
596 m_factorizationIsOk =
false;
604 m_lastError =
"UNABLE TO EXPAND MEMORY IN COPY_TO_UCOL() ";
606 m_factorizationIsOk =
false;
611 info =
Base::pivotL(jj, m_diagpivotthresh, m_perm_r.
indices(), iperm_c.indices(), pivrow, m_glu);
614 m_lastError =
"THE MATRIX IS STRUCTURALLY SINGULAR ... ZERO COLUMN AT ";
615 std::ostringstream returnInfo;
617 m_lastError += returnInfo.str();
619 m_factorizationIsOk =
false;
624 if (pivrow != jj) m_detPermR *= -1;
630 for (i = 0; i < nseg; i++)
633 repfnz_k(irep) = emptyIdxLU;
645 m_Lstore.
setInfos(m, n, m_glu.lusup, m_glu.xlusup, m_glu.lsub, m_glu.xlsub, m_glu.supno, m_glu.xsup);
647 new (&m_Ustore) MappedSparseMatrix<Scalar, ColMajor, Index> ( m, n, m_nnzU, m_glu.xusub.
data(), m_glu.usub.
data(), m_glu.ucol.
data() );
650 m_factorizationIsOk =
true;
Index copy_to_ucol(const Index jcol, const Index nseg, IndexVector &segrep, BlockIndexVector repfnz, IndexVector &perm_r, BlockScalarVector dense, GlobalLU_t &glu)
Performs numeric block updates (sup-col) in topological order.
void pruneL(const Index jcol, const IndexVector &perm_r, const Index pivrow, const Index nseg, const IndexVector &segrep, BlockIndexVector repfnz, IndexVector &xprune, GlobalLU_t &glu)
Prunes the L-structure.
void setInfos(Index m, Index n, ScalarVector &nzval, IndexVector &nzval_colptr, IndexVector &rowind, IndexVector &rowind_colptr, IndexVector &col_to_sup, IndexVector &sup_to_col)
void relax_snode(const Index n, IndexVector &et, const Index relax_columns, IndexVector &descendants, IndexVector &relax_end)
Identify the initial relaxed supernodes.
void fixupL(const Index n, const IndexVector &perm_r, GlobalLU_t &glu)
Fix up the data storage lsub for L-subscripts.
ComputationInfo info() const
Reports whether previous computation was successful.
void resize(Index newSize)
Index pivotL(const Index jcol, const RealScalar &diagpivotthresh, IndexVector &perm_r, IndexVector &iperm_c, Index &pivrow, GlobalLU_t &glu)
Performs the numerical pivotin on the current column of L, and the CDIV operation.
void countnz(const Index n, Index &nnzL, Index &nnzU, GlobalLU_t &glu)
Count Nonzero elements in the factors.
void heap_relax_snode(const Index n, IndexVector &et, const Index relax_columns, IndexVector &descendants, IndexVector &relax_end)
Identify the initial relaxed supernodes.
void panel_dfs(const Index m, const Index w, const Index jcol, MatrixType &A, IndexVector &perm_r, Index &nseg, ScalarVector &dense, IndexVector &panel_lsub, IndexVector &segrep, IndexVector &repfnz, IndexVector &xprune, IndexVector &marker, IndexVector &parent, IndexVector &xplore, GlobalLU_t &glu)
Performs a symbolic factorization on a panel of columns [jcol, jcol+w)
Index memInit(Index m, Index n, Index annz, Index lwork, Index fillratio, Index panel_size, GlobalLU_t &glu)
Allocate various working space for the numerical factorization phase.
Derived & setConstant(Index size, const Scalar &value)
EIGEN_STRONG_INLINE const Scalar * data() const
void panel_bmod(const Index m, const Index w, const Index jcol, const Index nseg, ScalarVector &dense, ScalarVector &tempv, IndexVector &segrep, IndexVector &repfnz, GlobalLU_t &glu)
Performs numeric block updates (sup-panel) in topological order.
const Index * innerNonZeroPtr() const
const IndicesType & indices() const
Transpose< PermutationBase > inverse() const
Derived & setZero(Index size)
Index column_dfs(const Index m, const Index jcol, IndexVector &perm_r, Index maxsuper, Index &nseg, BlockIndexVector lsub_col, IndexVector &segrep, BlockIndexVector repfnz, IndexVector &xprune, IndexVector &marker, IndexVector &parent, IndexVector &xplore, GlobalLU_t &glu)
Performs a symbolic factorization on column jcol and decide the supernode boundary.
const Index * outerIndexPtr() const
Index column_bmod(const Index jcol, const Index nseg, BlockScalarVector dense, ScalarVector &tempv, BlockIndexVector segrep, BlockIndexVector repfnz, Index fpanelc, GlobalLU_t &glu)
Performs numeric block updates (sup-col) in topological order.