Eigen::VectorwiseOp< ExpressionType, Direction > Class Template Reference

Pseudo expression providing broadcasting and partial reduction operations. More...

#include <VectorwiseOp.h>

Classes

struct  ExtendedType
 
struct  LpNormReturnType
 
struct  OppositeExtendedType
 
struct  ReduxReturnType
 
struct  ReturnType
 

Public Types

enum  { isVertical = (Direction == Vertical) ? 1 : 0 , isHorizontal = (Direction == Horizontal) ? 1 : 0 }
 
enum  { HNormalized_Size , HNormalized_SizeMinusOne = HNormalized_Size == Dynamic ? Dynamic : HNormalized_Size - 1 }
 
typedef ExpressionType::Scalar Scalar
 
typedef ExpressionType::RealScalar RealScalar
 
typedef Eigen::Index Index
 
typedef internal::ref_selector< ExpressionType >::non_const_type ExpressionTypeNested
 
typedef internal::remove_all_t< ExpressionTypeNestedExpressionTypeNestedCleaned
 
typedef internal::subvector_stl_iterator< ExpressionType, DirectionType(Direction)> iterator
 
typedef internal::subvector_stl_iterator< const ExpressionType, DirectionType(Direction)> const_iterator
 
typedef internal::subvector_stl_reverse_iterator< ExpressionType, DirectionType(Direction)> reverse_iterator
 
typedef internal::subvector_stl_reverse_iterator< const ExpressionType, DirectionType(Direction)> const_reverse_iterator
 
typedef ReturnType< internal::member_minCoeff >::Type MinCoeffReturnType
 
typedef ReturnType< internal::member_maxCoeff >::Type MaxCoeffReturnType
 
typedef PartialReduxExpr< const CwiseUnaryOp< internal::scalar_abs2_op< Scalar >, const ExpressionTypeNestedCleaned >, internal::member_sum< RealScalar, RealScalar >, DirectionSquaredNormReturnType
 
typedef CwiseUnaryOp< internal::scalar_sqrt_op< RealScalar >, const SquaredNormReturnTypeNormReturnType
 
typedef ReturnType< internal::member_blueNorm, RealScalar >::Type BlueNormReturnType
 
typedef ReturnType< internal::member_stableNorm, RealScalar >::Type StableNormReturnType
 
typedef ReturnType< internal::member_hypotNorm, RealScalar >::Type HypotNormReturnType
 
typedef ReturnType< internal::member_sum >::Type SumReturnType
 
typedef ReturnType< internal::member_all, bool >::Type AllReturnType
 
typedef ReturnType< internal::member_any, bool >::Type AnyReturnType
 
typedef PartialReduxExpr< ExpressionType, internal::member_count< Index, Scalar >, DirectionCountReturnType
 
typedef ReturnType< internal::member_prod >::Type ProdReturnType
 
typedef Reverse< const ExpressionType, DirectionConstReverseReturnType
 
typedef Reverse< ExpressionType, DirectionReverseReturnType
 
typedef Replicate< ExpressionType,(isVertical ? Dynamic :1),(isHorizontal ? Dynamic :1)> ReplicateReturnType
 
typedef Homogeneous< ExpressionType, DirectionHomogeneousReturnType
 
typedef ExpressionType::PlainObject CrossReturnType
 
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
 

Public Member Functions

EIGEN_DEVICE_FUNC VectorwiseOp (ExpressionType &matrix)
 
EIGEN_DEVICE_FUNC const ExpressionType & _expression () const
 
iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator crbegin () const
 
iterator end ()
 
const_iterator end () const
 
const_iterator cend () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
const_reverse_iterator crend () const
 
template<typename BinaryOp >
EIGEN_DEVICE_FUNC const ReduxReturnType< BinaryOp >::Type redux (const BinaryOp &func=BinaryOp()) const
 
typedef EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE (SumReturnType, Scalar, quotient) MeanReturnType
 
EIGEN_DEVICE_FUNC const MinCoeffReturnType minCoeff () const
 
EIGEN_DEVICE_FUNC const MaxCoeffReturnType maxCoeff () const
 
EIGEN_DEVICE_FUNC const SquaredNormReturnType squaredNorm () const
 
EIGEN_DEVICE_FUNC const NormReturnType norm () const
 
template<int p>
EIGEN_DEVICE_FUNC const LpNormReturnType< p >::Type lpNorm () const
 
EIGEN_DEVICE_FUNC const BlueNormReturnType blueNorm () const
 
EIGEN_DEVICE_FUNC const StableNormReturnType stableNorm () const
 
EIGEN_DEVICE_FUNC const HypotNormReturnType hypotNorm () const
 
EIGEN_DEVICE_FUNC const SumReturnType sum () const
 
EIGEN_DEVICE_FUNC const MeanReturnType mean () const
 
EIGEN_DEVICE_FUNC const AllReturnType all () const
 
EIGEN_DEVICE_FUNC const AnyReturnType any () const
 
EIGEN_DEVICE_FUNC const CountReturnType count () const
 
EIGEN_DEVICE_FUNC const ProdReturnType prod () const
 
EIGEN_DEVICE_FUNC const ConstReverseReturnType reverse () const
 
EIGEN_DEVICE_FUNC ReverseReturnType reverse ()
 
EIGEN_DEVICE_FUNC const ReplicateReturnType replicate (Index factor) const
 
template<int Factor>
const Replicate< ExpressionType, isVertical *Factor+isHorizontal, isHorizontal *Factor+isVertical > EIGEN_DEVICE_FUNC replicate (Index factor=Factor) const
 
