a lot of cleaning and fixes

This commit is contained in:
Gael Guennebaud
2009-12-16 19:18:40 +01:00
parent 22a6ab1f4b
commit 9f79558839
20 changed files with 258 additions and 298 deletions

View File

@@ -76,14 +76,16 @@ template<typename Derived> class ArrayBase
using Base::Flags;
using Base::CoeffReadCost;
using Base::_HasDirectAccess;
using Base::derived;
using Base::const_cast_derived;
using Base::rows;
using Base::cols;
using Base::size;
using Base::coeff;
using Base::coeffRef;
using Base::operator=;
typedef typename Base::RealScalar RealScalar;
typedef typename Base::CoeffReturnType CoeffReturnType;
#endif // not EIGEN_PARSED_BY_DOXYGEN
@@ -107,18 +109,15 @@ template<typename Derived> class ArrayBase
typedef CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> ConstantReturnType;
#endif // not EIGEN_PARSED_BY_DOXYGEN
#ifndef EIGEN_PARSED_BY_DOXYGEN
using AnyMatrixBase<Derived>::derived;
inline Derived& const_cast_derived() const
{ return *static_cast<Derived*>(const_cast<ArrayBase*>(this)); }
#endif // not EIGEN_PARSED_BY_DOXYGEN
#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::ArrayBase
# include "../plugins/CommonCwiseUnaryOps.h"
# include "../plugins/MatrixCwiseUnaryOps.h"
# include "../plugins/ArrayCwiseUnaryOps.h"
# include "../plugins/CommonCwiseBinaryOps.h"
# include "../plugins/ArrayCwiseBinaryOps.h"
# include "../plugins/CommonCwiseUnaryOps.h"
# include "../plugins/MatrixCwiseUnaryOps.h"
# include "../plugins/ArrayCwiseUnaryOps.h"
# include "../plugins/CommonCwiseBinaryOps.h"
# include "../plugins/ArrayCwiseBinaryOps.h"
# ifdef EIGEN_ARRAYBASE_PLUGIN
# include EIGEN_ARRAYBASE_PLUGIN
# endif
#undef EIGEN_CURRENT_STORAGE_BASE_CLASS
@@ -142,6 +141,8 @@ template<typename Derived> class ArrayBase
Derived& operator+=(const Scalar& scalar)
{ return *this = derived() + scalar; }
Derived& operator-=(const Scalar& scalar)
{ return *this = derived() - scalar; }
template<typename OtherDerived>
Derived& operator+=(const ArrayBase<OtherDerived>& other);
@@ -177,9 +178,7 @@ template<typename Derived> class ArrayBase
// const VectorwiseOp<Derived,Vertical> colwise() const;
// VectorwiseOp<Derived,Vertical> colwise();
#ifdef EIGEN_ARRAYBASE_PLUGIN
#include EIGEN_ARRAYBASE_PLUGIN
#endif
public:
MatrixWrapper<Derived> asMatrix() { return derived(); }

View File

