fix nesting in Arraywrapper and nesting_ops

This commit is contained in:
Gael Guennebaud 2010-02-09 16:38:36 +01:00
parent 905050b239
commit 71e580c4aa
3 changed files with 12 additions and 6 deletions

View File

@ -36,7 +36,7 @@
*/
template<typename ExpressionType>
struct ei_traits<ArrayWrapper<ExpressionType> >
: public ei_traits<ExpressionType>
: public ei_traits<typename ei_cleantype<typename ExpressionType::Nested>::type >
{
typedef DenseStorageArray DenseStorageType;
};
@ -49,6 +49,8 @@ class ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> >
EIGEN_DENSE_PUBLIC_INTERFACE(ArrayWrapper)
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(ArrayWrapper)
typedef typename ei_nested<ExpressionType>::type NestedExpressionType;
inline ArrayWrapper(const ExpressionType& matrix) : m_expression(matrix) {}
inline int rows() const { return m_expression.rows(); }
@ -103,7 +105,7 @@ class ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> >
inline void evalTo(Dest& dst) const { dst = m_expression; }
protected:
const ExpressionType& m_expression;
const NestedExpressionType m_expression;
};
/** \class MatrixWrapper
@ -118,7 +120,7 @@ class ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> >
template<typename ExpressionType>
struct ei_traits<MatrixWrapper<ExpressionType> >
: public ei_traits<ExpressionType>
: public ei_traits<typename ei_cleantype<typename ExpressionType::Nested>::type >
{
typedef DenseStorageMatrix DenseStorageType;
};
@ -131,6 +133,8 @@ class MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> >
EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper)
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixWrapper);
typedef typename ei_nested<ExpressionType>::type NestedExpressionType;
inline MatrixWrapper(const ExpressionType& matrix) : m_expression(matrix) {}
inline int rows() const { return m_expression.rows(); }
@ -182,7 +186,7 @@ class MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> >
}
protected:
const ExpressionType& m_expression;
const NestedExpressionType& m_expression;
};
#endif // EIGEN_ARRAYWRAPPER_H

View File

@ -96,5 +96,6 @@ void test_inverse()
CALL_SUBTEST_5( inverse(MatrixXf(s,s)) );
s = ei_random<int>(25,100);
CALL_SUBTEST_6( inverse(MatrixXcd(s,s)) );
CALL_SUBTEST_7( inverse(Matrix4d()) );
}
}

View File

@ -24,8 +24,9 @@
#include "main.h"
template <typename MatrixType> void run_nesting_ops(const MatrixType& m)
template <typename MatrixType> void run_nesting_ops(const MatrixType& _m)
{
typename MatrixType::Nested m(_m);
typedef typename MatrixType::Scalar Scalar;
#ifdef NDEBUG
@ -38,7 +39,7 @@ template <typename MatrixType> void run_nesting_ops(const MatrixType& m)
// inlining for these tests to pass.
VERIFY(is_debug);
// The only intention of these tests is to ensure that this code does
// The only intention of these tests is to ensure that this code does
// not trigger any asserts or segmentation faults... more to come.
VERIFY( (m.transpose() * m).diagonal().sum() == (m.transpose() * m).diagonal().sum() );
VERIFY( (m.transpose() * m).diagonal().array().abs().sum() == (m.transpose() * m).diagonal().array().abs().sum() );