|
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< ExpressionTypeNested > | ExpressionTypeNestedCleaned |
|
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 >, Direction > | SquaredNormReturnType |
|
typedef CwiseUnaryOp< internal::scalar_sqrt_op< RealScalar >, const SquaredNormReturnType > | NormReturnType |
|
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 >, Direction > | CountReturnType |
|
typedef ReturnType< internal::member_prod >::Type | ProdReturnType |
|
typedef Reverse< const ExpressionType, Direction > | ConstReverseReturnType |
|
typedef Reverse< ExpressionType, Direction > | ReverseReturnType |
|
typedef Replicate< ExpressionType,(isVertical ? Dynamic :1),(isHorizontal ? Dynamic :1)> | ReplicateReturnType |
|
typedef Homogeneous< ExpressionType, Direction > | HomogeneousReturnType |
|
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 |
|
|
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...
|
|
template<typename ExpressionType, int Direction>
class Eigen::VectorwiseOp< ExpressionType, Direction >
Pseudo expression providing broadcasting and partial reduction operations.
- Template Parameters
-
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:
[
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;
for (
auto c :
m.colwise()) {
}
cout <<
"Here is the matrix m after the for-range-loop:" << endl <<
m << endl;
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
template<typename ExpressionType , int Direction>
template<typename OtherDerived >
Replicates a vector to match the size of *this
225 YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)
227 YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)
#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=().