aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/product_small.cpp
diff options
context:
space:
mode:
authorGravatar Jitse Niesen <jitse@maths.leeds.ac.uk>2012-04-18 15:23:28 +0100
committerGravatar Jitse Niesen <jitse@maths.leeds.ac.uk>2012-04-18 15:23:28 +0100
commit57b5767fe25456f6d80f8c460b45cb1d1cab0da9 (patch)
tree3209f9e227c6e2218a26edde62031049bf205d91 /test/product_small.cpp
parent5cab18976bc2be4f9568777ed81db3d7ed4aba5a (diff)
Fix infinite recursion in ProductBase::coeff() (bug #447)
Triggered by product of dynamic-size 1 x n and n x 1 matrices. Also, add regression test.
Diffstat (limited to 'test/product_small.cpp')
-rw-r--r--test/product_small.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/product_small.cpp b/test/product_small.cpp
index d7f1c09ff..cf430a2d3 100644
--- a/test/product_small.cpp
+++ b/test/product_small.cpp
@@ -25,6 +25,25 @@
#define EIGEN_NO_STATIC_ASSERT
#include "product.h"
+// regression test for bug 447
+void product1x1()
+{
+ Matrix<float,1,3> matAstatic;
+ Matrix<float,3,1> matBstatic;
+ matAstatic.setRandom();
+ matBstatic.setRandom();
+ VERIFY_IS_APPROX( (matAstatic * matBstatic).coeff(0,0),
+ matAstatic.cwiseProduct(matBstatic.transpose()).sum() );
+
+ MatrixXf matAdynamic(1,3);
+ MatrixXf matBdynamic(3,1);
+ matAdynamic.setRandom();
+ matBdynamic.setRandom();
+ VERIFY_IS_APPROX( (matAdynamic * matBdynamic).coeff(0,0),
+ matAdynamic.cwiseProduct(matBdynamic.transpose()).sum() );
+}
+
+
void test_product_small()
{
for(int i = 0; i < g_repeat; i++) {
@@ -33,6 +52,7 @@ void test_product_small()
CALL_SUBTEST_3( product(Matrix3d()) );
CALL_SUBTEST_4( product(Matrix4d()) );
CALL_SUBTEST_5( product(Matrix4f()) );
+ CALL_SUBTEST_6( product1x1() );
}
#ifdef EIGEN_TEST_PART_6