template<typename OtherDerived >
EIGEN_DEVICE_FUNC ExpressionType & operator= (const DenseBase< OtherDerived > &other)
 
template<typename OtherDerived >
EIGEN_DEVICE_FUNC ExpressionType & operator+= (const DenseBase< OtherDerived > &other)
 
template<typename OtherDerived >
EIGEN_DEVICE_FUNC ExpressionType & operator-= (const DenseBase< OtherDerived > &other)
 
template<typename OtherDerived >
EIGEN_DEVICE_FUNC ExpressionType & operator*= (const DenseBase< OtherDerived > &other)
 
template<typename OtherDerived >
EIGEN_DEVICE_FUNC ExpressionType & operator/= (const DenseBase< OtherDerived > &other)
 
template<typename OtherDerived >
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC 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 >
EIGEN_DEVICE_FUNC 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 >
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC CwiseBinaryOp< internal::scalar_product_op< Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType< OtherDerived >::Type > EIGEN_DEVICE_FUNC operator* (const DenseBase< OtherDerived > &other) const
 
template<typename OtherDerived >
EIGEN_DEVICE_FUNC CwiseBinaryOp< internal::scalar_quotient_op< Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType< OtherDerived >::Type > operator/ (const DenseBase< OtherDerived > &other) const
 
EIGEN_DEVICE_FUNC CwiseBinaryOp< internal::scalar_quotient_op< Scalar >, const ExpressionTypeNestedCleaned, const typename OppositeExtendedType< NormReturnType >::Type > normalized () const
 
EIGEN_DEVICE_FUNC void normalize ()
 
EIGEN_DEVICE_FUNC void reverseInPlace ()
 
EIGEN_DEVICE_FUNC HomogeneousReturnType homogeneous () const
 
template<typename OtherDerived >
EIGEN_DEVICE_FUNC const CrossReturnType cross (const MatrixBase< OtherDerived > &other) const
 
EIGEN_DEVICE_FUNC const HNormalizedReturnType hnormalized () const
 column or row-wise homogeneous normalization More...
 

Protected Member Functions

template<typename OtherDerived >
EIGEN_DEVICE_FUNC ExtendedType< OtherDerived >::Type extendedTo (const DenseBase< OtherDerived > &other) const
 
template<typename OtherDerived >
EIGEN_DEVICE_FUNC OppositeExtendedType< OtherDerived >::Type extendedToOpposite (const DenseBase< OtherDerived > &other) const
 
EIGEN_DEVICE_FUNC Index redux_length () const
 

Protected Attributes

ExpressionTypeNested m_matrix
 

Detailed Description

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

Pseudo expression providing broadcasting and partial reduction operations.

Template Parameters
ExpressionTypethe type of the object on which to do partial reductions
Directionindicates whether to operate on columns (Vertical) or rows (Horizontal)

This class represents a pseudo expression with broadcasting and 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 explicitly used.

To understand the logic of rowwise/colwise expression, let's consider a generic case A.colwise().foo() where foo is any method of VectorwiseOp. This expression is equivalent to applying foo() to each column of A and then re-assemble the outputs in a matrix expression:

[A.col(0).foo(), A.col(1).foo(), ..., A.col(A.cols()-1).foo()]
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47

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;
int * m
Definition: level2_cplx_impl.h:294

Output:

The begin() and end() methods are obviously exceptions to the previous rule as they return STL-compatible begin/end iterators to the rows or columns of the nested expression. Typical use cases include for-range-loop and calls to STL algorithms:

Example:

Matrix3i m = Matrix3i::Random();
cout << "Here is the initial matrix m:" << endl << m << endl;
int i = -1;
for (auto c : m.colwise()) {
c *= i;
++i;
}
cout << "Here is the matrix m after the for-range-loop:" << endl << m << endl;
auto cols = m.colwise();
auto it = std::find_if(cols.cbegin(), cols.cend(), [](Matrix3i::ConstColXpr x) { return x.squaredNorm() == 0; });
cout << "The first empty column is: " << distance(cols.cbegin(), it) << endl;
int i
Definition: BiCGSTAB_step_by_step.cpp:9
int cols
Definition: Tutorial_commainit_02.cpp:1
int c
Definition: calibrate.py:100
list x
Definition: plotDoE.py:28

Output:

For a partial reduction on an empty input, some rules apply. For the sake of clarity, let's consider a vertical reduction:

  • If the number of columns is zero, then a 1x0 row-major vector expression is returned.
  • Otherwise, if the number of rows is zero, then
    • a row vector of zeros is returned for sum-like reductions (sum, squaredNorm, norm, etc.)
    • a row vector of ones is returned for a product reduction (e.g., MatrixXd(n,0).colwise().prod())
    • an assert is triggered for all other reductions (minCoeff,maxCoeff,redux(bin_op))
See also
DenseBase::colwise(), DenseBase::rowwise(), class PartialReduxExpr

Member Typedef Documentation

◆ AllReturnType

template<typename ExpressionType , int Direction>
typedef ReturnType<internal::member_all, bool>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::AllReturnType

◆ AnyReturnType

template<typename ExpressionType , int Direction>
typedef ReturnType<internal::member_any, bool>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::AnyReturnType

◆ BlueNormReturnType

template<typename ExpressionType , int Direction>
typedef ReturnType<internal::member_blueNorm, RealScalar>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::BlueNormReturnType

◆ const_iterator

