Pulled latest updates from trunk

This commit is contained in:
Benoit Steiner 2015-02-17 10:04:25 -08:00
commit 36c9d08274
4 changed files with 24 additions and 25 deletions

View File

@ -18,12 +18,12 @@ namespace Eigen {
* Row (column) i of A is the matperm(i) row (column) of Ap. * Row (column) i of A is the matperm(i) row (column) of Ap.
* WARNING: As computed by METIS, this corresponds to the vector iperm (instead of perm) * WARNING: As computed by METIS, this corresponds to the vector iperm (instead of perm)
*/ */
template <typename Index> template <typename StorageIndex>
class MetisOrdering class MetisOrdering
{ {
public: public:
typedef PermutationMatrix<Dynamic,Dynamic,Index> PermutationType; typedef PermutationMatrix<Dynamic,Dynamic,StorageIndex> PermutationType;
typedef Matrix<Index,Dynamic,1> IndexVector; typedef Matrix<StorageIndex,Dynamic,1> IndexVector;
template <typename MatrixType> template <typename MatrixType>
void get_symmetrized_graph(const MatrixType& A) void get_symmetrized_graph(const MatrixType& A)
@ -36,7 +36,7 @@ public:
Index TotNz = 0; Index TotNz = 0;
IndexVector visited(m); IndexVector visited(m);
visited.setConstant(-1); visited.setConstant(-1);
for (int j = 0; j < m; j++) for (StorageIndex j = 0; j < m; j++)
{ {
// Compute the union structure of of A(j,:) and At(j,:) // Compute the union structure of of A(j,:) and At(j,:)
visited(j) = j; // Do not include the diagonal element visited(j) = j; // Do not include the diagonal element
@ -67,8 +67,8 @@ public:
// Now compute the real adjacency list of each column/row // Now compute the real adjacency list of each column/row
visited.setConstant(-1); visited.setConstant(-1);
Index CurNz = 0; StorageIndex CurNz = 0;
for (int j = 0; j < m; j++) for (StorageIndex j = 0; j < m; j++)
{ {
m_indexPtr(j) = CurNz; m_indexPtr(j) = CurNz;
@ -76,7 +76,7 @@ public:
// Add the pattern of row/column j of A to A+At // Add the pattern of row/column j of A to A+At
for (typename MatrixType::InnerIterator it(A,j); it; ++it) for (typename MatrixType::InnerIterator it(A,j); it; ++it)
{ {
Index idx = it.index(); // Get the row index (for column major) or column index (for row major) StorageIndex idx = it.index(); // Get the row index (for column major) or column index (for row major)
if (visited(idx) != j ) if (visited(idx) != j )
{ {
visited(idx) = j; visited(idx) = j;
@ -87,7 +87,7 @@ public:
//Add the pattern of row/column j of At to A+At //Add the pattern of row/column j of At to A+At
for (typename MatrixType::InnerIterator it(At, j); it; ++it) for (typename MatrixType::InnerIterator it(At, j); it; ++it)
{ {
Index idx = it.index(); StorageIndex idx = it.index();
if(visited(idx) != j) if(visited(idx) != j)
{ {
visited(idx) = j; visited(idx) = j;
@ -102,7 +102,7 @@ public:
template <typename MatrixType> template <typename MatrixType>
void operator() (const MatrixType& A, PermutationType& matperm) void operator() (const MatrixType& A, PermutationType& matperm)
{ {
Index m = A.cols(); StorageIndex m = internal::convert_index<StorageIndex>(A.cols()); // must be StorageIndex, because it is passed by address to METIS
IndexVector perm(m),iperm(m); IndexVector perm(m),iperm(m);
// First, symmetrize the matrix graph. // First, symmetrize the matrix graph.
get_symmetrized_graph(A); get_symmetrized_graph(A);

View File

@ -90,7 +90,6 @@ class CompressedStorage
m_size = size; m_size = size;
} }
// FIXME i should be a StorageIndex
void append(const Scalar& v, Index i) void append(const Scalar& v, Index i)
{ {
Index id = m_size; Index id = m_size;
@ -110,13 +109,13 @@ class CompressedStorage
inline const StorageIndex& index(Index i) const { return m_indices[i]; } inline const StorageIndex& index(Index i) const { return m_indices[i]; }
/** \returns the largest \c k such that for all \c j in [0,k) index[\c j]\<\a key */ /** \returns the largest \c k such that for all \c j in [0,k) index[\c j]\<\a key */
inline StorageIndex searchLowerIndex(StorageIndex key) const inline Index searchLowerIndex(Index key) const
{ {
return searchLowerIndex(0, m_size, key); return searchLowerIndex(0, m_size, key);
} }
/** \returns the largest \c k in [start,end) such that for all \c j in [start,k) index[\c j]\<\a key */ /** \returns the largest \c k in [start,end) such that for all \c j in [start,k) index[\c j]\<\a key */
inline Index searchLowerIndex(Index start, Index end, StorageIndex key) const inline Index searchLowerIndex(Index start, Index end, Index key) const
{ {
while(end>start) while(end>start)
{ {
@ -131,7 +130,7 @@ class CompressedStorage
/** \returns the stored value at index \a key /** \returns the stored value at index \a key
* If the value does not exist, then the value \a defaultValue is returned without any insertion. */ * If the value does not exist, then the value \a defaultValue is returned without any insertion. */
inline Scalar at(StorageIndex key, const Scalar& defaultValue = Scalar(0)) const inline Scalar at(Index key, const Scalar& defaultValue = Scalar(0)) const
{ {
if (m_size==0) if (m_size==0)
return defaultValue; return defaultValue;
@ -144,7 +143,7 @@ class CompressedStorage
} }
/** Like at(), but the search is performed in the range [start,end) */ /** Like at(), but the search is performed in the range [start,end) */
inline Scalar atInRange(Index start, Index end, StorageIndex key, const Scalar &defaultValue = Scalar(0)) const inline Scalar atInRange(Index start, Index end, Index key, const Scalar &defaultValue = Scalar(0)) const
{ {
if (start>=end) if (start>=end)
return defaultValue; return defaultValue;
@ -159,7 +158,7 @@ class CompressedStorage
/** \returns a reference to the value at index \a key /** \returns a reference to the value at index \a key
* If the value does not exist, then the value \a defaultValue is inserted * If the value does not exist, then the value \a defaultValue is inserted
* such that the keys are sorted. */ * such that the keys are sorted. */
inline Scalar& atWithInsertion(StorageIndex key, const Scalar& defaultValue = Scalar(0)) inline Scalar& atWithInsertion(Index key, const Scalar& defaultValue = Scalar(0))
{ {
Index id = searchLowerIndex(0,m_size,key); Index id = searchLowerIndex(0,m_size,key);
if (id>=m_size || m_indices[id]!=key) if (id>=m_size || m_indices[id]!=key)
@ -189,7 +188,7 @@ class CompressedStorage
internal::smart_memmove(m_indices+id, m_indices+m_size, m_indices+id+1); internal::smart_memmove(m_indices+id, m_indices+m_size, m_indices+id+1);
} }
m_size++; m_size++;
m_indices[id] = key; m_indices[id] = internal::convert_index<StorageIndex>(key);
m_values[id] = defaultValue; m_values[id] = defaultValue;
} }
return m_values[id]; return m_values[id];

View File

@ -171,19 +171,19 @@ struct SluMatrix : SuperMatrix
if ((MatrixType::Flags&RowMajorBit)==RowMajorBit) if ((MatrixType::Flags&RowMajorBit)==RowMajorBit)
{ {
res.setStorageType(SLU_NR); res.setStorageType(SLU_NR);
res.nrow = mat.cols(); res.nrow = internal::convert_index<int>(mat.cols());
res.ncol = mat.rows(); res.ncol = internal::convert_index<int>(mat.rows());
} }
else else
{ {
res.setStorageType(SLU_NC); res.setStorageType(SLU_NC);
res.nrow = mat.rows(); res.nrow = internal::convert_index<int>(mat.rows());
res.ncol = mat.cols(); res.ncol = internal::convert_index<int>(mat.cols());
} }
res.Mtype = SLU_GE; res.Mtype = SLU_GE;
res.storage.nnz = mat.nonZeros(); res.storage.nnz = internal::convert_index<int>(mat.nonZeros());
res.storage.values = mat.derived().valuePtr(); res.storage.values = mat.derived().valuePtr();
res.storage.innerInd = mat.derived().innerIndexPtr(); res.storage.innerInd = mat.derived().innerIndexPtr();
res.storage.outerInd = mat.derived().outerIndexPtr(); res.storage.outerInd = mat.derived().outerIndexPtr();
@ -361,7 +361,7 @@ class SuperLUBase : public SparseSolverBase<Derived>
{ {
set_default_options(&this->m_sluOptions); set_default_options(&this->m_sluOptions);
const int size = a.rows(); const Index size = a.rows();
m_matrix = a; m_matrix = a;
m_sluA = internal::asSluMatrix(m_matrix); m_sluA = internal::asSluMatrix(m_matrix);
@ -380,7 +380,7 @@ class SuperLUBase : public SparseSolverBase<Derived>
m_sluB.storage.values = 0; m_sluB.storage.values = 0;
m_sluB.nrow = 0; m_sluB.nrow = 0;
m_sluB.ncol = 0; m_sluB.ncol = 0;
m_sluB.storage.lda = size; m_sluB.storage.lda = internal::convert_index<int>(size);
m_sluX = m_sluB; m_sluX = m_sluB;
m_extractedDataAreDirty = true; m_extractedDataAreDirty = true;
@ -682,7 +682,7 @@ void SuperLUBase<MatrixType,Derived>::extractData() const
NCformat *Ustore = static_cast<NCformat*>(m_sluU.Store); NCformat *Ustore = static_cast<NCformat*>(m_sluU.Store);
Scalar *SNptr; Scalar *SNptr;
const int size = m_matrix.rows(); const Index size = m_matrix.rows();
m_l.resize(size,size); m_l.resize(size,size);
m_l.resizeNonZeros(Lstore->nnz); m_l.resizeNonZeros(Lstore->nnz);
m_u.resize(size,size); m_u.resize(size,size);

View File

@ -296,7 +296,7 @@ class RandomSetter
const Index inner = SetterRowMajor ? col : row; const Index inner = SetterRowMajor ? col : row;
const Index outerMajor = outer >> OuterPacketBits; // index of the packet/map const Index outerMajor = outer >> OuterPacketBits; // index of the packet/map
const Index outerMinor = outer & OuterPacketMask; // index of the inner vector in the packet const Index outerMinor = outer & OuterPacketMask; // index of the inner vector in the packet
const KeyType key = (KeyType(outerMinor)<<m_keyBitsOffset) | inner; const KeyType key = internal::convert_index<KeyType>((outerMinor<<m_keyBitsOffset) | inner);
return m_hashmaps[outerMajor][key].value; return m_hashmaps[outerMajor][key].value;
} }