MOAB  4.9.3pre
Eigen::SparseLU< _MatrixType, _OrderingType > Class Template Reference

Sparse supernodal LU factorization for general matrices. More...

#include <SparseLU.h>

Inheritance diagram for Eigen::SparseLU< _MatrixType, _OrderingType >:
Collaboration diagram for Eigen::SparseLU< _MatrixType, _OrderingType >:

List of all members.

Public Types

enum  { ColsAtCompileTime = MatrixType::ColsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime }
typedef _MatrixType MatrixType
typedef _OrderingType OrderingType
typedef MatrixType::Scalar Scalar
typedef MatrixType::RealScalar RealScalar
typedef MatrixType::StorageIndex StorageIndex
typedef SparseMatrix< Scalar,
ColMajor, StorageIndex
NCMatrix
typedef
internal::MappedSuperNodalMatrix
< Scalar, StorageIndex
SCMatrix
typedef Matrix< Scalar,
Dynamic, 1 > 
ScalarVector
typedef Matrix< StorageIndex,
Dynamic, 1 > 
IndexVector
typedef PermutationMatrix
< Dynamic, Dynamic,
StorageIndex
PermutationType
typedef internal::SparseLUImpl
< Scalar, StorageIndex
Base

Public Member Functions

 SparseLU ()
 SparseLU (const MatrixType &matrix)
 ~SparseLU ()
void analyzePattern (const MatrixType &matrix)
void factorize (const MatrixType &matrix)
void simplicialfactorize (const MatrixType &matrix)
void compute (const MatrixType &matrix)
Index rows () const
Index cols () const
void isSymmetric (bool sym)
SparseLUMatrixLReturnType
< SCMatrix
matrixL () const
SparseLUMatrixUReturnType
< SCMatrix, MappedSparseMatrix
< Scalar, ColMajor,
StorageIndex > > 
matrixU () const
const PermutationTyperowsPermutation () const
const PermutationTypecolsPermutation () const
void setPivotThreshold (const RealScalar &thresh)
ComputationInfo info () const
 Reports whether previous computation was successful.
std::string lastErrorMessage () const
template<typename Rhs , typename Dest >
bool _solve_impl (const MatrixBase< Rhs > &B, MatrixBase< Dest > &X_base) const
Scalar absDeterminant ()
Scalar logAbsDeterminant () const
Scalar signDeterminant ()
Scalar determinant ()

Protected Types

typedef SparseSolverBase
< SparseLU< _MatrixType,
_OrderingType > > 
APIBase

Protected Member Functions

void initperfvalues ()

Protected Attributes

ComputationInfo m_info
bool m_factorizationIsOk
bool m_analysisIsOk
std::string m_lastError
NCMatrix m_mat
SCMatrix m_Lstore
MappedSparseMatrix< Scalar,
ColMajor, StorageIndex
m_Ustore
PermutationType m_perm_c
PermutationType m_perm_r
IndexVector m_etree
Base::GlobalLU_t m_glu
bool m_symmetricmode
internal::perfvalues m_perfv
RealScalar m_diagpivotthresh
Index m_nnzL
Index m_nnzU
Index m_detPermR
Index m_detPermC

Private Member Functions

 SparseLU (const SparseLU &)

Detailed Description

template<typename _MatrixType, typename _OrderingType>
class Eigen::SparseLU< _MatrixType, _OrderingType >

Sparse supernodal LU factorization for general matrices.