template<typename ExpressionType , int Direction>
typedef internal::subvector_stl_iterator<const ExpressionType, DirectionType(Direction)> Eigen::VectorwiseOp< ExpressionType, Direction >::const_iterator

◆ const_reverse_iterator

template<typename ExpressionType , int Direction>
typedef internal::subvector_stl_reverse_iterator<const ExpressionType, DirectionType(Direction)> Eigen::VectorwiseOp< ExpressionType, Direction >::const_reverse_iterator

◆ ConstReverseReturnType

template<typename ExpressionType , int Direction>
typedef Reverse<const ExpressionType, Direction> Eigen::VectorwiseOp< ExpressionType, Direction >::ConstReverseReturnType

◆ CountReturnType

template<typename ExpressionType , int Direction>
typedef PartialReduxExpr<ExpressionType, internal::member_count<Index, Scalar>, Direction> Eigen::VectorwiseOp< ExpressionType, Direction >::CountReturnType

◆ CrossReturnType

template<typename ExpressionType , int Direction>
typedef ExpressionType::PlainObject Eigen::VectorwiseOp< ExpressionType, Direction >::CrossReturnType

◆ ExpressionTypeNested

template<typename ExpressionType , int Direction>
typedef internal::ref_selector<ExpressionType>::non_const_type Eigen::VectorwiseOp< ExpressionType, Direction >::ExpressionTypeNested

◆ ExpressionTypeNestedCleaned

template<typename ExpressionType , int Direction>
typedef internal::remove_all_t<ExpressionTypeNested> Eigen::VectorwiseOp< ExpressionType, Direction >::ExpressionTypeNestedCleaned

◆ HNormalized_Block

template<typename ExpressionType , int Direction>
typedef Block<const ExpressionType, Direction == Vertical ? int(HNormalized_SizeMinusOne) : int(internal::traits<ExpressionType>::RowsAtCompileTime), Direction == Horizontal ? int(HNormalized_SizeMinusOne) : int(internal::traits<ExpressionType>::ColsAtCompileTime)> Eigen::VectorwiseOp< ExpressionType, Direction >::HNormalized_Block

◆ HNormalized_Factors

template<typename ExpressionType , int Direction>
typedef Block<const ExpressionType, Direction == Vertical ? 1 : int(internal::traits<ExpressionType>::RowsAtCompileTime), Direction == Horizontal ? 1 : int(internal::traits<ExpressionType>::ColsAtCompileTime)> Eigen::VectorwiseOp< ExpressionType, Direction >::HNormalized_Factors

◆ HNormalizedReturnType

◆ HomogeneousReturnType

template<typename ExpressionType , int Direction>
typedef Homogeneous<ExpressionType, Direction> Eigen::VectorwiseOp< ExpressionType, Direction >::HomogeneousReturnType

◆ HypotNormReturnType

template<typename ExpressionType , int Direction>
typedef ReturnType<internal::member_hypotNorm, RealScalar>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::HypotNormReturnType

◆ Index

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

◆ iterator

template<typename ExpressionType , int Direction>
typedef internal::subvector_stl_iterator<ExpressionType, DirectionType(Direction)> Eigen::VectorwiseOp< ExpressionType, Direction >::iterator

◆ MaxCoeffReturnType

template<typename ExpressionType , int Direction>
typedef ReturnType<internal::member_maxCoeff>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::MaxCoeffReturnType

◆ MinCoeffReturnType

template<typename ExpressionType , int Direction>
typedef ReturnType<internal::member_minCoeff>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::MinCoeffReturnType

◆ NormReturnType

template<typename ExpressionType , int Direction>
typedef CwiseUnaryOp<internal::scalar_sqrt_op<RealScalar>, const SquaredNormReturnType> Eigen::VectorwiseOp< ExpressionType, Direction >::NormReturnType

◆ ProdReturnType

template<typename ExpressionType , int Direction>
typedef ReturnType<internal::member_prod>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::ProdReturnType

◆ RealScalar

template<typename ExpressionType , int Direction>
typedef ExpressionType::RealScalar Eigen::VectorwiseOp< ExpressionType, Direction >::RealScalar

◆ ReplicateReturnType

template<typename ExpressionType , int Direction>
typedef Replicate<ExpressionType, (isVertical ? Dynamic : 1), (isHorizontal ? Dynamic : 1)> Eigen::VectorwiseOp< ExpressionType, Direction >::ReplicateReturnType

◆ reverse_iterator

template<typename ExpressionType , int Direction>
typedef internal::subvector_stl_reverse_iterator<ExpressionType, DirectionType(Direction)> Eigen::VectorwiseOp< ExpressionType, Direction >::reverse_iterator

◆ ReverseReturnType

template<typename ExpressionType , int Direction>
typedef Reverse<ExpressionType, Direction> Eigen::VectorwiseOp< ExpressionType, Direction >::ReverseReturnType

◆ Scalar

template<typename ExpressionType , int Direction>
typedef ExpressionType::Scalar Eigen::VectorwiseOp< ExpressionType, Direction >::Scalar

◆ SquaredNormReturnType

template<typename ExpressionType , int Direction>
typedef PartialReduxExpr<const CwiseUnaryOp<internal::scalar_abs2_op<Scalar>, const ExpressionTypeNestedCleaned>, internal::member_sum<RealScalar, RealScalar>, Direction> Eigen::VectorwiseOp< ExpressionType, Direction >::SquaredNormReturnType

◆ StableNormReturnType

