Cwise Class Template Reference

List of all members.


Detailed Description

template<typename ExpressionType>
class Eigen::Cwise< ExpressionType >

Pseudo expression providing additional coefficient-wise operations.

Parameters:
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.

Note that some methods are defined in the Array module.

Example:

Vector3d v(-1,2,-3);
cout << "the absolute values:" << endl << v.cwise().abs() << endl;
cout << "the absolute values plus one:" << endl << v.cwise().abs().cwise()+1 << endl;
cout << "sum of the squares: " << v.cwise().square().sum() << endl;
Output:
the absolute values:
1
2
3
the absolute values plus one:
2
3
4
sum of the squares: 14

See also:
MatrixBase::cwise() const, MatrixBase::cwise()

Public Types

typedef ei_meta_if
< ei_must_nest_by_value
< ExpressionType >::ret,
ExpressionType, const
ExpressionType & >::ret 
ExpressionTypeNested
typedef ei_traits
< ExpressionType >::Scalar 
Scalar
typedef CwiseUnaryOp
< ei_scalar_add_op< Scalar >
, ExpressionType > 
ScalarAddReturnType

Public Member Functions

const ExpressionType & _expression () const
const CwiseUnaryOp
< ei_scalar_abs_op< typename
ei_traits< ExpressionType >
::Scalar >, ExpressionType > 
abs () const
const CwiseUnaryOp
< ei_scalar_abs2_op< typename
ei_traits< ExpressionType >
::Scalar >, ExpressionType > 
abs2 () const
const CwiseUnaryOp
< ei_scalar_cos_op< typename
ei_traits< ExpressionType >
::Scalar >, ExpressionType > 
cos () const
const CwiseUnaryOp
< ei_scalar_cube_op< typename
ei_traits< ExpressionType >
::Scalar >, ExpressionType > 
cube () const
 Cwise (const ExpressionType &matrix)
const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE (std::not_equal_to) operator!
const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE (std::equal_to) operator
const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE (std::greater_equal) operator>
const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE (std::greater) operator>(Scalar s) const
const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE (std::less_equal) operator<
const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE (std::less) operator<(Scalar s) const
const CwiseUnaryOp
< ei_scalar_exp_op< typename
ei_traits< ExpressionType >
::Scalar >, ExpressionType > 
exp () const
const CwiseUnaryOp
< ei_scalar_inverse_op
< typename ei_traits
< ExpressionType >::Scalar >
, ExpressionType > 
inverse () const
const CwiseUnaryOp
< ei_scalar_log_op< typename
ei_traits< ExpressionType >
::Scalar >, ExpressionType > 
log () const
template<typename OtherDerived>
const CwiseBinaryOp
< ei_scalar_max_op< typename
ei_traits< ExpressionType >
::Scalar >, ExpressionType,
OtherDerived > 
max (const MatrixBase< OtherDerived > &other) const
template<typename OtherDerived>
const CwiseBinaryOp
< ei_scalar_min_op< typename
ei_traits< ExpressionType >
::Scalar >, ExpressionType,
OtherDerived > 
min (const MatrixBase< OtherDerived > &other) const
template<typename OtherDerived>
const CwiseBinaryOp
< std::not_equal_to< typename
ei_traits< ExpressionType >
::Scalar >, ExpressionType,
OtherDerived > 
operator!= (const MatrixBase< OtherDerived > &other) const
template<typename OtherDerived>
const
EIGEN_CWISE_PRODUCT_RETURN_TYPE 
operator* (const MatrixBase< OtherDerived > &other) const
template<typename OtherDerived>
ExpressionType & operator*= (const MatrixBase< OtherDerived > &other)
const ScalarAddReturnType operator+ (const Scalar &scalar) const
ExpressionType & operator+= (const Scalar &scalar)
const ScalarAddReturnType operator- (const Scalar &scalar) const
ExpressionType & operator-= (const Scalar &scalar)
template<typename OtherDerived>
const CwiseBinaryOp
< ei_scalar_quotient_op
< typename ei_traits
< ExpressionType >::Scalar >
, ExpressionType, OtherDerived > 
operator/ (const MatrixBase< OtherDerived > &other) const
template<typename OtherDerived>
ExpressionType & operator/= (const MatrixBase< OtherDerived > &other)
template<typename OtherDerived>
const CwiseBinaryOp< std::less
< typename ei_traits
< ExpressionType >::Scalar >
, ExpressionType, OtherDerived > 
operator< (const MatrixBase< OtherDerived > &other) const
template<typename OtherDerived>
const CwiseBinaryOp
< std::less_equal< typename
ei_traits< ExpressionType >
::Scalar >, ExpressionType,
OtherDerived > 
operator<= (const MatrixBase< OtherDerived > &other) const
template<typename OtherDerived>
const CwiseBinaryOp
< std::equal_to< typename
ei_traits< ExpressionType >
::Scalar >, ExpressionType,
OtherDerived > 
operator== (const MatrixBase< OtherDerived > &other) const
template<typename OtherDerived>
const CwiseBinaryOp
< std::greater< typename
ei_traits< ExpressionType >
::Scalar >, ExpressionType,
OtherDerived > 
operator> (const MatrixBase< OtherDerived > &other) const
template<typename OtherDerived>
const CwiseBinaryOp
< std::greater_equal< typename
ei_traits< ExpressionType >
::Scalar >, ExpressionType,
OtherDerived > 
operator>= (const MatrixBase< OtherDerived > &other) const
const CwiseUnaryOp
< ei_scalar_pow_op< typename
ei_traits< ExpressionType >
::Scalar >, ExpressionType > 
pow (const Scalar &exponent) const
const CwiseUnaryOp
< ei_scalar_sin_op< typename
ei_traits< ExpressionType >
::Scalar >, ExpressionType > 
sin () const
const CwiseUnaryOp
< ei_scalar_sqrt_op< typename
ei_traits< ExpressionType >
::Scalar >, ExpressionType > 
sqrt () const
const CwiseUnaryOp
< ei_scalar_square_op
< typename ei_traits
< ExpressionType >::Scalar >
, ExpressionType > 
square () const

