aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/OrderingMethods/Ordering.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2015-02-16 13:19:05 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2015-02-16 13:19:05 +0100
commitaa6c516ec17fb44dff85b1abf3a1b05d58d3bc01 (patch)
treecd0b6ce4d023ff6734beecc167749d00f301c017 /Eigen/src/OrderingMethods/Ordering.h
parentfc202bab398ed9b78ef8452f8e4ef35e233965f6 (diff)
Fix many long to int conversion warnings:
- fix usage of Index (API) versus StorageIndex (when multiple indexes are stored) - use StorageIndex(val) when the input has already been check - use internal::convert_index<StorageIndex>(val) when val is potentially unsafe (directly comes from user input)
Diffstat (limited to 'Eigen/src/OrderingMethods/Ordering.h')
-rw-r--r--Eigen/src/OrderingMethods/Ordering.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/Eigen/src/OrderingMethods/Ordering.h b/Eigen/src/OrderingMethods/Ordering.h
index f3c31f9cb..e88e637a4 100644
--- a/Eigen/src/OrderingMethods/Ordering.h
+++ b/Eigen/src/OrderingMethods/Ordering.h
@@ -111,12 +111,12 @@ class NaturalOrdering
* Functor computing the \em column \em approximate \em minimum \em degree ordering
* The matrix should be in column-major and \b compressed format (see SparseMatrix::makeCompressed()).
*/
-template<typename Index>
+template<typename StorageIndex>
class COLAMDOrdering
{
public:
- typedef PermutationMatrix<Dynamic, Dynamic, Index> PermutationType;
- typedef Matrix<Index, Dynamic, 1> IndexVector;
+ typedef PermutationMatrix<Dynamic, Dynamic, StorageIndex> PermutationType;
+ typedef Matrix<StorageIndex, Dynamic, 1> IndexVector;
/** Compute the permutation vector \a perm form the sparse matrix \a mat
* \warning The input sparse matrix \a mat must be in compressed mode (see SparseMatrix::makeCompressed()).
@@ -126,26 +126,26 @@ class COLAMDOrdering
{
eigen_assert(mat.isCompressed() && "COLAMDOrdering requires a sparse matrix in compressed mode. Call .makeCompressed() before passing it to COLAMDOrdering");
- Index m = mat.rows();
- Index n = mat.cols();
- Index nnz = mat.nonZeros();
+ StorageIndex m = StorageIndex(mat.rows());
+ StorageIndex n = StorageIndex(mat.cols());
+ StorageIndex nnz = StorageIndex(mat.nonZeros());
// Get the recommended value of Alen to be used by colamd
- Index Alen = internal::colamd_recommended(nnz, m, n);
+ StorageIndex Alen = internal::colamd_recommended(nnz, m, n);
// Set the default parameters
double knobs [COLAMD_KNOBS];
- Index stats [COLAMD_STATS];
+ StorageIndex stats [COLAMD_STATS];
internal::colamd_set_defaults(knobs);
IndexVector p(n+1), A(Alen);
- for(Index i=0; i <= n; i++) p(i) = mat.outerIndexPtr()[i];
- for(Index i=0; i < nnz; i++) A(i) = mat.innerIndexPtr()[i];
+ for(StorageIndex i=0; i <= n; i++) p(i) = mat.outerIndexPtr()[i];
+ for(StorageIndex i=0; i < nnz; i++) A(i) = mat.innerIndexPtr()[i];
// Call Colamd routine to compute the ordering
- Index info = internal::colamd(m, n, Alen, A.data(), p.data(), knobs, stats);
+ StorageIndex info = internal::colamd(m, n, Alen, A.data(), p.data(), knobs, stats);
EIGEN_UNUSED_VARIABLE(info);
eigen_assert( info && "COLAMD failed " );
perm.resize(n);
- for (Index i = 0; i < n; i++) perm.indices()(p(i)) = i;
+ for (StorageIndex i = 0; i < n; i++) perm.indices()(p(i)) = i;
}
};