template<typename ExpressionType , int Direction>
typedef ReturnType<internal::member_stableNorm, RealScalar>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::StableNormReturnType

◆ SumReturnType

template<typename ExpressionType , int Direction>
typedef ReturnType<internal::member_sum>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::SumReturnType

Member Enumeration Documentation

◆ anonymous enum

template<typename ExpressionType , int Direction>
anonymous enum
Enumerator
isVertical 
isHorizontal 
210 { isVertical = (Direction == Vertical) ? 1 : 0, isHorizontal = (Direction == Horizontal) ? 1 : 0 };
Direction
An enum that indicates the direction in Cartesian coordinates.
Definition: GeneralDefine.h:56
@ isVertical
Definition: VectorwiseOp.h:210
@ isHorizontal
Definition: VectorwiseOp.h:210
@ Horizontal
Definition: Constants.h:269
@ Vertical
Definition: Constants.h:266

◆ anonymous enum

template<typename ExpressionType , int Direction>
anonymous enum
Enumerator
HNormalized_Size 
HNormalized_SizeMinusOne 
657  {
658  HNormalized_Size = Direction == Vertical ? internal::traits<ExpressionType>::RowsAtCompileTime
659  : internal::traits<ExpressionType>::ColsAtCompileTime,
661  };
@ HNormalized_Size
Definition: VectorwiseOp.h:658
@ HNormalized_SizeMinusOne
Definition: VectorwiseOp.h:660
const int Dynamic
Definition: Constants.h:25

Constructor & Destructor Documentation

◆ VectorwiseOp()

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC Eigen::VectorwiseOp< ExpressionType, Direction >::VectorwiseOp ( ExpressionType &  matrix)
inlineexplicit
253 : m_matrix(matrix) {}
ExpressionTypeNested m_matrix
Definition: VectorwiseOp.h:686
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor >, 0, Eigen::OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: common.h:85

Member Function Documentation

◆ _expression()

◆ all()

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC 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()
473 { return AllReturnType(_expression()); }
EIGEN_DEVICE_FUNC const ExpressionType & _expression() const
Definition: VectorwiseOp.h:256
ReturnType< internal::member_all, bool >::Type AllReturnType
Definition: VectorwiseOp.h:346

References Eigen::VectorwiseOp< ExpressionType, Direction >::_expression().

◆ any()

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC 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()
480 { return AnyReturnType(_expression()); }
ReturnType< internal::member_any, bool >::Type AnyReturnType
Definition: VectorwiseOp.h:347

References Eigen::VectorwiseOp< ExpressionType, Direction >::_expression().

◆ begin() [1/2]

template<typename ExpressionType , int Direction>
iterator Eigen::VectorwiseOp< ExpressionType, Direction >::begin ( )
inline

returns an iterator to the first row (rowwise) or column (colwise) of the nested expression.

See also
end(), cbegin()
276 { return iterator(m_matrix, 0); }
internal::subvector_stl_iterator< ExpressionType, DirectionType(Direction)> iterator
Definition: VectorwiseOp.h:266

References Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ begin() [2/2]

template<typename ExpressionType , int Direction>
const_iterator Eigen::VectorwiseOp< ExpressionType, Direction >::begin ( ) const
inline

const version of begin()

278 { return const_iterator(m_matrix, 0); }
internal::subvector_stl_iterator< const ExpressionType, DirectionType(Direction)> const_iterator
Definition: VectorwiseOp.h:267

References Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ blueNorm()

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC 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()
433 { return BlueNormReturnType(_expression()); }
ReturnType< internal::member_blueNorm, RealScalar >::Type BlueNormReturnType
Definition: VectorwiseOp.h:341

References Eigen::VectorwiseOp< ExpressionType, Direction >::_expression().

◆ cbegin()

template<typename ExpressionType , int Direction>
const_iterator Eigen::VectorwiseOp< ExpressionType, Direction >::cbegin ( ) const
inline

const version of begin()

280 { return const_iterator(m_matrix, 0); }

References Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ cend()

template<typename ExpressionType , int Direction>
const_iterator Eigen::VectorwiseOp< ExpressionType, Direction >::cend ( ) const
inline

const version of end()

306  {
307  return const_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>());
308  }
DirectionType
Definition: Constants.h:263

References Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ count()

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC 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;
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3

Output:

See also
DenseBase::count()
491 { return CountReturnType(_expression()); }
PartialReduxExpr< ExpressionType, internal::member_count< Index, Scalar >, Direction > CountReturnType
Definition: VectorwiseOp.h:348

References Eigen::VectorwiseOp< ExpressionType, Direction >::_expression().

◆ crbegin()

template<typename ExpressionType , int Direction>
const_reverse_iterator Eigen::VectorwiseOp< ExpressionType, Direction >::crbegin ( ) const
inline

const version of rbegin()

293  {
294  return const_reverse_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>() - 1);
295  }
internal::subvector_stl_reverse_iterator< const ExpressionType, DirectionType(Direction)> const_reverse_iterator
Definition: VectorwiseOp.h:270

References Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ crend()

template<typename ExpressionType , int Direction>
const_reverse_iterator Eigen::VectorwiseOp< ExpressionType, Direction >::crend ( ) const
inline

const version of rend()

317 { return const_reverse_iterator(m_matrix, -1); }

References Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE()

template<typename ExpressionType , int Direction>
typedef Eigen::VectorwiseOp< ExpressionType, Direction >::EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE ( SumReturnType  ,
Scalar  ,
quotient   
)

◆ end() [1/2]

