Eigen Helpers

Wrap With Constant

template<typename ArgType>
Eigen::CwiseNullaryOp<wrap_with_constant_functor<ArgType>, typename array_passthrough_helper<ArgType>::ArrayType> hector_math::eigen::wrapWithConstant(const Eigen::ArrayBase<ArgType> &mat, typename ArgType::Scalar value, Eigen::Index rows, Eigen::Index cols, Eigen::Index row_offset = 0, Eigen::Index column_offset = 0)

Wraps the given array with a constant value. Example:

*   1 2
*   3 4
*
wrapped to rows = 4, cols = 5, row_offset = 1, col_offset = 2 and value = 0 results in
*   0 0 0 0 0
*   0 0 1 2 0
*   0 0 3 4 0
*   0 0 0 0 0
*

Returns:

An array of size rows, cols where every value outside of the by the offset shifted mat is the passed constant value.

Shift

template<typename ArgType>
Eigen::CwiseNullaryOp<shift_functor<ArgType>, typename array_passthrough_helper<ArgType>::ArrayType> hector_math::eigen::shift(const Eigen::ArrayBase<ArgType> &mat, Eigen::Index row_shift, Eigen::Index column_shift)

Shifts the given Eigen Array by the given row and column values. I.e. the access to arr(x, y) is mapped to arr(x+row_shift, y+column_shift). E.g. the array:

*   1 2 3
*   4 5 6
*   7 8 9
*
shifted by row_shift=2 and column_shift=1 would result in
*   8 9 7
*   2 3 1
*   5 6 4
*

Parameters:
  • row_shift – The number of rows that are added to the accessed location. In essence, this shifts the rows upwards by the given value.

  • column_shift – The number of columns that are added to the accessed location. In essence, this shifts the rows to the left by the given value.

Returns:

The shifted array.

Flip

enum hector_math::eigen::flip_ops::FlipOp

Values:

enumerator Rows
enumerator Columns
enumerator Both
template<typename ArgType, FlipOp FLIP_OP = flip_ops::Both>
Eigen::CwiseNullaryOp<flip_functor<ArgType, FLIP_OP>, typename array_passthrough_helper<ArgType>::ArrayType> hector_math::eigen::flip(const Eigen::ArrayBase<ArgType> &mat)

Flips the given Eigen Array in the specified axis (default: Both). Example:

*   1 2 3
*   4 5 6
*   7 8 9
*
flipped with FLIP_OP = flip_ops::Rows results in
*   7 8 9
*   4 5 6
*   1 2 3
*
flipped with FLIP_OP = flip_ops::Both instead would result in
*   9 8 7
*   6 5 4
*   3 2 1
*

Template Parameters:

FLIP_OP – The flip operation that is performed.

Returns:

The flipped array.

template<typename ArgType>
Eigen::CwiseNullaryOp<runtime_flip_functor<ArgType>, typename array_passthrough_helper<ArgType>::ArrayType> hector_math::eigen::flip(const Eigen::ArrayBase<ArgType> &mat, FlipOp flip_op)

Also flips the given Eigen::Array but can be used with flip ops determined at runtime.

See also

flip(const Eigen::ArrayBase<ArgType>&)

Parameters:

flip_op – The flip operation that is performed.

Returns:

The flipped array.