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< ExpressionTypeNested > | ExpressionTypeNestedCleaned |
typedef Block< const ExpressionType, Direction==Vertical ? int(HNormalized_SizeMinusOne) :int(internal::traits< ExpressionType >::RowsAtCompileTime), Direction==Horizontal ? int(HNormalized_SizeMinusOne) :int(internal::traits< ExpressionType >::ColsAtCompileTime)> | HNormalized_Block |
typedef Block< const ExpressionType, Direction==Vertical ? 1 :int(internal::traits< ExpressionType >::RowsAtCompileTime), Direction==Horizontal ? 1 :int(internal::traits< ExpressionType >::ColsAtCompileTime)> | HNormalized_Factors |
typedef CwiseBinaryOp< internal::scalar_quotient_op< typename internal::traits< ExpressionType >::Scalar >, const HNormalized_Block, const Replicate< HNormalized_Factors, Direction==Vertical ? HNormalized_SizeMinusOne :1, Direction==Horizontal ? HNormalized_SizeMinusOne :1 > > | HNormalizedReturnType |
typedef 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 SquaredNormReturnType > | NormReturnType |
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+isVertical > | replicate (Index factor=Factor) const |
ReverseReturnType | reverse () |
const ConstReverseReturnType | reverse () const |
void | reverseInPlace () |
const SquaredNormReturnType | squaredNorm () const |
const StableNormReturnType | stableNorm () const |
const SumReturnType | sum () const |
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 |
Pseudo expression providing broadcasting and partial reduction operations.
ExpressionType | the type of the object on which to do partial reductions |
Direction | indicates 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:
Example:
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:
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:
MatrixXd(n,0).colwise().prod()
)Definition at line 187 of file VectorwiseOp.h.
typedef ReturnType<internal::member_all, bool>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::AllReturnType |
Definition at line 353 of file VectorwiseOp.h.
typedef ReturnType<internal::member_any, bool>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::AnyReturnType |
Definition at line 354 of file VectorwiseOp.h.
typedef ReturnType<internal::member_blueNorm,RealScalar>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::BlueNormReturnType |
Definition at line 348 of file VectorwiseOp.h.
typedef Reverse<const ExpressionType, Direction> Eigen::VectorwiseOp< ExpressionType, Direction >::ConstReverseReturnType |
Definition at line 357 of file VectorwiseOp.h.
typedef PartialReduxExpr<ExpressionType, internal::member_count<Index,Scalar>, Direction> Eigen::VectorwiseOp< ExpressionType, Direction >::CountReturnType |
Definition at line 355 of file VectorwiseOp.h.
typedef ExpressionType::PlainObject Eigen::VectorwiseOp< ExpressionType, Direction >::CrossReturnType |
Definition at line 713 of file VectorwiseOp.h.
typedef internal::ref_selector<ExpressionType>::non_const_type Eigen::VectorwiseOp< ExpressionType, Direction >::ExpressionTypeNested |
Definition at line 194 of file VectorwiseOp.h.
typedef internal::remove_all_t<ExpressionTypeNested> Eigen::VectorwiseOp< ExpressionType, Direction >::ExpressionTypeNestedCleaned |
Definition at line 195 of file VectorwiseOp.h.
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.
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.
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.
typedef Homogeneous<ExpressionType,Direction> Eigen::VectorwiseOp< ExpressionType, Direction >::HomogeneousReturnType |
Definition at line 709 of file VectorwiseOp.h.
typedef ReturnType<internal::member_hypotNorm,RealScalar>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::HypotNormReturnType |
Definition at line 350 of file VectorwiseOp.h.
typedef Eigen::Index Eigen::VectorwiseOp< ExpressionType, Direction >::Index |
Definition at line 193 of file VectorwiseOp.h.
typedef ReturnType<internal::member_maxCoeff>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::MaxCoeffReturnType |
Definition at line 345 of file VectorwiseOp.h.
typedef ReturnType<internal::member_minCoeff>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::MinCoeffReturnType |
Definition at line 344 of file VectorwiseOp.h.
typedef CwiseUnaryOp<internal::scalar_sqrt_op<RealScalar>, const SquaredNormReturnType> Eigen::VectorwiseOp< ExpressionType, Direction >::NormReturnType |
Definition at line 347 of file VectorwiseOp.h.
typedef ReturnType<internal::member_prod>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::ProdReturnType |
Definition at line 356 of file VectorwiseOp.h.
typedef ExpressionType::RealScalar Eigen::VectorwiseOp< ExpressionType, Direction >::RealScalar |
Definition at line 192 of file VectorwiseOp.h.
typedef Replicate<ExpressionType,(isVertical?Dynamic:1),(isHorizontal?Dynamic:1)> Eigen::VectorwiseOp< ExpressionType, Direction >::ReplicateReturnType |
Definition at line 553 of file VectorwiseOp.h.
typedef Reverse<ExpressionType, Direction> Eigen::VectorwiseOp< ExpressionType, Direction >::ReverseReturnType |
Definition at line 358 of file VectorwiseOp.h.
typedef ExpressionType::Scalar Eigen::VectorwiseOp< ExpressionType, Direction >::Scalar |
Definition at line 191 of file VectorwiseOp.h.
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.
typedef ReturnType<internal::member_stableNorm,RealScalar>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::StableNormReturnType |
Definition at line 349 of file VectorwiseOp.h.
typedef ReturnType<internal::member_sum>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::SumReturnType |
Definition at line 351 of file VectorwiseOp.h.
anonymous enum |
anonymous enum |
Enumerator | |
---|---|
HNormalized_Size | |
HNormalized_SizeMinusOne |
Definition at line 718 of file VectorwiseOp.h.
|
inlineexplicit |
Definition at line 269 of file VectorwiseOp.h.
|
inline |
Definition at line 273 of file VectorwiseOp.h.
|
inline |
true
. This expression can be assigned to a vector with entries of type bool
.Definition at line 497 of file VectorwiseOp.h.
|
inline |
true
. This expression can be assigned to a vector with entries of type bool
.Definition at line 506 of file VectorwiseOp.h.
|
inline |
returns an iterator to the first row (rowwise) or column (colwise) of the nested expression.
Definition at line 292 of file VectorwiseOp.h.
|
inline |
const version of begin()
Definition at line 294 of file VectorwiseOp.h.
|
inline |
Definition at line 447 of file VectorwiseOp.h.
|
inline |
|
inline |
|
inline |
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:
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
Definition at line 519 of file VectorwiseOp.h.
|
inline |
const version of rbegin()
Definition at line 305 of file VectorwiseOp.h.
|
inline |
typedef Eigen::VectorwiseOp< ExpressionType, Direction >::EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE | ( | SumReturnType | , |
Scalar | , | ||
quotient | |||
) |
|
inline |
returns an iterator to the row (resp. column) following the last row (resp. column) of the nested expression
Definition at line 310 of file VectorwiseOp.h.
|
inline |
|
inlineprotected |
Definition at line 232 of file VectorwiseOp.h.
|
inlineprotected |
Definition at line 255 of file VectorwiseOp.h.
|
inline |
Definition at line 469 of file VectorwiseOp.h.
|
inline |
Example:
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
Definition at line 436 of file VectorwiseOp.h.
|
inline |
*this
contains NaN.Example:
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
Definition at line 396 of file VectorwiseOp.h.
|
inline |
Definition at line 488 of file VectorwiseOp.h.
|
inline |
*this
contains NaN.Example:
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
Definition at line 377 of file VectorwiseOp.h.
|
inline |
Example:
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
Definition at line 423 of file VectorwiseOp.h.
|
inline |
Normalize in-place each row or columns of the referenced matrix.
Definition at line 701 of file VectorwiseOp.h.
|
inline |
Definition at line 695 of file VectorwiseOp.h.
|
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.
|
inline |
Multiplies each subvector of *this
by the vector other
Definition at line 611 of file VectorwiseOp.h.
|
inline |
Returns the expression of the sum of the vector other to each subvector of *this
Definition at line 637 of file VectorwiseOp.h.
|
inline |
|
inline |
Returns the expression of the difference between each subvector of *this
and the vector other
Definition at line 650 of file VectorwiseOp.h.
|
inline |
Subtracts the vector other to each subvector of *this
Definition at line 601 of file VectorwiseOp.h.
|
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.
|
inline |
|
inline |
|
inline |
Example:
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
Definition at line 530 of file VectorwiseOp.h.
|
inline |
returns a reverse iterator to the last row (rowwise) or column (colwise) of the nested expression.
Definition at line 301 of file VectorwiseOp.h.
|
inline |
const version of rbegin()
Definition at line 303 of file VectorwiseOp.h.
|
inline |
*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.
Definition at line 338 of file VectorwiseOp.h.
|
inlineprotected |
Definition at line 748 of file VectorwiseOp.h.
|
inline |
returns a reverse iterator to the row (resp. column) before the first row (resp. column) of the nested expression
Definition at line 319 of file VectorwiseOp.h.
|
inline |
const VectorwiseOp< ExpressionType, Direction >::ReplicateReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::replicate | ( | Index | factor | ) | const |
*this
Example:
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
Definition at line 136 of file Replicate.h.
|
inline |
*this
Example:
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
Definition at line 569 of file VectorwiseOp.h.
|
inline |
Definition at line 550 of file VectorwiseOp.h.
|
inline |
Example:
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
Definition at line 542 of file VectorwiseOp.h.
|
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:
|
inline |
Example:
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
Definition at line 411 of file VectorwiseOp.h.
|
inline |
Definition at line 458 of file VectorwiseOp.h.
|
inline |
Example:
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
Definition at line 480 of file VectorwiseOp.h.
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.
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.
|
protected |
Definition at line 752 of file VectorwiseOp.h.