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

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

Classes

struct  ExtendedType
 
struct  LpNormReturnType
 
struct  OppositeExtendedType
 
struct  ReduxReturnType
 
struct  ReturnType
 

Public Types

enum  {
  isVertical ,
  isHorizontal
}
 
enum  {
  HNormalized_Size ,
  HNormalized_SizeMinusOne
}
 
typedef ReturnType< internal::member_all, bool >::Type AllReturnType
 
typedef ReturnType< internal::member_any, bool >::Type AnyReturnType
 
typedef ReturnType< internal::member_blueNorm, RealScalar >::Type BlueNormReturnType
 
typedef Reverse< const ExpressionType, Direction > ConstReverseReturnType
 
typedef PartialReduxExpr< ExpressionType, internal::member_count< Index, Scalar >, Direction > CountReturnType
 
typedef ExpressionType::PlainObject CrossReturnType
 
typedef internal::ref_selector< ExpressionType >::non_const_type ExpressionTypeNested
 
typedef internal::remove_all_t< ExpressionTypeNestedExpressionTypeNestedCleaned
 
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 Homogeneous< ExpressionType, Direction > HomogeneousReturnType
 
typedef ReturnType< internal::member_hypotNorm, RealScalar >::Type HypotNormReturnType
 
typedef Eigen::Index Index
 
typedef ReturnType< internal::member_maxCoeff >::Type MaxCoeffReturnType
 
typedef ReturnType< internal::member_minCoeff >::Type MinCoeffReturnType
 
typedef CwiseUnaryOp< internal::scalar_sqrt_op< RealScalar >, const SquaredNormReturnTypeNormReturnType
 
typedef ReturnType< internal::member_prod >::Type ProdReturnType
 
typedef ExpressionType::RealScalar RealScalar
 
typedef Replicate< ExpressionType,(isVertical?Dynamic:1),(isHorizontal?Dynamic:1)> ReplicateReturnType
 
typedef Reverse< ExpressionType, Direction > ReverseReturnType
 
typedef ExpressionType::Scalar Scalar
 
typedef PartialReduxExpr< const CwiseUnaryOp< internal::scalar_abs2_op< Scalar >, const ExpressionTypeNestedCleaned >, internal::member_sum< RealScalar, RealScalar >, Direction > SquaredNormReturnType
 
typedef ReturnType< internal::member_stableNorm, RealScalar >::Type StableNormReturnType
 
typedef ReturnType< internal::member_sum >::Type SumReturnType
 

Public Member Functions

const ExpressionType & _expression () const
 
const AllReturnType all () const
 
const AnyReturnType any () const
 
iterator begin ()
 
const_iterator begin () const
 
const BlueNormReturnType blueNorm () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
const CountReturnType count () const
 
const_reverse_iterator crbegin () const
 
const_reverse_iterator crend () const
 
template<typename OtherDerived >
const CrossReturnType cross (const MatrixBase< OtherDerived > &other) const
 
typedef EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE (SumReturnType, Scalar, quotient) MeanReturnType
 
iterator end ()
 
const_iterator end () 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< NormReturnType >::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
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
template<typename BinaryOp >
const ReduxReturnType< BinaryOp >::Type redux (const BinaryOp &func=BinaryOp()) const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
const ReplicateReturnType replicate (Index factor) const
 
template<int Factor>
const Replicate< ExpressionType, isVertical *Factor+isHorizontal, isHorizontal *Factor+isVerticalreplicate (Index factor=Factor) const
 
ReverseReturnType reverse ()
 
const ConstReverseReturnType reverse () const
 
void reverseInPlace ()
 
const SquaredNormReturnType squaredNorm () const
 
const StableNormReturnType stableNorm () const
 
const SumReturnType sum () const
 
 VectorwiseOp (ExpressionType &matrix)
 

Public Attributes

random_access_iterator_type const_iterator
 
random_access_iterator_type iterator
 

Protected Member Functions