This class implements the supernodal LU factorization for general matrices. It uses the main techniques from the sequential SuperLU package (http://crd-legacy.lbl.gov/~xiaoye/SuperLU/). It handles transparently real and complex arithmetics with single and double precision, depending on the scalar type of your input matrix. The code has been optimized to provide BLAS-3 operations during supernode-panel updates. It benefits directly from the built-in high-performant Eigen BLAS routines. Moreover, when the size of a supernode is very small, the BLAS calls are avoided to enable a better optimization from the compiler. For best performance, you should compile it with NDEBUG flag to avoid the numerous bounds checking on vectors.

An important parameter of this class is the ordering method. It is used to reorder the columns (and eventually the rows) of the matrix to reduce the number of new elements that are created during numerical factorization. The cheapest method available is COLAMD. See the OrderingMethods module for the list of built-in and external ordering methods.

Simple example with key steps

 VectorXd x(n), b(n);
 SparseMatrix<double, ColMajor> A;
 SparseLU<SparseMatrix<scalar, ColMajor>, COLAMDOrdering<Index> >   solver;
 // fill A and b;
 // Compute the ordering permutation vector from the structural pattern of A
 solver.analyzePattern(A); 
 // Compute the numerical factorization 
 solver.factorize(A); 
 //Use the factors to solve the linear system 
 x = solver.solve(b); 
Warning:
The input matrix A should be in a compressed and column-major form. Otherwise an expensive copy will be made. You can call the inexpensive makeCompressed() to get a compressed matrix.
Note:
Unlike the initial SuperLU implementation, there is no step to equilibrate the matrix. For badly scaled matrices, this step can be useful to reduce the pivoting during factorization. If this is the case for your matrices, you can try the basic scaling method at "unsupported/Eigen/src/IterativeSolvers/Scaling.h"
Template Parameters:
_MatrixTypeThe type of the sparse matrix. It must be a column-major SparseMatrix<>
_OrderingTypeThe ordering method to use, either AMD, COLAMD or METIS. Default is COLMAD
See also:
TutorialSparseSolverConcept
OrderingMethods_Module

Definition at line 74 of file SparseLU.h.


Member Typedef Documentation

template<typename _MatrixType , typename _OrderingType >
typedef SparseSolverBase<SparseLU<_MatrixType,_OrderingType> > Eigen::SparseLU< _MatrixType, _OrderingType >::APIBase [protected]

Definition at line 77 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
typedef internal::SparseLUImpl<Scalar, StorageIndex> Eigen::SparseLU< _MatrixType, _OrderingType >::Base

Definition at line 92 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
typedef Matrix<StorageIndex,Dynamic,1> Eigen::SparseLU< _MatrixType, _OrderingType >::IndexVector
template<typename _MatrixType , typename _OrderingType >
typedef _MatrixType Eigen::SparseLU< _MatrixType, _OrderingType >::MatrixType
template<typename _MatrixType , typename _OrderingType >
typedef SparseMatrix<Scalar,ColMajor,StorageIndex> Eigen::SparseLU< _MatrixType, _OrderingType >::NCMatrix

Definition at line 87 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
typedef _OrderingType Eigen::SparseLU< _MatrixType, _OrderingType >::OrderingType

Definition at line 83 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
typedef PermutationMatrix<Dynamic, Dynamic, StorageIndex> Eigen::SparseLU< _MatrixType, _OrderingType >::PermutationType

Definition at line 91 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
typedef MatrixType::RealScalar Eigen::SparseLU< _MatrixType, _OrderingType >::RealScalar
template<typename _MatrixType , typename _OrderingType >
typedef MatrixType::Scalar Eigen::SparseLU< _MatrixType, _OrderingType >::Scalar

Definition at line 84 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
typedef Matrix<Scalar,Dynamic,1> Eigen::SparseLU< _MatrixType, _OrderingType >::ScalarVector
template<typename _MatrixType , typename _OrderingType >
typedef internal::MappedSuperNodalMatrix<Scalar, StorageIndex> Eigen::SparseLU< _MatrixType, _OrderingType >::SCMatrix

Definition at line 88 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
typedef MatrixType::StorageIndex Eigen::SparseLU< _MatrixType, _OrderingType >::StorageIndex

Definition at line 86 of file SparseLU.h.


Member Enumeration Documentation

template<typename _MatrixType , typename _OrderingType >
anonymous enum
Enumerator:
ColsAtCompileTime 
MaxColsAtCompileTime 

Definition at line 94 of file SparseLU.h.

         {
      ColsAtCompileTime = MatrixType::ColsAtCompileTime,
      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
    };

Constructor & Destructor Documentation

template<typename _MatrixType , typename _OrderingType >
Eigen::SparseLU< _MatrixType, _OrderingType >::SparseLU ( ) [inline]

Definition at line 100 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
Eigen::SparseLU< _MatrixType, _OrderingType >::SparseLU ( const MatrixType matrix) [inline, explicit]

Definition at line 104 of file SparseLU.h.

      : m_lastError(""),m_Ustore(0,0,0,0,0,0),m_symmetricmode(false),m_diagpivotthresh(1.0),m_detPermR(1)
    {
      initperfvalues(); 
      compute(matrix);
    }
template<typename _MatrixType , typename _OrderingType >
Eigen::SparseLU< _MatrixType, _OrderingType >::~SparseLU ( ) [inline]

Definition at line 111 of file SparseLU.h.

    {
      // Free all explicit dynamic pointers 
    }
template<typename _MatrixType , typename _OrderingType >
Eigen::SparseLU< _MatrixType, _OrderingType >::SparseLU ( const SparseLU< _MatrixType, _OrderingType > &  ) [private]

Member Function Documentation

template<typename _MatrixType , typename _OrderingType >
template<typename Rhs , typename Dest >
bool Eigen::SparseLU< _MatrixType, _OrderingType >::_solve_impl ( const MatrixBase< Rhs > &  B,
MatrixBase< Dest > &  X_base 
) const [inline]

Definition at line 217 of file SparseLU.h.

    {
      Dest& X(X_base.derived());
      eigen_assert(m_factorizationIsOk && "The matrix should be factorized first");
      EIGEN_STATIC_ASSERT((Dest::Flags&RowMajorBit)==0,
                        THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
      
      // Permute the right hand side to form X = Pr*B
      // on return, X is overwritten by the computed solution
      X.resize(B.rows(),B.cols());

      // this ugly const_cast_derived() helps to detect aliasing when applying the permutations
      for(Index j = 0; j < B.cols(); ++j)
        X.col(j) = rowsPermutation() * B.const_cast_derived().col(j);
      
      //Forward substitution with L
      this->matrixL().solveInPlace(X);
      this->matrixU().solveInPlace(X);
      
      // Permute back the solution 
      for (Index j = 0; j < B.cols(); ++j)
        X.col(j) = colsPermutation().inverse() * X.col(j);
      
      return true; 
    }
template<typename _MatrixType , typename _OrderingType >
Scalar Eigen::SparseLU< _MatrixType, _OrderingType >::absDeterminant ( ) [inline]
Returns:
the absolute value of the determinant of the matrix of which *this is the QR decomposition.
Warning:
a determinant can be very big or small, so for matrices of large enough dimension, there is a risk of overflow/underflow. One way to work around that is to use logAbsDeterminant() instead.
See also:
logAbsDeterminant(), signDeterminant()

Definition at line 253 of file SparseLU.h.

    {
      using std::abs;
      eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
      // Initialize with the determinant of the row matrix
      Scalar det = Scalar(1.);
      // Note that the diagonal blocks of U are stored in supernodes,
      // which are available in the  L part :)
      for (Index j = 0; j < this->cols(); ++j)
      {
        for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)
        {
          if(it.index() == j)
          {
            det *= abs(it.value());
            break;
          }
        }
      }
      return det;
    }
template<typename MatrixType , typename OrderingType >
void Eigen::SparseLU< MatrixType, OrderingType >::analyzePattern ( const MatrixType mat)

Compute the column permutation to minimize the fill-in

  • Apply this permutation to the input matrix -
  • Compute the column elimination tree on the permuted matrix
  • Postorder the elimination tree and the column permutation

Definition at line 411 of file SparseLU.h.

{
  
  //TODO  It is possible as in SuperLU to compute row and columns scaling vectors to equilibrate the matrix mat.
  
  // Firstly, copy the whole input matrix. 
  m_mat = mat;
  
  // Compute fill-in ordering
  OrderingType ord; 
  ord(m_mat,m_perm_c);
  
  // Apply the permutation to the column of the input  matrix
  if (m_perm_c.size())
  {
    m_mat.uncompress(); //NOTE: The effect of this command is only to create the InnerNonzeros pointers. FIXME : This vector is filled but not subsequently used.  
    // Then, permute only the column pointers
    ei_declare_aligned_stack_constructed_variable(StorageIndex,outerIndexPtr,mat.cols()+1,mat.isCompressed()?const_cast<StorageIndex*>(mat.outerIndexPtr()):0);
    
    // If the input matrix 'mat' is uncompressed, then the outer-indices do not match the ones of m_mat, and a copy is thus needed.
    if(!mat.isCompressed()) 
      IndexVector::Map(outerIndexPtr, mat.cols()+1) = IndexVector::Map(m_mat.outerIndexPtr(),mat.cols()+1);
    
    // Apply the permutation and compute the nnz per column.
    for (Index i = 0; i < mat.cols(); i++)
    {
      m_mat.outerIndexPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i];
      m_mat.innerNonZeroPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i+1] - outerIndexPtr[i];
    }
  }
  
  // Compute the column elimination tree of the permuted matrix 
  IndexVector firstRowElt;
  internal::coletree(m_mat, m_etree,firstRowElt); 
     
  // In symmetric mode, do not do postorder here
  if (!m_symmetricmode) {
    IndexVector post, iwork; 
    // Post order etree
    internal::treePostorder(StorageIndex(m_mat.cols()), m_etree, post); 
      
   
    // Renumber etree in postorder 
    Index m = m_mat.cols(); 
    iwork.resize(m+1);
    for (Index i = 0; i < m; ++i) iwork(post(i)) = post(m_etree(i));
    m_etree = iwork;
    
    // Postmultiply A*Pc by post, i.e reorder the matrix according to the postorder of the etree
    PermutationType post_perm(m); 
    for (Index i = 0; i < m; i++) 
      post_perm.indices()(i) = post(i); 
        
    // Combine the two permutations : postorder the permutation for future use
    if(m_perm_c.size()) {
      m_perm_c = post_perm * m_perm_c;
    }
    
  } // end postordering 
  
  m_analysisIsOk = true; 
}
template<typename _MatrixType , typename _OrderingType >
Index Eigen::SparseLU< _MatrixType, _OrderingType >::cols ( void  ) const [inline]