template<typename ExpressionType , int Direction>
iterator Eigen::VectorwiseOp< ExpressionType, Direction >::end ( )
inline

returns an iterator to the row (resp. column) following the last row (resp. column) of the nested expression

See also
begin(), cend()
300 { return iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>()); }

References Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ end() [2/2]

template<typename ExpressionType , int Direction>
const_iterator Eigen::VectorwiseOp< ExpressionType, Direction >::end ( ) const
inline

const version of end()

302  {
303  return const_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>());
304  }

References Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ extendedTo()

template<typename ExpressionType , int Direction>
template<typename OtherDerived >
EIGEN_DEVICE_FUNC ExtendedType<OtherDerived>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::extendedTo ( const DenseBase< OtherDerived > &  other) const
inlineprotected

Replicates a vector to match the size of *this

223  {
224  EIGEN_STATIC_ASSERT(internal::check_implication(isVertical, OtherDerived::MaxColsAtCompileTime == 1),
225  YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)
226  EIGEN_STATIC_ASSERT(internal::check_implication(isHorizontal, OtherDerived::MaxRowsAtCompileTime == 1),
227  YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)
228  return typename ExtendedType<OtherDerived>::Type(other.derived(), isVertical ? 1 : m_matrix.rows(),
229  isHorizontal ? 1 : m_matrix.cols());
230  }
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
constexpr bool check_implication(bool a, bool b)
Definition: Meta.h:740
Replicate< OtherDerived, isVertical ? 1 :ExpressionType::RowsAtCompileTime, isHorizontal ? 1 :ExpressionType::ColsAtCompileTime > Type
Definition: VectorwiseOp.h:217

References Eigen::internal::check_implication(), EIGEN_STATIC_ASSERT, Eigen::VectorwiseOp< ExpressionType, Direction >::isHorizontal, Eigen::VectorwiseOp< ExpressionType, Direction >::isVertical, and Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

Referenced by Eigen::VectorwiseOp< ExpressionType, Direction >::operator*(), Eigen::VectorwiseOp< ExpressionType, Direction >::operator*=(), Eigen::VectorwiseOp< ExpressionType, Direction >::operator+(), Eigen::VectorwiseOp< ExpressionType, Direction >::operator+=(), Eigen::VectorwiseOp< ExpressionType, Direction >::operator-(), Eigen::VectorwiseOp< ExpressionType, Direction >::operator-=(), Eigen::VectorwiseOp< ExpressionType, Direction >::operator/(), Eigen::VectorwiseOp< ExpressionType, Direction >::operator/=(), and Eigen::VectorwiseOp< ExpressionType, Direction >::operator=().

◆ extendedToOpposite()

template<typename ExpressionType , int Direction>
template<typename OtherDerived >
EIGEN_DEVICE_FUNC OppositeExtendedType<OtherDerived>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::extendedToOpposite ( const DenseBase< OtherDerived > &  other) const
inlineprotected

Replicates a vector in the opposite direction to match the size of *this

243  {
244  EIGEN_STATIC_ASSERT(internal::check_implication(isHorizontal, OtherDerived::MaxColsAtCompileTime == 1),
245  YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)
246  EIGEN_STATIC_ASSERT(internal::check_implication(isVertical, OtherDerived::MaxRowsAtCompileTime == 1),
247  YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)
248  return typename OppositeExtendedType<OtherDerived>::Type(other.derived(), isHorizontal ? 1 : m_matrix.rows(),
249  isVertical ? 1 : m_matrix.cols());
250  }
Replicate< OtherDerived, isHorizontal ? 1 :ExpressionType::RowsAtCompileTime, isVertical ? 1 :ExpressionType::ColsAtCompileTime > Type
Definition: VectorwiseOp.h:236

References Eigen::internal::check_implication(), EIGEN_STATIC_ASSERT, Eigen::VectorwiseOp< ExpressionType, Direction >::isHorizontal, Eigen::VectorwiseOp< ExpressionType, Direction >::isVertical, and Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

Referenced by Eigen::VectorwiseOp< ExpressionType, Direction >::normalized().

◆ hypotNorm()

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC 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()
449 { return HypotNormReturnType(_expression()); }
ReturnType< internal::member_hypotNorm, RealScalar >::Type HypotNormReturnType
Definition: VectorwiseOp.h:343

References Eigen::VectorwiseOp< ExpressionType, Direction >::_expression().

◆ lpNorm()

template<typename ExpressionType , int Direction>
template<int p>
EIGEN_DEVICE_FUNC const LpNormReturnType<p>::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:

See also
DenseBase::norm()
423  {
424  return typename LpNormReturnType<p>::Type(_expression());
425  }
PartialReduxExpr< ExpressionType, internal::member_lpnorm< p, RealScalar, Scalar >, Direction > Type
Definition: VectorwiseOp.h:355

References Eigen::VectorwiseOp< ExpressionType, Direction >::_expression().

◆ maxCoeff()

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC 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 size along the reduction direction must be strictly positive, otherwise an assertion is triggered.
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:

See also
DenseBase::maxCoeff()
387  {
388  eigen_assert(redux_length() > 0 && "you are using an empty matrix");
390  }
#define eigen_assert(x)
Definition: Macros.h:910
ReturnType< internal::member_maxCoeff >::Type MaxCoeffReturnType
Definition: VectorwiseOp.h:336
EIGEN_DEVICE_FUNC Index redux_length() const
Definition: VectorwiseOp.h:685

