Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
VectorwiseOp< ExpressionType, Direction > Class Template Reference

Pseudo expression providing partial reduction operations. More...

#include <VectorwiseOp.h>

List of all members.

Classes

struct  ExtendedType
struct  ReduxReturnType
struct  ReturnType

Public Types

enum  {
  IsVertical,
  IsHorizontal
}
enum  {
  HNormalized_Size,
  HNormalized_SizeMinusOne
}
typedef ExpressionType::PlainObject CrossReturnType
typedef internal::conditional
< internal::must_nest_by_value
< ExpressionType >::ret,
ExpressionType, ExpressionType & >
::type 
ExpressionTypeNested
typedef internal::remove_all
< ExpressionTypeNested >::type 
ExpressionTypeNestedCleaned
typedef Block< const
ExpressionType, Direction==Vertical?int(HNormalized_SizeMinusOne):int(internal::traits
< ExpressionType >
::RowsAtCompileTime),
Direction==Horizontal?int(HNormalized_SizeMinusOne):int(internal::traits
< ExpressionType >
::ColsAtCompileTime)> 
HNormalized_Block
typedef Block< const
ExpressionType, Direction==Vertical?1:int(internal::traits
< ExpressionType >
::RowsAtCompileTime),
Direction==Horizontal?1:int(internal::traits
< ExpressionType >
::ColsAtCompileTime)> 
HNormalized_Factors
typedef CwiseBinaryOp
< internal::scalar_quotient_op
< typename internal::traits
< ExpressionType >::Scalar >
, const HNormalized_Block,
const Replicate
< HNormalized_Factors,
Direction==Vertical?HNormalized_SizeMinusOne:1,
Direction==Horizontal?HNormalized_SizeMinusOne:1 > > 
HNormalizedReturnType
typedef ExpressionType::Index Index
typedef ExpressionType::RealScalar RealScalar
typedef Replicate
< ExpressionType, Direction==Vertical?Dynamic:1,
Direction==Horizontal?Dynamic:1 > 
ReplicateReturnType
typedef ExpressionType::Scalar Scalar

Public Member Functions

const ExpressionType & _expression () const
const ReturnType
< internal::member_all >::Type 
all () const
const ReturnType
< internal::member_any >::Type 
any () const
const ReturnType
< internal::member_blueNorm,
RealScalar >::Type 
blueNorm () const
const PartialReduxExpr
< ExpressionType,
internal::member_count< Index >
, Direction > 
count () const
template<typename OtherDerived >
const CrossReturnType cross (const MatrixBase< OtherDerived > &other) const
const HNormalizedReturnType hnormalized () const
Homogeneous< ExpressionType,
Direction > 
homogeneous () const
const ReturnType
< internal::member_hypotNorm,
RealScalar >::Type 
hypotNorm () const
const ReturnType
< internal::member_maxCoeff >
::Type 
maxCoeff () const
const ReturnType
< internal::member_mean >
::Type 
mean () const
const ReturnType
< internal::member_minCoeff >
::Type 
minCoeff () const
const ReturnType
< internal::member_norm,
RealScalar >::Type 
norm () const
template<typename OtherDerived >
CwiseBinaryOp
< internal::scalar_product_op
< Scalar >, const
ExpressionTypeNestedCleaned,
const typename ExtendedType
< OtherDerived >::Type > 
operator* (const DenseBase< OtherDerived > &other) const
template<typename OtherDerived >
ExpressionType & operator*= (const DenseBase< OtherDerived > &other)
template<typename OtherDerived >
CwiseBinaryOp
< internal::scalar_sum_op
< Scalar >, const
ExpressionTypeNestedCleaned,
const typename ExtendedType
< OtherDerived >::Type > 
operator+ (const DenseBase< OtherDerived > &other) const
template<typename OtherDerived >
ExpressionType & operator+= (const DenseBase< OtherDerived > &other)
template<typename OtherDerived >
CwiseBinaryOp
< internal::scalar_difference_op
< Scalar >, const
ExpressionTypeNestedCleaned,
const typename ExtendedType
< OtherDerived >::Type > 
operator- (const DenseBase< OtherDerived > &other) const
template<typename OtherDerived >
ExpressionType & operator-= (const DenseBase< OtherDerived > &other)
template<typename OtherDerived >
CwiseBinaryOp
< internal::scalar_quotient_op
< Scalar >, const
ExpressionTypeNestedCleaned,
const typename ExtendedType
< OtherDerived >::Type > 
operator/ (const DenseBase< OtherDerived > &other) const
template<typename OtherDerived >
ExpressionType & operator/= (const DenseBase< OtherDerived > &other)
template<typename OtherDerived >
ExpressionType & operator= (const DenseBase< OtherDerived > &other)
const ReturnType
< internal::member_prod >
::Type 
prod () const
template<typename BinaryOp >
const ReduxReturnType
< BinaryOp >::Type 
redux (const BinaryOp &func=BinaryOp()) const
const ReplicateReturnType replicate (Index factor) const
template<int Factor>
const Replicate
< ExpressionType,(IsVertical?Factor:1),(IsHorizontal?Factor:1)> 
replicate (Index factor=Factor) const
const Reverse< ExpressionType,
Direction > 
reverse () const
const ReturnType
< internal::member_squaredNorm,
RealScalar >::Type 
squaredNorm () const
const ReturnType
< internal::member_stableNorm,
RealScalar >::Type 
stableNorm () const
const ReturnType
< internal::member_sum >::Type 
sum () const
 VectorwiseOp (ExpressionType &matrix)

