MCPcopy Create free account
hub / github.com/HiLab-git/SimpleCRF / factorize

Method factorize

dependency/densecrf/include/Eigen/src/SparseLU/SparseLU.h:595–796  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

593 */
594template <typename MatrixType, typename OrderingType>
595void SparseLU<MatrixType, OrderingType>::factorize(const MatrixType& matrix)
596{
597 using internal::emptyIdxLU;
598 eigen_assert(m_analysisIsOk && "analyzePattern() should be called first");
599 eigen_assert((matrix.rows() == matrix.cols()) && "Only for squared matrices");
600
601 m_isInitialized = true;
602
603 // Apply the column permutation computed in analyzepattern()
604 // m_mat = matrix * m_perm_c.inverse();
605 m_mat = matrix;
606 if (m_perm_c.size())
607 {
608 m_mat.uncompress(); //NOTE: The effect of this command is only to create the InnerNonzeros pointers.
609 //Then, permute only the column pointers
610 const StorageIndex * outerIndexPtr;
611 if (matrix.isCompressed()) outerIndexPtr = matrix.outerIndexPtr();
612 else
613 {
614 StorageIndex* outerIndexPtr_t = new StorageIndex[matrix.cols()+1];
615 for(Index i = 0; i <= matrix.cols(); i++) outerIndexPtr_t[i] = m_mat.outerIndexPtr()[i];
616 outerIndexPtr = outerIndexPtr_t;
617 }
618 for (Index i = 0; i < matrix.cols(); i++)
619 {
620 m_mat.outerIndexPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i];
621 m_mat.innerNonZeroPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i+1] - outerIndexPtr[i];
622 }
623 if(!matrix.isCompressed()) delete[] outerIndexPtr;
624 }
625 else
626 { //FIXME This should not be needed if the empty permutation is handled transparently
627 m_perm_c.resize(matrix.cols());
628 for(StorageIndex i = 0; i < matrix.cols(); ++i) m_perm_c.indices()(i) = i;
629 }
630
631 Index m = m_mat.rows();
632 Index n = m_mat.cols();
633 Index nnz = m_mat.nonZeros();
634 Index maxpanel = m_perfv.panel_size * m;
635 // Allocate working storage common to the factor routines
636 Index lwork = 0;
637 Index info = Base::memInit(m, n, nnz, lwork, m_perfv.fillfactor, m_perfv.panel_size, m_glu);
638 if (info)
639 {
640 m_lastError = "UNABLE TO ALLOCATE WORKING MEMORY\n\n" ;
641 m_factorizationIsOk = false;
642 return ;
643 }
644
645 // Set up pointers for integer working arrays
646 IndexVector segrep(m); segrep.setZero();
647 IndexVector parent(m); parent.setZero();
648 IndexVector xplore(m); xplore.setZero();
649 IndexVector repfnz(maxpanel);
650 IndexVector panel_lsub(maxpanel);
651 IndexVector xprune(n); xprune.setZero();
652 IndexVector marker(m*internal::LUNoMarker); marker.setZero();

Callers

nothing calls this directly

Calls 15

LUnumTempVFunction · 0.70
rowsMethod · 0.45
colsMethod · 0.45
sizeMethod · 0.45
uncompressMethod · 0.45
isCompressedMethod · 0.45
outerIndexPtrMethod · 0.45
innerNonZeroPtrMethod · 0.45
resizeMethod · 0.45
nonZerosMethod · 0.45
setZeroMethod · 0.45
inverseMethod · 0.45

Tested by

no test coverage detected