* rename XprCopy -> Nested

* rename OperatorEquals -> Assign
* move Util.h and FwDecl.h to a util/ subdir
This commit is contained in:
Benoit Jacob 2008-04-10 09:01:28 +00:00
parent 212da8ffe0
commit 9d8876ce82
19 changed files with 92 additions and 80 deletions

View File

@ -7,26 +7,17 @@
#include <cassert> #include <cassert>
#include <iostream> #include <iostream>
#ifdef EIGEN_VECTORIZE
#ifdef EIGEN_INTEL_PLATFORM
#include <emmintrin.h>
#include <xmmintrin.h>
#else
#undef EIGEN_VECTORIZE
#endif
#endif
namespace Eigen { namespace Eigen {
#include "src/Core/Util.h" #include "src/Core/util/Util.h"
#include "src/Core/ForwardDeclarations.h" #include "src/Core/util/ForwardDeclarations.h"
#include "src/Core/NumTraits.h" #include "src/Core/NumTraits.h"
#include "src/Core/MathFunctions.h" #include "src/Core/MathFunctions.h"
#include "src/Core/PacketMath.h" #include "src/Core/PacketMath.h"
#include "src/Core/Functors.h" #include "src/Core/Functors.h"
#include "src/Core/MatrixBase.h" #include "src/Core/MatrixBase.h"
#include "src/Core/Coeffs.h" #include "src/Core/Coeffs.h"
#include "src/Core/OperatorEquals.h" #include "src/Core/Assign.h"
#include "src/Core/MatrixStorage.h" #include "src/Core/MatrixStorage.h"
#include "src/Core/Matrix.h" #include "src/Core/Matrix.h"
#include "src/Core/Lazy.h" #include "src/Core/Lazy.h"

View File

@ -23,8 +23,8 @@
// License and a copy of the GNU General Public License along with // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_OPERATOREQUALS_H #ifndef EIGEN_ASSIGN_H
#define EIGEN_OPERATOREQUALS_H #define EIGEN_ASSIGN_H
template<typename Derived1, typename Derived2, int UnrollCount> template<typename Derived1, typename Derived2, int UnrollCount>
struct ei_matrix_operator_equals_unroller struct ei_matrix_operator_equals_unroller
@ -243,4 +243,4 @@ struct ei_operator_equals_impl<Derived, OtherDerived, true>
} }
}; };
#endif // EIGEN_OPERATOREQUALS_H #endif // EIGEN_ASSIGN_H

View File

@ -143,7 +143,7 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block
protected: protected:
const typename MatrixType::XprCopy m_matrix; const typename MatrixType::Nested m_matrix;
ei_int_if_dynamic<MatrixType::RowsAtCompileTime == 1 ? 0 : Dynamic> m_startRow; ei_int_if_dynamic<MatrixType::RowsAtCompileTime == 1 ? 0 : Dynamic> m_startRow;
ei_int_if_dynamic<MatrixType::ColsAtCompileTime == 1 ? 0 : Dynamic> m_startCol; ei_int_if_dynamic<MatrixType::ColsAtCompileTime == 1 ? 0 : Dynamic> m_startCol;
ei_int_if_dynamic<RowsAtCompileTime> m_blockRows; ei_int_if_dynamic<RowsAtCompileTime> m_blockRows;

View File

@ -4,3 +4,5 @@ INSTALL(FILES
${Eigen_Core_SRCS} ${Eigen_Core_SRCS}
DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core
) )
ADD_SUBDIRECTORY(util)

View File

@ -97,8 +97,8 @@ class CwiseBinaryOp : ei_no_assignment_operator,
} }
protected: protected:
const typename Lhs::XprCopy m_lhs; const typename Lhs::Nested m_lhs;
const typename Rhs::XprCopy m_rhs; const typename Rhs::Nested m_rhs;
const BinaryOp m_functor; const BinaryOp m_functor;
}; };

View File