Definition at line 133 of file SparseLU.h.

{ return m_mat.cols(); }
template<typename _MatrixType , typename _OrderingType >
const PermutationType& Eigen::SparseLU< _MatrixType, _OrderingType >::colsPermutation ( ) const [inline]
Returns:
a reference to the column matrix permutation $ P_c^T $ such that $P_r A P_c^T = L U$
See also:
rowsPermutation()

Definition at line 173 of file SparseLU.h.

    {
      return m_perm_c;
    }
template<typename _MatrixType , typename _OrderingType >
void Eigen::SparseLU< _MatrixType, _OrderingType >::compute ( const MatrixType matrix) [inline]

Compute the symbolic and numeric factorization of the input sparse matrix. The input matrix should be in column-major storage.

Definition at line 124 of file SparseLU.h.

    {
      // Analyze 
      analyzePattern(matrix); 
      //Factorize
      factorize(matrix);
    } 
template<typename _MatrixType , typename _OrderingType >
Scalar Eigen::SparseLU< _MatrixType, _OrderingType >::determinant ( ) [inline]
Returns:
The determinant of the matrix.
See also:
absDeterminant(), logAbsDeterminant()

Definition at line 337 of file SparseLU.h.

    {
      eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
      // Initialize with the determinant of the row matrix
      Scalar det = Scalar(1.);
      // Note that the diagonal blocks of U are stored in supernodes,
      // which are available in the  L part :)
      for (Index j = 0; j < this->cols(); ++j)
      {
        for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)
        {
          if(it.index() == j)
          {
            det *= it.value();
            break;
          }
        }
      }
      return (m_detPermR * m_detPermC) > 0 ? det : -det;
    }
