Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9 Eigen  3.3.9 Eigen::VectorwiseOp< ExpressionType, Direction > Class Template Reference

## Detailed Description

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

Pseudo expression providing partial reduction operations.

Template Parameters
 ExpressionType the type of the object on which to do partial reductions Direction indicates 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:
-1 -0.0827  -0.906
-0.737  0.0655   0.358
0.511  -0.562   0.359
Here is the sum of each column:
-1.23 -0.579  -0.19
Here is the maximum absolute value of each column:
1 0.562 0.906

See also
DenseBase::colwise(), DenseBase::rowwise(), class PartialReduxExpr

## Public Types

typedef Eigen::Index Index

## Public Member Functions

const AllReturnType all () const

const AnyReturnType any () const

const BlueNormReturnType blueNorm () const

const CountReturnType count () const

template<typename OtherDerived >
const CrossReturnType cross (const MatrixBase< OtherDerived > &other) const

const HNormalizedReturnType hnormalized () const
column or row-wise homogeneous normalization More...

HomogeneousReturnType homogeneous () const

const HypotNormReturnType hypotNorm () const

template<int p>
const LpNormReturnType< p >::Type lpNorm () const

const MaxCoeffReturnType maxCoeff () const

const MeanReturnType mean () const

const MinCoeffReturnType minCoeff () const

const NormReturnType norm () const

void normalize ()

CwiseBinaryOp< internal::scalar_quotient_op< Scalar >, const ExpressionTypeNestedCleaned, const typename OppositeExtendedType< typename ReturnType< internal::member_norm, RealScalar >::Type >::Type > normalized () 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, typename OtherDerived::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, typename OtherDerived::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 ProdReturnType 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+isHorizontal, isHorizontal *Factor+isVertical > replicate (Index factor=Factor) const

ReverseReturnType reverse ()

const ConstReverseReturnType reverse () const

void reverseInPlace ()

const SquaredNormReturnType squaredNorm () const

const StableNormReturnType stableNorm () const

const SumReturnType sum () const

## ◆ Index

template<typename ExpressionType , int Direction>
 typedef Eigen::Index Eigen::VectorwiseOp< ExpressionType, Direction >::Index
Deprecated:
since Eigen 3.3

## ◆ all()

template<typename ExpressionType , int Direction>
 const AllReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::all ( ) const
inline
Returns
a row (or column) vector expression representing whether all coefficients of each respective column (or row) are true. This expression can be assigned to a vector with entries of type bool.
See also
DenseBase::all()

## ◆ any()

template<typename ExpressionType , int Direction>
 const AnyReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::any ( ) const
inline
Returns
a row (or column) vector expression representing whether at least one coefficient of each respective column (or row) is true. This expression can be assigned to a vector with entries of type bool.
See also
DenseBase::any()

## ◆ blueNorm()

template<typename ExpressionType , int Direction>
 const BlueNormReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::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. This is a vector with real entries, even if the original matrix has complex entries.
See also
DenseBase::blueNorm()

## ◆ count()

template<typename ExpressionType , int Direction>
 const CountReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::count ( ) const
inline
Returns
a row (or column) vector expression representing the number of true coefficients of each respective column (or row). This expression can be assigned to a vector whose entries have the same type as is used to index entries of the original matrix; for dense matrices, this is std::ptrdiff_t .

Example:

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

Output:

Here is the matrix m:
-1 -0.0827  -0.906
-0.737  0.0655   0.358
0.511  -0.562   0.359
Here is the count of elements larger or equal than 0.5 of each row:
0
0
1

See also
DenseBase::count()

## ◆ hypotNorm()

template<typename ExpressionType , int Direction>
 const HypotNormReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::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. This is a vector with real entries, even if the original matrix has complex entries.
See also
DenseBase::hypotNorm()

## ◆ lpNorm()

template<typename ExpressionType , int Direction>
template<int p>
 const LpNormReturnType

::Type Eigen::VectorwiseOp< ExpressionType, Direction >::lpNorm ( ) const

inline
Returns
a row (or column) vector expression of the norm of each column (or row) of the referenced expression. This is a vector with real entries, even if the original matrix has complex entries.

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:
-1 -0.0827  -0.906
-0.737  0.0655   0.358
0.511  -0.562   0.359
Here is the norm of each column:
1.34 0.572  1.04

See also
DenseBase::norm()

## ◆ maxCoeff()

template<typename ExpressionType , int Direction>
 const MaxCoeffReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::maxCoeff ( ) const