Protected Attributes

ExpressionTypeNested m_matrix

Related Functions

(Note that these are not member functions.)

const ScalarAddReturnType operator+ (const Scalar &scalar, const Cwise &mat)

Member Function Documentation

const CwiseUnaryOp< ei_scalar_abs_op< typename ei_traits< ExpressionType >::Scalar >, ExpressionType > abs (  )  const [inline]

Returns:
an expression of the coefficient-wise absolute value of *this
Example:
Vector3d v(1,-2,-3);
cout << v.cwise().abs() << endl;
Output:
1
2
3

See also:
abs2()

const CwiseUnaryOp< ei_scalar_abs2_op< typename ei_traits< ExpressionType >::Scalar >, ExpressionType > abs2 (  )  const [inline]

Returns:
an expression of the coefficient-wise squared absolute value of *this
Example:
Vector3d v(1,-2,-3);
cout << v.cwise().abs2() << endl;
Output:
1
4
9

See also:
abs(), square()

const CwiseUnaryOp< ei_scalar_cos_op< typename ei_traits< ExpressionType >::Scalar >, ExpressionType > cos (  )  const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Returns:
an expression of the coefficient-wise cosine of *this.
Example:
Vector3d v(M_PI, M_PI/2, M_PI/3);
cout << v.cwise().cos() << endl;
Output:
-1
6.12e-17
0.5

See also:
sin(), exp()

const CwiseUnaryOp< ei_scalar_cube_op< typename ei_traits< ExpressionType >::Scalar >, ExpressionType > cube (  )  const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Returns:
an expression of the coefficient-wise cube of *this.
Example:
Vector3d v(2,3,4);
cout << v.cwise().cube() << endl;
Output:
8
27
64

See also:
square(), pow()

const CwiseUnaryOp< ei_scalar_exp_op< typename ei_traits< ExpressionType >::Scalar >, ExpressionType > exp (  )  const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Returns:
an expression of the coefficient-wise exponential of *this.
Example:
Vector3d v(1,2,3);
cout << v.cwise().exp() << endl;
Output:
2.72
7.39
20.1

See also:
pow(), log(), sin(), cos()

const CwiseUnaryOp< ei_scalar_inverse_op< typename ei_traits< ExpressionType >::Scalar >, ExpressionType > inverse (  )  const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Returns:
an expression of the coefficient-wise inverse of *this.
Example:
Vector3d v(2,3,4);
cout << v.cwise().inverse() << endl;
Output:
0.5
0.333
0.25

See also:
operator/(), operator*()

const CwiseUnaryOp< ei_scalar_log_op< typename ei_traits< ExpressionType >::Scalar >, ExpressionType > log (  )  const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Returns:
an expression of the coefficient-wise logarithm of *this.
Example:
Vector3d v(1,2,3);
cout << v.cwise().log() << endl;
Output:
0
0.693
1.1

See also:
exp()

const CwiseBinaryOp< ei_scalar_max_op< typename ei_traits< ExpressionType >::Scalar >, ExpressionType, OtherDerived > max ( const MatrixBase< OtherDerived > &  other  )  const [inline]