template<typename OtherDerived >
ExtendedType< OtherDerived >::Type extendedTo (const DenseBase< OtherDerived > &other) const
 
template<typename OtherDerived >
OppositeExtendedType< OtherDerived >::Type extendedToOpposite (const DenseBase< OtherDerived > &other) const
 
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()]
MatrixXcf A

Example:

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;
Matrix3f m
static const RandomReturnType Random()
Definition: Random.h:114
Matrix< double, 3, 3 > Matrix3d
3×3 matrix of type double.
Definition: Matrix.h:502

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

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:

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;
Array33i c
Matrix< int, 3, 3 > Matrix3i
3×3 matrix of type int.
Definition: Matrix.h:500

Output:

Here is the initial matrix m:
 7  6 -3
-2  9  6
 6 -6 -5
Here is the matrix m after the for-range-loop:
-7  0 -3
 2  0  6
-6  0 -5
The first empty column is: 1

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

Definition at line 187 of file VectorwiseOp.h.

Member Typedef Documentation

◆ AllReturnType

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

Definition at line 353 of file VectorwiseOp.h.

◆ AnyReturnType

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

Definition at line 354 of file VectorwiseOp.h.

◆ BlueNormReturnType

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

Definition at line 348 of file VectorwiseOp.h.

◆ ConstReverseReturnType

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

Definition at line 357 of file VectorwiseOp.h.

◆ CountReturnType

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

Definition at line 355 of file VectorwiseOp.h.

◆ CrossReturnType

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

Definition at line 713 of file VectorwiseOp.h.

◆ ExpressionTypeNested

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

Definition at line 194 of file VectorwiseOp.h.

◆ ExpressionTypeNestedCleaned

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

Definition at line 195 of file VectorwiseOp.h.

◆ 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

Definition at line 728 of file VectorwiseOp.h.

◆ 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

Definition at line 732 of file VectorwiseOp.h.

◆ HNormalizedReturnType

template<typename ExpressionType , int Direction>
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> > Eigen::VectorwiseOp< ExpressionType, Direction >::HNormalizedReturnType

Definition at line 738 of file VectorwiseOp.h.

◆ HomogeneousReturnType

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

Definition at line 709 of file VectorwiseOp.h.

◆ HypotNormReturnType

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

Definition at line 350 of file VectorwiseOp.h.

◆ Index

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

Definition at line 193 of file VectorwiseOp.h.

◆ MaxCoeffReturnType

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

Definition at line 345 of file VectorwiseOp.h.

◆ MinCoeffReturnType

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

Definition at line 344 of file VectorwiseOp.h.

◆ NormReturnType

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

Definition at line 347 of file VectorwiseOp.h.

◆ ProdReturnType

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

Definition at line 356 of file VectorwiseOp.h.

◆ RealScalar

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

Definition at line 192 of file VectorwiseOp.h.

◆ ReplicateReturnType

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

Definition at line 553 of file VectorwiseOp.h.

◆ ReverseReturnType

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

Definition at line 358 of file VectorwiseOp.h.

◆ Scalar

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

Definition at line 191 of file VectorwiseOp.h.

◆ 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

Definition at line 346 of file VectorwiseOp.h.

◆ StableNormReturnType

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

Definition at line 349 of file VectorwiseOp.h.

◆ SumReturnType

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

Definition at line 351 of file VectorwiseOp.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename ExpressionType , int Direction>
anonymous enum
Enumerator
isVertical 
isHorizontal 

Definition at line 214 of file VectorwiseOp.h.

214  {
215  isVertical = (Direction==Vertical) ? 1 : 0,
216  isHorizontal = (Direction==Horizontal) ? 1 : 0
217  };
@ Horizontal
Definition: Constants.h:269
@ Vertical
Definition: Constants.h:266

◆ anonymous enum

template<typename ExpressionType , int Direction>
anonymous enum
Enumerator
HNormalized_Size 
HNormalized_SizeMinusOne 

Definition at line 718 of file VectorwiseOp.h.