inline
Returns
a row (or column) vector expression of the largest coefficient of each column (or row) of the referenced expression.
Warning
the result is undefined if *this contains NaN.

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:
-1 -0.0827  -0.906
-0.737  0.0655   0.358
0.511  -0.562   0.359
Here is the maximum of each column:
0.511 0.0655  0.359

See also
DenseBase::maxCoeff()

## ◆ mean()

template<typename ExpressionType , int Direction>
 const MeanReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::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()

## ◆ minCoeff()

template<typename ExpressionType , int Direction>
 const MinCoeffReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::minCoeff ( ) const
inline
Returns
a row (or column) vector expression of the smallest coefficient of each column (or row) of the referenced expression.
Warning
the result is undefined if *this contains NaN.

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:
-1 -0.0827  -0.906
-0.737  0.0655   0.358
0.511  -0.562   0.359
Here is the minimum of each column:
-1 -0.562 -0.906

See also
DenseBase::minCoeff()

## ◆ norm()

template<typename ExpressionType , int Direction>
 const NormReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::norm ( ) const
inline
Returns
a row (or column) vector expression of the norm of each column (or row) of the referenced expression. This is a vector with real entries, even if the original matrix has complex entries.

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:
-1 -0.0827  -0.906
-0.737  0.0655   0.358
0.511  -0.562   0.359
Here is the norm of each column:
1.34 0.572  1.04

See also
DenseBase::norm()

## ◆ normalize()

template<typename ExpressionType , int Direction>
 void Eigen::VectorwiseOp< ExpressionType, Direction >::normalize ( )
inline

Normalize in-place each row or columns of the referenced matrix.

See also
MatrixBase::normalize(), normalized()

## ◆ normalized()

template<typename ExpressionType , int Direction>
 CwiseBinaryOp, const ExpressionTypeNestedCleaned, const typename OppositeExtendedType::Type>::Type> Eigen::VectorwiseOp< ExpressionType, Direction >::normalized ( ) const
inline
Returns
an expression where each column (or row) of the referenced matrix are normalized. The referenced matrix is not modified.
See also
MatrixBase::normalized(), normalize()

## ◆ operator*()

template<typename ExpressionType , int Direction>
template<typename OtherDerived >
 CwiseBinaryOp, const ExpressionTypeNestedCleaned, const typename ExtendedType::Type> Eigen::VectorwiseOp< ExpressionType, Direction >::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

## ◆ operator*=()

template<typename ExpressionType , int Direction>
template<typename OtherDerived >
 ExpressionType& Eigen::VectorwiseOp< ExpressionType, Direction >::operator*= ( const DenseBase< OtherDerived > & other )
inline

Multiples each subvector of *this by the vector other

## ◆ operator+()

template<typename ExpressionType , int Direction>
template<typename OtherDerived >
 CwiseBinaryOp, const ExpressionTypeNestedCleaned, const typename ExtendedType::Type> Eigen::VectorwiseOp< ExpressionType, Direction >::operator+ ( const DenseBase< OtherDerived > & other ) const
inline

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

## ◆ operator+=()

template<typename ExpressionType , int Direction>
template<typename OtherDerived >
 ExpressionType& Eigen::VectorwiseOp< ExpressionType, Direction >::operator+= ( const DenseBase< OtherDerived > & other )
inline

Adds the vector other to each subvector of *this

## ◆ operator-()

template<typename ExpressionType , int Direction>
template<typename OtherDerived >
 CwiseBinaryOp, const ExpressionTypeNestedCleaned, const typename ExtendedType::Type> Eigen::VectorwiseOp< ExpressionType, Direction >::operator- ( const DenseBase< OtherDerived > & other ) const
inline

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

## ◆ operator-=()

template<typename ExpressionType , int Direction>
template<typename OtherDerived >
 ExpressionType& Eigen::VectorwiseOp< ExpressionType, Direction >::operator-= ( const DenseBase< OtherDerived > & other )
inline

Substracts the vector other to each subvector of *this

## ◆ operator/()

template<typename ExpressionType , int Direction>
template<typename OtherDerived >
 CwiseBinaryOp, const ExpressionTypeNestedCleaned, const typename ExtendedType::Type> Eigen::VectorwiseOp< ExpressionType, Direction >::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

## ◆ operator/=()

template<typename ExpressionType , int Direction>
template<typename OtherDerived >
 ExpressionType& Eigen::VectorwiseOp< ExpressionType, Direction >::operator/= ( const DenseBase< OtherDerived > & other )
