aboutsummaryrefslogtreecommitdiff
path: root/unsupported/test/autodiff.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unsupported/test/autodiff.cpp')
-rw-r--r--unsupported/test/autodiff.cpp42
1 files changed, 31 insertions, 11 deletions
diff --git a/unsupported/test/autodiff.cpp b/unsupported/test/autodiff.cpp
index 85743137e..2cea56ba5 100644
--- a/unsupported/test/autodiff.cpp
+++ b/unsupported/test/autodiff.cpp
@@ -44,7 +44,7 @@ struct TestFunc1
int m_inputs, m_values;
TestFunc1() : m_inputs(InputsAtCompileTime), m_values(ValuesAtCompileTime) {}
- TestFunc1(int inputs, int values) : m_inputs(inputs), m_values(values) {}
+ TestFunc1(int inputs_, int values_) : m_inputs(inputs_), m_values(values_) {}
int inputs() const { return m_inputs; }
int values() const { return m_values; }
@@ -306,6 +306,8 @@ double bug_1222() {
return denom.value();
}
+#ifdef EIGEN_TEST_PART_5
+
double bug_1223() {
using std::min;
typedef Eigen::AutoDiffScalar<Eigen::Vector3d> AD;
@@ -326,8 +328,8 @@ double bug_1223() {
// regression test for some compilation issues with specializations of ScalarBinaryOpTraits
void bug_1260() {
- Matrix4d A;
- Vector4d v;
+ Matrix4d A = Matrix4d::Ones();
+ Vector4d v = Vector4d::Ones();
A*v;
}
@@ -336,7 +338,7 @@ double bug_1261() {
typedef AutoDiffScalar<Matrix2d> AD;
typedef Matrix<AD,2,1> VectorAD;
- VectorAD v;
+ VectorAD v(0.,0.);
const AD maxVal = v.maxCoeff();
const AD minVal = v.minCoeff();
return maxVal.value() + minVal.value();
@@ -344,13 +346,30 @@ double bug_1261() {
double bug_1264() {
typedef AutoDiffScalar<Vector2d> AD;
- const AD s;
- const Matrix<AD, 3, 1> v1;
+ const AD s = 0.;
+ const Matrix<AD, 3, 1> v1(0.,0.,0.);
const Matrix<AD, 3, 1> v2 = (s + 3.0) * v1;
return v2(0).value();
}
-void test_autodiff()
+// check with expressions on constants
+double bug_1281() {
+ int n = 2;
+ typedef AutoDiffScalar<VectorXd> AD;
+ const AD c = 1.;
+ AD x0(2,n,0);
+ AD y1 = (AD(c)+AD(c))*x0;
+ y1 = x0 * (AD(c)+AD(c));
+ AD y2 = (-AD(c))+x0;
+ y2 = x0+(-AD(c));
+ AD y3 = (AD(c)*(-AD(c))+AD(c))*x0;
+ y3 = x0 * (AD(c)*(-AD(c))+AD(c));
+ return (y1+y2+y3).value();
+}
+
+#endif
+
+EIGEN_DECLARE_TEST(autodiff)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( test_autodiff_scalar<1>() );
@@ -359,9 +378,10 @@ void test_autodiff()
CALL_SUBTEST_4( test_autodiff_hessian<1>() );
}
- bug_1222();
- bug_1223();
- bug_1260();
- bug_1261();
+ CALL_SUBTEST_5( bug_1222() );
+ CALL_SUBTEST_5( bug_1223() );
+ CALL_SUBTEST_5( bug_1260() );
+ CALL_SUBTEST_5( bug_1261() );
+ CALL_SUBTEST_5( bug_1281() );
}