aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-07-08 00:49:10 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-07-08 00:49:10 +0000
commitf5791eeb7054b78ded6eb080e9712651da6c6a34 (patch)
tree414c138b050003fdc32e0cebcc6f39ea1e94dc7f /Eigen/src/Core
parentc910c517b34b147894e7fa62cb9602cc19e0669b (diff)
the big Array/Cwise rework as discussed on the mailing list. The new API
can be seen in Eigen/src/Core/Cwise.h.
Diffstat (limited to 'Eigen/src/Core')
-rw-r--r--Eigen/src/Core/Cwise.h173
-rw-r--r--Eigen/src/Core/CwiseBinaryOp.h36
-rw-r--r--Eigen/src/Core/CwiseNullaryOp.h18
-rw-r--r--Eigen/src/Core/CwiseUnaryOp.h20
-rw-r--r--Eigen/src/Core/Fuzzy.h6
-rw-r--r--Eigen/src/Core/MatrixBase.h67
-rw-r--r--Eigen/src/Core/util/ForwardDeclarations.h4
-rw-r--r--Eigen/src/Core/util/Meta.h4
8 files changed, 225 insertions, 103 deletions
diff --git a/Eigen/src/Core/Cwise.h b/Eigen/src/Core/Cwise.h
new file mode 100644
index 000000000..63b9834c5
--- /dev/null
+++ b/Eigen/src/Core/Cwise.h
@@ -0,0 +1,173 @@
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra. Eigen itself is part of the KDE project.
+//
+// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
+// Copyright (C) 2008 Benoit Jacob <jacob@math.jussieu.fr>
+//
+// Eigen is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// Alternatively, you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of
+// the License, or (at your option) any later version.
+//
+// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License and a copy of the GNU General Public License along with
+// Eigen. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef EIGEN_CWISE_H
+#define EIGEN_CWISE_H
+
+/** \internal
+ * \array_module
+ *
+ * \brief Template functor to add a scalar to a fixed other one
+ *
+ * \sa class CwiseUnaryOp, Array::operator+
+ */
+template<typename Scalar, bool PacketAccess = (int(ei_packet_traits<Scalar>::size)>1?true:false) > struct ei_scalar_add_op;
+
+/** \class Cwise
+ *
+ * \brief Pseudo expression providing additional coefficient-wise operations
+ *
+ * \param ExpressionType the type of the object on which to do coefficient-wise operations
+ *
+ * This class represents an expression with additional coefficient-wise features.
+ * It is the return type of MatrixBase::cwise()
+ * and most of the time this is the only way it is used.
+ *
+ * \sa MatrixBase::cwise()
+ */
+template<typename ExpressionType> class Cwise
+{
+ public:
+
+ typedef typename ei_traits<ExpressionType>::Scalar Scalar;
+ typedef typename ei_meta_if<ei_must_nest_by_value<ExpressionType>::ret,
+ ExpressionType, const ExpressionType&>::ret ExpressionTypeNested;
+// typedef NestByValue<typename ExpressionType::ConstantReturnType> ConstantReturnType;
+ typedef CwiseUnaryOp<ei_scalar_add_op<Scalar>, ExpressionType> ScalarAddReturnType;
+
+ template<template<typename _Scalar> class Functor, typename OtherDerived> struct BinOp
+ {
+ typedef CwiseBinaryOp<Functor<typename ei_traits<ExpressionType>::Scalar>,
+ ExpressionType,
+ OtherDerived
+ > ReturnType;
+ };
+
+ template<template<typename _Scalar> class Functor> struct UnOp
+ {
+ typedef CwiseUnaryOp<Functor<typename ei_traits<ExpressionType>::Scalar>,
+ ExpressionType
+ > ReturnType;
+ };
+
+ inline Cwise(const ExpressionType& matrix) : m_matrix(matrix) {}
+
+ /** \internal */
+ inline const ExpressionType& _expression() const { return m_matrix; }
+
+ template<typename OtherDerived>
+ const typename BinOp<ei_scalar_product_op, OtherDerived>::ReturnType
+ operator*(const MatrixBase<OtherDerived> &other) const;
+
+ template<typename OtherDerived>
+ const typename BinOp<ei_scalar_quotient_op, OtherDerived>::ReturnType
+ operator/(const MatrixBase<OtherDerived> &other) const;
+
+ template<typename OtherDerived>
+ const typename BinOp<ei_scalar_min_op, OtherDerived>::ReturnType
+ min(const MatrixBase<OtherDerived> &other) const;
+
+ template<typename OtherDerived>
+ const typename BinOp<ei_scalar_max_op, OtherDerived>::ReturnType
+ max(const MatrixBase<OtherDerived> &other) const;
+
+ const typename UnOp<ei_scalar_abs_op>::ReturnType abs() const;
+ const typename UnOp<ei_scalar_abs2_op>::ReturnType abs2() const;
+ const typename UnOp<ei_scalar_square_op>::ReturnType square() const;
+ const typename UnOp<ei_scalar_cube_op>::ReturnType cube() const;
+ const typename UnOp<ei_scalar_inverse_op>::ReturnType inverse() const;
+ const typename UnOp<ei_scalar_sqrt_op>::ReturnType sqrt() const;
+ const typename UnOp<ei_scalar_exp_op>::ReturnType exp() const;
+ const typename UnOp<ei_scalar_log_op>::ReturnType log() const;
+ const typename UnOp<ei_scalar_cos_op>::ReturnType cos() const;
+ const typename UnOp<ei_scalar_sin_op>::ReturnType sin() const;
+ const typename UnOp<ei_scalar_pow_op>::ReturnType pow(const Scalar& exponent) const;
+
+
+ const ScalarAddReturnType
+ operator+(const Scalar& scalar) const;
+
+ /** \relates Cwise */
+ friend const ScalarAddReturnType
+ operator+(const Scalar& scalar, const Cwise& mat)
+ { return mat + scalar; }
+
+ ExpressionType& operator+=(const Scalar& scalar);
+
+ const ScalarAddReturnType
+ operator-(const Scalar& scalar) const;
+
+ ExpressionType& operator-=(const Scalar& scalar);
+
+ template<typename OtherDerived> const typename BinOp<std::less, OtherDerived>::ReturnType
+ operator<(const MatrixBase<OtherDerived>& other) const;
+
+ template<typename OtherDerived> const typename BinOp<std::less_equal, OtherDerived>::ReturnType
+ operator<=(const MatrixBase<OtherDerived>& other) const;
+
+ template<typename OtherDerived> const typename BinOp<std::greater, OtherDerived>::ReturnType
+ operator>(const MatrixBase<OtherDerived>& other) const;
+
+ template<typename OtherDerived> const typename BinOp<std::greater_equal, OtherDerived>::ReturnType
+ operator>=(const MatrixBase<OtherDerived>& other) const;
+
+ template<typename OtherDerived> const typename BinOp<std::equal_to, OtherDerived>::ReturnType
+ operator==(const MatrixBase<OtherDerived>& other) const;
+
+ template<typename OtherDerived> const typename BinOp<std::not_equal_to, OtherDerived>::ReturnType
+ operator!=(const MatrixBase<OtherDerived>& other) const;
+
+
+ protected:
+ ExpressionTypeNested m_matrix;
+};
+
+/** \array_module
+ *
+ * \returns a Cwise expression of *this providing additional coefficient-wise operations
+ *
+ * \sa class Cwise
+ */
+template<typename Derived>
+inline const Cwise<Derived>
+MatrixBase<Derived>::cwise() const
+{
+ return derived();
+}
+
+/** \array_module
+ *
+ * \returns a Cwise expression of *this providing additional coefficient-wise operations
+ *
+ * \sa class Cwise
+ */
+template<typename Derived>
+inline Cwise<Derived>
+MatrixBase<Derived>::cwise()
+{
+ return derived();
+}
+
+#endif // EIGEN_CWISE_H
diff --git a/Eigen/src/Core/CwiseBinaryOp.h b/Eigen/src/Core/CwiseBinaryOp.h
index 2441b30f6..063ea7853 100644
--- a/Eigen/src/Core/CwiseBinaryOp.h
+++ b/Eigen/src/Core/CwiseBinaryOp.h
@@ -41,7 +41,7 @@
* However, if you want to write a function returning such an expression, you
* will need to use this class.
*
- * \sa MatrixBase::cwise(const MatrixBase<OtherDerived> &,const CustomBinaryOp &) const, class CwiseUnaryOp, class CwiseNullaryOp
+ * \sa MatrixBase::binaryExpr(const MatrixBase<OtherDerived> &,const CustomBinaryOp &) const, class CwiseUnaryOp, class CwiseNullaryOp
*/
template<typename BinaryOp, typename Lhs, typename Rhs>
struct ei_traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
@@ -179,48 +179,48 @@ MatrixBase<Derived>::operator+=(const MatrixBase<OtherDerived>& other)
*
* \sa class CwiseBinaryOp
*/
-template<typename Derived>
+template<typename ExpressionType>
template<typename OtherDerived>
-inline const CwiseBinaryOp<ei_scalar_product_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
-MatrixBase<Derived>::cwiseProduct(const MatrixBase<OtherDerived> &other) const
+inline const typename Cwise<ExpressionType>::template BinOp<ei_scalar_product_op, OtherDerived>::ReturnType
+Cwise<ExpressionType>::operator*(const MatrixBase<OtherDerived> &other) const
{
- return CwiseBinaryOp<ei_scalar_product_op<Scalar>, Derived, OtherDerived>(derived(), other.derived());
+ return typename BinOp<ei_scalar_product_op, OtherDerived>::ReturnType(_expression(), other.derived());
}
/** \returns an expression of the coefficient-wise quotient of *this and \a other
*
* \sa class CwiseBinaryOp
*/
-template<typename Derived>
+template<typename ExpressionType>
template<typename OtherDerived>
-inline const CwiseBinaryOp<ei_scalar_quotient_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
-MatrixBase<Derived>::cwiseQuotient(const MatrixBase<OtherDerived> &other) const
+inline const typename Cwise<ExpressionType>::template BinOp<ei_scalar_quotient_op, OtherDerived>::ReturnType
+Cwise<ExpressionType>::operator/(const MatrixBase<OtherDerived> &other) const
{
- return CwiseBinaryOp<ei_scalar_quotient_op<Scalar>, Derived, OtherDerived>(derived(), other.derived());
+ return typename BinOp<ei_scalar_quotient_op, OtherDerived>::ReturnType(_expression(), other.derived());
}
/** \returns an expression of the coefficient-wise min of *this and \a other
*
* \sa class CwiseBinaryOp
*/
-template<typename Derived>
+template<typename ExpressionType>
template<typename OtherDerived>
-inline const CwiseBinaryOp<ei_scalar_min_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
-MatrixBase<Derived>::cwiseMin(const MatrixBase<OtherDerived> &other) const
+inline const typename Cwise<ExpressionType>::template BinOp<ei_scalar_min_op, OtherDerived>::ReturnType
+Cwise<ExpressionType>::min(const MatrixBase<OtherDerived> &other) const
{
- return CwiseBinaryOp<ei_scalar_min_op<Scalar>, Derived, OtherDerived>(derived(), other.derived());
+ return typename BinOp<ei_scalar_min_op, OtherDerived>::ReturnType(_expression(), other.derived());
}
/** \returns an expression of the coefficient-wise max of *this and \a other
*
* \sa class CwiseBinaryOp
*/
-template<typename Derived>
+template<typename ExpressionType>
template<typename OtherDerived>
-inline const CwiseBinaryOp<ei_scalar_max_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
-MatrixBase<Derived>::cwiseMax(const MatrixBase<OtherDerived> &other) const
+inline const typename Cwise<ExpressionType>::template BinOp<ei_scalar_max_op, OtherDerived>::ReturnType
+Cwise<ExpressionType>::max(const MatrixBase<OtherDerived> &other) const
{
- return CwiseBinaryOp<ei_scalar_max_op<Scalar>, Derived, OtherDerived>(derived(), other.derived());
+ return typename BinOp<ei_scalar_max_op, OtherDerived>::ReturnType(_expression(), other.derived());
}
/** \returns an expression of a custom coefficient-wise operator \a func of *this and \a other
@@ -237,7 +237,7 @@ MatrixBase<Derived>::cwiseMax(const MatrixBase<OtherDerived> &other) const
template<typename Derived>
template<typename CustomBinaryOp, typename OtherDerived>
inline const CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>
-MatrixBase<Derived>::cwise(const MatrixBase<OtherDerived> &other, const CustomBinaryOp& func) const
+MatrixBase<Derived>::binaryExpr(const MatrixBase<OtherDerived> &other, const CustomBinaryOp& func) const
{
return CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>(derived(), other.derived(), func);
}
diff --git a/Eigen/src/Core/CwiseNullaryOp.h b/Eigen/src/Core/CwiseNullaryOp.h
index 78ecb878b..9b15d4240 100644
--- a/Eigen/src/Core/CwiseNullaryOp.h
+++ b/Eigen/src/Core/CwiseNullaryOp.h
@@ -38,7 +38,7 @@
* However, if you want to write a function returning such an expression, you
* will need to use this class.
*
- * \sa class CwiseUnaryOp, class CwiseBinaryOp, MatrixBase::create()
+ * \sa class CwiseUnaryOp, class CwiseBinaryOp, MatrixBase::NullaryExpr()
*/
template<typename NullaryOp, typename MatrixType>
struct ei_traits<CwiseNullaryOp<NullaryOp, MatrixType> >
@@ -123,7 +123,7 @@ class CwiseNullaryOp : ei_no_assignment_operator,
template<typename Derived>
template<typename CustomNullaryOp>
const CwiseNullaryOp<CustomNullaryOp, Derived>
-MatrixBase<Derived>::create(int rows, int cols, const CustomNullaryOp& func)
+MatrixBase<Derived>::NullaryExpr(int rows, int cols, const CustomNullaryOp& func)
{
return CwiseNullaryOp<CustomNullaryOp, Derived>(rows, cols, func);
}
@@ -146,7 +146,7 @@ MatrixBase<Derived>::create(int rows, int cols, const CustomNullaryOp& func)
template<typename Derived>
template<typename CustomNullaryOp>
const CwiseNullaryOp<CustomNullaryOp, Derived>
-MatrixBase<Derived>::create(int size, const CustomNullaryOp& func)
+MatrixBase<Derived>::NullaryExpr(int size, const CustomNullaryOp& func)
{
ei_assert(IsVectorAtCompileTime);
if(RowsAtCompileTime == 1) return CwiseNullaryOp<CustomNullaryOp, Derived>(1, size, func);
@@ -165,7 +165,7 @@ MatrixBase<Derived>::create(int size, const CustomNullaryOp& func)
template<typename Derived>
template<typename CustomNullaryOp>
const CwiseNullaryOp<CustomNullaryOp, Derived>
-MatrixBase<Derived>::create(const CustomNullaryOp& func)
+MatrixBase<Derived>::NullaryExpr(const CustomNullaryOp& func)
{
return CwiseNullaryOp<CustomNullaryOp, Derived>(RowsAtCompileTime, ColsAtCompileTime, func);
}
@@ -187,7 +187,7 @@ template<typename Derived>
const typename MatrixBase<Derived>::ConstantReturnType
MatrixBase<Derived>::constant(int rows, int cols, const Scalar& value)
{
- return create(rows, cols, ei_scalar_constant_op<Scalar>(value));
+ return NullaryExpr(rows, cols, ei_scalar_constant_op<Scalar>(value));
}
/** \returns an expression of a constant matrix of value \a value
@@ -209,7 +209,7 @@ template<typename Derived>
const typename MatrixBase<Derived>::ConstantReturnType
MatrixBase<Derived>::constant(int size, const Scalar& value)
{
- return create(size, ei_scalar_constant_op<Scalar>(value));
+ return NullaryExpr(size, ei_scalar_constant_op<Scalar>(value));
}
/** \returns an expression of a constant matrix of value \a value
@@ -225,7 +225,7 @@ template<typename Derived>
const typename MatrixBase<Derived>::ConstantReturnType
MatrixBase<Derived>::constant(const Scalar& value)
{
- return create(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_constant_op<Scalar>(value));
+ return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_constant_op<Scalar>(value));
}
template<typename Derived>
@@ -455,7 +455,7 @@ template<typename Derived>
inline const CwiseNullaryOp<ei_scalar_identity_op<typename ei_traits<Derived>::Scalar>, Derived>
MatrixBase<Derived>::identity(int rows, int cols)
{
- return create(rows, cols, ei_scalar_identity_op<Scalar>());
+ return NullaryExpr(rows, cols, ei_scalar_identity_op<Scalar>());
}
/** \returns an expression of the identity matrix (not necessarily square).
@@ -472,7 +472,7 @@ template<typename Derived>
inline const CwiseNullaryOp<ei_scalar_identity_op<typename ei_traits<Derived>::Scalar>, Derived>
MatrixBase<Derived>::identity()
{
- return create(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_identity_op<Scalar>());
+ return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_identity_op<Scalar>());
}
/** \returns true if *this is approximately equal to the identity matrix
diff --git a/Eigen/src/Core/CwiseUnaryOp.h b/Eigen/src/Core/CwiseUnaryOp.h
index c80124b47..68ef9b4d4 100644
--- a/Eigen/src/Core/CwiseUnaryOp.h
+++ b/Eigen/src/Core/CwiseUnaryOp.h
@@ -37,7 +37,7 @@
* It is the return type of the unary operator-, of a matrix or a vector, and most
* of the time this is the only way it is used.
*
- * \sa MatrixBase::cwise(const CustomUnaryOp &) const, class CwiseBinaryOp, class CwiseNullaryOp
+ * \sa MatrixBase::unaryExpr(const CustomUnaryOp &) const, class CwiseBinaryOp, class CwiseNullaryOp
*/
template<typename UnaryOp, typename MatrixType>
struct ei_traits<CwiseUnaryOp<UnaryOp, MatrixType> >
@@ -118,7 +118,7 @@ class CwiseUnaryOp : ei_no_assignment_operator,
template<typename Derived>
template<typename CustomUnaryOp>
inline const CwiseUnaryOp<CustomUnaryOp, Derived>
-MatrixBase<Derived>::cwise(const CustomUnaryOp& func) const
+MatrixBase<Derived>::unaryExpr(const CustomUnaryOp& func) const
{
return CwiseUnaryOp<CustomUnaryOp, Derived>(derived(), func);
}
@@ -134,20 +134,20 @@ MatrixBase<Derived>::operator-() const
/** \returns an expression of the coefficient-wise absolute value of \c *this
*/
-template<typename Derived>
-inline const CwiseUnaryOp<ei_scalar_abs_op<typename ei_traits<Derived>::Scalar>,Derived>
-MatrixBase<Derived>::cwiseAbs() const
+template<typename ExpressionType>
+inline const typename Cwise<ExpressionType>::template UnOp<ei_scalar_abs_op>::ReturnType
+Cwise<ExpressionType>::abs() const
{
- return derived();
+ return _expression();
}
/** \returns an expression of the coefficient-wise squared absolute value of \c *this
*/
-template<typename Derived>
-inline const CwiseUnaryOp<ei_scalar_abs2_op<typename ei_traits<Derived>::Scalar>,Derived>
-MatrixBase<Derived>::cwiseAbs2() const
+template<typename ExpressionType>
+inline const typename Cwise<ExpressionType>::template UnOp<ei_scalar_abs2_op>::ReturnType
+Cwise<ExpressionType>::abs2() const
{
- return derived();
+ return _expression();
}
/** \returns an expression of the complex conjugate of \c *this.
diff --git a/Eigen/src/Core/Fuzzy.h b/Eigen/src/Core/Fuzzy.h
index 0b2305c57..b48c198b3 100644
--- a/Eigen/src/Core/Fuzzy.h
+++ b/Eigen/src/Core/Fuzzy.h
@@ -54,7 +54,7 @@ bool MatrixBase<Derived>::isApprox(
{
const typename ei_nested<Derived,2>::type nested(derived());
const typename ei_nested<OtherDerived,2>::type otherNested(other.derived());
- return (nested - otherNested).cwiseAbs2().sum() <= prec * prec * std::min(nested.cwiseAbs2().sum(), otherNested.cwiseAbs2().sum());
+ return (nested - otherNested).cwise().abs2().sum() <= prec * prec * std::min(nested.cwise().abs2().sum(), otherNested.cwise().abs2().sum());
}
/** \returns \c true if the norm of \c *this is much smaller than \a other,
@@ -76,7 +76,7 @@ bool MatrixBase<Derived>::isMuchSmallerThan(
typename NumTraits<Scalar>::Real prec
) const
{
- return cwiseAbs2().sum() <= prec * prec * other * other;
+ return cwise().abs2().sum() <= prec * prec * other * other;
}
/** \returns \c true if the norm of \c *this is much smaller than the norm of \a other,
@@ -96,7 +96,7 @@ bool MatrixBase<Derived>::isMuchSmallerThan(
typename NumTraits<Scalar>::Real prec
) const
{
- return this->cwiseAbs2().sum() <= prec * prec * other.cwiseAbs2().sum();
+ return this->cwise().abs2().sum() <= prec * prec * other.cwise().abs2().sum();
}
#else
diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h
index 63817102f..95c188621 100644
--- a/Eigen/src/Core/MatrixBase.h
+++ b/Eigen/src/Core/MatrixBase.h
@@ -371,13 +371,13 @@ template<typename Derived> class MatrixBase
template<typename CustomNullaryOp>
static const CwiseNullaryOp<CustomNullaryOp, Derived>
- create(int rows, int cols, const CustomNullaryOp& func);
+ NullaryExpr(int rows, int cols, const CustomNullaryOp& func);
template<typename CustomNullaryOp>
static const CwiseNullaryOp<CustomNullaryOp, Derived>
- create(int size, const CustomNullaryOp& func);
+ NullaryExpr(int size, const CustomNullaryOp& func);
template<typename CustomNullaryOp>
static const CwiseNullaryOp<CustomNullaryOp, Derived>
- create(const CustomNullaryOp& func);
+ NullaryExpr(const CustomNullaryOp& func);
static const ConstantReturnType zero(int rows, int cols);
static const ConstantReturnType zero(int size);
@@ -457,31 +457,12 @@ template<typename Derived> class MatrixBase
const ConjugateReturnType conjugate() const;
const RealReturnType real() const;
- template<typename OtherDerived>
- const CwiseBinaryOp<ei_scalar_product_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
- cwiseProduct(const MatrixBase<OtherDerived> &other) const;
-
- template<typename OtherDerived>
- const CwiseBinaryOp<ei_scalar_quotient_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
- cwiseQuotient(const MatrixBase<OtherDerived> &other) const;
-
- template<typename OtherDerived>
- const CwiseBinaryOp<ei_scalar_min_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
- cwiseMin(const MatrixBase<OtherDerived> &other) const;
-
- template<typename OtherDerived>
- const CwiseBinaryOp<ei_scalar_max_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
- cwiseMax(const MatrixBase<OtherDerived> &other) const;
-
- const CwiseUnaryOp<ei_scalar_abs_op<typename ei_traits<Derived>::Scalar>, Derived> cwiseAbs() const;
- const CwiseUnaryOp<ei_scalar_abs2_op<typename ei_traits<Derived>::Scalar>, Derived> cwiseAbs2() const;
-
template<typename CustomUnaryOp>
- const CwiseUnaryOp<CustomUnaryOp, Derived> cwise(const CustomUnaryOp& func = CustomUnaryOp()) const;
+ const CwiseUnaryOp<CustomUnaryOp, Derived> unaryExpr(const CustomUnaryOp& func = CustomUnaryOp()) const;
template<typename CustomBinaryOp, typename OtherDerived>
const CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>
- cwise(const MatrixBase<OtherDerived> &other, const CustomBinaryOp& func = CustomBinaryOp()) const;
+ binaryExpr(const MatrixBase<OtherDerived> &other, const CustomBinaryOp& func = CustomBinaryOp()) const;
Scalar sum() const;
@@ -506,45 +487,11 @@ template<typename Derived> class MatrixBase
inline Derived& const_cast_derived() const
{ return *static_cast<Derived*>(const_cast<MatrixBase*>(this)); }
+ const Cwise<Derived> cwise() const;
+ Cwise<Derived> cwise();
/////////// Array module ///////////
- const Array<Derived> array() const;
- Array<Derived> array();
-
- const CwiseUnaryOp<ei_scalar_sqrt_op<typename ei_traits<Derived>::Scalar>, Derived> cwiseSqrt() const;
- const CwiseUnaryOp<ei_scalar_exp_op<typename ei_traits<Derived>::Scalar>, Derived> cwiseExp() const;
- const CwiseUnaryOp<ei_scalar_log_op<typename ei_traits<Derived>::Scalar>, Derived> cwiseLog() const;
- const CwiseUnaryOp<ei_scalar_cos_op<typename ei_traits<Derived>::Scalar>, Derived> cwiseCos() const;
- const CwiseUnaryOp<ei_scalar_sin_op<typename ei_traits<Derived>::Scalar>, Derived> cwiseSin() const;
- const CwiseUnaryOp<ei_scalar_pow_op<typename ei_traits<Derived>::Scalar>, Derived>
- cwisePow(const Scalar& exponent) const;
- const CwiseUnaryOp<ei_scalar_inverse_op<typename ei_traits<Derived>::Scalar>, Derived> cwiseInverse() const;
-
- template<typename OtherDerived>
- const CwiseBinaryOp<std::less<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
- cwiseLessThan(const MatrixBase<OtherDerived> &other) const;
-
- template<typename OtherDerived>
- const CwiseBinaryOp<std::less_equal<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
- cwiseLessEqual(const MatrixBase<OtherDerived> &other) const;
-
- template<typename OtherDerived>
- const CwiseBinaryOp<std::greater<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
- cwiseGreaterThan(const MatrixBase<OtherDerived> &other) const;
-
- template<typename OtherDerived>
- const CwiseBinaryOp<std::greater_equal<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
- cwiseGreaterEqual(const MatrixBase<OtherDerived> &other) const;
-
- template<typename OtherDerived>
- const CwiseBinaryOp<std::equal_to<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
- cwiseEqualTo(const MatrixBase<OtherDerived> &other) const;
-
- template<typename OtherDerived>
- const CwiseBinaryOp<std::not_equal_to<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
- cwiseNotEqualTo(const MatrixBase<OtherDerived> &other) const;
-
bool all(void) const;
bool any(void) const;
diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h
index bad5cacdc..922a3716f 100644
--- a/Eigen/src/Core/util/ForwardDeclarations.h
+++ b/Eigen/src/Core/util/ForwardDeclarations.h
@@ -55,7 +55,7 @@ template<typename MatrixType, int Alignment = Unaligned> class Map;
template<int Direction, typename UnaryOp, typename MatrixType> class PartialRedux;
template<typename MatrixType, unsigned int Mode> class Part;
template<typename MatrixType, unsigned int Mode> class Extract;
-template<typename MatrixType> class Array;
+template<typename ExpressionType> class Cwise;
template<typename Lhs, typename Rhs> struct ei_product_mode;
template<typename Lhs, typename Rhs, int ProductMode = ei_product_mode<Lhs,Rhs>::value> struct ProductReturnType;
@@ -76,6 +76,8 @@ template<typename Scalar> struct ei_scalar_cos_op;
template<typename Scalar> struct ei_scalar_sin_op;
template<typename Scalar> struct ei_scalar_pow_op;
template<typename Scalar> struct ei_scalar_inverse_op;
+template<typename Scalar> struct ei_scalar_square_op;
+template<typename Scalar> struct ei_scalar_cube_op;
template<typename Scalar, typename NewType> struct ei_scalar_cast_op;
template<typename Scalar, bool PacketAccess> struct ei_scalar_multiple_op;
template<typename Scalar> struct ei_scalar_quotient1_op;
diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h
index b7796bb29..e7bfc195d 100644
--- a/Eigen/src/Core/util/Meta.h
+++ b/Eigen/src/Core/util/Meta.h
@@ -61,10 +61,10 @@ template<> class ei_int_if_dynamic<Dynamic>
};
-template <bool Condition, class Then, class Else>
+template<bool Condition, typename Then, typename Else>
struct ei_meta_if { typedef Then ret; };
-template <class Then, class Else>
+template<typename Then, typename Else>
struct ei_meta_if <false, Then, Else> { typedef Else ret; };
template<typename T, typename U> struct ei_is_same_type { enum { ret = 0 }; };