template<typename MatrixType , typename OrderingType >
void Eigen::SparseLU< MatrixType, OrderingType >::factorize ( const MatrixType matrix)
  • Numerical factorization
  • Interleaved with the symbolic factorization On exit, info is

= 0: successful factorization

> 0: if info = i, and i is

<= A->ncol: U(i,i) is exactly zero. The factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations.

> A->ncol: number of bytes allocated when memory allocation failure occurred, plus A->ncol. If lwork = -1, it is the estimated amount of space needed, plus A->ncol.

Definition at line 496 of file SparseLU.h.

{
  using internal::emptyIdxLU;
  eigen_assert(m_analysisIsOk && "analyzePattern() should be called first"); 
  eigen_assert((matrix.rows() == matrix.cols()) && "Only for squared matrices");
  
  typedef typename IndexVector::Scalar StorageIndex; 
  
  m_isInitialized = true;
  
  
  // Apply the column permutation computed in analyzepattern()
  //   m_mat = matrix * m_perm_c.inverse(); 
  m_mat = matrix;
  if (m_perm_c.size()) 
  {
    m_mat.uncompress(); //NOTE: The effect of this command is only to create the InnerNonzeros pointers.
    //Then, permute only the column pointers
    const StorageIndex * outerIndexPtr;
    if (matrix.isCompressed()) outerIndexPtr = matrix.outerIndexPtr();
    else
    {
      StorageIndex* outerIndexPtr_t = new StorageIndex[matrix.cols()+1];
      for(Index i = 0; i <= matrix.cols(); i++) outerIndexPtr_t[i] = m_mat.outerIndexPtr()[i];
      outerIndexPtr = outerIndexPtr_t;
    }
    for (Index i = 0; i < matrix.cols(); i++)
    {
      m_mat.outerIndexPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i];
      m_mat.innerNonZeroPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i+1] - outerIndexPtr[i];
    }
    if(!matrix.isCompressed()) delete[] outerIndexPtr;
  } 
  else 
  { //FIXME This should not be needed if the empty permutation is handled transparently
    m_perm_c.resize(matrix.cols());
    for(StorageIndex i = 0; i < matrix.cols(); ++i) m_perm_c.indices()(i) = i;
  }
  
  Index m = m_mat.rows();
  Index n = m_mat.cols();
  Index nnz = m_mat.nonZeros();
  Index maxpanel = m_perfv.panel_size * m;
  // Allocate working storage common to the factor routines
  Index lwork = 0;
  Index info = Base::memInit(m, n, nnz, lwork, m_perfv.fillfactor, m_perfv.panel_size, m_glu); 
  if (info) 
  {
    m_lastError = "UNABLE TO ALLOCATE WORKING MEMORY\n\n" ;
    m_factorizationIsOk = false;
    return ; 
  }
  
  // Set up pointers for integer working arrays 
  IndexVector segrep(m); segrep.setZero();
  IndexVector parent(m); parent.setZero();
  IndexVector xplore(m); xplore.setZero();
  IndexVector repfnz(maxpanel);
  IndexVector panel_lsub(maxpanel);
  IndexVector xprune(n); xprune.setZero();
  IndexVector marker(m*internal::LUNoMarker); marker.setZero();
  
  repfnz.setConstant(-1); 
  panel_lsub.setConstant(-1);
  
  // Set up pointers for scalar working arrays 
  ScalarVector dense; 
  dense.setZero(maxpanel);
  ScalarVector tempv; 
  tempv.setZero(internal::LUnumTempV(m, m_perfv.panel_size, m_perfv.maxsuper, /*m_perfv.rowblk*/m) );
  
  // Compute the inverse of perm_c
  PermutationType iperm_c(m_perm_c.inverse()); 
  
  // Identify initial relaxed snodes
  IndexVector relax_end(n);
  if ( m_symmetricmode == true ) 
    Base::heap_relax_snode(n, m_etree, m_perfv.relax, marker, relax_end);
  else
    Base::relax_snode(n, m_etree, m_perfv.relax, marker, relax_end);
  
  
  m_perm_r.resize(m); 
  m_perm_r.indices().setConstant(-1);
  marker.setConstant(-1);
  m_detPermR = 1; // Record the determinant of the row permutation
  
  m_glu.supno(0) = emptyIdxLU; m_glu.xsup.setConstant(0);
  m_glu.xsup(0) = m_glu.xlsub(0) = m_glu.xusub(0) = m_glu.xlusup(0) = Index(0);
  
  // Work on one 'panel' at a time. A panel is one of the following :
  //  (a) a relaxed supernode at the bottom of the etree, or
  //  (b) panel_size contiguous columns, <panel_size> defined by the user
  Index jcol; 
  IndexVector panel_histo(n);
  Index pivrow; // Pivotal row number in the original row matrix
  Index nseg1; // Number of segments in U-column above panel row jcol
  Index nseg; // Number of segments in each U-column 
  Index irep; 
  Index i, k, jj; 
  for (jcol = 0; jcol < n; )
  {
    // Adjust panel size so that a panel won't overlap with the next relaxed snode. 
    Index panel_size = m_perfv.panel_size; // upper bound on panel width
    for (k = jcol + 1; k < (std::min)(jcol+panel_size, n); k++)
    {
      if (relax_end(k) != emptyIdxLU) 
      {
        panel_size = k - jcol; 
        break; 
      }
    }
    if (k == n) 
      panel_size = n - jcol; 
      
    // Symbolic outer factorization on a panel of columns 
    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); 
    
    // Numeric sup-panel updates in topological order 
    Base::panel_bmod(m, panel_size, jcol, nseg1, dense, tempv, segrep, repfnz, m_glu); 
    
    // Sparse LU within the panel, and below the panel diagonal 
    for ( jj = jcol; jj< jcol + panel_size; jj++) 
    {
      k = (jj - jcol) * m; // Column index for w-wide arrays 
      
      nseg = nseg1; // begin after all the panel segments
      //Depth-first-search for the current column
      VectorBlock<IndexVector> panel_lsubk(panel_lsub, k, m);
      VectorBlock<IndexVector> repfnz_k(repfnz, k, m); 
      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); 
      if ( info ) 
      {
        m_lastError =  "UNABLE TO EXPAND MEMORY IN COLUMN_DFS() ";
        m_info = NumericalIssue; 
        m_factorizationIsOk = false; 
        return; 
      }
      // Numeric updates to this column 
      VectorBlock<ScalarVector> dense_k(dense, k, m); 
      VectorBlock<IndexVector> segrep_k(segrep, nseg1, m-nseg1); 
      info = Base::column_bmod(jj, (nseg - nseg1), dense_k, tempv, segrep_k, repfnz_k, jcol, m_glu); 
      if ( info ) 
      {
        m_lastError = "UNABLE TO EXPAND MEMORY IN COLUMN_BMOD() ";
        m_info = NumericalIssue; 
        m_factorizationIsOk = false; 
        return; 
      }
      
      // Copy the U-segments to ucol(*)
      info = Base::copy_to_ucol(jj, nseg, segrep, repfnz_k ,m_perm_r.indices(), dense_k, m_glu); 
      if ( info ) 
      {
        m_lastError = "UNABLE TO EXPAND MEMORY IN COPY_TO_UCOL() ";
        m_info = NumericalIssue; 
        m_factorizationIsOk = false; 
        return; 
      }
      
      // Form the L-segment 
      info = Base::pivotL(jj, m_diagpivotthresh, m_perm_r.indices(), iperm_c.indices(), pivrow, m_glu);
      if ( info ) 
      {
        m_lastError = "THE MATRIX IS STRUCTURALLY SINGULAR ... ZERO COLUMN AT ";
        std::ostringstream returnInfo;
        returnInfo << info; 
        m_lastError += returnInfo.str();
        m_info = NumericalIssue; 
        m_factorizationIsOk = false; 
        return; 
      }
      
      // Update the determinant of the row permutation matrix
      // FIXME: the following test is not correct, we should probably take iperm_c into account and pivrow is not directly the row pivot.
      if (pivrow != jj) m_detPermR = -m_detPermR;

      // Prune columns (0:jj-1) using column jj
      Base::pruneL(jj, m_perm_r.indices(), pivrow, nseg, segrep, repfnz_k, xprune, m_glu); 
      
      // Reset repfnz for this column 
      for (i = 0; i < nseg; i++)
      {
        irep = segrep(i); 
        repfnz_k(irep) = emptyIdxLU; 
      }
    } // end SparseLU within the panel  
    jcol += panel_size;  // Move to the next panel
  } // end for -- end elimination 
  
  m_detPermR = m_perm_r.determinant();
  m_detPermC = m_perm_c.determinant();
  
  // Count the number of nonzeros in factors 
  Base::countnz(n, m_nnzL, m_nnzU, m_glu); 
  // Apply permutation  to the L subscripts 
  Base::fixupL(n, m_perm_r.indices(), m_glu);
  
  // Create supernode matrix L 
  m_Lstore.setInfos(m, n, m_glu.lusup, m_glu.xlusup, m_glu.lsub, m_glu.xlsub, m_glu.supno, m_glu.xsup); 
  // Create the column major upper sparse matrix  U; 
  new (&m_Ustore) MappedSparseMatrix<Scalar, ColMajor, StorageIndex> ( m, n, m_nnzU, m_glu.xusub.data(), m_glu.usub.data(), m_glu.ucol.data() );
  
  m_info = Success;
  m_factorizationIsOk = true;
}
template<typename _MatrixType , typename _OrderingType >
ComputationInfo Eigen::SparseLU< _MatrixType, _OrderingType >::info ( ) const [inline]

