member_redux constructor is explicit too. Renamed some typedefs for more consistency.

This commit is contained in:
Christoph Hertzberg 2014-09-23 18:55:42 +02:00
parent 7817bc19a4
commit 421feea3b2
3 changed files with 20 additions and 22 deletions

View File

@ -128,7 +128,7 @@ struct member_redux {
>::type result_type;
template<typename _Scalar, int Size> struct Cost
{ enum { value = (Size-1) * functor_traits<BinaryOp>::Cost }; };
member_redux(const BinaryOp func) : m_functor(func) {} // FIXME this should actually be explicit, but lets not exaggerate
explicit member_redux(const BinaryOp func) : m_functor(func) {}
template<typename Derived>
inline result_type operator()(const DenseBase<Derived>& mat) const
{ return mat.redux(m_functor); }
@ -165,10 +165,10 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
typedef typename internal::remove_all<ExpressionTypeNested>::type ExpressionTypeNestedCleaned;
template<template<typename _Scalar> class Functor,
typename Scalar=typename internal::traits<ExpressionType>::Scalar> struct ReturnType
typename Scalar_=Scalar> struct ReturnType
{
typedef PartialReduxExpr<ExpressionType,
Functor<Scalar>,
Functor<Scalar_>,
Direction
> Type;
};
@ -176,7 +176,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
template<typename BinaryOp> struct ReduxReturnType
{
typedef PartialReduxExpr<ExpressionType,
internal::member_redux<BinaryOp,typename internal::traits<ExpressionType>::Scalar>,
internal::member_redux<BinaryOp,Scalar>,
Direction
> Type;
};
@ -264,11 +264,11 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
template<typename BinaryOp>
const typename ReduxReturnType<BinaryOp>::Type
redux(const BinaryOp& func = BinaryOp()) const
{ return typename ReduxReturnType<BinaryOp>::Type(_expression(), func); }
{ return typename ReduxReturnType<BinaryOp>::Type(_expression(), internal::member_redux<BinaryOp,Scalar>(func)); }
typedef typename ReturnType<internal::member_minCoeff>::Type MinCoeffReturnType;
typedef typename ReturnType<internal::member_maxCoeff>::Type MaxCoeffReturnType;
typedef typename ReturnType<internal::member_squaredNorm,RealScalar>::Type SquareNormReturnType;
typedef typename ReturnType<internal::member_squaredNorm,RealScalar>::Type SquaredNormReturnType;
typedef typename ReturnType<internal::member_norm,RealScalar>::Type NormReturnType;
typedef typename ReturnType<internal::member_blueNorm,RealScalar>::Type BlueNormReturnType;
typedef typename ReturnType<internal::member_stableNorm,RealScalar>::Type StableNormReturnType;
@ -313,8 +313,8 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
* Output: \verbinclude PartialRedux_squaredNorm.out
*
* \sa DenseBase::squaredNorm() */
const SquareNormReturnType squaredNorm() const
{ return SquareNormReturnType(_expression()); }
const SquaredNormReturnType squaredNorm() const
{ return SquaredNormReturnType(_expression()); }
/** \returns a row (or column) vector expression of the norm
* of each column (or row) of the referenced expression.

View File

@ -1,11 +1,9 @@
// These are already defined in MatrixCwiseUnaryOps.h
//typedef CwiseUnaryOp<internal::scalar_abs_op<Scalar>, const Derived> AbsReturnType;
//typedef CwiseUnaryOp<internal::scalar_abs2_op<Scalar>, const Derived> Abs2ReturnType;
//typedef CwiseUnaryOp<internal::scalar_sqrt_op<Scalar>, const Derived> SqrtReturnType;
typedef CwiseUnaryOp<internal::scalar_abs_op<Scalar>, const Derived> AbsReturnType;
typedef CwiseUnaryOp<internal::scalar_abs2_op<Scalar>, const Derived> Abs2ReturnType;
typedef CwiseUnaryOp<internal::scalar_sqrt_op<Scalar>, const Derived> SqrtReturnType;
typedef CwiseUnaryOp<internal::scalar_inverse_op<Scalar>, const Derived> InverseReturnType;
//typedef CwiseUnaryOp<std::binder1st<std::equal_to<Scalar> >, const Derived> CwiseScalarEqualReturnType;
typedef CwiseUnaryOp<internal::scalar_exp_op<Scalar>, const Derived> ExpReturnType;
typedef CwiseUnaryOp<internal::scalar_log_op<Scalar>, const Derived> LogReturnType;

View File

@ -10,9 +10,9 @@
// This file is a base class plugin containing matrix specifics coefficient wise functions.
typedef CwiseUnaryOp<internal::scalar_abs_op<Scalar>, const Derived> AbsReturnType;
typedef CwiseUnaryOp<internal::scalar_abs2_op<Scalar>, const Derived> Abs2ReturnType;
typedef CwiseUnaryOp<internal::scalar_sqrt_op<Scalar>, const Derived> SqrtReturnType;
typedef CwiseUnaryOp<internal::scalar_abs_op<Scalar>, const Derived> CwiseAbsReturnType;
typedef CwiseUnaryOp<internal::scalar_abs2_op<Scalar>, const Derived> CwiseAbs2ReturnType;
typedef CwiseUnaryOp<internal::scalar_sqrt_op<Scalar>, const Derived> CwiseSqrtReturnType;
typedef CwiseUnaryOp<internal::scalar_inverse_op<Scalar>, const Derived> CwiseInverseReturnType;
typedef CwiseUnaryOp<std::binder1st<std::equal_to<Scalar> >, const Derived> CwiseScalarEqualReturnType;
/** \returns an expression of the coefficient-wise absolute value of \c *this
@ -23,8 +23,8 @@ typedef CwiseUnaryOp<std::binder1st<std::equal_to<Scalar> >, const Derived> Cwis
* \sa cwiseAbs2()
*/
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE const AbsReturnType
cwiseAbs() const { return AbsReturnType(derived()); }
EIGEN_STRONG_INLINE const CwiseAbsReturnType
cwiseAbs() const { return CwiseAbsReturnType(derived()); }
/** \returns an expression of the coefficient-wise squared absolute value of \c *this
*
@ -34,8 +34,8 @@ cwiseAbs() const { return AbsReturnType(derived()); }
* \sa cwiseAbs()
*/
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE const Abs2ReturnType
cwiseAbs2() const { return Abs2ReturnType(derived()); }
EIGEN_STRONG_INLINE const CwiseAbs2ReturnType
cwiseAbs2() const { return CwiseAbs2ReturnType(derived()); }
/** \returns an expression of the coefficient-wise square root of *this.
*
@ -45,8 +45,8 @@ cwiseAbs2() const { return Abs2ReturnType(derived()); }
* \sa cwisePow(), cwiseSquare()
*/
EIGEN_DEVICE_FUNC
inline const SqrtReturnType
cwiseSqrt() const { return SqrtReturnType(derived()); }
inline const CwiseSqrtReturnType
cwiseSqrt() const { return CwiseSqrtReturnType(derived()); }
/** \returns an expression of the coefficient-wise inverse of *this.
*