Protected Types

typedef internal::conditional
< Direction==Vertical,
typename
ExpressionType::ColXpr,
typename
ExpressionType::RowXpr >::type 
SubVector

Protected Member Functions

template<typename OtherDerived >
ExtendedType< OtherDerived >::Type extendedTo (const DenseBase< OtherDerived > &other) const
SubVector subVector (Index i)
Index subVectors () const

Protected Attributes

ExpressionTypeNested m_matrix

Detailed Description

template<typename ExpressionType, int Direction>
class Eigen::VectorwiseOp< ExpressionType, Direction >

Pseudo expression providing partial reduction operations.

Parameters:
ExpressionTypethe type of the object on which to do partial reductions
Directionindicates the direction of the redux (Vertical or Horizontal)

This class represents a pseudo expression with partial reduction features. It is the return type of DenseBase::colwise() and DenseBase::rowwise() and most of the time this is the only way it is used.

Example:

Matrix3d m = Matrix3d::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the sum of each column:" << endl << m.colwise().sum() << endl;
cout << "Here is the maximum absolute value of each column:"
     << endl << m.cwiseAbs().colwise().maxCoeff() << endl;

Output:

Here is the matrix m:
  0.68  0.597  -0.33
-0.211  0.823  0.536
 0.566 -0.605 -0.444
Here is the sum of each column:
  1.04  0.815 -0.238
Here is the maximum absolute value of each column:
 0.68 0.823 0.536
See also:
DenseBase::colwise(), DenseBase::rowwise(), class PartialReduxExpr

Member Typedef Documentation

typedef ExpressionType::PlainObject CrossReturnType
typedef internal::conditional<internal::must_nest_by_value<ExpressionType>::ret, ExpressionType, ExpressionType&>::type ExpressionTypeNested
typedef internal::remove_all<ExpressionTypeNested>::type ExpressionTypeNestedCleaned
typedef Block<const ExpressionType, Direction==Vertical ? int(HNormalized_SizeMinusOne) : int(internal::traits<ExpressionType>::RowsAtCompileTime), Direction==Horizontal ? int(HNormalized_SizeMinusOne) : int(internal::traits<ExpressionType>::ColsAtCompileTime)> HNormalized_Block
typedef Block<const ExpressionType, Direction==Vertical ? 1 : int(internal::traits<ExpressionType>::RowsAtCompileTime), Direction==Horizontal ? 1 : int(internal::traits<ExpressionType>::ColsAtCompileTime)> HNormalized_Factors
typedef CwiseBinaryOp<internal::scalar_quotient_op<typename internal::traits<ExpressionType>::Scalar>, const HNormalized_Block, const Replicate<HNormalized_Factors, Direction==Vertical ? HNormalized_SizeMinusOne : 1, Direction==Horizontal ? HNormalized_SizeMinusOne : 1> > HNormalizedReturnType
typedef ExpressionType::Index Index
typedef ExpressionType::RealScalar RealScalar
typedef Replicate<ExpressionType,Direction==Vertical?Dynamic:1,Direction==Horizontal?Dynamic:1> ReplicateReturnType
typedef ExpressionType::Scalar Scalar
typedef internal::conditional<Direction==Vertical, typename ExpressionType::ColXpr, typename ExpressionType::RowXpr>::type SubVector [protected]

Member Enumeration Documentation

anonymous enum
Enumerator:
IsVertical 
IsHorizontal 
anonymous enum
Enumerator:
HNormalized_Size 
HNormalized_SizeMinusOne 

