From f1679c7185471289afaf702a45e336849d20a81a Mon Sep 17 00:00:00 2001 From: Hauke Heibel Date: Sun, 20 Jun 2010 17:37:56 +0200 Subject: [PATCH] Utilize Index in all unit tests. --- test/adjoint.cpp | 11 ++++--- test/array.cpp | 15 +++++---- test/array_for_matrix.cpp | 14 ++++---- test/array_replicate.cpp | 6 ++-- test/array_reverse.cpp | 5 +-- test/bandmatrix.cpp | 25 +++++++------- test/basicstuff.cpp | 10 +++--- test/block.cpp | 33 ++++++++++--------- test/cholesky.cpp | 5 +-- test/conservative_resize.cpp | 9 ++--- test/corners.cpp | 9 ++--- test/cwiseop.cpp | 5 +-- test/diagonal.cpp | 6 ++-- test/diagonalmatrices.cpp | 5 +-- test/eigen2support.cpp | 5 +-- test/eigensolver_complex.cpp | 5 +-- test/eigensolver_generic.cpp | 5 +-- test/eigensolver_selfadjoint.cpp | 5 +-- test/householder.cpp | 5 +-- test/integer_types.cpp | 10 +++--- test/inverse.cpp | 5 +-- test/jacobisvd.cpp | 5 +-- test/linearstructure.cpp | 6 ++-- test/lu.cpp | 14 ++++---- test/main.h | 2 +- test/map.cpp | 3 +- test/mapstride.cpp | 3 +- test/miscmatrices.cpp | 8 ++--- test/nomalloc.cpp | 10 +++--- test/nullary.cpp | 5 +-- test/permutationmatrices.cpp | 5 +-- test/product.h | 6 ++-- test/product_extra.cpp | 5 +-- test/product_notemporary.cpp | 6 ++-- test/product_selfadjoint.cpp | 5 +-- test/product_symm.cpp | 5 +-- test/product_syrk.cpp | 5 +-- test/product_trmm.cpp | 4 +-- test/product_trmv.cpp | 5 +-- test/qr.cpp | 6 ++-- test/qr_colpivoting.cpp | 6 ++-- test/qr_fullpivoting.cpp | 6 ++-- test/qtvector.cpp | 6 ++-- test/redux.cpp | 5 +-- test/resize.cpp | 2 +- test/selfadjoint.cpp | 5 +-- test/sparse_basic.cpp | 6 ++-- test/sparse_product.cpp | 5 +-- test/stable_norm.cpp | 6 ++-- test/stdlist.cpp | 6 ++-- test/stdvector.cpp | 4 +-- unsupported/Eigen/AlignedVector3 | 12 +++---- .../Eigen/src/SparseExtra/UmfPackSupport.h | 5 +-- unsupported/test/sparse_extra.cpp | 5 +-- 54 files changed, 222 insertions(+), 163 deletions(-) diff --git a/test/adjoint.cpp b/test/adjoint.cpp index fc6c8897b..2cf9ef380 100644 --- a/test/adjoint.cpp +++ b/test/adjoint.cpp @@ -31,13 +31,14 @@ template void adjoint(const MatrixType& m) /* this test covers the following files: Transpose.h Conjugate.h Dot.h */ - + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef Matrix VectorType; typedef Matrix SquareMatrixType; - int rows = m.rows(); - int cols = m.cols(); + + Index rows = m.rows(); + Index cols = m.cols(); RealScalar largerEps = test_precision(); if (ei_is_same_type::ret) @@ -79,8 +80,8 @@ template void adjoint(const MatrixType& m) VERIFY(ei_isApprox(v1.dot(square * v2), (square.adjoint() * v1).dot(v2), largerEps)); // like in testBasicStuff, test operator() to check const-qualification - int r = ei_random(0, rows-1), - c = ei_random(0, cols-1); + Index r = ei_random(0, rows-1), + c = ei_random(0, cols-1); VERIFY_IS_APPROX(m1.conjugate()(r,c), ei_conj(m1(r,c))); VERIFY_IS_APPROX(m1.adjoint()(c,r), ei_conj(m1(r,c))); diff --git a/test/array.cpp b/test/array.cpp index 7f44b7d5d..aea8d20b9 100644 --- a/test/array.cpp +++ b/test/array.cpp @@ -26,13 +26,14 @@ template void array(const ArrayType& m) { + typedef typename ArrayType::Index Index; typedef typename ArrayType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef Array ColVectorType; typedef Array RowVectorType; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); ArrayType m1 = ArrayType::Random(rows, cols), m2 = ArrayType::Random(rows, cols), @@ -78,12 +79,13 @@ template void array(const ArrayType& m) template void comparisons(const ArrayType& m) { + typedef typename ArrayType::Index Index; typedef typename ArrayType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef Array VectorType; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); int r = ei_random(0, rows-1), c = ei_random(0, cols-1); @@ -137,11 +139,12 @@ template void comparisons(const ArrayType& m) template void array_real(const ArrayType& m) { + typedef typename ArrayType::Index Index; typedef typename ArrayType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); ArrayType m1 = ArrayType::Random(rows, cols), m2 = ArrayType::Random(rows, cols), diff --git a/test/array_for_matrix.cpp b/test/array_for_matrix.cpp index 5d0b9bbbd..86637aa86 100644 --- a/test/array_for_matrix.cpp +++ b/test/array_for_matrix.cpp @@ -26,13 +26,14 @@ template void array_for_matrix(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef Matrix ColVectorType; typedef Matrix RowVectorType; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols), @@ -75,15 +76,16 @@ template void array_for_matrix(const MatrixType& m) template void comparisons(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef Matrix VectorType; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); - int r = ei_random(0, rows-1), - c = ei_random(0, cols-1); + Index r = ei_random(0, rows-1), + c = ei_random(0, cols-1); MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols), diff --git a/test/array_replicate.cpp b/test/array_replicate.cpp index 8c4845d3c..0a4c04262 100644 --- a/test/array_replicate.cpp +++ b/test/array_replicate.cpp @@ -29,15 +29,15 @@ template void replicate(const MatrixType& m) /* this test covers the following files: Replicate.cpp */ - + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef Matrix VectorType; typedef Matrix MatrixX; typedef Matrix VectorX; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols); diff --git a/test/array_reverse.cpp b/test/array_reverse.cpp index 3933ff523..144a0b088 100644 --- a/test/array_reverse.cpp +++ b/test/array_reverse.cpp @@ -30,11 +30,12 @@ using namespace std; template void reverse(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef Matrix VectorType; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); // this test relies a lot on Random.h, and there's not much more that we can do // to test it, hence I consider that we will have tested Random.h diff --git a/test/bandmatrix.cpp b/test/bandmatrix.cpp index dc54812b9..2745e527b 100644 --- a/test/bandmatrix.cpp +++ b/test/bandmatrix.cpp @@ -26,14 +26,15 @@ template void bandmatrix(const MatrixType& _m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef Matrix DenseMatrixType; - int rows = _m.rows(); - int cols = _m.cols(); - int supers = _m.supers(); - int subs = _m.subs(); + Index rows = _m.rows(); + Index cols = _m.cols(); + Index supers = _m.supers(); + Index subs = _m.subs(); MatrixType m(rows,cols,supers,subs); @@ -60,9 +61,9 @@ template void bandmatrix(const MatrixType& _m) m.col(i).setConstant(static_cast(i+1)); dm1.col(i).setConstant(static_cast(i+1)); } - int d = std::min(rows,cols); - int a = std::max(0,cols-d-supers); - int b = std::max(0,rows-d-subs); + Index d = std::min(rows,cols); + Index a = std::max(0,cols-d-supers); + Index b = std::max(0,rows-d-subs); if(a>0) dm1.block(0,d+supers,rows,a).setZero(); dm1.block(0,supers+1,cols-supers-1-a,cols-supers-1-a).template triangularView().setZero(); dm1.block(subs+1,0,rows-subs-1-b,rows-subs-1-b).template triangularView().setZero(); @@ -74,11 +75,13 @@ template void bandmatrix(const MatrixType& _m) void test_bandmatrix() { + typedef BandMatrix::Index Index; + for(int i = 0; i < 10*g_repeat ; i++) { - int rows = ei_random(1,10); - int cols = ei_random(1,10); - int sups = ei_random(0,cols-1); - int subs = ei_random(0,rows-1); + Index rows = ei_random(1,10); + Index sups = ei_random(0,cols-1); + Index subs = ei_random(0,rows-1); CALL_SUBTEST(bandmatrix(BandMatrix(rows,cols,sups,subs)) ); } } diff --git a/test/basicstuff.cpp b/test/basicstuff.cpp index ddddb5985..e1afc0ecc 100644 --- a/test/basicstuff.cpp +++ b/test/basicstuff.cpp @@ -28,11 +28,12 @@ template void basicStuff(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef Matrix VectorType; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); // this test relies a lot on Random.h, and there's not much more that we can do // to test it, hence I consider that we will have tested Random.h @@ -124,12 +125,13 @@ template void basicStuff(const MatrixType& m) template void basicStuffComplex(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef Matrix RealMatrixType; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); Scalar s1 = ei_random(), s2 = ei_random(); diff --git a/test/block.cpp b/test/block.cpp index a6bf47058..fcfa5191b 100644 --- a/test/block.cpp +++ b/test/block.cpp @@ -27,6 +27,7 @@ template void block(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; typedef Matrix VectorType; @@ -34,8 +35,8 @@ template void block(const MatrixType& m) typedef Matrix DynamicMatrixType; typedef Matrix DynamicVectorType; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols), @@ -158,13 +159,14 @@ template void block(const MatrixType& m) template void compare_using_data_and_stride(const MatrixType& m) { - int rows = m.rows(); - int cols = m.cols(); - int size = m.size(); - int innerStride = m.innerStride(); - int outerStride = m.outerStride(); - int rowStride = m.rowStride(); - int colStride = m.colStride(); + typedef MatrixType::Index Index; + Index rows = m.rows(); + Index cols = m.cols(); + Index size = m.size(); + Index innerStride = m.innerStride(); + Index outerStride = m.outerStride(); + Index rowStride = m.rowStride(); + Index colStride = m.colStride(); const typename MatrixType::Scalar* data = m.data(); for(int j=0;j void data_and_stride(const MatrixType& m) { - int rows = m.rows(); - int cols = m.cols(); + typedef typename MatrixType::Index Index; + Index rows = m.rows(); + Index cols = m.cols(); - int r1 = ei_random(0,rows-1); - int r2 = ei_random(r1,rows-1); - int c1 = ei_random(0,cols-1); - int c2 = ei_random(c1,cols-1); + Index r1 = ei_random(0,rows-1); + Index r2 = ei_random(r1,rows-1); + Index c1 = ei_random(0,cols-1); + Index c2 = ei_random(c1,cols-1); MatrixType m1 = MatrixType::Random(rows, cols); compare_using_data_and_stride(m1.block(r1, c1, r2-r1+1, c2-c1+1)); diff --git a/test/cholesky.cpp b/test/cholesky.cpp index 54ff94f32..a178b82b6 100644 --- a/test/cholesky.cpp +++ b/test/cholesky.cpp @@ -47,11 +47,12 @@ static int nb_temporaries; template void cholesky(const MatrixType& m) { + typedef typename MatrixType::Index Index; /* this test covers the following files: LLT.h LDLT.h */ - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; diff --git a/test/conservative_resize.cpp b/test/conservative_resize.cpp index 825f23b37..f0aff37b9 100644 --- a/test/conservative_resize.cpp +++ b/test/conservative_resize.cpp @@ -32,6 +32,7 @@ template void run_matrix_tests() { typedef Matrix MatrixType; + typedef MatrixType::Index Index; MatrixType m, n; @@ -51,8 +52,8 @@ void run_matrix_tests() // random shrinking ... for (int i=0; i<25; ++i) { - const int rows = ei_random(1,50); - const int cols = ei_random(1,50); + const Index rows = ei_random(1,50); + const Index cols = ei_random(1,50); m = n = MatrixType::Random(50,50); m.conservativeResize(rows,cols); VERIFY_IS_APPROX(m, n.block(0,0,rows,cols)); @@ -61,8 +62,8 @@ void run_matrix_tests() // random growing with zeroing ... for (int i=0; i<25; ++i) { - const int rows = ei_random(50,75); - const int cols = ei_random(50,75); + const Index rows = ei_random(50,75); + const Index cols = ei_random(50,75); m = n = MatrixType::Random(50,50); m.conservativeResizeLike(MatrixType::Zero(rows,cols)); VERIFY_IS_APPROX(m.block(0,0,n.rows(),n.cols()), n); diff --git a/test/corners.cpp b/test/corners.cpp index 3baea1b96..70d12fded 100644 --- a/test/corners.cpp +++ b/test/corners.cpp @@ -30,11 +30,12 @@ template void corners(const MatrixType& m) { - int rows = m.rows(); - int cols = m.cols(); + typedef typename MatrixType::Index Index; + Index rows = m.rows(); + Index cols = m.cols(); - int r = ei_random(1,rows); - int c = ei_random(1,cols); + Index r = ei_random(1,rows); + Index c = ei_random(1,cols); MatrixType matrix = MatrixType::Random(rows,cols); const MatrixType const_matrix = MatrixType::Random(rows,cols); diff --git a/test/cwiseop.cpp b/test/cwiseop.cpp index 8193c6e54..ee7c8d2c4 100644 --- a/test/cwiseop.cpp +++ b/test/cwiseop.cpp @@ -37,12 +37,13 @@ template struct AddIfNull { template void cwiseops(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef Matrix VectorType; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols), diff --git a/test/diagonal.cpp b/test/diagonal.cpp index 288d58c6e..50b341dfe 100644 --- a/test/diagonal.cpp +++ b/test/diagonal.cpp @@ -26,12 +26,14 @@ template void diagonal(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; typedef Matrix VectorType; typedef Matrix RowVectorType; - int rows = m.rows(); - int cols = m.cols(); + + Index rows = m.rows(); + Index cols = m.cols(); MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols); diff --git a/test/diagonalmatrices.cpp b/test/diagonalmatrices.cpp index c24c66d03..2bc75ba1c 100644 --- a/test/diagonalmatrices.cpp +++ b/test/diagonalmatrices.cpp @@ -26,6 +26,7 @@ using namespace std; template void diagonalmatrices(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; enum { Rows = MatrixType::RowsAtCompileTime, Cols = MatrixType::ColsAtCompileTime }; @@ -35,8 +36,8 @@ template void diagonalmatrices(const MatrixType& m) typedef DiagonalMatrix LeftDiagonalMatrix; typedef DiagonalMatrix RightDiagonalMatrix; typedef Matrix BigMatrix; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols); diff --git a/test/eigen2support.cpp b/test/eigen2support.cpp index a18e7ed8a..274014c1c 100644 --- a/test/eigen2support.cpp +++ b/test/eigen2support.cpp @@ -28,10 +28,11 @@ template void eigen2support(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols), diff --git a/test/eigensolver_complex.cpp b/test/eigensolver_complex.cpp index 1c1dd98f3..abb1f1110 100644 --- a/test/eigensolver_complex.cpp +++ b/test/eigensolver_complex.cpp @@ -47,11 +47,12 @@ void verify_is_approx_upto_permutation(const VectorType& vec1, const VectorType& template void eigensolver(const MatrixType& m) { + typedef typename MatrixType::Index Index; /* this test covers the following files: ComplexEigenSolver.h, and indirectly ComplexSchur.h */ - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; diff --git a/test/eigensolver_generic.cpp b/test/eigensolver_generic.cpp index 92741a35c..b261b7be7 100644 --- a/test/eigensolver_generic.cpp +++ b/test/eigensolver_generic.cpp @@ -33,11 +33,12 @@ template void eigensolver(const MatrixType& m) { + typedef typename MatrixType::Index Index; /* this test covers the following files: EigenSolver.h */ - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; diff --git a/test/eigensolver_selfadjoint.cpp b/test/eigensolver_selfadjoint.cpp index e8da32d22..2d7ac67ca 100644 --- a/test/eigensolver_selfadjoint.cpp +++ b/test/eigensolver_selfadjoint.cpp @@ -33,11 +33,12 @@ template void selfadjointeigensolver(const MatrixType& m) { + typedef typename MatrixType::Index Index; /* this test covers the following files: EigenSolver.h, SelfAdjointEigenSolver.h (and indirectly: Tridiagonalization.h) */ - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; diff --git a/test/householder.cpp b/test/householder.cpp index 310eb8c33..94ea5c602 100644 --- a/test/householder.cpp +++ b/test/householder.cpp @@ -27,13 +27,14 @@ template void householder(const MatrixType& m) { + typedef typename MatrixType::Index Index; static bool even = true; even = !even; /* this test covers the following files: Householder.h */ - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; diff --git a/test/integer_types.cpp b/test/integer_types.cpp index d2feb8a65..abed4a6ac 100644 --- a/test/integer_types.cpp +++ b/test/integer_types.cpp @@ -33,13 +33,14 @@ template void signed_integer_type_tests(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; enum { is_signed = (Scalar(-1) > Scalar(0)) ? 0 : 1 }; VERIFY(is_signed == 1); - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); MatrixType m1(rows, cols), m2 = MatrixType::Random(rows, cols), @@ -63,6 +64,7 @@ template void signed_integer_type_tests(const MatrixType& m template void integer_type_tests(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; VERIFY(NumTraits::IsInteger); @@ -71,8 +73,8 @@ template void integer_type_tests(const MatrixType& m) typedef Matrix VectorType; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); // this test relies a lot on Random.h, and there's not much more that we can do // to test it, hence I consider that we will have tested Random.h diff --git a/test/inverse.cpp b/test/inverse.cpp index 108ce7bcb..f050980ff 100644 --- a/test/inverse.cpp +++ b/test/inverse.cpp @@ -28,11 +28,12 @@ template void inverse(const MatrixType& m) { + typedef typename MatrixType::Index Index; /* this test covers the following files: Inverse.h */ - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; diff --git a/test/jacobisvd.cpp b/test/jacobisvd.cpp index bc9d93754..401682e64 100644 --- a/test/jacobisvd.cpp +++ b/test/jacobisvd.cpp @@ -29,8 +29,9 @@ template void svd(const MatrixType& m = MatrixType(), bool pickrandom = true) { - int rows = m.rows(); - int cols = m.cols(); + typedef typename MatrixType::Index Index; + Index rows = m.rows(); + Index cols = m.cols(); enum { RowsAtCompileTime = MatrixType::RowsAtCompileTime, diff --git a/test/linearstructure.cpp b/test/linearstructure.cpp index 53001652c..1d86af337 100644 --- a/test/linearstructure.cpp +++ b/test/linearstructure.cpp @@ -29,11 +29,11 @@ template void linearStructure(const MatrixType& m) /* this test covers the following files: Sum.h Difference.h Opposite.h ScalarMultiple.h */ - + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); // this test relies a lot on Random.h, and there's not much more that we can do // to test it, hence I consider that we will have tested Random.h diff --git a/test/lu.cpp b/test/lu.cpp index 9aa793e00..8cb3cbbee 100644 --- a/test/lu.cpp +++ b/test/lu.cpp @@ -28,15 +28,16 @@ using namespace std; template void lu_non_invertible() { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; /* this test covers the following files: LU.h */ - int rows, cols, cols2; + Index rows, cols, cols2; if(MatrixType::RowsAtCompileTime==Dynamic) { - rows = ei_random(2,200); + rows = ei_random(2,200); } else { @@ -44,7 +45,7 @@ template void lu_non_invertible() } if(MatrixType::ColsAtCompileTime==Dynamic) { - cols = ei_random(2,200); + cols = ei_random(2,200); cols2 = ei_random(2,200); } else @@ -63,7 +64,7 @@ template void lu_non_invertible() typedef Matrix RMatrixType; - int rank = ei_random(1, std::min(rows, cols)-1); + Index rank = ei_random(1, std::min(rows, cols)-1); // The image of the zero matrix should consist of a single (zero) column vector VERIFY((MatrixType::Zero(rows,cols).fullPivLu().image(MatrixType::Zero(rows,cols)).cols() == 1)); @@ -145,10 +146,11 @@ template void lu_partial_piv() /* this test covers the following files: PartialPivLU.h */ + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; - int rows = ei_random(1,4); - int cols = rows; + Index rows = ei_random(1,4); + Index cols = rows; MatrixType m1(cols, rows); m1.setRandom(); diff --git a/test/main.h b/test/main.h index 184a35b15..0f63a2435 100644 --- a/test/main.h +++ b/test/main.h @@ -385,7 +385,7 @@ bool test_is_equal(const T& actual, const U& expected) * This is very useful to test rank-revealing algorithms. */ template -void createRandomPIMatrixOfRank(int desired_rank, int rows, int cols, MatrixType& m) +void createRandomPIMatrixOfRank(typename MatrixType::Index desired_rank, typename MatrixType::Index rows, int cols, MatrixType& m) { typedef typename ei_traits::Scalar Scalar; enum { Rows = MatrixType::RowsAtCompileTime, Cols = MatrixType::ColsAtCompileTime }; diff --git a/test/map.cpp b/test/map.cpp index 0204e9e7d..695d62982 100644 --- a/test/map.cpp +++ b/test/map.cpp @@ -53,9 +53,10 @@ template void map_class_vector(const VectorType& m) template void map_class_matrix(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; - int rows = m.rows(), cols = m.cols(), size = rows*cols; + Index rows = m.rows(), cols = m.cols(), size = rows*cols; // test Map.h Scalar* array1 = ei_aligned_new(size); diff --git a/test/mapstride.cpp b/test/mapstride.cpp index 7a1605681..ff6e71a66 100644 --- a/test/mapstride.cpp +++ b/test/mapstride.cpp @@ -61,9 +61,10 @@ template void map_class_vector(const VectorType& m) template void map_class_matrix(const MatrixType& _m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; - int rows = _m.rows(), cols = _m.cols(); + Index rows = _m.rows(), cols = _m.cols(); MatrixType m = MatrixType::Random(rows,cols); diff --git a/test/miscmatrices.cpp b/test/miscmatrices.cpp index 0adccf5ce..b14bca61c 100644 --- a/test/miscmatrices.cpp +++ b/test/miscmatrices.cpp @@ -29,14 +29,14 @@ template void miscMatrices(const MatrixType& m) /* this test covers the following files: DiagonalMatrix.h Ones.h */ - + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef Matrix VectorType; typedef Matrix RowVectorType; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); - int r = ei_random(0, rows-1), r2 = ei_random(0, rows-1), c = ei_random(0, cols-1); + Index r = ei_random(0, rows-1), r2 = ei_random(0, rows-1), c = ei_random(0, cols-1); VERIFY_IS_APPROX(MatrixType::Ones(rows,cols)(r,c), static_cast(1)); MatrixType m1 = MatrixType::Ones(rows,cols); VERIFY_IS_APPROX(m1(r,c), static_cast(1)); diff --git a/test/nomalloc.cpp b/test/nomalloc.cpp index 9eb8d1310..f37dcd1b2 100644 --- a/test/nomalloc.cpp +++ b/test/nomalloc.cpp @@ -43,12 +43,12 @@ template void nomalloc(const MatrixType& m) { /* this test check no dynamic memory allocation are issued with fixed-size matrices */ - + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef Matrix VectorType; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols), @@ -64,8 +64,8 @@ template void nomalloc(const MatrixType& m) Scalar s1 = ei_random(); - int r = ei_random(0, rows-1), - c = ei_random(0, cols-1); + Index r = ei_random(0, rows-1), + c = ei_random(0, cols-1); VERIFY_IS_APPROX((m1+m2)*s1, s1*m1+s1*m2); VERIFY_IS_APPROX((m1+m2)(r,c), (m1(r,c))+(m2(r,c))); diff --git a/test/nullary.cpp b/test/nullary.cpp index 6e91ddd52..d46349991 100644 --- a/test/nullary.cpp +++ b/test/nullary.cpp @@ -97,8 +97,9 @@ void testVectorType(const VectorType& base) template void testMatrixType(const MatrixType& m) { - const int rows = m.rows(); - const int cols = m.cols(); + typedef typename MatrixType::Index Index; + const Index rows = m.rows(); + const Index cols = m.cols(); MatrixType A; A.setIdentity(rows, cols); diff --git a/test/permutationmatrices.cpp b/test/permutationmatrices.cpp index 89142d910..d3cdfeca0 100644 --- a/test/permutationmatrices.cpp +++ b/test/permutationmatrices.cpp @@ -43,6 +43,7 @@ void randomPermutationVector(PermutationVectorType& v, int size) using namespace std; template void permutationmatrices(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; enum { Rows = MatrixType::RowsAtCompileTime, Cols = MatrixType::ColsAtCompileTime, @@ -52,8 +53,8 @@ template void permutationmatrices(const MatrixType& m) typedef PermutationMatrix RightPermutationType; typedef Matrix RightPermutationVectorType; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); MatrixType m_original = MatrixType::Random(rows,cols); LeftPermutationVectorType lv; diff --git a/test/product.h b/test/product.h index 71dc4bde2..d004a4ec4 100644 --- a/test/product.h +++ b/test/product.h @@ -37,7 +37,7 @@ template void product(const MatrixType& m) /* this test covers the following files: Identity.h Product.h */ - + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::NonInteger NonInteger; typedef Matrix RowVectorType; @@ -47,8 +47,8 @@ template void product(const MatrixType& m) typedef Matrix OtherMajorMatrixType; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); // this test relies a lot on Random.h, and there's not much more that we can do // to test it, hence I consider that we will have tested Random.h diff --git a/test/product_extra.cpp b/test/product_extra.cpp index 3644593f0..e53d675c3 100644 --- a/test/product_extra.cpp +++ b/test/product_extra.cpp @@ -26,6 +26,7 @@ template void product_extra(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::NonInteger NonInteger; typedef Matrix RowVectorType; @@ -33,8 +34,8 @@ template void product_extra(const MatrixType& m) typedef Matrix OtherMajorMatrixType; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols), diff --git a/test/product_notemporary.cpp b/test/product_notemporary.cpp index ca1140353..84d73ff47 100644 --- a/test/product_notemporary.cpp +++ b/test/product_notemporary.cpp @@ -39,15 +39,15 @@ template void product_notemporary(const MatrixType& m) { /* This test checks the number of temporaries created * during the evaluation of a complex expression */ - + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; typedef Matrix RowVectorType; typedef Matrix ColVectorType; typedef Matrix RowMajorMatrixType; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols), diff --git a/test/product_selfadjoint.cpp b/test/product_selfadjoint.cpp index 2027fc8e5..10a661ef8 100644 --- a/test/product_selfadjoint.cpp +++ b/test/product_selfadjoint.cpp @@ -26,6 +26,7 @@ template void product_selfadjoint(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef Matrix VectorType; @@ -33,8 +34,8 @@ template void product_selfadjoint(const MatrixType& m) typedef Matrix RhsMatrixType; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols), diff --git a/test/product_symm.cpp b/test/product_symm.cpp index 08e0a6070..92a3f4594 100644 --- a/test/product_symm.cpp +++ b/test/product_symm.cpp @@ -50,9 +50,10 @@ template void symm(int size = Size, in typedef Matrix Rhs2; enum { order = OtherSize==1 ? 0 : RowMajor }; typedef Matrix Rhs3; + typedef MatrixType::Index Index; - int rows = size; - int cols = size; + Index rows = size; + Index cols = size; MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols), m3; diff --git a/test/product_syrk.cpp b/test/product_syrk.cpp index ec93056a9..18cdda152 100644 --- a/test/product_syrk.cpp +++ b/test/product_syrk.cpp @@ -26,14 +26,15 @@ template void syrk(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef Matrix Rhs1; typedef Matrix Rhs2; typedef Matrix Rhs3; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols); diff --git a/test/product_trmm.cpp b/test/product_trmm.cpp index a689deba6..382618492 100644 --- a/test/product_trmm.cpp +++ b/test/product_trmm.cpp @@ -31,8 +31,8 @@ template void trmm(int size,int /*othersize*/) typedef Matrix MatrixColMaj; typedef Matrix MatrixRowMaj; - int rows = size; - int cols = ei_random(1,size); + DenseIndex rows = size; + DenseIndex cols = ei_random(1,size); MatrixColMaj triV(rows,cols), triH(cols,rows), upTri(cols,rows), loTri(rows,cols), unitUpTri(cols,rows), unitLoTri(rows,cols); diff --git a/test/product_trmv.cpp b/test/product_trmv.cpp index 2f5743187..19210b047 100644 --- a/test/product_trmv.cpp +++ b/test/product_trmv.cpp @@ -26,14 +26,15 @@ template void trmv(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef Matrix VectorType; RealScalar largerEps = 10*test_precision(); - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); MatrixType m1 = MatrixType::Random(rows, cols), m3(rows, cols); diff --git a/test/qr.cpp b/test/qr.cpp index eae336e49..2218bdc13 100644 --- a/test/qr.cpp +++ b/test/qr.cpp @@ -27,8 +27,10 @@ template void qr(const MatrixType& m) { - int rows = m.rows(); - int cols = m.cols(); + typedef typename MatrixType::Index Index; + + Index rows = m.rows(); + Index cols = m.cols(); typedef typename MatrixType::Scalar Scalar; typedef Matrix MatrixQType; diff --git a/test/qr_colpivoting.cpp b/test/qr_colpivoting.cpp index 7064bc229..94b8efbef 100644 --- a/test/qr_colpivoting.cpp +++ b/test/qr_colpivoting.cpp @@ -28,8 +28,10 @@ template void qr() { - int rows = ei_random(2,200), cols = ei_random(2,200), cols2 = ei_random(2,200); - int rank = ei_random(1, std::min(rows, cols)-1); + typedef typename MatrixType::Index Index; + + Index rows = ei_random(2,200), cols = ei_random(2,200), cols2 = ei_random(2,200); + Index rank = ei_random(1, std::min(rows, cols)-1); typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; diff --git a/test/qr_fullpivoting.cpp b/test/qr_fullpivoting.cpp index 33350ce0e..6f7831c33 100644 --- a/test/qr_fullpivoting.cpp +++ b/test/qr_fullpivoting.cpp @@ -28,8 +28,10 @@ template void qr() { - int rows = ei_random(20,200), cols = ei_random(20,200), cols2 = ei_random(20,200); - int rank = ei_random(1, std::min(rows, cols)-1); + typedef typename MatrixType::Index Index; + + Index rows = ei_random(20,200), cols = ei_random(20,200), cols2 = ei_random(20,200); + Index rank = ei_random(1, std::min(rows, cols)-1); typedef typename MatrixType::Scalar Scalar; typedef Matrix MatrixQType; diff --git a/test/qtvector.cpp b/test/qtvector.cpp index bc780b45b..b9bb9d076 100644 --- a/test/qtvector.cpp +++ b/test/qtvector.cpp @@ -33,8 +33,10 @@ template void check_qtvector_matrix(const MatrixType& m) { - int rows = m.rows(); - int cols = m.cols(); + typedef typename MatrixType::Index Index; + + Index rows = m.rows(); + Index cols = m.cols(); MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols); QVector v(10, MatrixType(rows,cols)), w(20, y); for(int i = 0; i < 20; i++) diff --git a/test/redux.cpp b/test/redux.cpp index 104cd4cdd..2dfe8cb4b 100644 --- a/test/redux.cpp +++ b/test/redux.cpp @@ -26,11 +26,12 @@ template void matrixRedux(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); MatrixType m1 = MatrixType::Random(rows, cols); diff --git a/test/resize.cpp b/test/resize.cpp index dfe3bda17..48818ac46 100644 --- a/test/resize.cpp +++ b/test/resize.cpp @@ -24,7 +24,7 @@ #include "main.h" -template +template void resizeLikeTest() { MatrixXf A(rows, cols); diff --git a/test/selfadjoint.cpp b/test/selfadjoint.cpp index 1ea5a3a3c..9e3ccb4a7 100644 --- a/test/selfadjoint.cpp +++ b/test/selfadjoint.cpp @@ -29,11 +29,12 @@ template void selfadjoint(const MatrixType& m) { + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); MatrixType m1 = MatrixType::Random(rows, cols), m3(rows, cols); diff --git a/test/sparse_basic.cpp b/test/sparse_basic.cpp index 3d2210930..3ebd59294 100644 --- a/test/sparse_basic.cpp +++ b/test/sparse_basic.cpp @@ -26,8 +26,10 @@ template void sparse_basic(const SparseMatrixType& ref) { - const int rows = ref.rows(); - const int cols = ref.cols(); + typedef typename SparseMatrixType::Index Index; + + const Index rows = ref.rows(); + const Index cols = ref.cols(); typedef typename SparseMatrixType::Scalar Scalar; enum { Flags = SparseMatrixType::Flags }; diff --git a/test/sparse_product.cpp b/test/sparse_product.cpp index 04e089784..c07735e43 100644 --- a/test/sparse_product.cpp +++ b/test/sparse_product.cpp @@ -26,8 +26,9 @@ template void sparse_product(const SparseMatrixType& ref) { - const int rows = ref.rows(); - const int cols = ref.cols(); + typedef typename SparseMatrixType::Index Index; + const Index rows = ref.rows(); + const Index cols = ref.cols(); typedef typename SparseMatrixType::Scalar Scalar; enum { Flags = SparseMatrixType::Flags }; diff --git a/test/stable_norm.cpp b/test/stable_norm.cpp index 77b062303..74675e930 100644 --- a/test/stable_norm.cpp +++ b/test/stable_norm.cpp @@ -34,7 +34,7 @@ template void stable_norm(const MatrixType& m) /* this test covers the following files: StableNorm.h */ - + typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; @@ -52,8 +52,8 @@ template void stable_norm(const MatrixType& m) } - int rows = m.rows(); - int cols = m.cols(); + Index rows = m.rows(); + Index cols = m.cols(); Scalar big = ei_random() * (std::numeric_limits::max() * RealScalar(1e-4)); Scalar small = static_cast(1)/big; diff --git a/test/stdlist.cpp b/test/stdlist.cpp index 7a54d464f..a410b3eb2 100644 --- a/test/stdlist.cpp +++ b/test/stdlist.cpp @@ -30,8 +30,10 @@ template void check_stdlist_matrix(const MatrixType& m) { - int rows = m.rows(); - int cols = m.cols(); + typedef typename MatrixType::Index Index; + + Index rows = m.rows(); + Index cols = m.cols(); MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols); std::list > v(10, MatrixType(rows,cols)), w(20, y); v.front() = x; diff --git a/test/stdvector.cpp b/test/stdvector.cpp index bdca826f4..b44dadf42 100644 --- a/test/stdvector.cpp +++ b/test/stdvector.cpp @@ -29,8 +29,8 @@ template void check_stdvector_matrix(const MatrixType& m) { - int rows = m.rows(); - int cols = m.cols(); + typename MatrixType::Index rows = m.rows(); + typename MatrixType::Index cols = m.cols(); MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols); std::vector > v(10, MatrixType(rows,cols)), w(20, y); v[5] = x; diff --git a/unsupported/Eigen/AlignedVector3 b/unsupported/Eigen/AlignedVector3 index 6e9772cf5..7efe4ac21 100644 --- a/unsupported/Eigen/AlignedVector3 +++ b/unsupported/Eigen/AlignedVector3 @@ -68,19 +68,19 @@ template class AlignedVector3 EIGEN_DENSE_PUBLIC_INTERFACE(AlignedVector3) using Base::operator*; - inline int rows() const { return 3; } - inline int cols() const { return 1; } + inline Index rows() const { return 3; } + inline Index cols() const { return 1; } - inline const Scalar& coeff(int row, int col) const + inline const Scalar& coeff(Index row, Index col) const { return m_coeffs.coeff(row, col); } - inline Scalar& coeffRef(int row, int col) + inline Scalar& coeffRef(Index row, Index col) { return m_coeffs.coeffRef(row, col); } - inline const Scalar& coeff(int index) const + inline const Scalar& coeff(Index index) const { return m_coeffs.coeff(index); } - inline Scalar& coeffRef(int index) + inline Scalar& coeffRef(Index index) { return m_coeffs.coeffRef(index);} diff --git a/unsupported/Eigen/src/SparseExtra/UmfPackSupport.h b/unsupported/Eigen/src/SparseExtra/UmfPackSupport.h index 950624758..9c0dfcc08 100644 --- a/unsupported/Eigen/src/SparseExtra/UmfPackSupport.h +++ b/unsupported/Eigen/src/SparseExtra/UmfPackSupport.h @@ -200,8 +200,9 @@ class SparseLU : public SparseLU template void SparseLU::compute(const MatrixType& a) { - const int rows = a.rows(); - const int cols = a.cols(); + typedef typename MatrixType::Index Index; + const Index rows = a.rows(); + const Index cols = a.cols(); ei_assert((MatrixType::Flags&RowMajorBit)==0 && "Row major matrices are not supported yet"); m_matrixRef = &a; diff --git a/unsupported/test/sparse_extra.cpp b/unsupported/test/sparse_extra.cpp index fa6dc50f5..6cf1f50c4 100644 --- a/unsupported/test/sparse_extra.cpp +++ b/unsupported/test/sparse_extra.cpp @@ -61,8 +61,9 @@ bool test_random_setter(DynamicSparseMatrix& sm, const DenseType& ref, const template void sparse_extra(const SparseMatrixType& ref) { - const int rows = ref.rows(); - const int cols = ref.cols(); + typedef typename SparseMatrixType::Index Index; + const Index rows = ref.rows(); + const Index cols = ref.cols(); typedef typename SparseMatrixType::Scalar Scalar; enum { Flags = SparseMatrixType::Flags };