718  {
719  HNormalized_Size = Direction==Vertical ? internal::traits<ExpressionType>::RowsAtCompileTime
720  : internal::traits<ExpressionType>::ColsAtCompileTime,
722  };
const int Dynamic
Definition: Constants.h:24

Constructor & Destructor Documentation

◆ VectorwiseOp()

template<typename ExpressionType , int Direction>
Eigen::VectorwiseOp< ExpressionType, Direction >::VectorwiseOp ( ExpressionType &  matrix)
inlineexplicit

Definition at line 269 of file VectorwiseOp.h.

269 : m_matrix(matrix) {}
ExpressionTypeNested m_matrix
Definition: VectorwiseOp.h:752

Member Function Documentation

◆ _expression()

template<typename ExpressionType , int Direction>
const ExpressionType& Eigen::VectorwiseOp< ExpressionType, Direction >::_expression ( ) const
inline

Definition at line 273 of file VectorwiseOp.h.

273 { return m_matrix; }

◆ 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()

Definition at line 497 of file VectorwiseOp.h.

498  { return AllReturnType(_expression()); }
const ExpressionType & _expression() const
Definition: VectorwiseOp.h:273
ReturnType< internal::member_all, bool >::Type AllReturnType
Definition: VectorwiseOp.h:353

◆ 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()

Definition at line 506 of file VectorwiseOp.h.

507  { return AnyReturnType(_expression()); }
ReturnType< internal::member_any, bool >::Type AnyReturnType
Definition: VectorwiseOp.h:354

◆ 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()

Definition at line 292 of file VectorwiseOp.h.

292 { return iterator (m_matrix, 0); }
random_access_iterator_type iterator
Definition: VectorwiseOp.h:279

◆ begin() [2/2]

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

const version of begin()

Definition at line 294 of file VectorwiseOp.h.

294 { return const_iterator(m_matrix, 0); }
random_access_iterator_type const_iterator
Definition: VectorwiseOp.h:281

◆ 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()

Definition at line 447 of file VectorwiseOp.h.

448  { return BlueNormReturnType(_expression()); }
ReturnType< internal::member_blueNorm, RealScalar >::Type BlueNormReturnType
Definition: VectorwiseOp.h:348

◆ cbegin()

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

const version of begin()

Definition at line 296 of file VectorwiseOp.h.

296 { return const_iterator(m_matrix, 0); }

◆ cend()

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

const version of end()

Definition at line 314 of file VectorwiseOp.h.

314 { return const_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>()); }
EIGEN_CONSTEXPR Index subVectors() const
DirectionType
Definition: Constants.h:263

◆ 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:

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

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()

Definition at line 519 of file VectorwiseOp.h.

520  { return CountReturnType(_expression()); }
PartialReduxExpr< ExpressionType, internal::member_count< Index, Scalar >, Direction > CountReturnType
Definition: VectorwiseOp.h:355

◆ crbegin()

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

const version of rbegin()

Definition at line 305 of file VectorwiseOp.h.

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

◆ crend()

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

const version of rend()

Definition at line 323 of file VectorwiseOp.h.

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

◆ 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()

Definition at line 310 of file VectorwiseOp.h.

310 { return iterator (m_matrix, m_matrix.template subVectors<DirectionType(Direction)>()); }

◆ end() [2/2]

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

const version of end()

Definition at line 312 of file VectorwiseOp.h.

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

◆ extendedTo()

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

Definition at line 232 of file VectorwiseOp.h.

233  {
234  EIGEN_STATIC_ASSERT(internal::check_implication(isVertical, OtherDerived::MaxColsAtCompileTime==1),
235  YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)
236  EIGEN_STATIC_ASSERT(internal::check_implication(isHorizontal, OtherDerived::MaxRowsAtCompileTime==1),
237  YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)
238  return typename ExtendedType<OtherDerived>::Type
239  (other.derived(),
240  isVertical ? 1 : m_matrix.rows(),
241  isHorizontal ? 1 : m_matrix.cols());
242  }
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
constexpr bool check_implication(bool a, bool b)
Definition: Meta.h:579
Replicate< OtherDerived, isVertical ? 1 :ExpressionType::RowsAtCompileTime, isHorizontal ? 1 :ExpressionType::ColsAtCompileTime > Type
Definition: VectorwiseOp.h:224