References Eigen::VectorwiseOp< ExpressionType, Direction >::_expression(), eigen_assert, and Eigen::VectorwiseOp< ExpressionType, Direction >::redux_length().

◆ mean()

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC 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()
464  {
465  return sum() / Scalar(Direction == Vertical ? m_matrix.rows() : m_matrix.cols());
466  }
EIGEN_DEVICE_FUNC const SumReturnType sum() const
Definition: VectorwiseOp.h:458
ExpressionType::Scalar Scalar
Definition: VectorwiseOp.h:194

References Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix, Eigen::VectorwiseOp< ExpressionType, Direction >::sum(), and Eigen::Vertical.

◆ minCoeff()

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC 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 size along the reduction direction must be strictly positive, otherwise an assertion is triggered.
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:

See also
DenseBase::minCoeff()
370  {
371  eigen_assert(redux_length() > 0 && "you are using an empty matrix");
373  }
ReturnType< internal::member_minCoeff >::Type MinCoeffReturnType
Definition: VectorwiseOp.h:335

References Eigen::VectorwiseOp< ExpressionType, Direction >::_expression(), eigen_assert, and Eigen::VectorwiseOp< ExpressionType, Direction >::redux_length().

◆ norm()

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC 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:

See also
DenseBase::norm()
412 { return NormReturnType(squaredNorm()); }
EIGEN_DEVICE_FUNC const SquaredNormReturnType squaredNorm() const
Definition: VectorwiseOp.h:400
CwiseUnaryOp< internal::scalar_sqrt_op< RealScalar >, const SquaredNormReturnType > NormReturnType
Definition: VectorwiseOp.h:340

References Eigen::VectorwiseOp< ExpressionType, Direction >::squaredNorm().

Referenced by Eigen::VectorwiseOp< ExpressionType, Direction >::normalized().

◆ normalize()

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

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

See also
MatrixBase::normalize(), normalized()
644 { m_matrix = this->normalized(); }
EIGEN_DEVICE_FUNC CwiseBinaryOp< internal::scalar_quotient_op< Scalar >, const ExpressionTypeNestedCleaned, const typename OppositeExtendedType< NormReturnType >::Type > normalized() const
Definition: VectorwiseOp.h:637

References Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix, and Eigen::VectorwiseOp< ExpressionType, Direction >::normalized().

◆ normalized()

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const ExpressionTypeNestedCleaned, const typename OppositeExtendedType<NormReturnType>::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()
637  {
638  return m_matrix.cwiseQuotient(extendedToOpposite(this->norm()));
639  }
EIGEN_DEVICE_FUNC const NormReturnType norm() const
Definition: VectorwiseOp.h:412
EIGEN_DEVICE_FUNC OppositeExtendedType< OtherDerived >::Type extendedToOpposite(const DenseBase< OtherDerived > &other) const
Definition: VectorwiseOp.h:242

References Eigen::VectorwiseOp< ExpressionType, Direction >::extendedToOpposite(), Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix, and Eigen::VectorwiseOp< ExpressionType, Direction >::norm().

Referenced by Eigen::VectorwiseOp< ExpressionType, Direction >::normalize().

◆ operator*()

template<typename ExpressionType , int Direction>
template<typename OtherDerived >
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC CwiseBinaryOp<internal::scalar_product_op<Scalar>, const ExpressionTypeNestedCleaned, const typename ExtendedType<OtherDerived>::Type> EIGEN_DEVICE_FUNC 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

612  {
613  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
614  EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
615  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
616  return m_matrix * extendedTo(other.derived());
617  }
#define EIGEN_STATIC_ASSERT_ARRAYXPR(Derived)
Definition: StaticAssert.h:90
#define EIGEN_STATIC_ASSERT_SAME_XPR_KIND(Derived1, Derived2)
Definition: StaticAssert.h:94
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Definition: StaticAssert.h:36
EIGEN_DEVICE_FUNC ExtendedType< OtherDerived >::Type extendedTo(const DenseBase< OtherDerived > &other) const
Definition: VectorwiseOp.h:223

References EIGEN_STATIC_ASSERT_ARRAYXPR, EIGEN_STATIC_ASSERT_SAME_XPR_KIND, EIGEN_STATIC_ASSERT_VECTOR_ONLY, Eigen::VectorwiseOp< ExpressionType, Direction >::extendedTo(), and Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ operator*=()

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

Multiplies each subvector of *this by the vector other

567  {
568  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
569  EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
570  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
571  m_matrix *= extendedTo(other.derived());
572  return m_matrix;
573  }

References EIGEN_STATIC_ASSERT_ARRAYXPR, EIGEN_STATIC_ASSERT_SAME_XPR_KIND, EIGEN_STATIC_ASSERT_VECTOR_ONLY, Eigen::VectorwiseOp< ExpressionType, Direction >::extendedTo(), and Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ operator+()

template<typename ExpressionType , int Direction>
template<typename OtherDerived >
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC CwiseBinaryOp<internal::scalar_sum_op<Scalar, typename OtherDerived::Scalar>, const ExpressionTypeNestedCleaned, const typename ExtendedType<OtherDerived>::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

590  {
591  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
592  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
593  return m_matrix + extendedTo(other.derived());
594  }

References EIGEN_STATIC_ASSERT_SAME_XPR_KIND, EIGEN_STATIC_ASSERT_VECTOR_ONLY, Eigen::VectorwiseOp< ExpressionType, Direction >::extendedTo(), and Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ operator+=()

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

Adds the vector other to each subvector of *this

551  {
552  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
553  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
554  return m_matrix += extendedTo(other.derived());
555  }