Constructor & Destructor Documentation

VectorwiseOp ( ExpressionType &  matrix) [inline]

Member Function Documentation

const ExpressionType& _expression ( ) const [inline]
const ReturnType<internal::member_all>::Type all ( void  ) const [inline]
Returns:
a row (or column) vector expression representing whether all coefficients of each respective column (or row) are true.
See also:
DenseBase::all()
const ReturnType<internal::member_any>::Type any ( void  ) const [inline]
Returns:
a row (or column) vector expression representing whether at least one coefficient of each respective column (or row) is true.
See also:
DenseBase::any()
const ReturnType<internal::member_blueNorm,RealScalar>::Type blueNorm ( ) const [inline]
Returns:
a row (or column) vector expression of the norm of each column (or row) of the referenced expression, using blue's algorithm.
See also:
DenseBase::blueNorm()
const PartialReduxExpr<ExpressionType, internal::member_count<Index>, Direction> count ( ) const [inline]
Returns:
a row (or column) vector expression representing the number of true coefficients of each respective column (or row).

Example:

Matrix3d m = Matrix3d::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the count of elements larger or equal than 0.5 of each row:" << endl << (m.array() >= 0.5).rowwise().count() << endl;

Output:

Here is the matrix m:
  0.68  0.597  -0.33
-0.211  0.823  0.536
 0.566 -0.605 -0.444
Here is the count of elements larger or equal than 0.5 of each row:
2
2
1
See also:
DenseBase::count()
const VectorwiseOp< ExpressionType, Direction >::CrossReturnType cross ( const MatrixBase< OtherDerived > &  other) const
Returns:
a matrix expression of the cross product of each column or row of the referenced expression with the other vector.

The referenced matrix must have one dimension equal to 3. The result matrix has the same dimensions than the referenced one.

This is defined in the Geometry module.

 #include <Eigen/Geometry> 
See also:
MatrixBase::cross()

References DenseBase< Derived >::col(), conjugate(), EIGEN_STATIC_ASSERT, EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE, DenseBase< Derived >::row(), and Eigen::Vertical.

ExtendedType<OtherDerived>::Type extendedTo ( const DenseBase< OtherDerived > &  other) const [inline, protected]
const VectorwiseOp< ExpressionType, Direction >::HNormalizedReturnType hnormalized ( ) const [inline]

This is defined in the Geometry module.

 #include <Eigen/Geometry> 
Returns:
an expression of the homogeneous normalized vector of *this

Example:

Output:

See also:
MatrixBase::hnormalized()

References Eigen::Horizontal, and Eigen::Vertical.

Homogeneous< ExpressionType, Direction > homogeneous ( ) const [inline]

This is defined in the Geometry module.

 #include <Eigen/Geometry> 
Returns:
a matrix expression of homogeneous column (or row) vectors

Example:

Output:

See also:
MatrixBase::homogeneous()
const ReturnType<internal::member_hypotNorm,RealScalar>::Type hypotNorm ( ) const [inline]
Returns:
a row (or column) vector expression of the norm of each column (or row) of the referenced expression, avoiding underflow and overflow using a concatenation of hypot() calls.
See also:
DenseBase::hypotNorm()
const ReturnType<internal::member_maxCoeff>::Type maxCoeff ( ) const [inline]
Returns:
a row (or column) vector expression of the largest coefficient of each column (or row) of the referenced expression.

Example:

Matrix3d m = Matrix3d::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the maximum of each column:" << endl << m.colwise().maxCoeff() << endl;

Output:

Here is the matrix m:
  0.68  0.597  -0.33
-0.211  0.823  0.536
 0.566 -0.605 -0.444
Here is the maximum of each column:
 0.68 0.823 0.536
See also:
DenseBase::maxCoeff()
const ReturnType<internal::member_mean>::Type mean ( ) const [inline]
Returns:
a row (or column) vector expression of the mean of each column (or row) of the referenced expression.
See also:
DenseBase::mean()
const ReturnType<internal::member_minCoeff>::Type minCoeff ( ) const [inline]
Returns:
a row (or column) vector expression of the smallest coefficient of each column (or row) of the referenced expression.

Example:

Matrix3d m = Matrix3d::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the minimum of each column:" << endl << m.colwise().minCoeff() << endl;

Output:

Here is the matrix m:
  0.68  0.597  -0.33
-0.211  0.823  0.536
 0.566 -0.605 -0.444