◆ extendedToOpposite()

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

Definition at line 255 of file VectorwiseOp.h.

256  {
257  EIGEN_STATIC_ASSERT(internal::check_implication(isHorizontal, OtherDerived::MaxColsAtCompileTime==1),
258  YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)
259  EIGEN_STATIC_ASSERT(internal::check_implication(isVertical, OtherDerived::MaxRowsAtCompileTime==1),
260  YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)
262  (other.derived(),
263  isHorizontal ? 1 : m_matrix.rows(),
264  isVertical ? 1 : m_matrix.cols());
265  }
Replicate< OtherDerived, isHorizontal ? 1 :ExpressionType::RowsAtCompileTime, isVertical ? 1 :ExpressionType::ColsAtCompileTime > Type
Definition: VectorwiseOp.h:247

◆ 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()

Definition at line 469 of file VectorwiseOp.h.

470  { return HypotNormReturnType(_expression()); }
ReturnType< internal::member_hypotNorm, RealScalar >::Type HypotNormReturnType
Definition: VectorwiseOp.h:350

◆ lpNorm()

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

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()

Definition at line 436 of file VectorwiseOp.h.

437  { return typename LpNormReturnType<p>::Type(_expression()); }
PartialReduxExpr< ExpressionType, internal::member_lpnorm< p, RealScalar, Scalar >, Direction > Type
Definition: VectorwiseOp.h:361

◆ 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 size along the reduction direction must be strictly positive, otherwise an assertion is triggered.
the result is undefined if *this contains NaN.

Example:

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()

Definition at line 396 of file VectorwiseOp.h.

397  {
398  eigen_assert(redux_length()>0 && "you are using an empty matrix");
400  }
#define eigen_assert(x)
Definition: Macros.h:902
ReturnType< internal::member_maxCoeff >::Type MaxCoeffReturnType
Definition: VectorwiseOp.h:345
Index redux_length() const
Definition: VectorwiseOp.h:748

◆ 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()

Definition at line 488 of file VectorwiseOp.h.

489  { return sum() / Scalar(Direction==Vertical?m_matrix.rows():m_matrix.cols()); }
ExpressionType::Scalar Scalar
Definition: VectorwiseOp.h:191
const SumReturnType sum() const
Definition: VectorwiseOp.h:480

◆ 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 size along the reduction direction must be strictly positive, otherwise an assertion is triggered.
the result is undefined if *this contains NaN.

Example:

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()

Definition at line 377 of file VectorwiseOp.h.

378  {
379  eigen_assert(redux_length()>0 && "you are using an empty matrix");
381  }
ReturnType< internal::member_minCoeff >::Type MinCoeffReturnType
Definition: VectorwiseOp.h:344

◆ 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:

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()

Definition at line 423 of file VectorwiseOp.h.

424  { return NormReturnType(squaredNorm()); }
const SquaredNormReturnType squaredNorm() const
Definition: VectorwiseOp.h:411
CwiseUnaryOp< internal::scalar_sqrt_op< RealScalar >, const SquaredNormReturnType > NormReturnType
Definition: VectorwiseOp.h:347

◆ 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()

Definition at line 701 of file VectorwiseOp.h.

701  {
702  m_matrix = this->normalized();
703  }
CwiseBinaryOp< internal::scalar_quotient_op< Scalar >, const ExpressionTypeNestedCleaned, const typename OppositeExtendedType< NormReturnType >::Type > normalized() const
Definition: VectorwiseOp.h:695

◆ normalized()

template<typename ExpressionType , int Direction>
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()

Definition at line 695 of file VectorwiseOp.h.

