11#ifndef EIGEN_SPARSELU_SUPERNODAL_MATRIX_H
12#define EIGEN_SPARSELU_SUPERNODAL_MATRIX_H
32template <
typename _Scalar,
typename _StorageIndex>
33class MappedSuperNodalMatrix
36 typedef _Scalar Scalar;
37 typedef _StorageIndex StorageIndex;
41 MappedSuperNodalMatrix()
45 MappedSuperNodalMatrix(
Index m,
Index n, ScalarVector& nzval, IndexVector& nzval_colptr, IndexVector& rowind,
46 IndexVector& rowind_colptr, IndexVector& col_to_sup, IndexVector& sup_to_col )
48 setInfos(m, n, nzval, nzval_colptr, rowind, rowind_colptr, col_to_sup, sup_to_col);
51 ~MappedSuperNodalMatrix()
61 void setInfos(
Index m,
Index n, ScalarVector& nzval, IndexVector& nzval_colptr, IndexVector& rowind,
62 IndexVector& rowind_colptr, IndexVector& col_to_sup, IndexVector& sup_to_col )
66 m_nzval = nzval.
data();
67 m_nzval_colptr = nzval_colptr.
data();
68 m_rowind = rowind.
data();
69 m_rowind_colptr = rowind_colptr.
data();
70 m_nsuper = col_to_sup(n);
71 m_col_to_sup = col_to_sup.
data();
72 m_sup_to_col = sup_to_col.
data();
101 return m_nzval_colptr;
106 return m_nzval_colptr;
114 const StorageIndex*
rowIndex()
const
126 return m_rowind_colptr;
134 const StorageIndex*
colToSup()
const
143 const StorageIndex*
supToCol()
const
157 template<
typename Dest>
159 template<
bool Conjugate,
typename Dest>
171 StorageIndex* m_nzval_colptr;
172 StorageIndex* m_rowind;
173 StorageIndex* m_rowind_colptr;
174 StorageIndex* m_col_to_sup;
175 StorageIndex* m_sup_to_col;
184template<
typename Scalar,
typename StorageIndex>
193 m_startidval(m_idval),
204 inline Scalar value()
const {
return m_matrix.valuePtr()[m_idval]; }
206 inline Scalar& valueRef() {
return const_cast<Scalar&
>(m_matrix.valuePtr()[m_idval]); }
208 inline Index index()
const {
return m_matrix.rowIndex()[m_idrow]; }
209 inline Index row()
const {
return index(); }
210 inline Index col()
const {
return m_outer; }
212 inline Index supIndex()
const {
return m_supno; }
214 inline operator bool()
const
216 return ( (m_idval < m_endidval) && (m_idval >= m_startidval)
217 && (m_idrow < m_endidrow) );
221 const MappedSuperNodalMatrix& m_matrix;
225 const Index m_startidval;
226 const Index m_endidval;
235template<
typename Scalar,
typename Index_>
236template<
typename Dest>
242 Index n = int(X.rows());
253 Index nrow = nsupr - nsupc;
258 for (
Index j = 0; j < nrhs; j++)
265 X(irow, j) -= X(fsupc, j) * it.value();
277 typename Dest::RowsBlockXpr U = X.derived().
middleRows(fsupc, nsupc);
278 U = A.template triangularView<UnitLower>().solve(U);
281 work.
topRows(nrow).noalias() = A * U;
284 for (
Index j = 0; j < nrhs; j++)
286 Index iptr = istart + nsupc;
287 for (
Index i = 0; i < nrow; i++)
290 X(irow, j) -= work(i, j);
291 work(i, j) = Scalar(0);
299template<
typename Scalar,
typename Index_>
300template<
bool Conjugate,
typename Dest>
301void MappedSuperNodalMatrix<Scalar,Index_>::solveTransposedInPlace(
MatrixBase<Dest>&X)
const
304 Index n = int(X.rows());
306 const Scalar * Lval = valuePtr();
309 for (
Index k = nsuper(); k >= 0; k--)
311 Index fsupc = supToCol()[k];
312 Index istart = rowIndexPtr()[fsupc];
313 Index nsupr = rowIndexPtr()[fsupc+1] - istart;
314 Index nsupc = supToCol()[k+1] - fsupc;
315 Index nrow = nsupr - nsupc;
320 for (
Index j = 0; j < nrhs; j++)
322 InnerIterator it(*
this, fsupc);
327 X(fsupc,j) -= X(irow, j) * (Conjugate?
conj(it.value()):it.value());
334 Index luptr = colIndexPtr()[fsupc];
335 Index lda = colIndexPtr()[fsupc+1] - luptr;
338 for (
Index j = 0; j < nrhs; j++)
340 Index iptr = istart + nsupc;
341 for (
Index i = 0; i < nrow; i++)
343 irow = rowIndex()[iptr];
344 work.topRows(nrow)(i,j)= X(irow,j);
350 Map<const Matrix<Scalar,Dynamic,Dynamic, ColMajor>, 0, OuterStride<> > A( &(Lval[luptr+nsupc]), nrow, nsupc, OuterStride<>(lda) );
351 typename Dest::RowsBlockXpr U = X.derived().
middleRows(fsupc, nsupc);
353 U = U - A.adjoint() * work.topRows(nrow);
355 U = U - A.transpose() * work.topRows(nrow);
358 new (&A) Map<
const Matrix<Scalar,Dynamic,Dynamic, ColMajor>, 0, OuterStride<> > ( &(Lval[luptr]), nsupc, nsupc, OuterStride<>(lda) );
360 U = A.adjoint().template triangularView<UnitUpper>().solve(U);
362 U = A.transpose().template triangularView<UnitUpper>().solve(U);
NRowsBlockXpr<... >::Type middleRows(Index startRow, NRowsType n)
Definition DenseBase.h:722
NRowsBlockXpr<... >::Type topRows(NRowsType n)
Definition DenseBase.h:571
A matrix or vector expression mapping an existing array of data.
Definition Map.h:96
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
Convenience specialization of Stride to specify only an outer stride See class Map for some examples.
Definition Stride.h:111
Derived & setZero(Index size)
Definition CwiseNullaryOp.h:562
const Scalar * data() const
Definition PlainObjectBase.h:247
InnerIterator class to iterate over nonzero values of the current column in the supernodal matrix L.
Definition SparseLU_SupernodalMatrix.h:186
StorageIndex * supToCol()
Definition SparseLU_SupernodalMatrix.h:141
StorageIndex * rowIndex()
Definition SparseLU_SupernodalMatrix.h:112
StorageIndex * rowIndexPtr()
Definition SparseLU_SupernodalMatrix.h:122
StorageIndex * colToSup()
Definition SparseLU_SupernodalMatrix.h:132
StorageIndex * colIndexPtr()
Definition SparseLU_SupernodalMatrix.h:99
Index nsuper() const
Definition SparseLU_SupernodalMatrix.h:151
Index rows() const
Definition SparseLU_SupernodalMatrix.h:78
void solveInPlace(MatrixBase< Dest > &X) const
Solve with the supernode triangular matrix.
Definition SparseLU_SupernodalMatrix.h:237
Scalar * valuePtr()
Definition SparseLU_SupernodalMatrix.h:90
Index cols() const
Definition SparseLU_SupernodalMatrix.h:83
void setInfos(Index m, Index n, ScalarVector &nzval, IndexVector &nzval_colptr, IndexVector &rowind, IndexVector &rowind_colptr, IndexVector &col_to_sup, IndexVector &sup_to_col)
Definition SparseLU_SupernodalMatrix.h:61
Namespace containing all symbols from the Eigen library.
Definition B01_Experimental.dox:1
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_conjugate_op< typename Derived::Scalar >, const Derived > conj(const Eigen::ArrayBase< Derived > &x)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74