inline

Divides each subvector of *this by the vector other

## ◆ operator=()

template<typename ExpressionType , int Direction>
template<typename OtherDerived >
 ExpressionType& Eigen::VectorwiseOp< ExpressionType, Direction >::operator= ( const DenseBase< OtherDerived > & other )
inline

Copies the vector other to each subvector of *this

## ◆ prod()

template<typename ExpressionType , int Direction>
 const ProdReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::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:
-1 -0.0827  -0.906
-0.737  0.0655   0.358
0.511  -0.562   0.359
Here is the product of each row:
-0.0749
-0.0173
-0.103

See also
DenseBase::prod()

## ◆ redux()

template<typename ExpressionType , int Direction>
template<typename BinaryOp >
 const ReduxReturnType::Type Eigen::VectorwiseOp< ExpressionType, Direction >::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()

## ◆ replicate() [1/2]

template<typename ExpressionType , int Direction>
 const VectorwiseOp< ExpressionType, Direction >::ReplicateReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::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:
-10
-8
5
v.rowwise().replicate(5) = ...
-10 -10 -10 -10 -10
-8  -8  -8  -8  -8
5   5   5   5   5

See also
VectorwiseOp::replicate(), DenseBase::replicate(), class Replicate

## ◆ replicate() [2/2]

template<typename ExpressionType , int Direction>
template<int Factor>
 const Replicate Eigen::VectorwiseOp< ExpressionType, Direction >::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:
-10   5   1
-8  -1  -6
m.colwise().replicate<3>() = ...
-10   5   1
-8  -1  -6
-10   5   1
-8  -1  -6
-10   5   1
-8  -1  -6

See also
VectorwiseOp::replicate(Index), DenseBase::replicate(), class Replicate

## ◆ reverse() [1/2]

template<typename ExpressionType , int Direction>
 ReverseReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::reverse ( )
inline
Returns
a writable matrix expression where each column (or row) are reversed.
See also
reverse() const

## ◆ reverse() [2/2]

template<typename ExpressionType , int Direction>
 const ConstReverseReturnType Eigen::VectorwiseOp< 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:
-10  -1 -10   9
-8   1   4  -2
5  -6   4   0
Here is the rowwise reverse of m:
9 -10  -1 -10
-2   4   1  -8
0   4  -6   5
Here is the colwise reverse of m:
5  -6   4   0
-8   1   4  -2
-10  -1 -10   9
Here is the coefficient (1,0) in the rowise reverse of m:
-2
Let us overwrite this coefficient with the value 4.
Now the matrix m is:
-10  -1 -10   9
-8   1   4  -2
5  -6   4   0

See also
DenseBase::reverse()

## ◆ reverseInPlace()

template<typename ExpressionType , int Direction>
 void Eigen::VectorwiseOp< ExpressionType, Direction >::reverseInPlace
inline

This is the "in place" version of VectorwiseOp::reverse: it reverses each column or row of *this.

In most cases it is probably better to simply use the reversed expression of a matrix. However, when reversing the matrix data itself is really needed, then this "in-place" version is probably the right choice because it provides the following additional benefits:

• less error prone: doing the same operation with .reverse() requires special care:
m = m.reverse().eval();
• this API enables reverse operations without the need for a temporary
See also
DenseBase::reverseInPlace(), reverse()

## ◆ squaredNorm()

template<typename ExpressionType , int Direction>
 const SquaredNormReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::squaredNorm ( ) const
inline
Returns
a row (or column) vector expression of the squared norm of each column (or row) of the referenced expression. This is a vector with real entries, even if the original matrix has complex entries.

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:
-1 -0.0827  -0.906
-0.737  0.0655   0.358
0.511  -0.562   0.359
Here is the square norm of each row:
1.83
0.675
0.706

See also
DenseBase::squaredNorm()

## ◆ stableNorm()

template<typename ExpressionType , int Direction>
 const StableNormReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::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. This is a vector with real entries, even if the original matrix has complex entries.
See also
DenseBase::stableNorm()

## ◆ sum()

template<typename ExpressionType , int Direction>
 const SumReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::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:
-1 -0.0827  -0.906
-0.737  0.0655   0.358
0.511  -0.562   0.359
Here is the sum of each row:
-1.99
-0.314
0.308

See also
DenseBase::sum()

The documentation for this class was generated from the following files:
Eigen::DenseBase::Random
static const RandomReturnType Random()
Definition: Random.h:113