695 { return m_matrix.cwiseQuotient(extendedToOpposite(this->norm())); }
OppositeExtendedType< OtherDerived >::Type extendedToOpposite(const DenseBase< OtherDerived > &other) const
Definition: VectorwiseOp.h:255
const NormReturnType norm() const
Definition: VectorwiseOp.h:423

◆ operator*()

template<typename ExpressionType , int Direction>
template<typename OtherDerived >
CwiseBinaryOp<internal::scalar_product_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 product of the vector other by the corresponding subvector of *this

Definition at line 664 of file VectorwiseOp.h.

665  {
666  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
667  EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
668  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
669  return m_matrix * extendedTo(other.derived());
670  }
#define EIGEN_STATIC_ASSERT_ARRAYXPR(Derived)
Definition: StaticAssert.h:100
#define EIGEN_STATIC_ASSERT_SAME_XPR_KIND(Derived1, Derived2)
Definition: StaticAssert.h:104
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Definition: StaticAssert.h:36
ExtendedType< OtherDerived >::Type extendedTo(const DenseBase< OtherDerived > &other) const
Definition: VectorwiseOp.h:232

◆ operator*=()

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

Multiplies each subvector of *this by the vector other

Definition at line 611 of file VectorwiseOp.h.

612  {
613  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
614  EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
615  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
616  m_matrix *= extendedTo(other.derived());
617  return m_matrix;
618  }

◆ operator+()

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

Definition at line 637 of file VectorwiseOp.h.

638  {
639  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
640  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
641  return m_matrix + extendedTo(other.derived());
642  }

◆ 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

Definition at line 591 of file VectorwiseOp.h.

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

◆ operator-()

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

Definition at line 650 of file VectorwiseOp.h.

651  {
652  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
653  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
654  return m_matrix - extendedTo(other.derived());
655  }

◆ operator-=()

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

Subtracts the vector other to each subvector of *this

Definition at line 601 of file VectorwiseOp.h.

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

◆ operator/()

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

Definition at line 679 of file VectorwiseOp.h.

680  {
681  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
682  EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
683  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
684  return m_matrix / extendedTo(other.derived());
685  }

◆ 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

Definition at line 623 of file VectorwiseOp.h.

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

◆ 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

Definition at line 580 of file VectorwiseOp.h.

581  {
582  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
583  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
584  //eigen_assert((m_matrix.isNull()) == (other.isNull())); FIXME
585  return m_matrix = extendedTo(other.derived());
586  }

◆ 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:

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()

Definition at line 530 of file VectorwiseOp.h.

531  { return ProdReturnType(_expression()); }
ReturnType< internal::member_prod >::Type ProdReturnType
Definition: VectorwiseOp.h:356

◆ 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()

Definition at line 301 of file VectorwiseOp.h.

301 { return reverse_iterator (m_matrix, m_matrix.template subVectors<DirectionType(Direction)>()-1); }

◆ rbegin() [2/2]

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

const version of rbegin()

Definition at line 303 of file VectorwiseOp.h.

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

◆ redux()

template<typename ExpressionType , int Direction>
template<typename BinaryOp >
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()

Definition at line 338 of file VectorwiseOp.h.

339  {
340  eigen_assert(redux_length()>0 && "you are using an empty matrix");
341  return typename ReduxReturnType<BinaryOp>::Type(_expression(), internal::member_redux<BinaryOp,Scalar>(func));
342  }
PartialReduxExpr< ExpressionType, internal::member_redux< BinaryOp, Scalar >, Direction > Type
Definition: VectorwiseOp.h:211

◆ redux_length()

template<typename ExpressionType , int Direction>
Index Eigen::VectorwiseOp< ExpressionType, Direction >::redux_length ( ) const
inlineprotected

Definition at line 748 of file VectorwiseOp.h.

749  {
750  return Direction==Vertical ? m_matrix.rows() : m_matrix.cols();
751  }

◆ 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()

