From 35f7829af10c61e33dd2e2a7a015058e11a11ea0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 25 Mar 2017 14:17:07 +0100 Subject: update --- .../Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h | 69 +++++++++++----------- 1 file changed, 36 insertions(+), 33 deletions(-) (limited to 'eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h') diff --git a/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h b/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h index 54a5694..721e188 100644 --- a/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +++ b/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h @@ -29,20 +29,20 @@ namespace internal { * SuperInnerIterator to iterate through all supernodes * Function for triangular solve */ -template +template class MappedSuperNodalMatrix { public: typedef _Scalar Scalar; - typedef _Index Index; - typedef Matrix IndexVector; + typedef _StorageIndex StorageIndex; + typedef Matrix IndexVector; typedef Matrix ScalarVector; public: MappedSuperNodalMatrix() { } - MappedSuperNodalMatrix(Index m, Index n, ScalarVector& nzval, IndexVector& nzval_colptr, IndexVector& rowind, + MappedSuperNodalMatrix(Index m, Index n, ScalarVector& nzval, IndexVector& nzval_colptr, IndexVector& rowind, IndexVector& rowind_colptr, IndexVector& col_to_sup, IndexVector& sup_to_col ) { setInfos(m, n, nzval, nzval_colptr, rowind, rowind_colptr, col_to_sup, sup_to_col); @@ -58,7 +58,7 @@ class MappedSuperNodalMatrix * FIXME This class will be modified such that it can be use in the course * of the factorization. */ - void setInfos(Index m, Index n, ScalarVector& nzval, IndexVector& nzval_colptr, IndexVector& rowind, + void setInfos(Index m, Index n, ScalarVector& nzval, IndexVector& nzval_colptr, IndexVector& rowind, IndexVector& rowind_colptr, IndexVector& col_to_sup, IndexVector& sup_to_col ) { m_row = m; @@ -96,12 +96,12 @@ class MappedSuperNodalMatrix /** * Return the pointers to the beginning of each column in \ref valuePtr() */ - Index* colIndexPtr() + StorageIndex* colIndexPtr() { return m_nzval_colptr; } - const Index* colIndexPtr() const + const StorageIndex* colIndexPtr() const { return m_nzval_colptr; } @@ -109,9 +109,9 @@ class MappedSuperNodalMatrix /** * Return the array of compressed row indices of all supernodes */ - Index* rowIndex() { return m_rowind; } + StorageIndex* rowIndex() { return m_rowind; } - const Index* rowIndex() const + const StorageIndex* rowIndex() const { return m_rowind; } @@ -119,9 +119,9 @@ class MappedSuperNodalMatrix /** * Return the location in \em rowvaluePtr() which starts each column */ - Index* rowIndexPtr() { return m_rowind_colptr; } + StorageIndex* rowIndexPtr() { return m_rowind_colptr; } - const Index* rowIndexPtr() const + const StorageIndex* rowIndexPtr() const { return m_rowind_colptr; } @@ -129,18 +129,18 @@ class MappedSuperNodalMatrix /** * Return the array of column-to-supernode mapping */ - Index* colToSup() { return m_col_to_sup; } + StorageIndex* colToSup() { return m_col_to_sup; } - const Index* colToSup() const + const StorageIndex* colToSup() const { return m_col_to_sup; } /** * Return the array of supernode-to-column mapping */ - Index* supToCol() { return m_sup_to_col; } + StorageIndex* supToCol() { return m_sup_to_col; } - const Index* supToCol() const + const StorageIndex* supToCol() const { return m_sup_to_col; } @@ -148,7 +148,7 @@ class MappedSuperNodalMatrix /** * Return the number of supernodes */ - Index nsuper() const + Index nsuper() const { return m_nsuper; } @@ -162,14 +162,14 @@ class MappedSuperNodalMatrix protected: Index m_row; // Number of rows - Index m_col; // Number of columns - Index m_nsuper; // Number of supernodes + Index m_col; // Number of columns + Index m_nsuper; // Number of supernodes Scalar* m_nzval; //array of nonzero values packed by column - Index* m_nzval_colptr; //nzval_colptr[j] Stores the location in nzval[] which starts column j - Index* m_rowind; // Array of compressed row indices of rectangular supernodes - Index* m_rowind_colptr; //rowind_colptr[j] stores the location in rowind[] which starts column j - Index* m_col_to_sup; // col_to_sup[j] is the supernode number to which column j belongs - Index* m_sup_to_col; //sup_to_col[s] points to the starting column of the s-th supernode + StorageIndex* m_nzval_colptr; //nzval_colptr[j] Stores the location in nzval[] which starts column j + StorageIndex* m_rowind; // Array of compressed row indices of rectangular supernodes + StorageIndex* m_rowind_colptr; //rowind_colptr[j] stores the location in rowind[] which starts column j + StorageIndex* m_col_to_sup; // col_to_sup[j] is the supernode number to which column j belongs + StorageIndex* m_sup_to_col; //sup_to_col[s] points to the starting column of the s-th supernode private : }; @@ -178,13 +178,13 @@ class MappedSuperNodalMatrix * \brief InnerIterator class to iterate over nonzero values of the current column in the supernodal matrix L * */ -template -class MappedSuperNodalMatrix::InnerIterator +template +class MappedSuperNodalMatrix::InnerIterator { public: InnerIterator(const MappedSuperNodalMatrix& mat, Index outer) : m_matrix(mat), - m_outer(outer), + m_outer(outer), m_supno(mat.colToSup()[outer]), m_idval(mat.colIndexPtr()[outer]), m_startidval(m_idval), @@ -229,14 +229,17 @@ class MappedSuperNodalMatrix::InnerIterator * \brief Solve with the supernode triangular matrix * */ -template +template template -void MappedSuperNodalMatrix::solveInPlace( MatrixBase&X) const +void MappedSuperNodalMatrix::solveInPlace( MatrixBase&X) const { - Index n = X.rows(); - Index nrhs = X.cols(); + /* Explicit type conversion as the Index type of MatrixBase may be wider than Index */ +// eigen_assert(X.rows() <= NumTraits::highest()); +// eigen_assert(X.cols() <= NumTraits::highest()); + Index n = int(X.rows()); + Index nrhs = Index(X.cols()); const Scalar * Lval = valuePtr(); // Nonzero values - Matrix work(n, nrhs); // working vector + Matrix work(n, nrhs); // working vector work.setZero(); for (Index k = 0; k <= nsuper(); k ++) { @@ -268,12 +271,12 @@ void MappedSuperNodalMatrix::solveInPlace( MatrixBase&X) con // Triangular solve Map, 0, OuterStride<> > A( &(Lval[luptr]), nsupc, nsupc, OuterStride<>(lda) ); - Map< Matrix, 0, OuterStride<> > U (&(X(fsupc,0)), nsupc, nrhs, OuterStride<>(n) ); + Map< Matrix, 0, OuterStride<> > U (&(X(fsupc,0)), nsupc, nrhs, OuterStride<>(n) ); U = A.template triangularView().solve(U); // Matrix-vector product new (&A) Map, 0, OuterStride<> > ( &(Lval[luptr+nsupc]), nrow, nsupc, OuterStride<>(lda) ); - work.block(0, 0, nrow, nrhs) = A * U; + work.topRows(nrow).noalias() = A * U; //Begin Scatter for (Index j = 0; j < nrhs; j++) -- cgit v1.2.3