@@ -63,11 +63,11 @@ struct ei_traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType>
class Select : ei_no_assignment_operator,
public ConditionMatrixType::template MakeBase< Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >::Type
public ThenMatrixType::template MakeBase< Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >::Type
{
public:
typedef typename ConditionMatrixType::template MakeBase< Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >::Type Base;
typedef typename ThenMatrixType::template MakeBase< Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >::Type Base;
_EIGEN_GENERIC_PUBLIC_INTERFACE(Select)
Select(const ConditionMatrixType& conditionMatrix,

View File

@@ -39,9 +39,14 @@ template<typename Derived> struct AnyMatrixBase
{
typedef typename ei_plain_matrix_type<Derived>::type PlainMatrixType;
/** \returns a reference to the derived object */
Derived& derived() { return *static_cast<Derived*>(this); }
/** \returns a const reference to the derived object */
const Derived& derived() const { return *static_cast<const Derived*>(this); }
inline Derived& const_cast_derived() const
{ return *static_cast<Derived*>(const_cast<AnyMatrixBase*>(this)); }
/** \returns the number of rows. \sa cols(), RowsAtCompileTime */
inline int rows() const { return derived().rows(); }
/** \returns the number of columns. \sa rows(), ColsAtCompileTime*/

View File

@@ -194,7 +194,7 @@ EIGEN_STRONG_INLINE Derived &
MatrixBase<Derived>::operator+=(const MatrixBase<OtherDerived>& other)
{
SelfCwiseBinaryOp<ei_scalar_sum_op<Scalar>, Derived> tmp(derived());
tmp = other;
tmp = other.derived();
return derived();
}

View File

@@ -51,6 +51,9 @@ template<typename Derived> class DenseBase
typedef typename ei_traits<Derived>::Scalar Scalar;
typedef typename ei_packet_traits<Scalar>::type PacketScalar;
using AnyMatrixBase<Derived>::derived;
using AnyMatrixBase<Derived>::const_cast_derived;
#endif // not EIGEN_PARSED_BY_DOXYGEN
enum {
@@ -391,10 +394,25 @@ template<typename Derived> class DenseBase
bool isZero(RealScalar prec = precision<Scalar>()) const;
bool isOnes(RealScalar prec = precision<Scalar>()) const;
EIGEN_STRONG_INLINE Derived& operator*=(const Scalar& other)
{
SelfCwiseBinaryOp<ei_scalar_product_op<Scalar>, Derived> tmp(derived());
typedef typename Derived::PlainMatrixType PlainMatrixType;
tmp = PlainMatrixType::Constant(rows(),cols(),other);
return derived();
}
EIGEN_STRONG_INLINE Derived& operator/=(const Scalar& other)
{
SelfCwiseBinaryOp<typename ei_meta_if<NumTraits<Scalar>::HasFloatingPoint,ei_scalar_product_op<Scalar>,ei_scalar_quotient_op<Scalar> >::ret, Derived> tmp(derived());
typedef typename Derived::PlainMatrixType PlainMatrixType;
tmp = PlainMatrixType::Constant(rows(),cols(), NumTraits<Scalar>::HasFloatingPoint ? Scalar(1)/other : other);
return derived();
}
// template<typename OtherDerived>
// inline bool operator==(const DenseBase<OtherDerived>& other) const
// { return cwiseEqual(other).all(); }
//
//
// template<typename OtherDerived>
// inline bool operator!=(const DenseBase<OtherDerived>& other) const
// { return cwiseNotEqual(other).all(); }
@@ -446,12 +464,6 @@ template<typename Derived> class DenseBase
template<typename Visitor>
void visit(Visitor& func) const;
#ifndef EIGEN_PARSED_BY_DOXYGEN
using AnyMatrixBase<Derived>::derived;
inline Derived& const_cast_derived() const
{ return *static_cast<Derived*>(const_cast<DenseBase*>(this)); }
#endif // not EIGEN_PARSED_BY_DOXYGEN
inline const WithFormat<Derived> format(const IOFormat& fmt) const;
/////////// Array module ///////////

View File

@@ -52,7 +52,7 @@ enum { StreamPrecision = -1,
* Example: \include IOFormat.cpp
* Output: \verbinclude IOFormat.out
*
* \sa MatrixBase::format(), class WithFormat
* \sa DenseBase::format(), class WithFormat
*/
struct IOFormat
{
@@ -86,12 +86,12 @@ struct IOFormat
* \param ExpressionType the type of the object on which IO stream operations are performed
*
* This class represents an expression with stream operators controlled by a given IOFormat.
* It is the return type of MatrixBase::format()
* It is the return type of DenseBase::format()
* and most of the time this is the only way it is used.
*
* See class IOFormat for some examples.
*
* \sa MatrixBase::format(), class IOFormat
* \sa DenseBase::format(), class IOFormat
*/
template<typename ExpressionType>
class WithFormat
@@ -133,9 +133,9 @@ std::ostream & ei_print_matrix(std::ostream & s, const Derived& _m, const IOForm
{
const typename Derived::Nested m = _m;
typedef typename Derived::Scalar Scalar;
int width = 0;
std::streamsize explicit_precision;
if(fmt.precision == StreamPrecision)
{
@@ -151,7 +151,7 @@ std::ostream & ei_print_matrix(std::ostream & s, const Derived& _m, const IOForm
{
explicit_precision = fmt.precision;
}
bool align_cols = !(fmt.flags & DontAlignCols);
if(align_cols)
{

View File

@@ -69,89 +69,36 @@ template<typename Derived> class MatrixBase
typedef typename ei_packet_traits<Scalar>::type PacketScalar;
typedef DenseBase<Derived> Base;
using Base::RowsAtCompileTime;
using Base::ColsAtCompileTime;
using Base::SizeAtCompileTime;
using Base::MaxRowsAtCompileTime;
using Base::MaxColsAtCompileTime;
using Base::MaxSizeAtCompileTime;
using Base::IsVectorAtCompileTime;
using Base::Flags;
using Base::CoeffReadCost;
using Base::_HasDirectAccess;
using Base::derived;
using Base::const_cast_derived;
using Base::rows;
using Base::cols;
using Base::size;
using Base::coeff;
using Base::coeffRef;
using Base::lazyAssign;
using Base::operator=;
using Base::operator+=;
using Base::operator-=;
using Base::operator*=;
using Base::operator/=;
typedef typename Base::CoeffReturnType CoeffReturnType;
#endif // not EIGEN_PARSED_BY_DOXYGEN
enum {
RowsAtCompileTime = ei_traits<Derived>::RowsAtCompileTime,
/**< The number of rows at compile-time. This is just a copy of the value provided
* by the \a Derived type. If a value is not known at compile-time,
* it is set to the \a Dynamic constant.
* \sa MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime */
ColsAtCompileTime = ei_traits<Derived>::ColsAtCompileTime,
/**< The number of columns at compile-time. This is just a copy of the value provided
* by the \a Derived type. If a value is not known at compile-time,
* it is set to the \a Dynamic constant.
* \sa MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime */
SizeAtCompileTime = (ei_size_at_compile_time<ei_traits<Derived>::RowsAtCompileTime,
ei_traits<Derived>::ColsAtCompileTime>::ret),
/**< This is equal to the number of coefficients, i.e. the number of
* rows times the number of columns, or to \a Dynamic if this is not
* known at compile-time. \sa RowsAtCompileTime, ColsAtCompileTime */
MaxRowsAtCompileTime = ei_traits<Derived>::MaxRowsAtCompileTime,
/**< This value is equal to the maximum possible number of rows that this expression
* might have. If this expression might have an arbitrarily high number of rows,
* this value is set to \a Dynamic.
*
* This value is useful to know when evaluating an expression, in order to determine
* whether it is possible to avoid doing a dynamic memory allocation.
*
* \sa RowsAtCompileTime, MaxColsAtCompileTime, MaxSizeAtCompileTime
*/
MaxColsAtCompileTime = ei_traits<Derived>::MaxColsAtCompileTime,
/**< This value is equal to the maximum possible number of columns that this expression
* might have. If this expression might have an arbitrarily high number of columns,
* this value is set to \a Dynamic.
*
* This value is useful to know when evaluating an expression, in order to determine
* whether it is possible to avoid doing a dynamic memory allocation.
*
* \sa ColsAtCompileTime, MaxRowsAtCompileTime, MaxSizeAtCompileTime
*/
MaxSizeAtCompileTime = (ei_size_at_compile_time<ei_traits<Derived>::MaxRowsAtCompileTime,
ei_traits<Derived>::MaxColsAtCompileTime>::ret),
/**< This value is equal to the maximum possible number of coefficients that this expression
* might have. If this expression might have an arbitrarily high number of coefficients,
* this value is set to \a Dynamic.
*
* This value is useful to know when evaluating an expression, in order to determine
* whether it is possible to avoid doing a dynamic memory allocation.
*
* \sa SizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime
*/
IsVectorAtCompileTime = ei_traits<Derived>::RowsAtCompileTime == 1
|| ei_traits<Derived>::ColsAtCompileTime == 1,
/**< This is set to true if either the number of rows or the number of
* columns is known at compile-time to be equal to 1. Indeed, in that case,
* we are dealing with a column-vector (if there is only one column) or with
* a row-vector (if there is only one row). */
Flags = ei_traits<Derived>::Flags,
/**< This stores expression \ref flags flags which may or may not be inherited by new expressions
* constructed from this one. See the \ref flags "list of flags".
*/
CoeffReadCost = ei_traits<Derived>::CoeffReadCost,
/**< This is a rough measure of how expensive it is to read one coefficient from
* this expression.
*/
#ifndef EIGEN_PARSED_BY_DOXYGEN
_HasDirectAccess = (int(Flags)&DirectAccessBit) ? 1 : 0 // workaround sunCC
#endif
};
#ifndef EIGEN_PARSED_BY_DOXYGEN
/** This is the "real scalar" type; if the \a Scalar type is already real numbers
@@ -167,30 +114,9 @@ template<typename Derived> class MatrixBase
EIGEN_ENUM_MAX(RowsAtCompileTime,ColsAtCompileTime)> SquareMatrixType;
#endif // not EIGEN_PARSED_BY_DOXYGEN
/** \returns the number of rows. \sa cols(), RowsAtCompileTime */
// inline int rows() const { return derived().rows(); }
/** \returns the number of columns. \sa rows(), ColsAtCompileTime*/
// inline int cols() const { return derived().cols(); }
/** \returns the number of coefficients, which is rows()*cols().
* \sa rows(), cols(), SizeAtCompileTime. */
// inline int size() const { return rows() * cols(); }
/** \returns the size of the main diagonal, which is min(rows(),cols()).
* \sa rows(), cols(), SizeAtCompileTime. */
inline int diagonalSize() const { return std::min(rows(),cols()); }
/** \returns the number of nonzero coefficients which is in practice the number
* of stored coefficients. */
inline int nonZeros() const { return size(); }
/** \returns true if either the number of rows or the number of columns is equal to 1.
* In other words, this function returns
* \code rows()==1 || cols()==1 \endcode
* \sa rows(), cols(), IsVectorAtCompileTime. */
inline bool isVector() const { return rows()==1 || cols()==1; }
/** \returns the size of the storage major dimension,
* i.e., the number of columns for a columns major matrix, and the number of rows otherwise */
int outerSize() const { return (int(Flags)&RowMajorBit) ? this->rows() : this->cols(); }
/** \returns the size of the inner dimension according to the storage order,
* i.e., the number of rows for a columns major matrix, and the number of cols otherwise */
int innerSize() const { return (int(Flags)&RowMajorBit) ? this->cols() : this->rows(); }
/** Only plain matrices, not expressions may be resized; therefore the only useful resize method is
* Matrix::resize(). The present method only asserts that the new size equals the old size, and does
@@ -232,9 +158,6 @@ template<typename Derived> class MatrixBase
*/
// typedef typename ei_plain_matrix_type<Derived>::type PlainMatrixType_ColMajor;
/** \internal the return type of coeff()
*/
typedef typename ei_meta_if<_HasDirectAccess, const Scalar&, Scalar>::ret CoeffReturnType;
/** \internal Represents a matrix with all coefficients equal to one another*/
typedef CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> ConstantReturnType;
@@ -282,11 +205,6 @@ template<typename Derived> class MatrixBase
Derived& operator=(const ReturnByValue<OtherDerived>& func);
#ifndef EIGEN_PARSED_BY_DOXYGEN
using DenseBase<Derived>::lazyAssign;
/** Copies \a other into *this without evaluating other. \returns a reference to *this. */
// template<typename OtherDerived>
// Derived& lazyAssign(const MatrixBase<OtherDerived>& other);
template<typename ProductDerived, typename Lhs, typename Rhs>
Derived& lazyAssign(const ProductBase<ProductDerived, Lhs,Rhs>& other);
@@ -426,14 +344,6 @@ template<typename Derived> class MatrixBase
Scalar mean() const;
Scalar trace() const;
#ifndef EIGEN_PARSED_BY_DOXYGEN
using AnyMatrixBase<Derived>::derived;
inline Derived& const_cast_derived() const
{ return *static_cast<Derived*>(const_cast<MatrixBase*>(this)); }
#endif // not EIGEN_PARSED_BY_DOXYGEN
inline const WithFormat<Derived> format(const IOFormat& fmt) const;
/////////// Array module ///////////
const VectorwiseOp<Derived,Horizontal> rowwise() const;

View File

@@ -174,7 +174,7 @@ void fitHyperplane(int numPoints,
// let's compute the constant coefficient such that the
// plane pass trough the mean point:
result->offset() = - (result->normal().cwise()* mean).sum();
result->offset() = - (result->normal().cwiseProduct(mean)).sum();
}

View File

@@ -324,14 +324,14 @@ SparseMatrixBase<Derived>::operator+=(const SparseMatrixBase<OtherDerived>& othe
// {
// return EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE(_expression(), other.derived());
// }
//
// template<typename ExpressionType>
// template<typename OtherDerived>
// EIGEN_STRONG_INLINE const EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE
// SparseCwise<ExpressionType>::operator*(const MatrixBase<OtherDerived> &other) const
// {
// return EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE(_expression(), other.derived());
// }
template<typename Derived>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE
SparseMatrixBase<Derived>::cwiseProduct(const MatrixBase<OtherDerived> &other) const
{
return EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE(derived(), other.derived());
}
// template<typename ExpressionType>
// template<typename OtherDerived>

View File

@@ -121,24 +121,24 @@ class CwiseUnaryViewImpl<ViewOp,MatrixType,Sparse>::InnerIterator
const ViewOp m_functor;
};
// template<typename Derived>
// EIGEN_STRONG_INLINE Derived&
// SparseMatrixBase<Derived>::operator*=(const Scalar& other)
// {
// for (int j=0; j<outerSize(); ++j)
// for (typename Derived::InnerIterator i(derived(),j); i; ++i)
// i.valueRef() *= other;
// return derived();
// }
//
// template<typename Derived>
// EIGEN_STRONG_INLINE Derived&
// SparseMatrixBase<Derived>::operator/=(const Scalar& other)
// {
// for (int j=0; j<outerSize(); ++j)
// for (typename Derived::InnerIterator i(derived(),j); i; ++i)
// i.valueRef() /= other;
// return derived();
// }
template<typename Derived>
EIGEN_STRONG_INLINE Derived&
SparseMatrixBase<Derived>::operator*=(const Scalar& other)
{
for (int j=0; j<outerSize(); ++j)
for (typename Derived::InnerIterator i(derived(),j); i; ++i)
i.valueRef() *= other;
return derived();
}
template<typename Derived>
EIGEN_STRONG_INLINE Derived&
SparseMatrixBase<Derived>::operator/=(const Scalar& other)
{
for (int j=0; j<outerSize(); ++j)
for (typename Derived::InnerIterator i(derived(),j); i; ++i)
i.valueRef() /= other;
return derived();
}
#endif // EIGEN_SPARSE_CWISE_UNARY_OP_H

View File

@@ -133,7 +133,7 @@ class ei_sparse_diagonal_product_inner_iterator_selector
public:
inline ei_sparse_diagonal_product_inner_iterator_selector(
const SparseDiagonalProductType& expr, int outer)
: Base(expr.rhs().innerVector(outer) .cwise()* expr.lhs().diagonal(), 0)
: Base(expr.rhs().innerVector(outer) .cwiseProduct(expr.lhs().diagonal()), 0)
{}
};
@@ -165,7 +165,7 @@ class ei_sparse_diagonal_product_inner_iterator_selector
public:
inline ei_sparse_diagonal_product_inner_iterator_selector(
const SparseDiagonalProductType& expr, int outer)
: Base(expr.lhs().innerVector(outer) .cwise()* expr.rhs().diagonal().transpose().nestByValue(), 0)
: Base(expr.lhs().innerVector(outer) .cwiseProduct(expr.rhs().diagonal().transpose().nestByValue()), 0)
{}
};

View File

@@ -109,9 +109,19 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
Transpose<Derived>
>::ret AdjointReturnType;
// typedef Matrix<typename ei_traits<Derived>::Scalar,
// ei_traits<Derived>::RowsAtCompileTime,
// ei_traits<Derived>::ColsAtCompileTime,
// AutoAlign | (ei_traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor),
// ei_traits<Derived>::MaxRowsAtCompileTime,
// ei_traits<Derived>::MaxColsAtCompileTime
// > PlainMatrixType;
#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase
#include "../Core/CwiseUnaryOps.h"
#include "../Core/CwiseBinaryOps.h"
#include "../plugins/CommonCwiseUnaryOps.h"
#include "../plugins/CommonCwiseBinaryOps.h"
#include "../plugins/MatrixCwiseUnaryOps.h"
#include "../plugins/MatrixCwiseBinaryOps.h"
#undef EIGEN_CURRENT_STORAGE_BASE_CLASS
#ifndef EIGEN_PARSED_BY_DOXYGEN
@@ -307,8 +317,24 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
// template<typename Lhs,typename Rhs>
// Derived& operator+=(const Flagged<Product<Lhs,Rhs,CacheFriendlyProduct>, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit>& other);
// Derived& operator*=(const Scalar& other);
// Derived& operator/=(const Scalar& other);
Derived& operator*=(const Scalar& other);
Derived& operator/=(const Scalar& other);
#define EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE \
CwiseBinaryOp< \
ei_scalar_product_op< \
typename ei_scalar_product_traits< \
typename ei_traits<Derived>::Scalar, \
typename ei_traits<OtherDerived>::Scalar \
>::ReturnType \
>, \
Derived, \
OtherDerived \
>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE
cwiseProduct(const MatrixBase<OtherDerived> &other) const;
// const SparseCwiseUnaryOp<ei_scalar_multiple_op<typename ei_traits<Derived>::Scalar>, Derived>
// operator*(const Scalar& scalar) const;

View File

@@ -1,4 +1,29 @@
/** \returns an expression of the coefficient wise product of \c *this and \a other
*
* \sa MatrixBase::cwiseProduct
*/
#define EIGEN_CWISE_PRODUCT_RETURN_TYPE \
CwiseBinaryOp< \
ei_scalar_product_op< \
typename ei_scalar_product_traits< \
typename ei_traits<Derived>::Scalar, \
typename ei_traits<OtherDerived>::Scalar \
>::ReturnType \
>, \
Derived, \
OtherDerived \
>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE
operator*(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
{
return EIGEN_CWISE_PRODUCT_RETURN_TYPE(derived(), other.derived());
}
#undef EIGEN_CWISE_PRODUCT_RETURN_TYPE
/** \returns an expression of the coefficient-wise \< operator of *this and \a other
*
* Example: \include Cwise_less.cpp
@@ -16,13 +41,6 @@ EIGEN_MAKE_CWISE_BINARY_OP(operator<,std::less)
* \sa all(), any(), operator>=(), operator<()
*/
EIGEN_MAKE_CWISE_BINARY_OP(operator<=,std::less_equal)
// template<typename ExpressionType>
// template<typename OtherDerived>
// inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)
// operator<=(const MatrixBase<OtherDerived> &other) const
// {
// return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)(_expression(), other.derived());
// }
/** \returns an expression of the coefficient-wise \> operator of *this and \a other
*
@@ -32,13 +50,6 @@ EIGEN_MAKE_CWISE_BINARY_OP(operator<=,std::less_equal)
* \sa all(), any(), operator>=(), operator<()
*/
EIGEN_MAKE_CWISE_BINARY_OP(operator>,std::greater)
// template<typename ExpressionType>
// template<typename OtherDerived>
// inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)
// operator>(const MatrixBase<OtherDerived> &other) const
// {
// return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)(_expression(), other.derived());
// }
/** \returns an expression of the coefficient-wise \>= operator of *this and \a other
*
@@ -48,13 +59,6 @@ EIGEN_MAKE_CWISE_BINARY_OP(operator>,std::greater)
* \sa all(), any(), operator>(), operator<=()
*/
EIGEN_MAKE_CWISE_BINARY_OP(operator>=,std::greater_equal)
// template<typename ExpressionType>
// template<typename OtherDerived>
// inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)
// operator>=(const MatrixBase<OtherDerived> &other) const
// {
// return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)(_expression(), other.derived());
// }
/** \returns an expression of the coefficient-wise == operator of *this and \a other
*
@@ -106,7 +110,6 @@ EIGEN_MAKE_CWISE_BINARY_OP(operator!=,std::not_equal_to)
*
* \sa operator<(const MatrixBase<OtherDerived> &) const
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)
operator<(Scalar s) const
{
@@ -118,7 +121,6 @@ operator<(Scalar s) const
*
* \sa operator<=(const MatrixBase<OtherDerived> &) const
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)
operator<=(Scalar s) const
{
@@ -130,7 +132,6 @@ operator<=(Scalar s) const
*
* \sa operator>(const MatrixBase<OtherDerived> &) const
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)
operator>(Scalar s) const
{
@@ -142,7 +143,6 @@ operator>(Scalar s) const
*
* \sa operator>=(const MatrixBase<OtherDerived> &) const
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)
operator>=(Scalar s) const
{
@@ -159,7 +159,6 @@ operator>=(Scalar s) const
*
* \sa operator==(const MatrixBase<OtherDerived> &) const
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)
operator==(Scalar s) const
{
@@ -176,7 +175,6 @@ operator==(Scalar s) const
*
* \sa operator!=(const MatrixBase<OtherDerived> &) const
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)
operator!=(Scalar s) const
{
@@ -201,6 +199,12 @@ operator+(const Scalar& scalar) const
return CwiseUnaryOp<ei_scalar_add_op<Scalar>, Derived>(derived(), ei_scalar_add_op<Scalar>(scalar));
}
friend inline const CwiseUnaryOp<ei_scalar_add_op<Scalar>, Derived>
operator+(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other)
{
return other + scalar;
}
/** Adds the given \a scalar to each coeff of this expression.
*
* Example: \include Cwise_plus_equal.cpp
@@ -208,10 +212,9 @@ operator+(const Scalar& scalar) const
*
* \sa operator+(), operator-=()
*/
// template<typename ExpressionType>
// inline ExpressionType& operator+=(const Scalar& scalar)
// inline Derived& operator+=(const Scalar& scalar)
// {
// return m_matrix.const_cast_derived() = *this + scalar;
// return derived() = *this + scalar;
// }
/** \returns an expression of \c *this with each coeff decremented by the constant \a scalar
@@ -221,12 +224,17 @@ operator+(const Scalar& scalar) const
*
* \sa operator+(), operator-=()
*/
// template<typename ExpressionType>
// inline const typename ScalarAddReturnType
// operator-(const Scalar& scalar) const
// {
// return *this + (-scalar);
// }
inline const CwiseUnaryOp<ei_scalar_add_op<Scalar>, Derived>
operator-(const Scalar& scalar) const
{
return *this + (-scalar);
}
friend inline const CwiseUnaryOp<ei_scalar_add_op<Scalar>, Derived>
operator-(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other)
{
return other + (-scalar);
}
/** Substracts the given \a scalar from each coeff of this expression.
*
@@ -235,9 +243,7 @@ operator+(const Scalar& scalar) const
*
* \sa operator+=(), operator-()
*/
// template<typename ExpressionType>
// inline ExpressionType& operator-=(const Scalar& scalar)
// inline Derived& operator-=(const Scalar& scalar)
// {
// return m_matrix.const_cast_derived() = *this - scalar;
// return derived() = *this - scalar;
// }

View File

@@ -146,3 +146,17 @@ cube() const
{
return derived();
}
#define EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(METHOD_NAME,FUNCTOR) \
inline const CwiseUnaryOp<std::binder1st<FUNCTOR<Scalar> >,Derived> \
METHOD_NAME(Scalar s) const { \
return CwiseUnaryOp<std::binder1st<FUNCTOR<Scalar> >,Derived> \
(derived(), std::bind1st(FUNCTOR<Scalar>(), s)); \
}
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator==, std::equal_to);
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator!=, std::not_equal_to);
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator<, std::less);
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator<=, std::less_equal);
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator>, std::greater);
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator>=, std::greater_equal);

View File

@@ -58,18 +58,6 @@ typedef CwiseUnaryView<ei_scalar_imag_op<Scalar>, Derived> NonConstImagReturnTyp
EIGEN_STRONG_INLINE const CwiseUnaryOp<ei_scalar_opposite_op<typename ei_traits<Derived>::Scalar>,Derived>
operator-() const { return derived(); }
EIGEN_STRONG_INLINE Derived& operator*=(const Scalar& other)
{
SelfCwiseBinaryOp<ei_scalar_product_op<Scalar>, Derived> tmp(derived());
tmp = PlainMatrixType::Constant(rows(),cols(),other);
return derived();
}
EIGEN_STRONG_INLINE Derived& operator/=(const Scalar& other)
{
SelfCwiseBinaryOp<typename ei_meta_if<NumTraits<Scalar>::HasFloatingPoint,ei_scalar_product_op<Scalar>,ei_scalar_quotient_op<Scalar> >::ret, Derived> tmp(derived());
tmp = PlainMatrixType::Constant(rows(),cols(), NumTraits<Scalar>::HasFloatingPoint ? Scalar(1)/other : other);
return derived();
}
/** \returns an expression of \c *this scaled by the scalar factor \a scalar */
EIGEN_STRONG_INLINE const ScalarMultipleReturnType