Definition at line 319 of file VectorwiseOp.h.

319 { return reverse_iterator (m_matrix, -1); }

◆ rend() [2/2]

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

const version of rend()

Definition at line 321 of file VectorwiseOp.h.

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

◆ 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:

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
Matrix< int, 3, 1 > Vector3i
3×1 vector of type int.
Definition: Matrix.h:500

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

Definition at line 136 of file Replicate.h.

137 {
139  (_expression(),Direction==Vertical?factor:1,Direction==Horizontal?factor:1);
140 }
Replicate< ExpressionType,(isVertical?Dynamic:1),(isHorizontal?Dynamic:1)> ReplicateReturnType
Definition: VectorwiseOp.h:553

◆ replicate() [2/2]

template<typename ExpressionType , int Direction>
template<int Factor>
const Replicate<ExpressionType,isVertical*Factor+isHorizontal,isHorizontal*Factor+isVertical> Eigen::VectorwiseOp< ExpressionType, Direction >::replicate ( Index  factor = Factor) const
inline
Returns
an expression of the replication of each column (or row) of *this

Example:

cout << "Here is the matrix m:" << endl << m << endl;
cout << "m.colwise().replicate<3>() = ..." << endl;
cout << m.colwise().replicate<3>() << endl;
Matrix< int, Dynamic, Dynamic > MatrixXi
Dynamic×Dynamic matrix of type int.
Definition: Matrix.h:500

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

Definition at line 569 of file VectorwiseOp.h.

570  {
571  return Replicate<ExpressionType,(isVertical?Factor:1),(isHorizontal?Factor:1)>
572  (_expression(),isVertical?factor:1,isHorizontal?factor:1);
573  }

◆ 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

Definition at line 550 of file VectorwiseOp.h.

551  { return ReverseReturnType( _expression() ); }
Reverse< ExpressionType, Direction > ReverseReturnType
Definition: VectorwiseOp.h:358

◆ 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:

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()

Definition at line 542 of file VectorwiseOp.h.

543  { return ConstReverseReturnType( _expression() ); }
Reverse< const ExpressionType, Direction > ConstReverseReturnType
Definition: VectorwiseOp.h:357

◆ 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()

Definition at line 212 of file Reverse.h.

213 {
214  internal::vectorwise_reverse_inplace_impl<Direction>::run(m_matrix);
215 }

◆ 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:

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()

Definition at line 411 of file VectorwiseOp.h.

412  { return SquaredNormReturnType(m_matrix.cwiseAbs2()); }
PartialReduxExpr< const CwiseUnaryOp< internal::scalar_abs2_op< Scalar >, const ExpressionTypeNestedCleaned >, internal::member_sum< RealScalar, RealScalar >, Direction > SquaredNormReturnType
Definition: VectorwiseOp.h:346

◆ 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()

Definition at line 458 of file VectorwiseOp.h.

459  { return StableNormReturnType(_expression()); }
ReturnType< internal::member_stableNorm, RealScalar >::Type StableNormReturnType
Definition: VectorwiseOp.h:349

◆ 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:

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()

Definition at line 480 of file VectorwiseOp.h.

481  { return SumReturnType(_expression()); }
ReturnType< internal::member_sum >::Type SumReturnType
Definition: VectorwiseOp.h:351

Member Data Documentation

◆ const_iterator

template<typename ExpressionType , int Direction>
random_access_iterator_type Eigen::VectorwiseOp< ExpressionType, Direction >::const_iterator

This is the const version of iterator (aka read-only)

Definition at line 281 of file VectorwiseOp.h.

◆ iterator

template<typename ExpressionType , int Direction>
random_access_iterator_type Eigen::VectorwiseOp< ExpressionType, Direction >::iterator

STL-like RandomAccessIterator iterator type over the columns or rows as returned by the begin() and end() methods.

Definition at line 279 of file VectorwiseOp.h.

◆ m_matrix

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

Definition at line 752 of file VectorwiseOp.h.


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