Reports whether previous computation was successful.

Returns:
Success if computation was succesful, NumericalIssue if the LU factorization reports a problem, zero diagonal for instance InvalidInput if the input matrix is invalid
See also:
iparm()

Definition at line 202 of file SparseLU.h.

    {
      eigen_assert(m_isInitialized && "Decomposition is not initialized.");
      return m_info;
    }
template<typename _MatrixType , typename _OrderingType >
void Eigen::SparseLU< _MatrixType, _OrderingType >::initperfvalues ( ) [inline, protected]

Definition at line 360 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
void Eigen::SparseLU< _MatrixType, _OrderingType >::isSymmetric ( bool  sym) [inline]

Indicate that the pattern of the input matrix is symmetric

Definition at line 135 of file SparseLU.h.

    {
      m_symmetricmode = sym;
    }
template<typename _MatrixType , typename _OrderingType >
std::string Eigen::SparseLU< _MatrixType, _OrderingType >::lastErrorMessage ( ) const [inline]
Returns:
A string describing the type of error

Definition at line 211 of file SparseLU.h.

    {
      return m_lastError; 
    }
template<typename _MatrixType , typename _OrderingType >
Scalar Eigen::SparseLU< _MatrixType, _OrderingType >::logAbsDeterminant ( ) const [inline]
Returns:
the natural log of the absolute value of the determinant of the matrix of which **this is the QR decomposition
Note:
This method is useful to work around the risk of overflow/underflow that's inherent to the determinant computation.
See also:
absDeterminant(), signDeterminant()