Returns:
an expression of the coefficient-wise max of *this and other
Example:
Vector3d v(2,3,4), w(4,2,3);
cout << v.cwise().max(w) << endl;
Output:
4
3
4

See also:
class CwiseBinaryOp

const CwiseBinaryOp< ei_scalar_min_op< typename ei_traits< ExpressionType >::Scalar >, ExpressionType, OtherDerived > min ( const MatrixBase< OtherDerived > &  other  )  const [inline]

Returns:
an expression of the coefficient-wise min of *this and other
Example:
Vector3d v(2,3,4), w(4,2,3);
cout << v.cwise().min(w) << endl;
Output:
2
2
3

See also:
class CwiseBinaryOp

const CwiseBinaryOp< std::not_equal_to< typename ei_traits< ExpressionType >::Scalar >, ExpressionType, OtherDerived > operator!= ( const MatrixBase< OtherDerived > &  other  )  const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Returns:
an expression of the coefficient-wise != operator of *this and other
Warning:
this performs an exact comparison, which is generally a bad idea with floating-point types. In order to check for equality between two vectors or matrices with floating-point coefficients, it is generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and MatrixBase::isMuchSmallerThan().
Example:
Vector3d v(1,2,3), w(3,2,1);
cout << (v.cwise()!=w) << endl;
Output:
1
0
1

See also:
MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan()

const EIGEN_CWISE_PRODUCT_RETURN_TYPE operator* ( const MatrixBase< OtherDerived > &  other  )  const [inline]

Returns:
an expression of the Schur product (coefficient wise product) of *this and other
Example:
Matrix3i a = Matrix3i::Random(), b = Matrix3i::Random();
Matrix3i c = a.cwise() * b;
cout << "a:\n" << a << "\nb:\n" << b << "\nc:\n" << c << endl;

Output:
a:
 7  6 -3
-2  9  6
 6 -6 -5
b:
 1 -3  9
 0  0  3
 3  9  5
c:
  7 -18 -27
  0   0  18
 18 -54 -25

See also:
class CwiseBinaryOp, operator/(), square()

ExpressionType & operator*= ( const MatrixBase< OtherDerived > &  other  )  [inline]

Replaces this expression by its coefficient-wise product with other.

Example:

Vector3d v(1,2,3);
Vector3d w(2,3,0);
v.cwise() *= w;
cout << v << endl;
Output:
2
6
0

See also:
operator*(), operator/=()

const Cwise< ExpressionType >::ScalarAddReturnType operator+ ( const Scalar &  scalar  )  const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Returns:
an expression of *this with each coeff incremented by the constant scalar
Example:
Vector3d v(1,2,3);
cout << v.cwise()+5 << endl;
Output:
6
7
8

See also:
operator+=(), operator-()

