| 593 | */ |
| 594 | template <typename MatrixType, typename OrderingType> |
| 595 | void 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(); |
nothing calls this directly
no test coverage detected