Definition at line 283 of file SparseLU.h.

    {
      using std::log;
      using std::abs;

      eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
      Scalar det = Scalar(0.);
      for (Index j = 0; j < this->cols(); ++j)
      {
        for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)
        {
          if(it.row() < j) continue;
          if(it.row() == j)
          {
            det += log(abs(it.value()));
            break;
          }
        }
      }
      return det;
    }
template<typename _MatrixType , typename _OrderingType >
SparseLUMatrixLReturnType<SCMatrix> Eigen::SparseLU< _MatrixType, _OrderingType >::matrixL ( ) const [inline]
Returns:
an expression of the matrix L, internally stored as supernodes The only operation available with this expression is the triangular solve
 y = b; matrixL().solveInPlace(y);

Definition at line 146 of file SparseLU.h.

    {
      return SparseLUMatrixLReturnType<SCMatrix>(m_Lstore);
    }
template<typename _MatrixType , typename _OrderingType >
SparseLUMatrixUReturnType<SCMatrix,MappedSparseMatrix<Scalar,ColMajor,StorageIndex> > Eigen::SparseLU< _MatrixType, _OrderingType >::matrixU ( ) const [inline]
Returns:
an expression of the matrix U, The only operation available with this expression is the triangular solve
 y = b; matrixU().solveInPlace(y);

