MCPcopy Create free account
hub / github.com/OriginQ/QPanda-2 / factorize

Method factorize

ThirdParty/Eigen/src/SparseLU/SparseLU.h:496–699  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

494 */
495template <typename MatrixType, typename OrderingType>
496void SparseLU<MatrixType, OrderingType>::factorize(const MatrixType& matrix)
497{
498 using internal::emptyIdxLU;
499 eigen_assert(m_analysisIsOk && "analyzePattern() should be called first");
500 eigen_assert((matrix.rows() == matrix.cols()) && "Only for squared matrices");
501
502 m_isInitialized = true;
503
504
505 // Apply the column permutation computed in analyzepattern()
506 // m_mat = matrix * m_perm_c.inverse();
507 m_mat = matrix;
508 if (m_perm_c.size())
509 {
510 m_mat.uncompress(); //NOTE: The effect of this command is only to create the InnerNonzeros pointers.
511 //Then, permute only the column pointers
512 const StorageIndex * outerIndexPtr;
513 if (matrix.isCompressed()) outerIndexPtr = matrix.outerIndexPtr();
514 else
515 {
516 StorageIndex* outerIndexPtr_t = new StorageIndex[matrix.cols()+1];
517 for(Index i = 0; i <= matrix.cols(); i++) outerIndexPtr_t[i] = m_mat.outerIndexPtr()[i];
518 outerIndexPtr = outerIndexPtr_t;
519 }
520 for (Index i = 0; i < matrix.cols(); i++)
521 {
522 m_mat.outerIndexPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i];
523 m_mat.innerNonZeroPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i+1] - outerIndexPtr[i];
524 }
525 if(!matrix.isCompressed()) delete[] outerIndexPtr;
526 }
527 else
528 { //FIXME This should not be needed if the empty permutation is handled transparently
529 m_perm_c.resize(matrix.cols());
530 for(StorageIndex i = 0; i < matrix.cols(); ++i) m_perm_c.indices()(i) = i;
531 }
532
533 Index m = m_mat.rows();
534 Index n = m_mat.cols();
535 Index nnz = m_mat.nonZeros();
536 Index maxpanel = m_perfv.panel_size * m;
537 // Allocate working storage common to the factor routines
538 Index lwork = 0;
539 Index info = Base::memInit(m, n, nnz, lwork, m_perfv.fillfactor, m_perfv.panel_size, m_glu);
540 if (info)
541 {
542 m_lastError = "UNABLE TO ALLOCATE WORKING MEMORY\n\n" ;
543 m_factorizationIsOk = false;
544 return ;
545 }
546
547 // Set up pointers for integer working arrays
548 IndexVector segrep(m); segrep.setZero();
549 IndexVector parent(m); parent.setZero();
550 IndexVector xplore(m); xplore.setZero();
551 IndexVector repfnz(maxpanel);
552 IndexVector panel_lsub(maxpanel);
553 IndexVector xprune(n); xprune.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