mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-01-06 14:14:46 +08:00
Fix evaluators unit test (i.e., when only EIGEN_ENABLE_EVALUATORS is defined
This commit is contained in:
parent
cbc572caf7
commit
5c0f294098
@ -353,10 +353,13 @@ template<typename Lhs, typename Rhs>
|
|||||||
struct traits<GeneralProduct<Lhs,Rhs,GemvProduct> >
|
struct traits<GeneralProduct<Lhs,Rhs,GemvProduct> >
|
||||||
: traits<ProductBase<GeneralProduct<Lhs,Rhs,GemvProduct>, Lhs, Rhs> >
|
: traits<ProductBase<GeneralProduct<Lhs,Rhs,GemvProduct>, Lhs, Rhs> >
|
||||||
{};
|
{};
|
||||||
#endif
|
|
||||||
|
|
||||||
template<int Side, int StorageOrder, bool BlasCompatible>
|
template<int Side, int StorageOrder, bool BlasCompatible>
|
||||||
struct gemv_selector;
|
struct gemv_selector;
|
||||||
|
#endif
|
||||||
|
#ifdef EIGEN_ENABLE_EVALUATORS
|
||||||
|
template<int Side, int StorageOrder, bool BlasCompatible>
|
||||||
|
struct gemv_dense_sense_selector;
|
||||||
|
#endif
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
@ -594,23 +597,25 @@ template<> struct gemv_selector<OnTheRight,RowMajor,false>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#else // EIGEN_TEST_EVALUATORS
|
#endif // EIGEN_TEST_EVALUATORS
|
||||||
|
|
||||||
|
#ifdef EIGEN_ENABLE_EVALUATORS
|
||||||
|
|
||||||
// The vector is on the left => transposition
|
// The vector is on the left => transposition
|
||||||
template<int StorageOrder, bool BlasCompatible>
|
template<int StorageOrder, bool BlasCompatible>
|
||||||
struct gemv_selector<OnTheLeft,StorageOrder,BlasCompatible>
|
struct gemv_dense_sense_selector<OnTheLeft,StorageOrder,BlasCompatible>
|
||||||
{
|
{
|
||||||
template<typename Lhs, typename Rhs, typename Dest>
|
template<typename Lhs, typename Rhs, typename Dest>
|
||||||
static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
|
static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
|
||||||
{
|
{
|
||||||
Transpose<Dest> destT(dest);
|
Transpose<Dest> destT(dest);
|
||||||
enum { OtherStorageOrder = StorageOrder == RowMajor ? ColMajor : RowMajor };
|
enum { OtherStorageOrder = StorageOrder == RowMajor ? ColMajor : RowMajor };
|
||||||
gemv_selector<OnTheRight,OtherStorageOrder,BlasCompatible>
|
gemv_dense_sense_selector<OnTheRight,OtherStorageOrder,BlasCompatible>
|
||||||
::run(rhs.transpose(), lhs.transpose(), destT, alpha);
|
::run(rhs.transpose(), lhs.transpose(), destT, alpha);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct gemv_selector<OnTheRight,ColMajor,true>
|
template<> struct gemv_dense_sense_selector<OnTheRight,ColMajor,true>
|
||||||
{
|
{
|
||||||
template<typename Lhs, typename Rhs, typename Dest>
|
template<typename Lhs, typename Rhs, typename Dest>
|
||||||
static inline void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
|
static inline void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
|
||||||
@ -685,7 +690,7 @@ template<> struct gemv_selector<OnTheRight,ColMajor,true>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct gemv_selector<OnTheRight,RowMajor,true>
|
template<> struct gemv_dense_sense_selector<OnTheRight,RowMajor,true>
|
||||||
{
|
{
|
||||||
template<typename Lhs, typename Rhs, typename Dest>
|
template<typename Lhs, typename Rhs, typename Dest>
|
||||||
static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
|
static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
|
||||||
@ -737,7 +742,7 @@ template<> struct gemv_selector<OnTheRight,RowMajor,true>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct gemv_selector<OnTheRight,ColMajor,false>
|
template<> struct gemv_dense_sense_selector<OnTheRight,ColMajor,false>
|
||||||
{
|
{
|
||||||
template<typename Lhs, typename Rhs, typename Dest>
|
template<typename Lhs, typename Rhs, typename Dest>
|
||||||
static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
|
static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
|
||||||
@ -750,7 +755,7 @@ template<> struct gemv_selector<OnTheRight,ColMajor,false>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct gemv_selector<OnTheRight,RowMajor,false>
|
template<> struct gemv_dense_sense_selector<OnTheRight,RowMajor,false>
|
||||||
{
|
{
|
||||||
template<typename Lhs, typename Rhs, typename Dest>
|
template<typename Lhs, typename Rhs, typename Dest>
|
||||||
static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
|
static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
|
||||||
@ -763,7 +768,7 @@ template<> struct gemv_selector<OnTheRight,RowMajor,false>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EIGEN_TEST_EVALUATORS
|
#endif // EIGEN_ENABLE_EVALUATORS
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ struct generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,GemvProduct>
|
|||||||
template<typename Dest>
|
template<typename Dest>
|
||||||
static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha)
|
static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha)
|
||||||
{
|
{
|
||||||
internal::gemv_selector<Side,
|
internal::gemv_dense_sense_selector<Side,
|
||||||
(int(MatrixType::Flags)&RowMajorBit) ? RowMajor : ColMajor,
|
(int(MatrixType::Flags)&RowMajorBit) ? RowMajor : ColMajor,
|
||||||
bool(internal::blas_traits<MatrixType>::HasUsableDirectAccess)
|
bool(internal::blas_traits<MatrixType>::HasUsableDirectAccess)
|
||||||
>::run(lhs, rhs, dst, alpha);
|
>::run(lhs, rhs, dst, alpha);
|
||||||
|
@ -422,7 +422,9 @@ class GeneralProduct<Lhs, Rhs, GemmProduct>
|
|||||||
internal::parallelize_gemm<(Dest::MaxRowsAtCompileTime>32 || Dest::MaxRowsAtCompileTime==Dynamic)>(GemmFunctor(lhs, rhs, dst, actualAlpha, blocking), this->rows(), this->cols(), Dest::Flags&RowMajorBit);
|
internal::parallelize_gemm<(Dest::MaxRowsAtCompileTime>32 || Dest::MaxRowsAtCompileTime==Dynamic)>(GemmFunctor(lhs, rhs, dst, actualAlpha, blocking), this->rows(), this->cols(), Dest::Flags&RowMajorBit);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#else // EIGEN_TEST_EVALUATORS
|
#endif // EIGEN_TEST_EVALUATORS
|
||||||
|
|
||||||
|
#ifdef EIGEN_ENABLE_EVALUATORS
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template<typename Lhs, typename Rhs>
|
template<typename Lhs, typename Rhs>
|
||||||
@ -477,7 +479,7 @@ struct generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,GemmProduct>
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
#endif // EIGEN_TEST_EVALUATORS
|
#endif // EIGEN_ENABLE_EVALUATORS
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
|
@ -431,7 +431,8 @@ struct SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,RhsMode,false>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#else // EIGEN_TEST_EVALUATORS
|
#endif // EIGEN_TEST_EVALUATORS
|
||||||
|
#ifdef EIGEN_ENABLE_EVALUATORS
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template<typename Lhs, int LhsMode, typename Rhs, int RhsMode>
|
template<typename Lhs, int LhsMode, typename Rhs, int RhsMode>
|
||||||
@ -481,7 +482,7 @@ struct selfadjoint_product_impl<Lhs,LhsMode,false,Rhs,RhsMode,false>
|
|||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
#endif
|
#endif // EIGEN_ENABLE_EVALUATORS
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
|
@ -421,7 +421,8 @@ struct TriangularProduct<Mode,LhsIsTriangular,Lhs,false,Rhs,false>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#else // EIGEN_TEST_EVALUATORS
|
#endif // EIGEN_TEST_EVALUATORS
|
||||||
|
#ifdef EIGEN_ENABLE_EVALUATORS
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template<int Mode, bool LhsIsTriangular, typename Lhs, typename Rhs>
|
template<int Mode, bool LhsIsTriangular, typename Lhs, typename Rhs>
|
||||||
struct triangular_product_impl<Mode,LhsIsTriangular,Lhs,false,Rhs,false>
|
struct triangular_product_impl<Mode,LhsIsTriangular,Lhs,false,Rhs,false>
|
||||||
@ -471,7 +472,7 @@ struct triangular_product_impl<Mode,LhsIsTriangular,Lhs,false,Rhs,false>
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
#endif // EIGEN_TEST_EVALUATORS
|
#endif // EIGEN_ENABLE_EVALUATORS
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
|
@ -293,44 +293,10 @@ struct transfer_constness
|
|||||||
>::type type;
|
>::type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef EIGEN_TEST_EVALUATORS
|
|
||||||
|
|
||||||
// When using evaluators, we never evaluate when assembling the expression!!
|
|
||||||
// TODO: get rid of this nested class since it's just an alias for ref_selector.
|
|
||||||
template<typename T, int n=1, typename PlainObject = typename eval<T>::type> struct nested
|
|
||||||
{
|
|
||||||
typedef typename ref_selector<T>::type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
// However, we still need a mechanism to detect whether an expression which is evaluated multiple time
|
#ifndef EIGEN_TEST_EVALUATORS
|
||||||
// has to be evaluated into a temporary.
|
|
||||||
// That's the purpose of this new nested_eval helper:
|
|
||||||
template<typename T, int n, typename PlainObject = typename eval<T>::type> struct nested_eval
|
|
||||||
{
|
|
||||||
enum {
|
|
||||||
// For the purpose of this test, to keep it reasonably simple, we arbitrarily choose a value of Dynamic values.
|
|
||||||
// the choice of 10000 makes it larger than any practical fixed value and even most dynamic values.
|
|
||||||
// in extreme cases where these assumptions would be wrong, we would still at worst suffer performance issues
|
|
||||||
// (poor choice of temporaries).
|
|
||||||
// It's important that this value can still be squared without integer overflowing.
|
|
||||||
DynamicAsInteger = 10000,
|
|
||||||
ScalarReadCost = NumTraits<typename traits<T>::Scalar>::ReadCost,
|
|
||||||
ScalarReadCostAsInteger = ScalarReadCost == Dynamic ? int(DynamicAsInteger) : int(ScalarReadCost),
|
|
||||||
CoeffReadCost = traits<T>::CoeffReadCost,
|
|
||||||
CoeffReadCostAsInteger = CoeffReadCost == Dynamic ? int(DynamicAsInteger) : int(CoeffReadCost),
|
|
||||||
NAsInteger = n == Dynamic ? int(DynamicAsInteger) : n,
|
|
||||||
CostEvalAsInteger = (NAsInteger+1) * ScalarReadCostAsInteger + CoeffReadCostAsInteger,
|
|
||||||
CostNoEvalAsInteger = NAsInteger * CoeffReadCostAsInteger
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef typename conditional<
|
|
||||||
int(CostEvalAsInteger) < int(CostNoEvalAsInteger),
|
|
||||||
PlainObject,
|
|
||||||
typename ref_selector<T>::type
|
|
||||||
>::type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
#else
|
|
||||||
/** \internal Determines how a given expression should be nested into another one.
|
/** \internal Determines how a given expression should be nested into another one.
|
||||||
* For example, when you do a * (b+c), Eigen will determine how the expression b+c should be
|
* For example, when you do a * (b+c), Eigen will determine how the expression b+c should be
|
||||||
* nested into the bigger product expression. The choice is between nesting the expression b+c as-is, or
|
* nested into the bigger product expression. The choice is between nesting the expression b+c as-is, or
|
||||||
@ -377,8 +343,48 @@ template<typename T, int n=1, typename PlainObject = typename eval<T>::type> str
|
|||||||
typename ref_selector<T>::type
|
typename ref_selector<T>::type
|
||||||
>::type type;
|
>::type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
// When using evaluators, we never evaluate when assembling the expression!!
|
||||||
|
// TODO: get rid of this nested class since it's just an alias for ref_selector.
|
||||||
|
template<typename T, int n=1, typename PlainObject = typename eval<T>::type> struct nested
|
||||||
|
{
|
||||||
|
typedef typename ref_selector<T>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // EIGEN_TEST_EVALUATORS
|
#endif // EIGEN_TEST_EVALUATORS
|
||||||
|
|
||||||
|
#ifdef EIGEN_ENABLE_EVALUATORS
|
||||||
|
// However, we still need a mechanism to detect whether an expression which is evaluated multiple time
|
||||||
|
// has to be evaluated into a temporary.
|
||||||
|
// That's the purpose of this new nested_eval helper:
|
||||||
|
template<typename T, int n, typename PlainObject = typename eval<T>::type> struct nested_eval
|
||||||
|
{
|
||||||
|
enum {
|
||||||
|
// For the purpose of this test, to keep it reasonably simple, we arbitrarily choose a value of Dynamic values.
|
||||||
|
// the choice of 10000 makes it larger than any practical fixed value and even most dynamic values.
|
||||||
|
// in extreme cases where these assumptions would be wrong, we would still at worst suffer performance issues
|
||||||
|
// (poor choice of temporaries).
|
||||||
|
// It's important that this value can still be squared without integer overflowing.
|
||||||
|
DynamicAsInteger = 10000,
|
||||||
|
ScalarReadCost = NumTraits<typename traits<T>::Scalar>::ReadCost,
|
||||||
|
ScalarReadCostAsInteger = ScalarReadCost == Dynamic ? int(DynamicAsInteger) : int(ScalarReadCost),
|
||||||
|
CoeffReadCost = traits<T>::CoeffReadCost,
|
||||||
|
CoeffReadCostAsInteger = CoeffReadCost == Dynamic ? int(DynamicAsInteger) : int(CoeffReadCost),
|
||||||
|
NAsInteger = n == Dynamic ? int(DynamicAsInteger) : n,
|
||||||
|
CostEvalAsInteger = (NAsInteger+1) * ScalarReadCostAsInteger + CoeffReadCostAsInteger,
|
||||||
|
CostNoEvalAsInteger = NAsInteger * CoeffReadCostAsInteger
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef typename conditional<
|
||||||
|
int(CostEvalAsInteger) < int(CostNoEvalAsInteger),
|
||||||
|
PlainObject,
|
||||||
|
typename ref_selector<T>::type
|
||||||
|
>::type type;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
T* const_cast_ptr(const T* ptr)
|
T* const_cast_ptr(const T* ptr)
|
||||||
|
Loading…
Reference in New Issue
Block a user