References EIGEN_STATIC_ASSERT_SAME_XPR_KIND, EIGEN_STATIC_ASSERT_VECTOR_ONLY, Eigen::VectorwiseOp< ExpressionType, Direction >::extendedTo(), and Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ operator-()

template<typename ExpressionType , int Direction>
template<typename OtherDerived >
EIGEN_DEVICE_FUNC CwiseBinaryOp<internal::scalar_difference_op<Scalar, typename OtherDerived::Scalar>, const ExpressionTypeNestedCleaned, const typename ExtendedType<OtherDerived>::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

600  {
601  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
602  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
603  return m_matrix - extendedTo(other.derived());
604  }

References EIGEN_STATIC_ASSERT_SAME_XPR_KIND, EIGEN_STATIC_ASSERT_VECTOR_ONLY, Eigen::VectorwiseOp< ExpressionType, Direction >::extendedTo(), and Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ operator-=()

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

Subtracts the vector other to each subvector of *this

559  {
560  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
561  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
562  return m_matrix -= extendedTo(other.derived());
563  }

References EIGEN_STATIC_ASSERT_SAME_XPR_KIND, EIGEN_STATIC_ASSERT_VECTOR_ONLY, Eigen::VectorwiseOp< ExpressionType, Direction >::extendedTo(), and Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ operator/()

template<typename ExpressionType , int Direction>
template<typename OtherDerived >
EIGEN_DEVICE_FUNC CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const ExpressionTypeNestedCleaned, const typename ExtendedType<OtherDerived>::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

624  {
625  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
626  EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
627  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
628  return m_matrix / extendedTo(other.derived());
629  }

References EIGEN_STATIC_ASSERT_ARRAYXPR, EIGEN_STATIC_ASSERT_SAME_XPR_KIND, EIGEN_STATIC_ASSERT_VECTOR_ONLY, Eigen::VectorwiseOp< ExpressionType, Direction >::extendedTo(), and Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ operator/=()

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

◆ operator=()

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

Copies the vector other to each subvector of *this

542  {
543  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
544  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
545  // eigen_assert((m_matrix.isNull()) == (other.isNull())); FIXME
546  return m_matrix = extendedTo(other.derived());
547  }

References EIGEN_STATIC_ASSERT_SAME_XPR_KIND, EIGEN_STATIC_ASSERT_VECTOR_ONLY, Eigen::VectorwiseOp< ExpressionType, Direction >::extendedTo(), and Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ prod()

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC 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:

See also
DenseBase::prod()
500 { return ProdReturnType(_expression()); }
ReturnType< internal::member_prod >::Type ProdReturnType
Definition: VectorwiseOp.h:349

References Eigen::VectorwiseOp< ExpressionType, Direction >::_expression().

◆ rbegin() [1/2]

template<typename ExpressionType , int Direction>
reverse_iterator Eigen::VectorwiseOp< ExpressionType, Direction >::rbegin ( )
inline

returns a reverse iterator to the last row (rowwise) or column (colwise) of the nested expression.

See also
rend(), crbegin()
285  {
286  return reverse_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>() - 1);
287  }
internal::subvector_stl_reverse_iterator< ExpressionType, DirectionType(Direction)> reverse_iterator
Definition: VectorwiseOp.h:268

References Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ rbegin() [2/2]

template<typename ExpressionType , int Direction>
const_reverse_iterator Eigen::VectorwiseOp< ExpressionType, Direction >::rbegin ( ) const
inline

const version of rbegin()

289  {
290  return const_reverse_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>() - 1);
291  }

References Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ redux()

template<typename ExpressionType , int Direction>
template<typename BinaryOp >
EIGEN_DEVICE_FUNC const ReduxReturnType<BinaryOp>::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.

Warning
the size along the reduction direction must be strictly positive, otherwise an assertion is triggered.
See also
class VectorwiseOp, DenseBase::colwise(), DenseBase::rowwise()
330  {
331  eigen_assert(redux_length() > 0 && "you are using an empty matrix");
332  return typename ReduxReturnType<BinaryOp>::Type(_expression(), internal::member_redux<BinaryOp, Scalar>(func));
333  }
PartialReduxExpr< ExpressionType, internal::member_redux< BinaryOp, Scalar >, Direction > Type
Definition: VectorwiseOp.h:207
Definition: benchGeometry.cpp:21

References Eigen::VectorwiseOp< ExpressionType, Direction >::_expression(), eigen_assert, and Eigen::VectorwiseOp< ExpressionType, Direction >::redux_length().

◆ redux_length()

◆ rend() [1/2]

template<typename ExpressionType , int Direction>
reverse_iterator Eigen::VectorwiseOp< ExpressionType, Direction >::rend ( )
inline

returns a reverse iterator to the row (resp. column) before the first row (resp. column) of the nested expression

See also
begin(), cend()
313 { return reverse_iterator(m_matrix, -1); }

References Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ rend() [2/2]

template<typename ExpressionType , int Direction>
const_reverse_iterator Eigen::VectorwiseOp< ExpressionType, Direction >::rend ( ) const
inline

const version of rend()

315 { return const_reverse_iterator(m_matrix, -1); }

References Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

◆ replicate() [1/2]

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC 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;
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1

Output:

See also
VectorwiseOp::replicate(), DenseBase::replicate(), class Replicate
123  {
125  _expression(), Direction == Vertical ? factor : 1, Direction == Horizontal ? factor : 1);
126 }
Replicate< ExpressionType,(isVertical ? Dynamic :1),(isHorizontal ? Dynamic :1)> ReplicateReturnType
Definition: VectorwiseOp.h:517

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

