aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/Transpose.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2009-12-16 11:41:16 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2009-12-16 11:41:16 +0100
commit6db6774c4685b997ab4343e5c5b4d48af84e45e7 (patch)
tree6e0a2bb73d959179b735a7cebb588cb72cdef570 /Eigen/src/Core/Transpose.h
parent0d8ffe5240e4324a6ada046eeb2c2bb25b36af9a (diff)
* fix aliasing checks when the lhs is also transposed. At the same time,
significantly simplify the code of these checks while extending them to catch much more expressions! * move the enabling/disabling of vectorized sin/cos to the architecture traits
Diffstat (limited to 'Eigen/src/Core/Transpose.h')
-rw-r--r--Eigen/src/Core/Transpose.h78
1 files changed, 20 insertions, 58 deletions
diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h
index 79aef9fa7..796ec8573 100644
--- a/Eigen/src/Core/Transpose.h
+++ b/Eigen/src/Core/Transpose.h
@@ -268,13 +268,7 @@ inline void MatrixBase<Derived>::adjointInPlace()
#ifndef EIGEN_NO_DEBUG
-// The following is to detect aliasing problems in the following common cases:
-// a = a.transpose()
-// a = a.transpose() + X
-// a = X + a.transpose()
-// a = a.adjoint()
-// a = a.adjoint() + X
-// a = X + a.adjoint()
+// The following is to detect aliasing problems in most common cases.
template<typename T, int Access=ei_blas_traits<T>::ActualAccess>
struct ei_extract_data_selector {
@@ -294,63 +288,31 @@ template<typename T> typename T::Scalar* ei_extract_data(const T& m)
return ei_extract_data_selector<T>::run(m);
}
-template<typename Derived>
-template<typename OtherDerived>
-Derived& MatrixBase<Derived>::lazyAssign(const Transpose<OtherDerived>& other)
-{
- ei_assert(ei_extract_data(other) != ei_extract_data(derived())
- && "aliasing detected during tranposition, please use transposeInPlace()");
- return lazyAssign(static_cast<const MatrixBase<Transpose<OtherDerived> >& >(other));
-}
-
-template<typename Derived>
-template<typename DerivedA, typename DerivedB>
-Derived& MatrixBase<Derived>::
-lazyAssign(const CwiseBinaryOp<ei_scalar_sum_op<Scalar>,Transpose<DerivedA>,DerivedB>& other)
-{
- ei_assert(ei_extract_data(derived()) != ei_extract_data(other.lhs())
- && "aliasing detected during tranposition, please evaluate your expression");
- return lazyAssign(static_cast<const MatrixBase<CwiseBinaryOp<ei_scalar_sum_op<Scalar>,Transpose<DerivedA>,DerivedB> >& >(other));
-}
-
-template<typename Derived>
-template<typename DerivedA, typename DerivedB>
-Derived& MatrixBase<Derived>::
-lazyAssign(const CwiseBinaryOp<ei_scalar_sum_op<Scalar>,DerivedA,Transpose<DerivedB> >& other)
-{
- ei_assert(ei_extract_data(derived()) != ei_extract_data(other.rhs())
- && "aliasing detected during tranposition, please evaluate your expression");
- return lazyAssign(static_cast<const MatrixBase<CwiseBinaryOp<ei_scalar_sum_op<Scalar>,DerivedA,Transpose<DerivedB> > >& >(other));
-}
-
-template<typename Derived>
-template<typename OtherDerived> Derived&
-MatrixBase<Derived>::
-lazyAssign(const CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, Eigen::Transpose<OtherDerived> >& other)
+template<typename Scalar, bool DestIsTranposed, typename OtherDerived>
+struct ei_check_transpose_aliasing_selector
{
- ei_assert(ei_extract_data(other) != ei_extract_data(derived())
- && "aliasing detected during tranposition, please use adjointInPlace()");
- return lazyAssign(static_cast<const MatrixBase<CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, Eigen::Transpose<OtherDerived> > >& >(other));
-}
+ static bool run(const Scalar* dest, const OtherDerived& src)
+ {
+ return (ei_blas_traits<OtherDerived>::IsTransposed != DestIsTranposed) && (dest==ei_extract_data(src));
+ }
+};
-template<typename Derived>
-template<typename DerivedA, typename DerivedB>
-Derived& MatrixBase<Derived>::
-lazyAssign(const CwiseBinaryOp<ei_scalar_sum_op<Scalar>,CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, Eigen::Transpose<DerivedA> >,DerivedB>& other)
+template<typename Scalar, bool DestIsTranposed, typename BinOp, typename DerivedA, typename DerivedB>
+struct ei_check_transpose_aliasing_selector<Scalar,DestIsTranposed,CwiseBinaryOp<BinOp,DerivedA,DerivedB> >
{
- ei_assert(ei_extract_data(derived()) != ei_extract_data(other.lhs())
- && "aliasing detected during tranposition, please evaluate your expression");
- return lazyAssign(static_cast<const MatrixBase<CwiseBinaryOp<ei_scalar_sum_op<Scalar>,CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, Eigen::Transpose<DerivedA> >,DerivedB> >& >(other));
-}
+ static bool run(const Scalar* dest, const CwiseBinaryOp<BinOp,DerivedA,DerivedB>& src)
+ {
+ return ((ei_blas_traits<DerivedA>::IsTransposed != DestIsTranposed) && dest==ei_extract_data(src.lhs()))
+ || ((ei_blas_traits<DerivedB>::IsTransposed != DestIsTranposed) && dest==ei_extract_data(src.rhs()));
+ }
+};
template<typename Derived>
-template<typename DerivedA, typename DerivedB>
-Derived& MatrixBase<Derived>::
-lazyAssign(const CwiseBinaryOp<ei_scalar_sum_op<Scalar>,DerivedA,CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, Eigen::Transpose<DerivedB> > >& other)
+template<typename OtherDerived>
+void MatrixBase<Derived>::checkTransposeAliasing(const OtherDerived& other) const
{
- ei_assert(ei_extract_data(derived()) != ei_extract_data(other.rhs())
- && "aliasing detected during tranposition, please evaluate your expression");
- return lazyAssign(static_cast<const MatrixBase<CwiseBinaryOp<ei_scalar_sum_op<Scalar>,DerivedA,CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, Eigen::Transpose<DerivedB> > > >& >(other));
+ ei_assert((!ei_check_transpose_aliasing_selector<Scalar,ei_blas_traits<Derived>::IsTransposed,OtherDerived>::run(ei_extract_data(derived()), other))
+ && "aliasing detected during tranposition, use transposeInPlace() or evaluate the rhs into a temporary using .eval()");
}
#endif