Here is the minimum of each column:
-0.211 -0.605 -0.444
See also:
DenseBase::minCoeff()
const ReturnType<internal::member_norm,RealScalar>::Type norm ( ) const [inline]
Returns:
a row (or column) vector expression of the norm of each column (or row) of the referenced expression.

Example:

Matrix3d m = Matrix3d::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the norm of each column:" << endl << m.colwise().norm() << endl;

Output:

Here is the matrix m:
  0.68  0.597  -0.33
-0.211  0.823  0.536
 0.566 -0.605 -0.444
Here is the norm of each column:
 0.91  1.18 0.771
See also:
DenseBase::norm()
CwiseBinaryOp<internal::scalar_product_op<Scalar>, const ExpressionTypeNestedCleaned, const typename ExtendedType<OtherDerived>::Type> operator* ( const DenseBase< OtherDerived > &  other) const [inline]

Returns the expression where each subvector is the product of the vector other by the corresponding subvector of *this

References EIGEN_STATIC_ASSERT_ARRAYXPR, EIGEN_STATIC_ASSERT_SAME_XPR_KIND, and EIGEN_STATIC_ASSERT_VECTOR_ONLY.

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

Multiples each subvector of *this by the vector other

References EIGEN_STATIC_ASSERT_ARRAYXPR, EIGEN_STATIC_ASSERT_SAME_XPR_KIND, and EIGEN_STATIC_ASSERT_VECTOR_ONLY.

CwiseBinaryOp<internal::scalar_sum_op<Scalar>, const ExpressionTypeNestedCleaned, const typename ExtendedType<OtherDerived>::Type> operator+ ( const DenseBase< OtherDerived > &  other) const [inline]

Returns the expression of the sum of the vector other to each subvector of *this

References EIGEN_STATIC_ASSERT_SAME_XPR_KIND, and EIGEN_STATIC_ASSERT_VECTOR_ONLY.

ExpressionType& operator+= ( const DenseBase< OtherDerived > &  other) [inline]

Adds the vector other to each subvector of *this

References EIGEN_STATIC_ASSERT_SAME_XPR_KIND, and EIGEN_STATIC_ASSERT_VECTOR_ONLY.

CwiseBinaryOp<internal::scalar_difference_op<Scalar>, const ExpressionTypeNestedCleaned, const typename ExtendedType<OtherDerived>::Type> operator- ( const DenseBase< OtherDerived > &  other) const [inline]

Returns the expression of the difference between each subvector of *this and the vector other

References EIGEN_STATIC_ASSERT_SAME_XPR_KIND, and EIGEN_STATIC_ASSERT_VECTOR_ONLY.

ExpressionType& operator-= ( const DenseBase< OtherDerived > &  other) [inline]

Substracts the vector other to each subvector of *this

References EIGEN_STATIC_ASSERT_SAME_XPR_KIND, and EIGEN_STATIC_ASSERT_VECTOR_ONLY.

CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const ExpressionTypeNestedCleaned, const typename ExtendedType<OtherDerived>::Type> operator/ ( const DenseBase< OtherDerived > &  other) const [inline]

Returns the expression where each subvector is the quotient of the corresponding subvector of *this by the vector other

References EIGEN_STATIC_ASSERT_ARRAYXPR, EIGEN_STATIC_ASSERT_SAME_XPR_KIND, and EIGEN_STATIC_ASSERT_VECTOR_ONLY.

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

Divides each subvector of *this by the vector other

References EIGEN_STATIC_ASSERT_ARRAYXPR, EIGEN_STATIC_ASSERT_SAME_XPR_KIND, and EIGEN_STATIC_ASSERT_VECTOR_ONLY.

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

Copies the vector other to each subvector of *this

References EIGEN_STATIC_ASSERT_SAME_XPR_KIND, and EIGEN_STATIC_ASSERT_VECTOR_ONLY.

const ReturnType<internal::member_prod>::Type prod ( ) const [inline]
Returns:
a row (or column) vector expression of the product of each column (or row) of the referenced expression.

Example:

Matrix3d m = Matrix3d::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the product of each row:" << endl << m.rowwise().prod() << endl;

Output:

Here is the matrix m:
  0.68  0.597  -0.33
-0.211  0.823  0.536
 0.566 -0.605 -0.444
Here is the product of each row:
-0.134
-0.0933
0.152
See also:
DenseBase::prod()
const ReduxReturnType<BinaryOp>::Type redux ( const BinaryOp &  func = BinaryOp()) const [inline]
Returns:
a row or column vector expression of *this reduxed by func