ExpressionType & operator+= ( const Scalar &  scalar  )  [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Adds the given scalar to each coeff of this expression.

Example:

Vector3d v(1,2,3);
v.cwise() += 5;
cout << v << endl;
Output:
6
7
8

See also:
operator+(), operator-=()

const Cwise< ExpressionType >::ScalarAddReturnType operator- ( const Scalar &  scalar  )  const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Returns:
an expression of *this with each coeff decremented by the constant scalar
Example:
Vector3d v(1,2,3);
cout << v.cwise()-5 << endl;
Output:
-4
-3
-2

See also:
operator+(), operator-=()

ExpressionType & operator-= ( const Scalar &  scalar  )  [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Substracts the given scalar from each coeff of this expression.

Example:

Vector3d v(1,2,3);
v.cwise() -= 5;
cout << v << endl;
Output:
-4
-3
-2

See also:
operator+=(), operator-()

const CwiseBinaryOp< ei_scalar_quotient_op< typename ei_traits< ExpressionType >::Scalar >, ExpressionType, OtherDerived > operator/ ( const MatrixBase< OtherDerived > &  other  )  const [inline]

Returns:
an expression of the coefficient-wise quotient of *this and other
Example:
Vector3d v(2,3,4), w(4,2,3);
cout << v.cwise()/w << endl;
Output:
0.5
1.5
1.33

See also:
class CwiseBinaryOp, operator*(), inverse()

ExpressionType & operator/= ( const MatrixBase< OtherDerived > &  other  )  [inline]

Replaces this expression by its coefficient-wise quotient by other.

Example:

Vector3d v(3,2,4);
Vector3d w(5,4,2);
v.cwise() /= w;
cout << v << endl;
Output:
0.6
0.5
2

See also:
operator/(), operator*=()

const CwiseBinaryOp< std::less< typename ei_traits< ExpressionType >::Scalar >, ExpressionType, OtherDerived > operator< ( const MatrixBase< OtherDerived > &  other  )  const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Returns:
an expression of the coefficient-wise < operator of *this and other
Example:
Vector3d v(1,2,3), w(3,2,1);
cout << (v.cwise()<w) << endl;
Output:
1
0
0

See also:
MatrixBase::all(), MatrixBase::any(), operator>(), operator<=()

const CwiseBinaryOp< std::less_equal< typename ei_traits< ExpressionType >::Scalar >, ExpressionType, OtherDerived > operator<= ( const MatrixBase< OtherDerived > &  other  )  const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Returns:
an expression of the coefficient-wise <= operator of *this and other
Example:
Vector3d v(1,2,3), w(3,2,1);
cout << (v.cwise()<=w) << endl;
Output:
1
1
0

See also:
MatrixBase::all(), MatrixBase::any(), operator>=(), operator<()

const CwiseBinaryOp< std::equal_to< typename ei_traits< ExpressionType >::Scalar >, ExpressionType, OtherDerived > operator== ( const MatrixBase< OtherDerived > &  other  )  const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Returns:
an expression of the coefficient-wise == operator of *this and other
Warning:
this performs an exact comparison, which is generally a bad idea with floating-point types. In order to check for equality between two vectors or matrices with floating-point coefficients, it is generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and MatrixBase::isMuchSmallerThan().
Example:
Vector3d v(1,2,3), w(3,2,1);
cout << (v.cwise()==w) << endl;
Output:
0
1
0

See also:
MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan()

const CwiseBinaryOp< std::greater< typename ei_traits< ExpressionType >::Scalar >, ExpressionType, OtherDerived > operator> ( const MatrixBase< OtherDerived > &  other  )  const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Returns:
an expression of the coefficient-wise > operator of *this and other
Example:
Vector3d v(1,2,3), w(3,2,1);
cout << (v.cwise()>w) << endl;
Output:
0
0
1

See also:
MatrixBase::all(), MatrixBase::any(), operator>=(), operator<()

const CwiseBinaryOp< std::greater_equal< typename ei_traits< ExpressionType >::Scalar >, ExpressionType, OtherDerived > operator>= ( const MatrixBase< OtherDerived > &  other  )  const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Returns:
an expression of the coefficient-wise >= operator of *this and other
Example:
Vector3d v(1,2,3), w(3,2,1);
cout << (v.cwise()>=w) << endl;
Output:
0
1
1

See also:
MatrixBase::all(), MatrixBase::any(), operator>(), operator<=()

const CwiseUnaryOp< ei_scalar_pow_op< typename ei_traits< ExpressionType >::Scalar >, ExpressionType > pow ( const Scalar &  exponent  )  const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Returns:
an expression of the coefficient-wise power of *this to the given exponent.
Example:
Vector3d v(8,27,64);
cout << v.cwise().pow(0.333333) << endl;
Output:
2
3
4

See also:
exp(), log()

const CwiseUnaryOp< ei_scalar_sin_op< typename ei_traits< ExpressionType >::Scalar >, ExpressionType > sin (  )  const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Returns:
an expression of the coefficient-wise sine of *this.
Example:
Vector3d v(M_PI, M_PI/2, M_PI/3);
cout << v.cwise().sin() << endl;
Output:
1.22e-16
1
0.866

See also:
cos(), exp()

const CwiseUnaryOp< ei_scalar_sqrt_op< typename ei_traits< ExpressionType >::Scalar >, ExpressionType > sqrt (  )  const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Returns:
an expression of the coefficient-wise square root of *this.
Example:
Vector3d v(1,2,4);
cout << v.cwise().sqrt() << endl;
Output:
1
1.41
2

See also:
pow(), square()

const CwiseUnaryOp< ei_scalar_square_op< typename ei_traits< ExpressionType >::Scalar >, ExpressionType > square (  )  const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Returns:
an expression of the coefficient-wise square of *this.
Example:
Vector3d v(2,3,4);
cout << v.cwise().square() << endl;
Output:
4
9
16

See also:
operator/(), operator*(), abs2()


Friends And Related Function Documentation

const ScalarAddReturnType operator+ ( const Scalar &  scalar,
const Cwise< ExpressionType > &  mat 
) [friend]


The documentation for this class was generated from the following files:

Generated on Thu Apr 9 10:10:01 2009 for Eigen by  doxygen 1.5.5