Definition at line 156 of file SparseLU.h.

    {
      return SparseLUMatrixUReturnType<SCMatrix, MappedSparseMatrix<Scalar,ColMajor,StorageIndex> >(m_Lstore, m_Ustore);
    }
template<typename _MatrixType , typename _OrderingType >
Index Eigen::SparseLU< _MatrixType, _OrderingType >::rows ( void  ) const [inline]

Definition at line 132 of file SparseLU.h.

{ return m_mat.rows(); }
template<typename _MatrixType , typename _OrderingType >
const PermutationType& Eigen::SparseLU< _MatrixType, _OrderingType >::rowsPermutation ( ) const [inline]
Returns:
a reference to the row matrix permutation $ P_r $ such that $P_r A P_c^T = L U$
See also:
colsPermutation()

Definition at line 165 of file SparseLU.h.

    {
      return m_perm_r;
    }
template<typename _MatrixType , typename _OrderingType >
void Eigen::SparseLU< _MatrixType, _OrderingType >::setPivotThreshold ( const RealScalar thresh) [inline]

Set the threshold used for a diagonal entry to be an acceptable pivot.

Definition at line 178 of file SparseLU.h.

    {
      m_diagpivotthresh = thresh; 
    }
template<typename _MatrixType , typename _OrderingType >
Scalar Eigen::SparseLU< _MatrixType, _OrderingType >::signDeterminant ( ) [inline]
Returns:
A number representing the sign of the determinant
See also:
absDeterminant(), logAbsDeterminant()