◆ replicate() [2/2]

template<typename ExpressionType , int Direction>
template<int Factor>
const Replicate<ExpressionType, isVertical * Factor + isHorizontal, isHorizontal * Factor + isVertical> EIGEN_DEVICE_FUNC 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:

See also
VectorwiseOp::replicate(Index), DenseBase::replicate(), class Replicate
533  {
534  return Replicate<ExpressionType, (isVertical ? Factor : 1), (isHorizontal ? Factor : 1)>(
535  _expression(), isVertical ? factor : 1, isHorizontal ? factor : 1);
536  }

References Eigen::VectorwiseOp< ExpressionType, Direction >::_expression(), Eigen::VectorwiseOp< ExpressionType, Direction >::isHorizontal, and Eigen::VectorwiseOp< ExpressionType, Direction >::isVertical.

◆ reverse() [1/2]

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC ReverseReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::reverse ( )
inline
Returns
a writable matrix expression where each column (or row) are reversed.
See also
reverse() const
515 { return ReverseReturnType(_expression()); }
Reverse< ExpressionType, Direction > ReverseReturnType
Definition: VectorwiseOp.h:351

References Eigen::VectorwiseOp< ExpressionType, Direction >::_expression().

◆ reverse() [2/2]

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC 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:

See also
DenseBase::reverse()
509 { return ConstReverseReturnType(_expression()); }
Reverse< const ExpressionType, Direction > ConstReverseReturnType
Definition: VectorwiseOp.h:350

References Eigen::VectorwiseOp< ExpressionType, Direction >::_expression().

◆ reverseInPlace()

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC 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()
196  {
198 }
void run(const string &dir_name, LinearSolver *linear_solver_pt, const unsigned nel_1d, bool mess_up_order)
Definition: two_d_poisson_compare_solvers.cc:317

References run().

◆ squaredNorm()

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC 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:

See also
DenseBase::squaredNorm()
400  {
401  return SquaredNormReturnType(m_matrix.cwiseAbs2());
402  }
PartialReduxExpr< const CwiseUnaryOp< internal::scalar_abs2_op< Scalar >, const ExpressionTypeNestedCleaned >, internal::member_sum< RealScalar, RealScalar >, Direction > SquaredNormReturnType
Definition: VectorwiseOp.h:339

References Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix.

Referenced by Eigen::VectorwiseOp< ExpressionType, Direction >::norm().

◆ stableNorm()

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC 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()
441 { return StableNormReturnType(_expression()); }
ReturnType< internal::member_stableNorm, RealScalar >::Type StableNormReturnType
Definition: VectorwiseOp.h:342

References Eigen::VectorwiseOp< ExpressionType, Direction >::_expression().

◆ sum()

template<typename ExpressionType , int Direction>
EIGEN_DEVICE_FUNC 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:

See also
DenseBase::sum()
458 { return SumReturnType(_expression()); }
ReturnType< internal::member_sum >::Type SumReturnType
Definition: VectorwiseOp.h:344

References Eigen::VectorwiseOp< ExpressionType, Direction >::_expression().

Referenced by Eigen::VectorwiseOp< ExpressionType, Direction >::mean(), and Eigen::umeyama().

Member Data Documentation

◆ m_matrix

template<typename ExpressionType , int Direction>
ExpressionTypeNested Eigen::VectorwiseOp< ExpressionType, Direction >::m_matrix
protected

Referenced by Eigen::VectorwiseOp< ExpressionType, Direction >::_expression(), Eigen::VectorwiseOp< ExpressionType, Direction >::begin(), Eigen::VectorwiseOp< ExpressionType, Direction >::cbegin(), Eigen::VectorwiseOp< ExpressionType, Direction >::cend(), Eigen::VectorwiseOp< ExpressionType, Direction >::crbegin(), Eigen::VectorwiseOp< ExpressionType, Direction >::crend(), Eigen::VectorwiseOp< ExpressionType, Direction >::end(), Eigen::VectorwiseOp< ExpressionType, Direction >::extendedTo(), Eigen::VectorwiseOp< ExpressionType, Direction >::extendedToOpposite(), Eigen::VectorwiseOp< ExpressionType, Direction >::mean(), Eigen::VectorwiseOp< ExpressionType, Direction >::normalize(), Eigen::VectorwiseOp< ExpressionType, Direction >::normalized(), Eigen::VectorwiseOp< ExpressionType, Direction >::operator*(), Eigen::VectorwiseOp< ExpressionType, Direction >::operator*=(), Eigen::VectorwiseOp< ExpressionType, Direction >::operator+(), Eigen::VectorwiseOp< ExpressionType, Direction >::operator+=(), Eigen::VectorwiseOp< ExpressionType, Direction >::operator-(), Eigen::VectorwiseOp< ExpressionType, Direction >::operator-=(), Eigen::VectorwiseOp< ExpressionType, Direction >::operator/(), Eigen::VectorwiseOp< ExpressionType, Direction >::operator/=(), Eigen::VectorwiseOp< ExpressionType, Direction >::operator=(), Eigen::VectorwiseOp< ExpressionType, Direction >::rbegin(), Eigen::VectorwiseOp< ExpressionType, Direction >::redux_length(), Eigen::VectorwiseOp< ExpressionType, Direction >::rend(), and Eigen::VectorwiseOp< ExpressionType, Direction >::squaredNorm().


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