The template parameter BinaryOp is the type of the functor of the custom redux operator. Note that func must be an associative operator.

See also:
class VectorwiseOp, DenseBase::colwise(), DenseBase::rowwise()
const VectorwiseOp< ExpressionType, Direction >::ReplicateReturnType replicate ( Index  factor) const
Returns:
an expression of the replication of each column (or row) of *this

Example:

Vector3i v = Vector3i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "v.rowwise().replicate(5) = ..." << endl;
cout << v.rowwise().replicate(5) << endl;

Output:

Here is the vector v:
7
-2
6
v.rowwise().replicate(5) = ...
 7  7  7  7  7
-2 -2 -2 -2 -2
 6  6  6  6  6
See also:
VectorwiseOp::replicate(), DenseBase::replicate(), class Replicate

References Eigen::Horizontal, and Eigen::Vertical.

const Replicate<ExpressionType,(IsVertical?Factor:1),(IsHorizontal?Factor:1)> replicate ( Index  factor = Factor) const [inline]
Returns:
an expression of the replication of each column (or row) of *this

Example:

MatrixXi m = MatrixXi::Random(2,3);
cout << "Here is the matrix m:" << endl << m << endl;
cout << "m.colwise().replicate<3>() = ..." << endl;
cout << m.colwise().replicate<3>() << endl;

Output:

Here is the matrix m:
 7  6  9
-2  6 -6
m.colwise().replicate<3>() = ...
 7  6  9
-2  6 -6
 7  6  9
-2  6 -6
 7  6  9
-2  6 -6
See also:
VectorwiseOp::replicate(Index), DenseBase::replicate(), class Replicate

References Eigen::Horizontal, and Eigen::Vertical.

const Reverse<ExpressionType, Direction> reverse ( ) const [inline]
Returns:
a matrix expression where each column (or row) are reversed.

Example:

MatrixXi m = MatrixXi::Random(3,4);
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the rowwise reverse of m:" << endl << m.rowwise().reverse() << endl;
cout << "Here is the colwise reverse of m:" << endl << m.colwise().reverse() << endl;

cout << "Here is the coefficient (1,0) in the rowise reverse of m:" << endl
<< m.rowwise().reverse()(1,0) << endl;
cout << "Let us overwrite this coefficient with the value 4." << endl;
//m.colwise().reverse()(1,0) = 4;
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  6 -3  1
-2  9  6  0
 6 -6 -5  3
Here is the rowwise reverse of m:
 1 -3  6  7
 0  6  9 -2
 3 -5 -6  6
Here is the colwise reverse of m:
 6 -6 -5  3
-2  9  6  0
 7  6 -3  1
Here is the coefficient (1,0) in the rowise reverse of m:
0
Let us overwrite this coefficient with the value 4.
Now the matrix m is:
 7  6 -3  1
-2  9  6  0
 6 -6 -5  3
See also:
DenseBase::reverse()
const ReturnType<internal::member_squaredNorm,RealScalar>::Type squaredNorm ( ) const [inline]
Returns:
a row (or column) vector expression of the squared norm of each column (or row) of the referenced expression.

Example:

Matrix3d m = Matrix3d::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the square norm of each row:" << endl << m.rowwise().squaredNorm() << endl;

Output:

Here is the matrix m:
  0.68  0.597  -0.33
-0.211  0.823  0.536
 0.566 -0.605 -0.444
Here is the square norm of each row:
0.928
1.01
0.884
See also:
DenseBase::squaredNorm()
const ReturnType<internal::member_stableNorm,RealScalar>::Type stableNorm ( ) const [inline]
Returns:
a row (or column) vector expression of the norm of each column (or row) of the referenced expression, avoiding underflow and overflow.
See also:
DenseBase::stableNorm()
SubVector subVector ( Index  i) [inline, protected]
Index subVectors ( ) const [inline, protected]

References Eigen::Vertical.

const ReturnType<internal::member_sum>::Type sum ( ) const [inline]
Returns:
a row (or column) vector expression of the sum of each column (or row) of the referenced expression.

Example:

Matrix3d m = Matrix3d::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the sum of each row:" << endl << m.rowwise().sum() << endl;

Output:

Here is the matrix m:
  0.68  0.597  -0.33
-0.211  0.823  0.536
 0.566 -0.605 -0.444
Here is the sum of each row:
0.948
1.15
-0.483
See also:
DenseBase::sum()

Referenced by main().


Member Data Documentation


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