Definition at line 309 of file SparseLU.h.

    {
      eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
      // Initialize with the determinant of the row matrix
      Index det = 1;
      // Note that the diagonal blocks of U are stored in supernodes,
      // which are available in the  L part :)
      for (Index j = 0; j < this->cols(); ++j)
      {
        for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)
        {
          if(it.index() == j)
          {
            if(it.value()<0)
              det = -det;
            else if(it.value()==0)
              return 0;
            break;
          }
        }
      }
      return det * m_detPermR * m_detPermC;
    }
template<typename _MatrixType , typename _OrderingType >
void Eigen::SparseLU< _MatrixType, _OrderingType >::simplicialfactorize ( const MatrixType matrix)

Member Data Documentation

template<typename _MatrixType , typename _OrderingType >
bool Eigen::SparseLU< _MatrixType, _OrderingType >::m_analysisIsOk [protected]

Definition at line 373 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
Index Eigen::SparseLU< _MatrixType, _OrderingType >::m_detPermC [protected]

Definition at line 390 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
Index Eigen::SparseLU< _MatrixType, _OrderingType >::m_detPermR [protected]

Definition at line 390 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
RealScalar Eigen::SparseLU< _MatrixType, _OrderingType >::m_diagpivotthresh [protected]

Definition at line 388 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
IndexVector Eigen::SparseLU< _MatrixType, _OrderingType >::m_etree [protected]

Definition at line 380 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
bool Eigen::SparseLU< _MatrixType, _OrderingType >::m_factorizationIsOk [protected]

Definition at line 372 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
Base::GlobalLU_t Eigen::SparseLU< _MatrixType, _OrderingType >::m_glu [protected]

Definition at line 382 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
ComputationInfo Eigen::SparseLU< _MatrixType, _OrderingType >::m_info [mutable, protected]

Definition at line 371 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
std::string Eigen::SparseLU< _MatrixType, _OrderingType >::m_lastError [protected]

Definition at line 374 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
SCMatrix Eigen::SparseLU< _MatrixType, _OrderingType >::m_Lstore [protected]

Definition at line 376 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
NCMatrix Eigen::SparseLU< _MatrixType, _OrderingType >::m_mat [protected]

Definition at line 375 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
Index Eigen::SparseLU< _MatrixType, _OrderingType >::m_nnzL [protected]

Definition at line 389 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
Index Eigen::SparseLU< _MatrixType, _OrderingType >::m_nnzU [protected]

Definition at line 389 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
internal::perfvalues Eigen::SparseLU< _MatrixType, _OrderingType >::m_perfv [protected]

Definition at line 387 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
PermutationType Eigen::SparseLU< _MatrixType, _OrderingType >::m_perm_c [protected]

Definition at line 378 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
PermutationType Eigen::SparseLU< _MatrixType, _OrderingType >::m_perm_r [protected]

Definition at line 379 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
bool Eigen::SparseLU< _MatrixType, _OrderingType >::m_symmetricmode [protected]

Definition at line 385 of file SparseLU.h.

template<typename _MatrixType , typename _OrderingType >
MappedSparseMatrix<Scalar,ColMajor,StorageIndex> Eigen::SparseLU< _MatrixType, _OrderingType >::m_Ustore [protected]

Definition at line 377 of file SparseLU.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines