![]() |
Eigen
3.3.3
|
Pseudo expression providing partial reduction operations.
ExpressionType | the type of the object on which to do partial reductions |
Direction | indicates the direction of the redux (#Vertical or #Horizontal) |
This class represents a pseudo expression with partial reduction features. It is the return type of DenseBase::colwise() and DenseBase::rowwise() and most of the time this is the only way it is used.
Example:
Matrix3d m = Matrix3d::Random(); cout << "Here is the matrix m:" << endl << m << endl; cout << "Here is the sum of each column:" << endl << m.colwise().sum() << endl; cout << "Here is the maximum absolute value of each column:" << endl << m.cwiseAbs().colwise().maxCoeff() << endl;
Output:
Here is the matrix m: 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
Public Types | |
typedef Eigen::Index | Index |
Public Member Functions | |
const AllReturnType | all () const |
const AnyReturnType | any () const |
const BlueNormReturnType | blueNorm () const |
const CountReturnType | count () const |
template<typename OtherDerived > | |
const CrossReturnType | cross (const MatrixBase< OtherDerived > &other) const |
const HNormalizedReturnType | hnormalized () const |
column or row-wise homogeneous normalization | |
HomogeneousReturnType | homogeneous () const |
const HypotNormReturnType | hypotNorm () const |
template<int p> | |
const LpNormReturnType< p >::Type | lpNorm () const |
const MaxCoeffReturnType | maxCoeff () const |
const MeanReturnType | mean () const |
const MinCoeffReturnType | minCoeff () const |
const NormReturnType | norm () const |
void | normalize () |
CwiseBinaryOp < internal::scalar_quotient_op < Scalar >, const ExpressionTypeNestedCleaned, const typename OppositeExtendedType< typename ReturnType < internal::member_norm, RealScalar >::Type >::Type > | normalized () const |
template<typename OtherDerived > | |
CwiseBinaryOp < internal::scalar_product_op < Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType < OtherDerived >::Type > | operator* (const DenseBase< OtherDerived > &other) const |
template<typename OtherDerived > | |
ExpressionType & | operator*= (const DenseBase< OtherDerived > &other) |
template<typename OtherDerived > | |
CwiseBinaryOp < internal::scalar_sum_op < Scalar, typename OtherDerived::Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType < OtherDerived >::Type > | operator+ (const DenseBase< OtherDerived > &other) const |
template<typename OtherDerived > | |
ExpressionType & | operator+= (const DenseBase< OtherDerived > &other) |
template<typename OtherDerived > | |
CwiseBinaryOp < internal::scalar_difference_op < Scalar, typename OtherDerived::Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType < OtherDerived >::Type > | operator- (const DenseBase< OtherDerived > &other) const |
template<typename OtherDerived > | |
ExpressionType & | operator-= (const DenseBase< OtherDerived > &other) |
template<typename OtherDerived > | |
CwiseBinaryOp < internal::scalar_quotient_op < Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType < OtherDerived >::Type > | operator/ (const DenseBase< OtherDerived > &other) const |
template<typename OtherDerived > | |
ExpressionType & | operator/= (const DenseBase< OtherDerived > &other) |
template<typename OtherDerived > | |
ExpressionType & | operator= (const DenseBase< OtherDerived > &other) |
const ProdReturnType | prod () const |
template<typename BinaryOp > | |
const ReduxReturnType < BinaryOp >::Type | redux (const BinaryOp &func=BinaryOp()) const |
const ReplicateReturnType | replicate (Index factor) const |
template<int Factor> | |
const Replicate < ExpressionType, isVertical *Factor+isHorizontal, isHorizontal *Factor+isVertical > | replicate (Index factor=Factor) const |
const ConstReverseReturnType | reverse () const |
ReverseReturnType | reverse () |
void | reverseInPlace () |
const SquaredNormReturnType | squaredNorm () const |
const StableNormReturnType | stableNorm () const |
const SumReturnType | sum () const |
typedef Eigen::Index Eigen::VectorwiseOp< ExpressionType, Direction >::Index |
const AllReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::all | ( | ) | const [inline] |
true
. This expression can be assigned to a vector with entries of type bool
.const AnyReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::any | ( | ) | const [inline] |
true
. This expression can be assigned to a vector with entries of type bool
.const BlueNormReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::blueNorm | ( | ) | const [inline] |
const CountReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::count | ( | ) | const [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:
Matrix3d m = Matrix3d::Random(); cout << "Here is the matrix m:" << endl << m << endl; Matrix<ptrdiff_t, 3, 1> res = (m.array() >= 0.5).rowwise().count(); cout << "Here is the count of elements larger or equal than 0.5 of each row:" << endl; cout << res << endl;
Output:
Here is the matrix m: 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
const HypotNormReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::hypotNorm | ( | ) | const [inline] |
const LpNormReturnType<p>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::lpNorm | ( | ) | const [inline] |
Example:
Matrix3d m = Matrix3d::Random(); cout << "Here is the matrix m:" << endl << m << endl; cout << "Here is the norm of each column:" << endl << m.colwise().norm() << endl;
Output:
Here is the matrix m: 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
const MaxCoeffReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::maxCoeff | ( | ) | const [inline] |
*this
contains NaN.Example:
Matrix3d m = Matrix3d::Random(); cout << "Here is the matrix m:" << endl << m << endl; cout << "Here is the maximum of each column:" << endl << m.colwise().maxCoeff() << endl;
Output:
Here is the matrix m: 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
const MeanReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::mean | ( | ) | const [inline] |
const MinCoeffReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::minCoeff | ( | ) | const [inline] |
*this
contains NaN.Example:
Matrix3d m = Matrix3d::Random(); cout << "Here is the matrix m:" << endl << m << endl; cout << "Here is the minimum of each column:" << endl << m.colwise().minCoeff() << endl;
Output:
Here is the matrix m: 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
const NormReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::norm | ( | ) | const [inline] |
Example:
Matrix3d m = Matrix3d::Random(); cout << "Here is the matrix m:" << endl << m << endl; cout << "Here is the norm of each column:" << endl << m.colwise().norm() << endl;
Output:
Here is the matrix m: 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
void Eigen::VectorwiseOp< ExpressionType, Direction >::normalize | ( | ) | [inline] |
Normalize in-place each row or columns of the referenced matrix.
CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const ExpressionTypeNestedCleaned, const typename OppositeExtendedType<typename ReturnType<internal::member_norm,RealScalar>::Type>::Type> Eigen::VectorwiseOp< ExpressionType, Direction >::normalized | ( | ) | const [inline] |
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
ExpressionType& Eigen::VectorwiseOp< ExpressionType, Direction >::operator*= | ( | const DenseBase< OtherDerived > & | other | ) | [inline] |
Multiples each subvector of *this
by the vector other
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
ExpressionType& Eigen::VectorwiseOp< ExpressionType, Direction >::operator+= | ( | const DenseBase< OtherDerived > & | other | ) | [inline] |
Adds the vector other to each subvector of *this
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
ExpressionType& Eigen::VectorwiseOp< ExpressionType, Direction >::operator-= | ( | const DenseBase< OtherDerived > & | other | ) | [inline] |
Substracts the vector other to each subvector of *this
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
ExpressionType& Eigen::VectorwiseOp< ExpressionType, Direction >::operator/= | ( | const DenseBase< OtherDerived > & | other | ) | [inline] |
Divides each subvector of *this
by the vector other
ExpressionType& Eigen::VectorwiseOp< ExpressionType, Direction >::operator= | ( | const DenseBase< OtherDerived > & | other | ) | [inline] |
Copies the vector other to each subvector of *this
const ProdReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::prod | ( | ) | const [inline] |
Example:
Matrix3d m = Matrix3d::Random(); cout << "Here is the matrix m:" << endl << m << endl; cout << "Here is the product of each row:" << endl << m.rowwise().prod() << endl;
Output:
Here is the matrix m: 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
const ReduxReturnType<BinaryOp>::Type Eigen::VectorwiseOp< ExpressionType, Direction >::redux | ( | const BinaryOp & | func = BinaryOp() | ) | const [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.
const VectorwiseOp< ExpressionType, Direction >::ReplicateReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::replicate | ( | Index | factor | ) | const |
*this
Example:
Vector3i v = Vector3i::Random(); cout << "Here is the vector v:" << endl << v << endl; cout << "v.rowwise().replicate(5) = ..." << endl; cout << v.rowwise().replicate(5) << endl;
Output:
Here is the vector v: 7 -2 6 v.rowwise().replicate(5) = ... 7 7 7 7 7 -2 -2 -2 -2 -2 6 6 6 6 6
const Replicate<ExpressionType,isVertical*Factor+isHorizontal,isHorizontal*Factor+isVertical> Eigen::VectorwiseOp< ExpressionType, Direction >::replicate | ( | Index | factor = Factor | ) | const [inline] |
*this
Example:
MatrixXi m = MatrixXi::Random(2,3); cout << "Here is the matrix m:" << endl << m << endl; cout << "m.colwise().replicate<3>() = ..." << endl; cout << m.colwise().replicate<3>() << endl;
Output:
Here is the matrix m: 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
const ConstReverseReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::reverse | ( | ) | const [inline] |
Example:
MatrixXi m = MatrixXi::Random(3,4); cout << "Here is the matrix m:" << endl << m << endl; cout << "Here is the rowwise reverse of m:" << endl << m.rowwise().reverse() << endl; cout << "Here is the colwise reverse of m:" << endl << m.colwise().reverse() << endl; cout << "Here is the coefficient (1,0) in the rowise reverse of m:" << endl << m.rowwise().reverse()(1,0) << endl; cout << "Let us overwrite this coefficient with the value 4." << endl; //m.colwise().reverse()(1,0) = 4; cout << "Now the matrix m is:" << endl << m << endl;
Output:
Here is the matrix m: 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
ReverseReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::reverse | ( | ) | [inline] |
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:
m = m.reverse().eval();
const SquaredNormReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::squaredNorm | ( | ) | const [inline] |
Example:
Matrix3d m = Matrix3d::Random(); cout << "Here is the matrix m:" << endl << m << endl; cout << "Here is the square norm of each row:" << endl << m.rowwise().squaredNorm() << endl;
Output:
Here is the matrix m: 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
const StableNormReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::stableNorm | ( | ) | const [inline] |
const SumReturnType Eigen::VectorwiseOp< ExpressionType, Direction >::sum | ( | ) | const [inline] |
Example:
Matrix3d m = Matrix3d::Random(); cout << "Here is the matrix m:" << endl << m << endl; cout << "Here is the sum of each row:" << endl << m.rowwise().sum() << endl;
Output:
Here is the matrix m: 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