@ -83,7 +83,7 @@ class CwiseUnaryOp : ei_no_assignment_operator,
} }
protected: protected:
const typename MatrixType::XprCopy m_matrix; const typename MatrixType::Nested m_matrix;
const UnaryOp m_functor; const UnaryOp m_functor;
}; };

View File

@ -87,7 +87,7 @@ template<typename MatrixType> class DiagonalCoeffs
protected: protected:
const typename MatrixType::XprCopy m_matrix; const typename MatrixType::Nested m_matrix;
}; };
/** \returns an expression of the main diagonal of the matrix \c *this /** \returns an expression of the main diagonal of the matrix \c *this

View File

@ -77,7 +77,7 @@ class DiagonalMatrix : ei_no_assignment_operator,
} }
protected: protected:
const typename CoeffsVectorType::XprCopy m_coeffs; const typename CoeffsVectorType::Nested m_coeffs;
}; };
/** \returns an expression of a diagonal matrix with *this as vector of diagonal coefficients /** \returns an expression of a diagonal matrix with *this as vector of diagonal coefficients

View File

@ -72,31 +72,31 @@ template<typename OtherDerived>
typename ei_traits<Derived>::Scalar typename ei_traits<Derived>::Scalar
MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const
{ {
typedef typename Derived::XprCopy XprCopy; typedef typename Derived::Nested Nested;
typedef typename OtherDerived::XprCopy OtherXprCopy; typedef typename OtherDerived::Nested OtherNested;
typedef typename ei_unref<XprCopy>::type _XprCopy; typedef typename ei_unref<Nested>::type _Nested;
typedef typename ei_unref<OtherXprCopy>::type _OtherXprCopy; typedef typename ei_unref<OtherNested>::type _OtherNested;
XprCopy xprCopy(derived()); Nested nested(derived());
OtherXprCopy otherXprCopy(other.derived()); OtherNested otherNested(other.derived());
ei_assert(_XprCopy::IsVectorAtCompileTime ei_assert(_Nested::IsVectorAtCompileTime
&& _OtherXprCopy::IsVectorAtCompileTime && _OtherNested::IsVectorAtCompileTime
&& xprCopy.size() == otherXprCopy.size()); && nested.size() == otherNested.size());
Scalar res; Scalar res;
const bool unroll = SizeAtCompileTime const bool unroll = SizeAtCompileTime
* (_XprCopy::CoeffReadCost + _OtherXprCopy::CoeffReadCost + NumTraits<Scalar>::MulCost) * (_Nested::CoeffReadCost + _OtherNested::CoeffReadCost + NumTraits<Scalar>::MulCost)
+ (SizeAtCompileTime - 1) * NumTraits<Scalar>::AddCost + (SizeAtCompileTime - 1) * NumTraits<Scalar>::AddCost
<= EIGEN_UNROLLING_LIMIT; <= EIGEN_UNROLLING_LIMIT;
if(unroll) if(unroll)
ei_dot_unroller<SizeAtCompileTime-1, ei_dot_unroller<SizeAtCompileTime-1,
unroll ? SizeAtCompileTime : Dynamic, unroll ? SizeAtCompileTime : Dynamic,
_XprCopy, _OtherXprCopy> _Nested, _OtherNested>
::run(xprCopy, otherXprCopy, res); ::run(nested, otherNested, res);
else else
{ {
res = xprCopy.coeff(0) * ei_conj(otherXprCopy.coeff(0)); res = nested.coeff(0) * ei_conj(otherNested.coeff(0));
for(int i = 1; i < size(); i++) for(int i = 1; i < size(); i++)
res += xprCopy.coeff(i)* ei_conj(otherXprCopy.coeff(i)); res += nested.coeff(i)* ei_conj(otherNested.coeff(i));
} }
return res; return res;
} }
@ -149,9 +149,9 @@ template<typename OtherDerived>
bool MatrixBase<Derived>::isOrtho bool MatrixBase<Derived>::isOrtho
(const MatrixBase<OtherDerived>& other, RealScalar prec) const (const MatrixBase<OtherDerived>& other, RealScalar prec) const
{ {
typename ei_xpr_copy<Derived,2>::type xprCopy(derived()); typename ei_nested<Derived,2>::type nested(derived());
typename ei_xpr_copy<OtherDerived,2>::type otherXprCopy(other.derived()); typename ei_nested<OtherDerived,2>::type otherNested(other.derived());
return ei_abs2(xprCopy.dot(otherXprCopy)) <= prec * prec * xprCopy.norm2() * otherXprCopy.norm2(); return ei_abs2(nested.dot(otherNested)) <= prec * prec * nested.norm2() * otherNested.norm2();
} }
/** \returns true if *this is approximately an unitary matrix, /** \returns true if *this is approximately an unitary matrix,
@ -168,13 +168,13 @@ bool MatrixBase<Derived>::isOrtho
template<typename Derived> template<typename Derived>
bool MatrixBase<Derived>::isOrtho(RealScalar prec) const bool MatrixBase<Derived>::isOrtho(RealScalar prec) const
{ {
typename Derived::XprCopy xprCopy(derived()); typename Derived::Nested nested(derived());
for(int i = 0; i < cols(); i++) for(int i = 0; i < cols(); i++)
{ {
if(!ei_isApprox(xprCopy.col(i).norm2(), static_cast<Scalar>(1), prec)) if(!ei_isApprox(nested.col(i).norm2(), static_cast<Scalar>(1), prec))
return false; return false;
for(int j = 0; j < i; j++) for(int j = 0; j < i; j++)
if(!ei_isMuchSmallerThan(xprCopy.col(i).dot(xprCopy.col(j)), static_cast<Scalar>(1), prec)) if(!ei_isMuchSmallerThan(nested.col(i).dot(nested.col(j)), static_cast<Scalar>(1), prec))
return false; return false;
} }
return true; return true;

View File

@ -55,11 +55,11 @@ bool MatrixBase<Derived>::isApprox(
} }
else else
{ {
typename Derived::XprCopy xprCopy(derived()); typename Derived::Nested nested(derived());
typename OtherDerived::XprCopy otherXprCopy(other.derived()); typename OtherDerived::Nested otherNested(other.derived());
for(int i = 0; i < cols(); i++) for(int i = 0; i < cols(); i++)
if((xprCopy.col(i) - otherXprCopy.col(i)).norm2() if((nested.col(i) - otherNested.col(i)).norm2()
> std::min(xprCopy.col(i).norm2(), otherXprCopy.col(i).norm2()) * prec * prec) > std::min(nested.col(i).norm2(), otherNested.col(i).norm2()) * prec * prec)
return false; return false;
return true; return true;
} }
@ -87,9 +87,9 @@ bool MatrixBase<Derived>::isMuchSmallerThan(
} }
else else
{ {
typename Derived::XprCopy xprCopy(*this); typename Derived::Nested nested(*this);
for(int i = 0; i < cols(); i++) for(int i = 0; i < cols(); i++)
if(xprCopy.col(i).norm2() > ei_abs2(other * prec)) if(nested.col(i).norm2() > ei_abs2(other * prec))
return false; return false;
return true; return true;
} }
@ -119,10 +119,10 @@ bool MatrixBase<Derived>::isMuchSmallerThan(
} }
else else
{ {
typename Derived::XprCopy xprCopy(*this); typename Derived::Nested nested(*this);
typename OtherDerived::XprCopy otherXprCopy(other); typename OtherDerived::Nested otherNested(other);
for(int i = 0; i < cols(); i++) for(int i = 0; i < cols(); i++)
if(xprCopy.col(i).norm2() > otherXprCopy.col(i).norm2() * prec * prec) if(nested.col(i).norm2() > otherNested.col(i).norm2() * prec * prec)
return false; return false;
return true; return true;
} }

View File

@ -73,7 +73,7 @@ template<typename ExpressionType> class Lazy
} }
protected: protected:
const typename ExpressionType::XprCopy m_expression; const typename ExpressionType::Nested m_expression;
}; };
/** \returns an expression of the lazy version of *this. /** \returns an expression of the lazy version of *this.

View File

@ -88,7 +88,7 @@ template<typename MatrixType> class Minor
} }
protected: protected:
const typename MatrixType::XprCopy m_matrix; const typename MatrixType::Nested m_matrix;
const int m_row, m_col; const int m_row, m_col;
}; };

View File

@ -116,15 +116,15 @@ template<typename Lhs, typename Rhs, int EvalMode>
struct ei_traits<Product<Lhs, Rhs, EvalMode> > struct ei_traits<Product<Lhs, Rhs, EvalMode> >
{ {
typedef typename Lhs::Scalar Scalar; typedef typename Lhs::Scalar Scalar;
typedef typename ei_xpr_copy<Lhs,Rhs::ColsAtCompileTime>::type LhsXprCopy; typedef typename ei_nested<Lhs,Rhs::ColsAtCompileTime>::type LhsNested;
typedef typename ei_xpr_copy<Rhs,Lhs::RowsAtCompileTime>::type RhsXprCopy; typedef typename ei_nested<Rhs,Lhs::RowsAtCompileTime>::type RhsNested;
typedef typename ei_unref<LhsXprCopy>::type _LhsXprCopy; typedef typename ei_unref<LhsNested>::type _LhsNested;
typedef typename ei_unref<RhsXprCopy>::type _RhsXprCopy; typedef typename ei_unref<RhsNested>::type _RhsNested;
enum { enum {
LhsCoeffReadCost = _LhsXprCopy::CoeffReadCost, LhsCoeffReadCost = _LhsNested::CoeffReadCost,
RhsCoeffReadCost = _RhsXprCopy::CoeffReadCost, RhsCoeffReadCost = _RhsNested::CoeffReadCost,
LhsFlags = _LhsXprCopy::Flags, LhsFlags = _LhsNested::Flags,
RhsFlags = _RhsXprCopy::Flags, RhsFlags = _RhsNested::Flags,
RowsAtCompileTime = Lhs::RowsAtCompileTime, RowsAtCompileTime = Lhs::RowsAtCompileTime,
ColsAtCompileTime = Rhs::ColsAtCompileTime, ColsAtCompileTime = Rhs::ColsAtCompileTime,
MaxRowsAtCompileTime = Lhs::MaxRowsAtCompileTime, MaxRowsAtCompileTime = Lhs::MaxRowsAtCompileTime,
@ -153,10 +153,10 @@ template<typename Lhs, typename Rhs, int EvalMode> class Product : ei_no_assignm
public: public:
EIGEN_GENERIC_PUBLIC_INTERFACE(Product) EIGEN_GENERIC_PUBLIC_INTERFACE(Product)
typedef typename ei_traits<Product>::LhsXprCopy LhsXprCopy; typedef typename ei_traits<Product>::LhsNested LhsNested;
typedef typename ei_traits<Product>::RhsXprCopy RhsXprCopy; typedef typename ei_traits<Product>::RhsNested RhsNested;
typedef typename ei_traits<Product>::_LhsXprCopy _LhsXprCopy; typedef typename ei_traits<Product>::_LhsNested _LhsNested;
typedef typename ei_traits<Product>::_RhsXprCopy _RhsXprCopy; typedef typename ei_traits<Product>::_RhsNested _RhsNested;
Product(const Lhs& lhs, const Rhs& rhs) Product(const Lhs& lhs, const Rhs& rhs)
: m_lhs(lhs), m_rhs(rhs) : m_lhs(lhs), m_rhs(rhs)
@ -181,7 +181,7 @@ template<typename Lhs, typename Rhs, int EvalMode> class Product : ei_no_assignm
{ {
ei_product_unroller<Lhs::ColsAtCompileTime-1, ei_product_unroller<Lhs::ColsAtCompileTime-1,
unroll ? Lhs::ColsAtCompileTime : Dynamic, unroll ? Lhs::ColsAtCompileTime : Dynamic,
_LhsXprCopy, _RhsXprCopy> _LhsNested, _RhsNested>
::run(row, col, m_lhs, m_rhs, res); ::run(row, col, m_lhs, m_rhs, res);
} }
else else
@ -224,8 +224,8 @@ template<typename Lhs, typename Rhs, int EvalMode> class Product : ei_no_assignm
} }
protected: protected:
const LhsXprCopy m_lhs; const LhsNested m_lhs;
const RhsXprCopy m_rhs; const RhsNested m_rhs;
}; };
/** \returns the matrix product of \c *this and \a other. /** \returns the matrix product of \c *this and \a other.

View File

@ -87,18 +87,18 @@ struct ei_traits<PartialRedux<Direction, BinaryOp, MatrixType> >
typedef typename ei_result_of< typedef typename ei_result_of<
BinaryOp(typename MatrixType::Scalar) BinaryOp(typename MatrixType::Scalar)
>::type Scalar; >::type Scalar;
typedef typename ei_xpr_copy<MatrixType>::type MatrixTypeXprCopy; typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
typedef typename ei_unref<MatrixTypeXprCopy>::type _MatrixTypeXprCopy; typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
enum { enum {
RowsAtCompileTime = Direction==Vertical ? 1 : MatrixType::RowsAtCompileTime, RowsAtCompileTime = Direction==Vertical ? 1 : MatrixType::RowsAtCompileTime,
ColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::ColsAtCompileTime, ColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::ColsAtCompileTime,
MaxRowsAtCompileTime = Direction==Vertical ? 1 : MatrixType::MaxRowsAtCompileTime, MaxRowsAtCompileTime = Direction==Vertical ? 1 : MatrixType::MaxRowsAtCompileTime,
MaxColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::MaxColsAtCompileTime, MaxColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::MaxColsAtCompileTime,
Flags = ((RowsAtCompileTime == Dynamic || ColsAtCompileTime == Dynamic) Flags = ((RowsAtCompileTime == Dynamic || ColsAtCompileTime == Dynamic)
? (unsigned int)_MatrixTypeXprCopy::Flags ? (unsigned int)_MatrixTypeNested::Flags
: (unsigned int)_MatrixTypeXprCopy::Flags & ~LargeBit) & ~VectorizableBit, : (unsigned int)_MatrixTypeNested::Flags & ~LargeBit) & ~VectorizableBit,
TraversalSize = Direction==Vertical ? RowsAtCompileTime : ColsAtCompileTime, TraversalSize = Direction==Vertical ? RowsAtCompileTime : ColsAtCompileTime,
CoeffReadCost = TraversalSize * _MatrixTypeXprCopy::CoeffReadCost CoeffReadCost = TraversalSize * _MatrixTypeNested::CoeffReadCost
+ (TraversalSize - 1) * ei_functor_traits<BinaryOp>::Cost + (TraversalSize - 1) * ei_functor_traits<BinaryOp>::Cost
}; };
}; };
@ -110,8 +110,8 @@ class PartialRedux : ei_no_assignment_operator,
public: public:
EIGEN_GENERIC_PUBLIC_INTERFACE(PartialRedux) EIGEN_GENERIC_PUBLIC_INTERFACE(PartialRedux)
typedef typename ei_traits<PartialRedux>::MatrixTypeXprCopy MatrixTypeXprCopy; typedef typename ei_traits<PartialRedux>::MatrixTypeNested MatrixTypeNested;
typedef typename ei_traits<PartialRedux>::_MatrixTypeXprCopy _MatrixTypeXprCopy; typedef typename ei_traits<PartialRedux>::_MatrixTypeNested _MatrixTypeNested;
PartialRedux(const MatrixType& mat, const BinaryOp& func = BinaryOp()) PartialRedux(const MatrixType& mat, const BinaryOp& func = BinaryOp())
: m_matrix(mat), m_functor(func) {} : m_matrix(mat), m_functor(func) {}
@ -130,7 +130,7 @@ class PartialRedux : ei_no_assignment_operator,
} }
protected: protected:
const MatrixTypeXprCopy m_matrix; const MatrixTypeNested m_matrix;
const BinaryOp m_functor; const BinaryOp m_functor;
}; };

View File

@ -88,7 +88,7 @@ template<typename MatrixType> class Transpose
} }
protected: protected:
const typename MatrixType::XprCopy m_matrix; const typename MatrixType::Nested m_matrix;
}; };
/** \returns an expression of the transpose of *this. /** \returns an expression of the transpose of *this.

View File

@ -0,0 +1,6 @@
FILE(GLOB Eigen_Core_util_SRCS "*.h")
INSTALL(FILES
${Eigen_Core_SRCS}
DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/util
)

View File

@ -93,7 +93,7 @@ template<typename T> struct ei_is_temporary<Temporary<T> >
enum { ret = 1 }; enum { ret = 1 };
}; };
template<typename T, int n=1> struct ei_xpr_copy template<typename T, int n=1> struct ei_nested
{ {
typedef typename ei_meta_if< typedef typename ei_meta_if<
ei_is_temporary<T>::ret, ei_is_temporary<T>::ret,

View File

@ -26,6 +26,15 @@
#ifndef EIGEN_UTIL_H #ifndef EIGEN_UTIL_H
#define EIGEN_UTIL_H #define EIGEN_UTIL_H
#ifdef EIGEN_VECTORIZE
#ifdef EIGEN_INTEL_PLATFORM
#include <emmintrin.h>
#include <xmmintrin.h>
#else
#undef EIGEN_VECTORIZE
#endif
#endif
#ifdef EIGEN_DONT_USE_UNROLLED_LOOPS #ifdef EIGEN_DONT_USE_UNROLLED_LOOPS
#define EIGEN_UNROLLING_LIMIT 0 #define EIGEN_UNROLLING_LIMIT 0
#endif #endif
@ -117,7 +126,7 @@ EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=)
typedef BaseClass Base; \ typedef BaseClass Base; \
typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; \ typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; \
typedef typename Base::PacketScalar PacketScalar; \ typedef typename Base::PacketScalar PacketScalar; \
typedef typename Eigen::ei_xpr_copy<Derived>::type XprCopy; \ typedef typename Eigen::ei_nested<Derived>::type Nested; \
typedef typename Eigen::ei_eval<Derived>::type Eval; \ typedef typename Eigen::ei_eval<Derived>::type Eval; \
enum { RowsAtCompileTime = Base::RowsAtCompileTime, \ enum { RowsAtCompileTime = Base::RowsAtCompileTime, \
ColsAtCompileTime = Base::ColsAtCompileTime, \ ColsAtCompileTime = Base::ColsAtCompileTime, \

View File

@ -12,10 +12,14 @@ USING_PART_OF_NAMESPACE_EIGEN
#define REPEAT 40000000 #define REPEAT 40000000
#endif #endif
#ifndef SCALAR
#define SCALAR double
#endif
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
Matrix<double,MATSIZE,MATSIZE> I; Matrix<SCALAR,MATSIZE,MATSIZE> I;
Matrix<double,MATSIZE,MATSIZE> m; Matrix<SCALAR,MATSIZE,MATSIZE> m;
for(int i = 0; i < MATSIZE; i++) for(int i = 0; i < MATSIZE; i++)
for(int j = 0; j < MATSIZE; j++) for(int j = 0; j < MATSIZE; j++)
{ {