MCPcopy Create free account
hub / github.com/TinyMPC/TinyMPC / factorize

Method factorize

include/Eigen/Eigen/src/SparseLU/SparseLU.h:598–802  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

LUnumTempVFunction · 0.85
uncompressMethod · 0.80
setInfosMethod · 0.80
rowsMethod · 0.45
colsMethod · 0.45
sizeMethod · 0.45
isCompressedMethod · 0.45
outerIndexPtrMethod · 0.45
innerNonZeroPtrMethod · 0.45
resizeMethod · 0.45
nonZerosMethod · 0.45
setZeroMethod · 0.45

Tested by

no test coverage detected