aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2014-02-15 09:35:23 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2014-02-15 09:35:23 +0100
commit4b6b3f310f5b651d82a65eb546e61d70c09407c5 (patch)
tree4d0631070b5b0bf08f0da8d18f0033b0c06e98d8 /test
parentcd606bbc943c4862cf0cf596d3ef97aae32c2887 (diff)
Fix a few Index to int buggy conversions
Diffstat (limited to 'test')
-rw-r--r--test/sparse.h6
-rw-r--r--test/sparse_product.cpp1
-rw-r--r--test/sparse_vector.cpp13
3 files changed, 11 insertions, 9 deletions
diff --git a/test/sparse.h b/test/sparse.h
index a09c65e5f..433d48ec4 100644
--- a/test/sparse.h
+++ b/test/sparse.h
@@ -154,16 +154,16 @@ initSparse(double density,
sparseMat.finalize();
}
-template<typename Scalar> void
+template<typename Scalar,int Options,typename Index> void
initSparse(double density,
Matrix<Scalar,Dynamic,1>& refVec,
- SparseVector<Scalar>& sparseVec,
+ SparseVector<Scalar,Options,Index>& sparseVec,
std::vector<int>* zeroCoords = 0,
std::vector<int>* nonzeroCoords = 0)
{
sparseVec.reserve(int(refVec.size()*density));
sparseVec.setZero();
- for(int i=0; i<refVec.size(); i++)
+ for(Index i=0; i<refVec.size(); i++)
{
Scalar v = (internal::random<double>(0,1) < density) ? internal::random<Scalar>() : Scalar(0);
if (v!=Scalar(0))
diff --git a/test/sparse_product.cpp b/test/sparse_product.cpp
index 664e33887..948b0026b 100644
--- a/test/sparse_product.cpp
+++ b/test/sparse_product.cpp
@@ -244,6 +244,7 @@ void test_sparse_product()
CALL_SUBTEST_1( (sparse_product<SparseMatrix<double,RowMajor> >()) );
CALL_SUBTEST_2( (sparse_product<SparseMatrix<std::complex<double>, ColMajor > >()) );
CALL_SUBTEST_2( (sparse_product<SparseMatrix<std::complex<double>, RowMajor > >()) );
+ CALL_SUBTEST_3( (sparse_product<SparseMatrix<float,ColMajor,long int> >()) );
CALL_SUBTEST_4( (sparse_product_regression_test<SparseMatrix<double,RowMajor>, Matrix<double, Dynamic, Dynamic, RowMajor> >()) );
}
}
diff --git a/test/sparse_vector.cpp b/test/sparse_vector.cpp
index ec5877b6a..0c9476803 100644
--- a/test/sparse_vector.cpp
+++ b/test/sparse_vector.cpp
@@ -9,14 +9,14 @@
#include "sparse.h"
-template<typename Scalar> void sparse_vector(int rows, int cols)
+template<typename Scalar,typename Index> void sparse_vector(int rows, int cols)
{
double densityMat = (std::max)(8./(rows*cols), 0.01);
double densityVec = (std::max)(8./float(rows), 0.1);
typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix;
typedef Matrix<Scalar,Dynamic,1> DenseVector;
- typedef SparseVector<Scalar> SparseVectorType;
- typedef SparseMatrix<Scalar> SparseMatrixType;
+ typedef SparseVector<Scalar,0,Index> SparseVectorType;
+ typedef SparseMatrix<Scalar,0,Index> SparseMatrixType;
Scalar eps = 1e-6;
SparseMatrixType m1(rows,rows);
@@ -101,9 +101,10 @@ template<typename Scalar> void sparse_vector(int rows, int cols)
void test_sparse_vector()
{
for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( sparse_vector<double>(8, 8) );
- CALL_SUBTEST_2( sparse_vector<std::complex<double> >(16, 16) );
- CALL_SUBTEST_1( sparse_vector<double>(299, 535) );
+ CALL_SUBTEST_1(( sparse_vector<double,int>(8, 8) ));
+ CALL_SUBTEST_2(( sparse_vector<std::complex<double>, int>(16, 16) ));
+ CALL_SUBTEST_1(( sparse_vector<double,long int>(299, 535) ));
+ CALL_SUBTEST_1(( sparse_vector<double,short>(299, 535) ));
}
}