aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/product_extra.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2009-09-07 14:04:56 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2009-09-07 14:04:56 +0200
commitae1d1c8f6ce77c6137bedd3d8c571297524d0d78 (patch)
tree26b57e22da3e56ae1b9e0113b8c9f249f242ab82 /test/product_extra.cpp
parentfb5f546161fd3c4620bad9a8aef71faa7f520d1e (diff)
improve coverage of matrix-vector product
Diffstat (limited to 'test/product_extra.cpp')
-rw-r--r--test/product_extra.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/test/product_extra.cpp b/test/product_extra.cpp
index fcec362a5..3ad99fc7a 100644
--- a/test/product_extra.cpp
+++ b/test/product_extra.cpp
@@ -104,13 +104,24 @@ template<typename MatrixType> void product_extra(const MatrixType& m)
VERIFY_IS_APPROX((-m1.adjoint() * s2) * (s1 * v1.adjoint()),
(-m1.adjoint()*s2).eval() * (s1 * v1.adjoint()).eval());
+ // test the vector-matrix product with non aligned starts
+ int i = ei_random<int>(0,m1.rows()-2);
+ int j = ei_random<int>(0,m1.cols()-2);
+ int r = ei_random<int>(1,m1.rows()-i);
+ int c = ei_random<int>(1,m1.cols()-j);
+ int i2 = ei_random<int>(0,m1.rows()-1);
+ int j2 = ei_random<int>(0,m1.cols()-1);
+
+ VERIFY_IS_APPROX(m1.col(j2).adjoint() * m1.block(0,j,m1.rows(),c), m1.col(j2).adjoint().eval() * m1.block(0,j,m1.rows(),c).eval());
+ VERIFY_IS_APPROX(m1.block(i,0,r,m1.cols()) * m1.row(i2).adjoint(), m1.block(i,0,r,m1.cols()).eval() * m1.row(i2).adjoint().eval());
+
}
void test_product_extra()
{
for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST( product_extra(MatrixXf(ei_random<int>(1,320), ei_random<int>(1,320))) );
+ CALL_SUBTEST( product_extra(MatrixXf(ei_random<int>(2,320), ei_random<int>(2,320))) );
CALL_SUBTEST( product_extra(MatrixXcf(ei_random<int>(50,50), ei_random<int>(50,50))) );
- CALL_SUBTEST( product_extra(Matrix<std::complex<double>,Dynamic,Dynamic,RowMajor>(ei_random<int>(1,50), ei_random<int>(1,50))) );
+ CALL_SUBTEST( product_extra(Matrix<std::complex<double>,Dynamic,Dynamic,RowMajor>(ei_random<int>(2,50), ei_random<int>(2,50))) );
}
}