Various documentation updates:

- update the tutorial
- update doc of deprecated cwise function
- update cwise doc snippets
This commit is contained in:
Gael Guennebaud 2010-01-06 17:18:38 +01:00
parent c11300dbd5
commit 7d3fe69eff
43 changed files with 320 additions and 472 deletions

View File

@ -30,13 +30,7 @@
***************************************************************************/ ***************************************************************************/
/** \returns an expression of the coefficient-wise absolute value of \c *this /** \deprecated ArrayBase::abs() */
*
* Example: \include Cwise_abs.cpp
* Output: \verbinclude Cwise_abs.out
*
* \sa abs2()
*/
template<typename ExpressionType> template<typename ExpressionType>
EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs_op) EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs_op)
Cwise<ExpressionType>::abs() const Cwise<ExpressionType>::abs() const
@ -44,13 +38,7 @@ Cwise<ExpressionType>::abs() const
return _expression(); return _expression();
} }
/** \returns an expression of the coefficient-wise squared absolute value of \c *this /** \deprecated ArrayBase::abs2() */
*
* Example: \include Cwise_abs2.cpp
* Output: \verbinclude Cwise_abs2.out
*
* \sa abs(), square()
*/
template<typename ExpressionType> template<typename ExpressionType>
EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs2_op) EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs2_op)
Cwise<ExpressionType>::abs2() const Cwise<ExpressionType>::abs2() const
@ -58,13 +46,7 @@ Cwise<ExpressionType>::abs2() const
return _expression(); return _expression();
} }
/** \returns an expression of the coefficient-wise exponential of *this. /** \deprecated ArrayBase::exp() */
*
* Example: \include Cwise_exp.cpp
* Output: \verbinclude Cwise_exp.out
*
* \sa pow(), log(), sin(), cos()
*/
template<typename ExpressionType> template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_exp_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_exp_op)
Cwise<ExpressionType>::exp() const Cwise<ExpressionType>::exp() const
@ -72,13 +54,7 @@ Cwise<ExpressionType>::exp() const
return _expression(); return _expression();
} }
/** \returns an expression of the coefficient-wise logarithm of *this. /** \deprecated ArrayBase::log() */
*
* Example: \include Cwise_log.cpp
* Output: \verbinclude Cwise_log.out
*
* \sa exp()
*/
template<typename ExpressionType> template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_log_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_log_op)
Cwise<ExpressionType>::log() const Cwise<ExpressionType>::log() const
@ -86,13 +62,7 @@ Cwise<ExpressionType>::log() const
return _expression(); return _expression();
} }
/** \returns an expression of the Schur product (coefficient wise product) of *this and \a other /** \deprecated ArrayBase::operator*() */
*
* Example: \include Cwise_product.cpp
* Output: \verbinclude Cwise_product.out
*
* \sa class CwiseBinaryOp, operator/(), square()
*/
template<typename ExpressionType> template<typename ExpressionType>
template<typename OtherDerived> template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE(ExpressionType,OtherDerived) EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE(ExpressionType,OtherDerived)
@ -101,13 +71,7 @@ Cwise<ExpressionType>::operator*(const MatrixBase<OtherDerived> &other) const
return EIGEN_CWISE_PRODUCT_RETURN_TYPE(ExpressionType,OtherDerived)(_expression(), other.derived()); return EIGEN_CWISE_PRODUCT_RETURN_TYPE(ExpressionType,OtherDerived)(_expression(), other.derived());
} }
/** \returns an expression of the coefficient-wise quotient of *this and \a other /** \deprecated ArrayBase::operator/() */
*
* Example: \include Cwise_quotient.cpp
* Output: \verbinclude Cwise_quotient.out
*
* \sa class CwiseBinaryOp, operator*(), inverse()
*/
template<typename ExpressionType> template<typename ExpressionType>
template<typename OtherDerived> template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op) EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)
@ -116,13 +80,7 @@ Cwise<ExpressionType>::operator/(const MatrixBase<OtherDerived> &other) const
return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)(_expression(), other.derived());
} }
/** Replaces this expression by its coefficient-wise product with \a other. /** \deprecated ArrayBase::operator*=() */
*
* Example: \include Cwise_times_equal.cpp
* Output: \verbinclude Cwise_times_equal.out
*
* \sa operator*(), operator/=()
*/
template<typename ExpressionType> template<typename ExpressionType>
template<typename OtherDerived> template<typename OtherDerived>
inline ExpressionType& Cwise<ExpressionType>::operator*=(const MatrixBase<OtherDerived> &other) inline ExpressionType& Cwise<ExpressionType>::operator*=(const MatrixBase<OtherDerived> &other)
@ -130,13 +88,7 @@ inline ExpressionType& Cwise<ExpressionType>::operator*=(const MatrixBase<OtherD
return m_matrix.const_cast_derived() = *this * other; return m_matrix.const_cast_derived() = *this * other;
} }
/** Replaces this expression by its coefficient-wise quotient by \a other. /** \deprecated ArrayBase::operator/=() */
*
* Example: \include Cwise_slash_equal.cpp
* Output: \verbinclude Cwise_slash_equal.out
*
* \sa operator/(), operator*=()
*/
template<typename ExpressionType> template<typename ExpressionType>
template<typename OtherDerived> template<typename OtherDerived>
inline ExpressionType& Cwise<ExpressionType>::operator/=(const MatrixBase<OtherDerived> &other) inline ExpressionType& Cwise<ExpressionType>::operator/=(const MatrixBase<OtherDerived> &other)
@ -144,13 +96,7 @@ inline ExpressionType& Cwise<ExpressionType>::operator/=(const MatrixBase<OtherD
return m_matrix.const_cast_derived() = *this / other; return m_matrix.const_cast_derived() = *this / other;
} }
/** \returns an expression of the coefficient-wise min of *this and \a other /** \deprecated ArrayBase::min() */
*
* Example: \include Cwise_min.cpp
* Output: \verbinclude Cwise_min.out
*
* \sa class CwiseBinaryOp
*/
template<typename ExpressionType> template<typename ExpressionType>
template<typename OtherDerived> template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op) EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op)
@ -159,13 +105,7 @@ Cwise<ExpressionType>::min(const MatrixBase<OtherDerived> &other) const
return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op)(_expression(), other.derived());
} }
/** \returns an expression of the coefficient-wise max of *this and \a other /** \deprecated ArrayBase::max() */
*
* Example: \include Cwise_max.cpp
* Output: \verbinclude Cwise_max.out
*
* \sa class CwiseBinaryOp
*/
template<typename ExpressionType> template<typename ExpressionType>
template<typename OtherDerived> template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op) EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op)
@ -180,15 +120,7 @@ Cwise<ExpressionType>::max(const MatrixBase<OtherDerived> &other) const
// -- unary operators -- // -- unary operators --
/** \array_module /** \deprecated ArrayBase::sqrt() */
*
* \returns an expression of the coefficient-wise square root of *this.
*
* Example: \include Cwise_sqrt.cpp
* Output: \verbinclude Cwise_sqrt.out
*
* \sa pow(), square()
*/
template<typename ExpressionType> template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sqrt_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sqrt_op)
Cwise<ExpressionType>::sqrt() const Cwise<ExpressionType>::sqrt() const
@ -196,15 +128,7 @@ Cwise<ExpressionType>::sqrt() const
return _expression(); return _expression();
} }
/** \array_module /** \deprecated ArrayBase::cos() */
*
* \returns an expression of the coefficient-wise cosine of *this.
*
* Example: \include Cwise_cos.cpp
* Output: \verbinclude Cwise_cos.out
*
* \sa sin(), exp(), EIGEN_FAST_MATH
*/
template<typename ExpressionType> template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cos_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cos_op)
Cwise<ExpressionType>::cos() const Cwise<ExpressionType>::cos() const
@ -213,15 +137,7 @@ Cwise<ExpressionType>::cos() const
} }
/** \array_module /** \deprecated ArrayBase::sin() */
*
* \returns an expression of the coefficient-wise sine of *this.
*
* Example: \include Cwise_sin.cpp
* Output: \verbinclude Cwise_sin.out
*
* \sa cos(), exp(), EIGEN_FAST_MATH
*/
template<typename ExpressionType> template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sin_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sin_op)
Cwise<ExpressionType>::sin() const Cwise<ExpressionType>::sin() const
@ -230,15 +146,7 @@ Cwise<ExpressionType>::sin() const
} }
/** \array_module /** \deprecated ArrayBase::log() */
*
* \returns an expression of the coefficient-wise power of *this to the given exponent.
*
* Example: \include Cwise_pow.cpp
* Output: \verbinclude Cwise_pow.out
*
* \sa exp(), log()
*/
template<typename ExpressionType> template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op)
Cwise<ExpressionType>::pow(const Scalar& exponent) const Cwise<ExpressionType>::pow(const Scalar& exponent) const
@ -247,15 +155,7 @@ Cwise<ExpressionType>::pow(const Scalar& exponent) const
} }
/** \array_module /** \deprecated ArrayBase::inverse() */
*
* \returns an expression of the coefficient-wise inverse of *this.
*
* Example: \include Cwise_inverse.cpp
* Output: \verbinclude Cwise_inverse.out
*
* \sa operator/(), operator*()
*/
template<typename ExpressionType> template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_inverse_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_inverse_op)
Cwise<ExpressionType>::inverse() const Cwise<ExpressionType>::inverse() const
@ -263,15 +163,7 @@ Cwise<ExpressionType>::inverse() const
return _expression(); return _expression();
} }
/** \array_module /** \deprecated ArrayBase::square() */
*
* \returns an expression of the coefficient-wise square of *this.
*
* Example: \include Cwise_square.cpp
* Output: \verbinclude Cwise_square.out
*
* \sa operator/(), operator*(), abs2()
*/
template<typename ExpressionType> template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_square_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_square_op)
Cwise<ExpressionType>::square() const Cwise<ExpressionType>::square() const
@ -279,15 +171,7 @@ Cwise<ExpressionType>::square() const
return _expression(); return _expression();
} }
/** \array_module /** \deprecated ArrayBase::cube() */
*
* \returns an expression of the coefficient-wise cube of *this.
*
* Example: \include Cwise_cube.cpp
* Output: \verbinclude Cwise_cube.out
*
* \sa square(), pow()
*/
template<typename ExpressionType> template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cube_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cube_op)
Cwise<ExpressionType>::cube() const Cwise<ExpressionType>::cube() const
@ -298,15 +182,7 @@ Cwise<ExpressionType>::cube() const
// -- binary operators -- // -- binary operators --
/** \array_module /** \deprecated ArrayBase::operator<() */
*
* \returns an expression of the coefficient-wise \< operator of *this and \a other
*
* Example: \include Cwise_less.cpp
* Output: \verbinclude Cwise_less.out
*
* \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=()
*/
template<typename ExpressionType> template<typename ExpressionType>
template<typename OtherDerived> template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less) inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)
@ -315,15 +191,7 @@ Cwise<ExpressionType>::operator<(const MatrixBase<OtherDerived> &other) const
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)(_expression(), other.derived());
} }
/** \array_module /** \deprecated ArrayBase::<=() */
*
* \returns an expression of the coefficient-wise \<= operator of *this and \a other
*
* Example: \include Cwise_less_equal.cpp
* Output: \verbinclude Cwise_less_equal.out
*
* \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<()
*/
template<typename ExpressionType> template<typename ExpressionType>
template<typename OtherDerived> template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal) inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)
@ -332,15 +200,7 @@ Cwise<ExpressionType>::operator<=(const MatrixBase<OtherDerived> &other) const
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)(_expression(), other.derived());
} }
/** \array_module /** \deprecated ArrayBase::operator>() */
*
* \returns an expression of the coefficient-wise \> operator of *this and \a other
*
* Example: \include Cwise_greater.cpp
* Output: \verbinclude Cwise_greater.out
*
* \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<()
*/
template<typename ExpressionType> template<typename ExpressionType>
template<typename OtherDerived> template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater) inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)
@ -349,15 +209,7 @@ Cwise<ExpressionType>::operator>(const MatrixBase<OtherDerived> &other) const
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)(_expression(), other.derived());
} }
/** \array_module /** \deprecated ArrayBase::operator>=() */
*
* \returns an expression of the coefficient-wise \>= operator of *this and \a other
*
* Example: \include Cwise_greater_equal.cpp
* Output: \verbinclude Cwise_greater_equal.out
*
* \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=()
*/
template<typename ExpressionType> template<typename ExpressionType>
template<typename OtherDerived> template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal) inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)
@ -366,20 +218,7 @@ Cwise<ExpressionType>::operator>=(const MatrixBase<OtherDerived> &other) const
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)(_expression(), other.derived());
} }
/** \array_module /** \deprecated ArrayBase::operator==() */
*
* \returns an expression of the coefficient-wise == operator of *this and \a other
*
* \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
* In order to check for equality between two vectors or matrices with floating-point coefficients, it is
* generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and
* MatrixBase::isMuchSmallerThan().
*
* Example: \include Cwise_equal_equal.cpp
* Output: \verbinclude Cwise_equal_equal.out
*
* \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan()
*/
template<typename ExpressionType> template<typename ExpressionType>
template<typename OtherDerived> template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to) inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)
@ -388,20 +227,7 @@ Cwise<ExpressionType>::operator==(const MatrixBase<OtherDerived> &other) const
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)(_expression(), other.derived());
} }
/** \array_module /** \deprecated ArrayBase::operator!=() */
*
* \returns an expression of the coefficient-wise != operator of *this and \a other
*
* \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
* In order to check for equality between two vectors or matrices with floating-point coefficients, it is
* generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and
* MatrixBase::isMuchSmallerThan().
*
* Example: \include Cwise_not_equal.cpp
* Output: \verbinclude Cwise_not_equal.out
*
* \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan()
*/
template<typename ExpressionType> template<typename ExpressionType>
template<typename OtherDerived> template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to) inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)
@ -412,12 +238,7 @@ Cwise<ExpressionType>::operator!=(const MatrixBase<OtherDerived> &other) const
// comparisons to scalar value // comparisons to scalar value
/** \array_module /** \deprecated ArrayBase::operator<(Scalar) */
*
* \returns an expression of the coefficient-wise \< operator of *this and a scalar \a s
*
* \sa operator<(const MatrixBase<OtherDerived> &) const
*/
template<typename ExpressionType> template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less) inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)
Cwise<ExpressionType>::operator<(Scalar s) const Cwise<ExpressionType>::operator<(Scalar s) const
@ -426,12 +247,7 @@ Cwise<ExpressionType>::operator<(Scalar s) const
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
} }
/** \array_module /** \deprecated ArrayBase::operator<=(Scalar) */
*
* \returns an expression of the coefficient-wise \<= operator of *this and a scalar \a s
*
* \sa operator<=(const MatrixBase<OtherDerived> &) const
*/
template<typename ExpressionType> template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal) inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)
Cwise<ExpressionType>::operator<=(Scalar s) const Cwise<ExpressionType>::operator<=(Scalar s) const
@ -440,12 +256,7 @@ Cwise<ExpressionType>::operator<=(Scalar s) const
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
} }
/** \array_module /** \deprecated ArrayBase::operator>(Scalar) */
*
* \returns an expression of the coefficient-wise \> operator of *this and a scalar \a s
*
* \sa operator>(const MatrixBase<OtherDerived> &) const
*/
template<typename ExpressionType> template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater) inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)
Cwise<ExpressionType>::operator>(Scalar s) const Cwise<ExpressionType>::operator>(Scalar s) const
@ -454,12 +265,7 @@ Cwise<ExpressionType>::operator>(Scalar s) const
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
} }
/** \array_module /** \deprecated ArrayBase::operator>=(Scalar) */
*
* \returns an expression of the coefficient-wise \>= operator of *this and a scalar \a s
*
* \sa operator>=(const MatrixBase<OtherDerived> &) const
*/
template<typename ExpressionType> template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal) inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)
Cwise<ExpressionType>::operator>=(Scalar s) const Cwise<ExpressionType>::operator>=(Scalar s) const
@ -468,17 +274,7 @@ Cwise<ExpressionType>::operator>=(Scalar s) const
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
} }
/** \array_module /** \deprecated ArrayBase::operator==(Scalar) */
*
* \returns an expression of the coefficient-wise == operator of *this and a scalar \a s
*
* \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
* In order to check for equality between two vectors or matrices with floating-point coefficients, it is
* generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and
* MatrixBase::isMuchSmallerThan().
*
* \sa operator==(const MatrixBase<OtherDerived> &) const
*/
template<typename ExpressionType> template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to) inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)
Cwise<ExpressionType>::operator==(Scalar s) const Cwise<ExpressionType>::operator==(Scalar s) const
@ -487,17 +283,7 @@ Cwise<ExpressionType>::operator==(Scalar s) const
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
} }
/** \array_module /** \deprecated ArrayBase::operator!=(Scalar) */
*
* \returns an expression of the coefficient-wise != operator of *this and a scalar \a s
*
* \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
* In order to check for equality between two vectors or matrices with floating-point coefficients, it is
* generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and
* MatrixBase::isMuchSmallerThan().
*
* \sa operator!=(const MatrixBase<OtherDerived> &) const
*/
template<typename ExpressionType> template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to) inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)
Cwise<ExpressionType>::operator!=(Scalar s) const Cwise<ExpressionType>::operator!=(Scalar s) const
@ -508,15 +294,7 @@ Cwise<ExpressionType>::operator!=(Scalar s) const
// scalar addition // scalar addition
/** \array_module /** \deprecated ArrayBase::operator+(Scalar) */
*
* \returns an expression of \c *this with each coeff incremented by the constant \a scalar
*
* Example: \include Cwise_plus.cpp
* Output: \verbinclude Cwise_plus.out
*
* \sa operator+=(), operator-()
*/
template<typename ExpressionType> template<typename ExpressionType>
inline const typename Cwise<ExpressionType>::ScalarAddReturnType inline const typename Cwise<ExpressionType>::ScalarAddReturnType
Cwise<ExpressionType>::operator+(const Scalar& scalar) const Cwise<ExpressionType>::operator+(const Scalar& scalar) const
@ -524,30 +302,14 @@ Cwise<ExpressionType>::operator+(const Scalar& scalar) const
return typename Cwise<ExpressionType>::ScalarAddReturnType(m_matrix, ei_scalar_add_op<Scalar>(scalar)); return typename Cwise<ExpressionType>::ScalarAddReturnType(m_matrix, ei_scalar_add_op<Scalar>(scalar));
} }
/** \array_module /** \deprecated ArrayBase::operator+=(Scalar) */
*
* Adds the given \a scalar to each coeff of this expression.
*
* Example: \include Cwise_plus_equal.cpp
* Output: \verbinclude Cwise_plus_equal.out
*
* \sa operator+(), operator-=()
*/
template<typename ExpressionType> template<typename ExpressionType>
inline ExpressionType& Cwise<ExpressionType>::operator+=(const Scalar& scalar) inline ExpressionType& Cwise<ExpressionType>::operator+=(const Scalar& scalar)
{ {
return m_matrix.const_cast_derived() = *this + scalar; return m_matrix.const_cast_derived() = *this + scalar;
} }
/** \array_module /** \deprecated ArrayBase::operator-(Scalar) */
*
* \returns an expression of \c *this with each coeff decremented by the constant \a scalar
*
* Example: \include Cwise_minus.cpp
* Output: \verbinclude Cwise_minus.out
*
* \sa operator+(), operator-=()
*/
template<typename ExpressionType> template<typename ExpressionType>
inline const typename Cwise<ExpressionType>::ScalarAddReturnType inline const typename Cwise<ExpressionType>::ScalarAddReturnType
Cwise<ExpressionType>::operator-(const Scalar& scalar) const Cwise<ExpressionType>::operator-(const Scalar& scalar) const
@ -555,16 +317,7 @@ Cwise<ExpressionType>::operator-(const Scalar& scalar) const
return *this + (-scalar); return *this + (-scalar);
} }
/** \array_module /** \deprecated ArrayBase::operator-=(Scalar) */
*
* Substracts the given \a scalar from each coeff of this expression.
*
* Example: \include Cwise_minus_equal.cpp
* Output: \verbinclude Cwise_minus_equal.out
*
* \sa operator+=(), operator-()
*/
template<typename ExpressionType> template<typename ExpressionType>
inline ExpressionType& Cwise<ExpressionType>::operator-=(const Scalar& scalar) inline ExpressionType& Cwise<ExpressionType>::operator-=(const Scalar& scalar)
{ {

View File

@ -136,26 +136,26 @@ public:
template<class OtherDerived> Scalar angularDistance(const QuaternionBase<OtherDerived>& other) const; template<class OtherDerived> Scalar angularDistance(const QuaternionBase<OtherDerived>& other) const;
/** \returns an equivalent 3x3 rotation matrix */ /** \returns an equivalent 3x3 rotation matrix */
Matrix3 toRotationMatrix() const; Matrix3 toRotationMatrix() const;
/** \returns the quaternion which transform \a a into \a b through a rotation */ /** \returns the quaternion which transform \a a into \a b through a rotation */
template<typename Derived1, typename Derived2> template<typename Derived1, typename Derived2>
Derived& setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b); Derived& setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b);
template<class OtherDerived> EIGEN_STRONG_INLINE Quaternion<Scalar> operator* (const QuaternionBase<OtherDerived>& q) const; template<class OtherDerived> EIGEN_STRONG_INLINE Quaternion<Scalar> operator* (const QuaternionBase<OtherDerived>& q) const;
template<class OtherDerived> EIGEN_STRONG_INLINE Derived& operator*= (const QuaternionBase<OtherDerived>& q); template<class OtherDerived> EIGEN_STRONG_INLINE Derived& operator*= (const QuaternionBase<OtherDerived>& q);
/** \returns the quaternion describing the inverse rotation */ /** \returns the quaternion describing the inverse rotation */
Quaternion<Scalar> inverse() const; Quaternion<Scalar> inverse() const;
/** \returns the conjugated quaternion */ /** \returns the conjugated quaternion */
Quaternion<Scalar> conjugate() const; Quaternion<Scalar> conjugate() const;
/** \returns an interpolation for a constant motion between \a other and \c *this /** \returns an interpolation for a constant motion between \a other and \c *this
* \a t in [0;1] * \a t in [0;1]
* see http://en.wikipedia.org/wiki/Slerp * see http://en.wikipedia.org/wiki/Slerp
*/ */
template<class OtherDerived> Quaternion<Scalar> slerp(Scalar t, const QuaternionBase<OtherDerived>& other) const; template<class OtherDerived> Quaternion<Scalar> slerp(Scalar t, const QuaternionBase<OtherDerived>& other) const;
/** \returns \c true if \c *this is approximately equal to \a other, within the precision /** \returns \c true if \c *this is approximately equal to \a other, within the precision

View File

@ -21,6 +21,24 @@ operator/(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
return CwiseBinaryOp<ei_scalar_quotient_op<Scalar>, Derived, OtherDerived>(derived(), other.derived()); return CwiseBinaryOp<ei_scalar_quotient_op<Scalar>, Derived, OtherDerived>(derived(), other.derived());
} }
/** \returns an expression of the coefficient-wise min of \c *this and \a other
*
* Example: \include Cwise_min.cpp
* Output: \verbinclude Cwise_min.out
*
* \sa max()
*/
EIGEN_MAKE_CWISE_BINARY_OP(min,ei_scalar_min_op)
/** \returns an expression of the coefficient-wise max of \c *this and \a other
*
* Example: \include Cwise_max.cpp
* Output: \verbinclude Cwise_max.out
*
* \sa min()
*/
EIGEN_MAKE_CWISE_BINARY_OP(max,ei_scalar_max_op)
/** \returns an expression of the coefficient-wise \< operator of *this and \a other /** \returns an expression of the coefficient-wise \< operator of *this and \a other
* *
* Example: \include Cwise_less.cpp * Example: \include Cwise_less.cpp

View File

@ -78,13 +78,20 @@ This slows compilation down but at least you don't have to worry anymore about i
<a href="#" class="top">top</a> <a href="#" class="top">top</a>
\section TutorialCoreMatrixTypes Array, matrix and vector types \section TutorialCoreMatrixTypes Array, matrix and vector types
Eigen provides two kinds of dense objects: mathematical matrices and vectors which are both represented by the template class Matrix, and 1D and 2D arrays represented by the template class Array. While the former (Matrix) is specialized for the representation of mathematical objects, the latter (Array) represents a collection of scalar values arranged in a 1D or 2D fashion. In particular, all operations performed on arrays are coefficient wise. Conversion between the two worlds can be done using the MatrixBase::array() and ArrayBase::matrix() functions respectively without any overhead. See \ref TutorialCoreArithmeticOperators for further details. Eigen provides two kinds of dense objects: mathematical matrices and vectors which are both represented by the template class Matrix, and 1D and 2D arrays represented by the template class Array. While the former (Matrix) is specialized for the representation of mathematical objects, the latter (Array) represents a collection of scalar values arranged in a 1D or 2D fashion. As a major difference, all operations performed on arrays are coefficient wise. Matrix and Array have a lot of similarities since they both inherits the DenseBase and DenseStorageBase classes. In the rest of this tutorial we will use the following symbols to emphasize the features which are specifics to a given kind of object:
\li <a name="matrixonly"><a/>\matrixworld for matrix/vector only features
\li <a name="arrayonly"><a/>\arrayworld for array only features
In most cases, you can simply use one of the \ref matrixtypedefs "convenience typedefs". Note that conversion between the two worlds can be done using the MatrixBase::array() and ArrayBase::matrix() functions respectively without any overhead.
The template class Matrix, just like the class Array) take a number of template parameters, but for now it is enough to understand the 3 first ones (and the others can then be left unspecified): In most cases, you can simply use one of the convenience typedefs for \ref matrixtypedefs "matrices" and \ref arraytypedefs "arrays".
\code Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime> \endcode The template class Matrix (just like the class Array) take a number of template parameters, but for now it is enough to understand the 3 first ones (and the others can then be left unspecified):
\code
Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime>
Array<Scalar, RowsAtCompileTime, ColsAtCompileTime>
\endcode
\li \c Scalar is the scalar type, i.e. the type of the coefficients. That is, if you want a vector of floats, choose \c float here. \li \c Scalar is the scalar type, i.e. the type of the coefficients. That is, if you want a vector of floats, choose \c float here.
\li \c RowsAtCompileTime and \c ColsAtCompileTime are the number of rows and columns of the matrix as known at compile-time. \li \c RowsAtCompileTime and \c ColsAtCompileTime are the number of rows and columns of the matrix as known at compile-time.
@ -96,23 +103,36 @@ For dynamic-size, that is in order to left the number of rows or of columns unsp
All combinations are allowed: you can have a matrix with a fixed number of rows and a dynamic number of columns, etc. The following are all valid: All combinations are allowed: you can have a matrix with a fixed number of rows and a dynamic number of columns, etc. The following are all valid:
\code \code
Matrix<double, 6, Dynamic> // Dynamic number of columns Matrix<double, 6, Dynamic> // Dynamic number of columns
Matrix<double, Dynamic, 2> // Dynamic number of rows Matrix<double, Dynamic, 2> // Dynamic number of rows
Matrix<double, Dynamic, Dynamic> // Fully dynamic Matrix<double, Dynamic, Dynamic> // Fully dynamic
Matrix<double, 13, 3> // Fully fixed Matrix<double, 13, 3> // Fully fixed
\endcode \endcode
Fixed-size and partially-dynamic-size matrices may use all the same API calls as fully dynamic Fixed-size and partially-dynamic-size matrices may use all the same API calls as fully dynamic
matrices, but the fixed dimension(s) must remain constant, or an assertion failure will occur. matrices, but the fixed dimension(s) must remain constant, or an assertion failure will occur.
<a href="#" class="top">top</a>\section TutorialCoreCoefficients Coefficient access Finally, note that the default typedefs for array containers is slighlty different as we have to distinghish between 1D and 2D arrays:
\code
ArrayXf // 1D dynamic array of floats
Array2i // 1D array of integers of size 2
ArrayXXd // 2D fully dynamic array of doubles
Array44f // 2D array of floats of size 4x4
\endcode
Eigen supports the following syntaxes for read and write coefficient access:
<a href="#" class="top">top</a>
\section TutorialCoreCoefficients Coefficient access
Eigen supports the following syntaxes for read and write coefficient access of matrices, vectors and arrays:
\code \code
matrix(i,j); matrix(i,j);
vector(i) vector(i)
vector[i] vector[i]
\endcode
Vectors support also the following additional read-write accessors:
\code
vector.x() // first coefficient vector.x() // first coefficient
vector.y() // second coefficient vector.y() // second coefficient
vector.z() // third coefficient vector.z() // third coefficient
@ -121,9 +141,11 @@ vector.w() // fourth coefficient
Notice that these coefficient access methods have assertions checking the ranges. So if you do a lot of coefficient access, these assertion can have an important cost. There are then two possibilities if you want avoid paying this cost: Notice that these coefficient access methods have assertions checking the ranges. So if you do a lot of coefficient access, these assertion can have an important cost. There are then two possibilities if you want avoid paying this cost:
\li Either you can disable assertions altogether, by defining EIGEN_NO_DEBUG or NDEBUG. Notice that some IDEs like MS Visual Studio define NDEBUG automatically in "Release Mode". \li Either you can disable assertions altogether, by defining EIGEN_NO_DEBUG or NDEBUG. Notice that some IDEs like MS Visual Studio define NDEBUG automatically in "Release Mode".
\li Or you can disable the checks on a case-by-case basis by using the coeff() and coeffRef() methods: see MatrixBase::coeff(int,int) const, MatrixBase::coeffRef(int,int), etc. \li Or you can disable the checks on a case-by-case basis by using the coeff() and coeffRef() methods: see DenseBase::coeff(int,int) const, DenseBase::coeffRef(int,int), etc.
<a href="#" class="top">top</a>\section TutorialCoreMatrixInitialization Matrix and vector creation and initialization
<a href="#" class="top">top</a>
\section TutorialCoreMatrixInitialization Matrix and vector creation and initialization
\subsection TutorialCtors Matrix constructors \subsection TutorialCtors Matrix constructors
@ -169,7 +191,8 @@ Vector4f w(1.2f, 3.4f, 5.6f, 7.8f);
\endcode \endcode
\subsection TutorialPredefMat Predefined Matrices \subsection TutorialPredefMat Predefined Matrices
Eigen offers several static methods to create special matrix expressions, and non-static methods to assign these expressions to existing matrices: Eigen offers several static methods to create special matrix expressions, and non-static methods to assign these expressions to existing matrices.
The following are
<table class="tutorial_code"> <table class="tutorial_code">
<tr> <tr>
@ -180,13 +203,14 @@ Eigen offers several static methods to create special matrix expressions, and no
<tr style="border-bottom-style: none;"> <tr style="border-bottom-style: none;">
<td> <td>
\code \code
Matrix3f x; typedef {Matrix3f|Array33f} FixedXD;
FixedXD x;
x = Matrix3f::Zero(); x = FixedXD::Zero();
x = Matrix3f::Ones(); x = FixedXD::Ones();
x = Matrix3f::Constant(value); x = FixedXD::Constant(value);
x = Matrix3f::Identity(); x = FixedXD::Identity();
x = Matrix3f::Random(); x = FixedXD::Random();
x.setZero(); x.setZero();
x.setOnes(); x.setOnes();
@ -197,13 +221,14 @@ x.setRandom();
</td> </td>
<td> <td>
\code \code
MatrixXf x; typedef {MatrixXf|ArrayXXf} Dynamic2D;
Dynamic2D x;
x = MatrixXf::Zero(rows, cols); x = Dynamic2D::Zero(rows, cols);
x = MatrixXf::Ones(rows, cols); x = Dynamic2D::Ones(rows, cols);
x = MatrixXf::Constant(rows, cols, value); x = Dynamic2D::Constant(rows, cols, value);
x = MatrixXf::Identity(rows, cols); x = Dynamic2D::Identity(rows, cols);
x = MatrixXf::Random(rows, cols); x = Dynamic2D::Random(rows, cols);
x.setZero(rows, cols); x.setZero(rows, cols);
x.setOnes(rows, cols); x.setOnes(rows, cols);
@ -214,13 +239,14 @@ x.setRandom(rows, cols);
</td> </td>
<td> <td>
\code \code
VectorXf x; typedef {VectorXf|ArrayXf} Dynamic1D;
Dynamic1D x;
x = VectorXf::Zero(size); x = Dynamic1D::Zero(size);
x = VectorXf::Ones(size); x = Dynamic1D::Ones(size);
x = VectorXf::Constant(size, value); x = Dynamic1D::Constant(size, value);
x = VectorXf::Identity(size); x = Dynamic1D::Identity(size);
x = VectorXf::Random(size); x = Dynamic1D::Random(size);
x.setZero(size); x.setZero(size);
x.setOnes(size); x.setOnes(size);
@ -231,7 +257,25 @@ x.setRandom(size);
</td> </td>
</tr> </tr>
<tr style="border-top-style: none;"><td colspan="3">\redstar the Random() and setRandom() functions require the inclusion of the Array module (\c \#include \c <Eigen/Array>)</td></tr> <tr style="border-top-style: none;"><td colspan="3">\redstar the Random() and setRandom() functions require the inclusion of the Array module (\c \#include \c <Eigen/Array>)</td></tr>
<tr><td colspan="3">Basis vectors \link MatrixBase::Unit [details]\endlink</td></tr>
<tr><td colspan="3">The following are for matrix only: \matrixworld</td></tr>
<tr style="border-bottom-style: none;">
<td>
\code
x = FixedXD::Identity();
x.setIdentity();
\endcode
</td>
<td>
\code
x = Dynamic2D::Identity(rows, cols);
x.setIdentity(rows, cols);
\endcode
</td>
<td>
</td>
</tr>
<tr><td colspan="3">Basis vectors \matrixworld \link MatrixBase::Unit [details]\endlink</td></tr>
<tr><td>\code <tr><td>\code
Vector3f::UnitX() // 1 0 0 Vector3f::UnitX() // 1 0 0
Vector3f::UnitY() // 0 1 0 Vector3f::UnitY() // 0 1 0
@ -265,7 +309,7 @@ v = 6 6 6
\subsection TutorialCasting Casting \subsection TutorialCasting Casting
In Eigen, any matrices of same size and same scalar type are all naturally compatible. The scalar type can be explicitly casted to another one using the template MatrixBase::cast() function: In Eigen, any matrices of same size and same scalar type are all naturally compatible. The scalar type can be explicitly casted to another one using the template DenseBase::cast() function:
\code \code
Matrix3d md(1,2,3); Matrix3d md(1,2,3);
Matrix3f mf = md.cast<float>(); Matrix3f mf = md.cast<float>();
@ -280,6 +324,28 @@ res = a+b; // OK: res is resized to size 3x3
\endcode \endcode
Of course, fixed-size matrices can't be resized. Of course, fixed-size matrices can't be resized.
An array object or expression can be directly assigned to a matrix, and vice versa:
\code
Matrix4f res;
Array44f a, b;
res = a * b;
\endcode
On the other hand, an array and a matrix expressions cannot be mixed in an expression, and one have to be converted to the other using the MatrixBase::array() \matrixworld and ArrayBase::matrix() \arrayworld functions respectively:
\code
Matrix4f m1, m2;
Array44f a1, a2;
m2 = a1 * m1.array(); // coeffwise product
a2 = a1.matrix() * m1; // matrix product
\endcode
Finally it is possible to declare a variable wrapping a matrix as an array object and vice versa:
\code
MatrixXf m1;
ArrayWrapper<MatrixXf> a1(m1); // a1 and m1 share the same coefficients
// now you can use a1 as an alias for m1.array()
ArrayXXf a2;
MatrixWrapper<ArrayXXf> m2(a1); // a2 and m2 share the same coefficients
// ...
\endcode
\subsection TutorialMap Map \subsection TutorialMap Map
Any memory buffer can be mapped as an Eigen expression using the Map() static method: Any memory buffer can be mapped as an Eigen expression using the Map() static method:
@ -289,21 +355,21 @@ VectorXf::Map(&stlarray[0], stlarray.size()).squaredNorm();
\endcode \endcode
Here VectorXf::Map returns an object of class Map<VectorXf>, which behaves like a VectorXf except that it uses the existing array. You can write to this object, that will write to the existing array. You can also construct a named obtect to reuse it: Here VectorXf::Map returns an object of class Map<VectorXf>, which behaves like a VectorXf except that it uses the existing array. You can write to this object, that will write to the existing array. You can also construct a named obtect to reuse it:
\code \code
float array[rows*cols]; float data[rows*cols];
Map<MatrixXf> m(array,rows,cols); Map<MatrixXf> m(data,rows,cols);
m = othermatrix1 * othermatrix2; m = othermatrix1 * othermatrix2;
m.eigenvalues(); m.eigenvalues();
\endcode \endcode
In the fixed-size case, no need to pass sizes: In the fixed-size case, no need to pass sizes:
\code \code
float array[9]; float data[9];
Map<Matrix3d> m(array); Map<Matrix3d> m(data);
Matrix3d::Map(array).setIdentity(); Matrix3d::Map(data).setIdentity();
\endcode \endcode
\subsection TutorialCommaInit Comma initializer \subsection TutorialCommaInit Comma initializer
Eigen also offers a \ref MatrixBaseCommaInitRef "comma initializer syntax" which allows you to set all the coefficients of a matrix to specific values: Eigen also offers a \ref MatrixBaseCommaInitRef "comma initializer syntax" which allows you to set all the coefficients of any dense objects (matrix, vector, array, block, etc.) to specific values:
<table class="tutorial_code"><tr><td> <table class="tutorial_code"><tr><td>
\include Tutorial_commainit_01.cpp \include Tutorial_commainit_01.cpp
</td> </td>
@ -328,12 +394,12 @@ Eigen's comma initializer usually compiles to very optimized code without any ov
<a href="#" class="top">top</a>
\section TutorialCoreArithmeticOperators Arithmetic Operators
In short, all arithmetic operators can be used right away as in the following example. Note however that for matrices and vectors arithmetic operators are only given their usual meaning from mathematics tradition while all array operators are performed coefficient wise.
Here is an example demonstrating basic arithmetic operators:
<a href="#" class="top">top</a>\section TutorialCoreArithmeticOperators Arithmetic Operators
In short, all arithmetic operators can be used right away as in the following example. Note however that arithmetic operators are only given their usual meaning from mathematics tradition. For other operations, such as taking the coefficient-wise product of two vectors, see the discussion of \link Cwise .cwise() \endlink below. Anyway, here is an example demonstrating basic arithmetic operators:
\code \code
mat4 -= mat1*1.5 + mat2 * (mat3/4); mat4 -= mat1*1.5 + mat2 * (mat3/4);
\endcode \endcode
@ -342,7 +408,7 @@ a matrix addition ("+") and subtraction with assignment ("-=").
<table class="tutorial_code"> <table class="tutorial_code">
<tr><td> <tr><td>
matrix/vector product</td><td>\code matrix/vector product \matrixworld</td><td>\code
col2 = mat1 * col1; col2 = mat1 * col1;
row2 = row1 * mat1; row1 *= mat1; row2 = row1 * mat1; row1 *= mat1;
mat3 = mat1 * mat2; mat3 *= mat1; \endcode mat3 = mat1 * mat2; mat3 *= mat1; \endcode
@ -357,107 +423,108 @@ scalar product</td><td>\code
mat3 = mat1 * s1; mat3 = s1 * mat1; mat3 *= s1; mat3 = mat1 * s1; mat3 = s1 * mat1; mat3 *= s1;
mat3 = mat1 / s1; mat3 /= s1;\endcode mat3 = mat1 / s1; mat3 /= s1;\endcode
</td></tr> </td></tr>
<tr><td>
Other coefficient wise operators</td><td>\code
mat1.cwiseProduct(mat2); mat1.cwiseQuotient(mat2);
mat1.cwiseMin(mat2); mat1.cwiseMax(mat2);
mat1.cwiseAbs2(); mat1.cwiseSqrt();
mat1.cwiseAbs();\endcode
</td></tr>
</table> </table>
In Eigen, only traditional mathematical operators can be used right away. In addition to the above operators, array objects supports all kind of coefficient wise operators which usually apply to scalar values. Recall that those operators can be used on matrices by converting them to arrays using the array() function (see \ref TutorialCasting Casting).
But don't worry, thanks to the \link Cwise .cwise() \endlink operator prefix,
Eigen's matrices are also very powerful as a numerical container supporting
most common coefficient-wise operators.
<table class="noborder"> <table class="noborder">
<tr><td> <tr><td>
<table class="tutorial_code" style="margin-right:10pt"> <table class="tutorial_code" style="margin-right:10pt">
<tr><td>Coefficient wise \link Cwise::operator*() product \endlink</td> <tr><td>Coefficient wise \link ArrayBase::operator*() product \arrayworld \endlink</td>
<td>\code mat3 = mat1.cwise() * mat2; \endcode <td>\code array3 = array1 * array2; \endcode
</td></tr> </td></tr>
<tr><td> <tr><td>
Add a scalar to all coefficients \redstar</td><td>\code Add a scalar to all coefficients</td><td>\code
mat3 = mat1.cwise() + scalar; array3 = array1 + scalar;
mat3.array() += scalar; array3 += scalar;
mat3.array() -= scalar; array3 -= scalar;
\endcode \endcode
</td></tr> </td></tr>
<tr><td> <tr><td>
Coefficient wise \link Cwise::operator/() division \endlink \redstar</td><td>\code Coefficient wise \link ArrayBase::operator/() division \endlink \arrayworld</td><td>\code
mat3 = mat1.array() / mat2.array(); \endcode array3 = array1 / array2; \endcode
</td></tr> </td></tr>
<tr><td> <tr><td>
Coefficient wise \link Cwise::inverse() reciprocal \endlink \redstar</td><td>\code Coefficient wise \link ArrayBase::inverse() reciprocal \endlink \arrayworld</td><td>\code
mat3 = mat1.array().inverse(); \endcode array3 = array1.inverse(); \endcode
</td></tr> </td></tr>
<tr><td> <tr><td>
Coefficient wise comparisons \redstar \n Coefficient wise comparisons \arrayworld \n
(support all operators)</td><td>\code (support all operators)</td><td>\code
mat3 = mat1.array() < mat2.array(); array3 = array1 < array2;
mat3 = mat1.array() <= mat2.array(); array3 = array1 <= array2;
mat3 = mat1.array() > mat2.array(); array3 = array1 > array2;
etc. etc.
\endcode \endcode
</td></tr></table> </td></tr></table>
</td> </td>
<td><table class="tutorial_code"> <td><table class="tutorial_code">
<tr><td> <tr><td>
\b Trigo \redstar: \n \b Trigo \arrayworld: \n
\link Cwise::sin sin \endlink, \link Cwise::cos cos \endlink</td><td>\code \link ArrayBase::sin sin \endlink, \link ArrayBase::cos cos \endlink</td><td>\code
mat3 = mat1.array().sin(); array3 = array1.sin();
etc. etc.
\endcode \endcode
</td></tr> </td></tr>
<tr><td> <tr><td>
\b Power \redstar: \n \link Cwise::pow() pow \endlink, \b Power \arrayworld: \n \link ArrayBase::pow() pow \endlink,
\link ArrayBase::square square \endlink, \link ArrayBase::square square \endlink,
\link ArrayBase::cube cube \endlink, \n \link ArrayBase::cube cube \endlink, \n
\link ArrayBase::sqrt sqrt \endlink, \link ArrayBase::sqrt sqrt \endlink,
\link ArrayBase::exp exp \endlink, \link ArrayBase::exp exp \endlink,
\link ArrayBase::log log \endlink </td><td>\code \link ArrayBase::log log \endlink </td><td>\code
mat3 = mat1.array().square(); array3 = array1.square();
mat3 = mat1.array().pow(5); array3 = array1.pow(5);
mat3 = mat1.array().log(); array3 = array1.log();
etc. etc.
\endcode \endcode
</td></tr> </td></tr>
<tr><td> <tr><td>
\link Cwise::min min \endlink, \link Cwise::max max \endlink, \n \link ArrayBase::min min \endlink, \link ArrayBase::max max \endlink, \n
absolute value (\link Cwise::abs() abs \endlink, \link Cwise::abs2() abs2 \endlink) absolute value (\link ArrayBase::abs() abs \endlink, \link ArrayBase::abs2() abs2 \endlink \arrayworld)
</td><td>\code </td><td>\code
mat3 = mat1.cwiseMin(mat2); array3 = array1.min(array2);
mat3 = mat1.cwiseMax(mat2); array3 = array1.max(array2);
mat3 = mat1.cwiseAbs(); array3 = array1.abs();
mat3 = mat1.cwiseAbs2(); array3 = array1.abs2();
\endcode</td></tr> \endcode</td></tr>
</table> </table>
</td></tr></table> </td></tr></table>
\redstar Those functions require the inclusion of the Array module (\c \#include \c <Eigen/Array>).
<span class="note">\b Side \b note: If you think that the \c .cwise() syntax is too verbose for your own taste and prefer to have non-conventional mathematical operators directly available, then feel free to extend MatrixBase as described \ref ExtendingMatrixBase "here".</span> So far, we saw the notation \code mat1*mat2 \endcode for matrix product, and \code array1*array2 \endcode for coefficient-wise product. What about other kinds of products, which in some other libraries also use arithmetic operators? In Eigen, they are accessed as follows -- note that here we are anticipating on further sections, for convenience.
So far, we saw the notation \code mat1*mat2 \endcode for matrix product, and \code mat1.cwise()*mat2 \endcode for coefficient-wise product. What about other kinds of products, which in some other libraries also use arithmetic operators? In Eigen, they are accessed as follows -- note that here we are anticipating on further sections, for convenience.
<table class="tutorial_code"> <table class="tutorial_code">
<tr><td>\link MatrixBase::dot() dot product \endlink (inner product)</td><td>\code <tr><td>\link MatrixBase::dot() dot product \endlink (inner product) \matrixworld</td><td>\code
scalar = vec1.dot(vec2);\endcode scalar = vec1.dot(vec2);\endcode
</td></tr> </td></tr>
<tr><td> <tr><td>
outer product</td><td>\code outer product \matrixworld</td><td>\code
mat = vec1 * vec2.transpose();\endcode mat = vec1 * vec2.transpose();\endcode
</td></tr> </td></tr>
<tr><td> <tr><td>
\link MatrixBase::cross() cross product \endlink</td><td>\code \link MatrixBase::cross() cross product \endlink \matrixworld</td><td>\code
#include <Eigen/Geometry> #include <Eigen/Geometry>
vec3 = vec1.cross(vec2);\endcode</td></tr> vec3 = vec1.cross(vec2);\endcode</td></tr>
</table> </table>
<a href="#" class="top">top</a>
<a href="#" class="top">top</a>\section TutorialCoreReductions Reductions \section TutorialCoreReductions Reductions
Eigen provides several reduction methods such as: Eigen provides several reduction methods such as:
\link MatrixBase::minCoeff() minCoeff() \endlink, \link MatrixBase::maxCoeff() maxCoeff() \endlink, \link DenseBase::minCoeff() minCoeff() \endlink, \link DenseBase::maxCoeff() maxCoeff() \endlink,
\link MatrixBase::sum() sum() \endlink, \link MatrixBase::trace() trace() \endlink, \link DenseBase::sum() sum() \endlink, \link MatrixBase::trace() trace() \endlink \matrixworld,
\link MatrixBase::norm() norm() \endlink, \link MatrixBase::squaredNorm() squaredNorm() \endlink, \link MatrixBase::norm() norm() \endlink \matrixworld, \link MatrixBase::squaredNorm() squaredNorm() \endlink \matrixworld,
\link MatrixBase::all() all() \endlink \redstar,and \link MatrixBase::any() any() \endlink \redstar. \link DenseBase::all() all() \endlink \redstar,and \link DenseBase::any() any() \endlink \redstar.
All reduction operations can be done matrix-wise, All reduction operations can be done matrix-wise,
\link MatrixBase::colwise() column-wise \endlink \redstar or \link DenseBase::colwise() column-wise \endlink \redstar or
\link MatrixBase::rowwise() row-wise \endlink \redstar. Usage example: \link DenseBase::rowwise() row-wise \endlink \redstar. Usage example:
<table class="tutorial_code"> <table class="tutorial_code">
<tr><td rowspan="3" style="border-right-style:dashed">\code <tr><td rowspan="3" style="border-right-style:dashed">\code
5 3 1 5 3 1
@ -472,7 +539,7 @@ mat = 2 7 8
\endcode</td></tr> \endcode</td></tr>
</table> </table>
Also note that maxCoeff and minCoeff can takes optional arguments returning the coordinates of the respective min/max coeff: \link MatrixBase::maxCoeff(int*,int*) const maxCoeff(int* i, int* j) \endlink, \link MatrixBase::minCoeff(int*,int*) const minCoeff(int* i, int* j) \endlink. Also note that maxCoeff and minCoeff can takes optional arguments returning the coordinates of the respective min/max coeff: \link DenseBase::maxCoeff(int*,int*) const maxCoeff(int* i, int* j) \endlink, \link DenseBase::minCoeff(int*,int*) const minCoeff(int* i, int* j) \endlink.
<span class="note">\b Side \b note: The all() and any() functions are especially useful in combination with coeff-wise comparison operators.</span> <span class="note">\b Side \b note: The all() and any() functions are especially useful in combination with coeff-wise comparison operators.</span>
@ -482,8 +549,8 @@ Also note that maxCoeff and minCoeff can takes optional arguments returning the
<a href="#" class="top">top</a>\section TutorialCoreMatrixBlocks Matrix blocks <a href="#" class="top">top</a>\section TutorialCoreMatrixBlocks Matrix blocks
Read-write access to a \link MatrixBase::col(int) column \endlink Read-write access to a \link DenseBase::col(int) column \endlink
or a \link MatrixBase::row(int) row \endlink of a matrix: or a \link DenseBase::row(int) row \endlink of a matrix (or array):
\code \code
mat1.row(i) = mat2.col(j); mat1.row(i) = mat2.col(j);
mat1.col(j1).swap(mat1.col(j2)); mat1.col(j1).swap(mat1.col(j2));
@ -505,34 +572,34 @@ Read-write access to sub-vectors:
Read-write access to sub-matrices:</td><td></td><td></td></tr> Read-write access to sub-matrices:</td><td></td><td></td></tr>
<tr> <tr>
<td>\code mat1.block(i,j,rows,cols)\endcode <td>\code mat1.block(i,j,rows,cols)\endcode
\link MatrixBase::block(int,int,int,int) (more) \endlink</td> \link DenseBase::block(int,int,int,int) (more) \endlink</td>
<td>\code mat1.block<rows,cols>(i,j)\endcode <td>\code mat1.block<rows,cols>(i,j)\endcode
\link MatrixBase::block(int,int) (more) \endlink</td> \link DenseBase::block(int,int) (more) \endlink</td>
<td>the \c rows x \c cols sub-matrix \n starting from position (\c i,\c j)</td></tr><tr> <td>the \c rows x \c cols sub-matrix \n starting from position (\c i,\c j)</td></tr><tr>
<td>\code <td>\code
mat1.corner(TopLeft,rows,cols) mat1.corner(TopLeft,rows,cols)
mat1.corner(TopRight,rows,cols) mat1.corner(TopRight,rows,cols)
mat1.corner(BottomLeft,rows,cols) mat1.corner(BottomLeft,rows,cols)
mat1.corner(BottomRight,rows,cols)\endcode mat1.corner(BottomRight,rows,cols)\endcode
\link MatrixBase::corner(CornerType,int,int) (more) \endlink</td> \link DenseBase::corner(CornerType,int,int) (more) \endlink</td>
<td>\code <td>\code
mat1.corner<rows,cols>(TopLeft) mat1.corner<rows,cols>(TopLeft)
mat1.corner<rows,cols>(TopRight) mat1.corner<rows,cols>(TopRight)
mat1.corner<rows,cols>(BottomLeft) mat1.corner<rows,cols>(BottomLeft)
mat1.corner<rows,cols>(BottomRight)\endcode mat1.corner<rows,cols>(BottomRight)\endcode
\link MatrixBase::corner(CornerType) (more) \endlink</td> \link DenseBase::corner(CornerType) (more) \endlink</td>
<td>the \c rows x \c cols sub-matrix \n taken in one of the four corners</td></tr> <td>the \c rows x \c cols sub-matrix \n taken in one of the four corners</td></tr>
<tr><td>\code <tr><td>\code
mat4x4.minor(i,j) = mat3x3; mat4x4.minor(i,j) = mat3x3;
mat3x3 = mat4x4.minor(i,j);\endcode mat3x3 = mat4x4.minor(i,j);\endcode
</td><td></td><td> </td><td></td><td>
\link MatrixBase::minor() minor \endlink (read-write)</td> \link DenseBase::minor() minor \endlink (read-write)</td>
</tr> </tr>
</table> </table>
<a href="#" class="top">top</a>\section TutorialCoreDiagonalMatrices Diagonal matrices <a href="#" class="top">top</a>\section TutorialCoreDiagonalMatrices Diagonal matrices \matrixworld
<table class="tutorial_code"> <table class="tutorial_code">
<tr><td> <tr><td>
@ -549,23 +616,29 @@ mat3 = mat1 * vec2.asDiagonal();\endcode
</tr> </tr>
</table> </table>
<a href="#" class="top">top</a>\section TutorialCoreTransposeAdjoint Transpose and Adjoint operations
<a href="#" class="top">top</a>
\section TutorialCoreTransposeAdjoint Transpose and Adjoint operations
<table class="tutorial_code"> <table class="tutorial_code">
<tr><td> <tr><td>
\link MatrixBase::transpose() transposition \endlink (read-write)</td><td>\code \link DenseBase::transpose() transposition \endlink (read-write)</td><td>\code
mat3 = mat1.transpose() * mat2; mat3 = mat1.transpose() * mat2;
mat3.transpose() = mat1 * mat2.transpose(); mat3.transpose() = mat1 * mat2.transpose();
\endcode \endcode
</td></tr> </td></tr>
<tr><td> <tr><td>
\link MatrixBase::adjoint() adjoint \endlink (read only)\n</td><td>\code \link MatrixBase::adjoint() adjoint \endlink (read only) \matrixworld\n</td><td>\code
mat3 = mat1.adjoint() * mat2; mat3 = mat1.adjoint() * mat2;
\endcode \endcode
</td></tr> </td></tr>
</table> </table>
<a href="#" class="top">top</a>\section TutorialCoreDotNorm Dot-product, vector norm, normalization
<a href="#" class="top">top</a>
\section TutorialCoreDotNorm Dot-product, vector norm, normalization \matrixworld
<table class="tutorial_code"> <table class="tutorial_code">
<tr><td> <tr><td>
@ -586,7 +659,10 @@ vec1.normalize();\endcode
</td></tr> </td></tr>
</table> </table>
<a href="#" class="top">top</a>\section TutorialCoreTriangularMatrix Dealing with triangular matrices
<a href="#" class="top">top</a>
\section TutorialCoreTriangularMatrix Dealing with triangular matrices \matrixworld
Currently, Eigen does not provide any explicit triangular matrix, with storage class. Instead, we Currently, Eigen does not provide any explicit triangular matrix, with storage class. Instead, we
can reference a triangular part of a square matrix or expression to perform special treatment on it. can reference a triangular part of a square matrix or expression to perform special treatment on it.
@ -629,7 +705,9 @@ m1.adjoint().triangularView<Eigen::UpperTriangular>().solveInPlace(m2)\endcode
</table> </table>
<a href="#" class="top">top</a>\section TutorialCoreSelfadjointMatrix Dealing with symmetric/selfadjoint matrices
<a href="#" class="top">top</a>
\section TutorialCoreSelfadjointMatrix Dealing with symmetric/selfadjoint matrices \matrixworld
Just as for triangular matrix, you can reference any triangular part of a square matrix to see it a selfadjoint Just as for triangular matrix, you can reference any triangular part of a square matrix to see it a selfadjoint
matrix to perform special and optimized operations. Again the opposite triangular is never referenced and can be matrix to perform special and optimized operations. Again the opposite triangular is never referenced and can be
@ -673,7 +751,8 @@ m1.selfadjointView<Eigen::UpperTriangular>().ldlt().solveInPlace(m2);
</table> </table>
<a href="#" class="top">top</a>\section TutorialCoreSpecialTopics Special Topics <a href="#" class="top">top</a>
\section TutorialCoreSpecialTopics Special Topics
\ref TopicLazyEvaluation "Lazy Evaluation and Aliasing": Thanks to expression templates, Eigen is able to apply lazy evaluation wherever that is beneficial. \ref TopicLazyEvaluation "Lazy Evaluation and Aliasing": Thanks to expression templates, Eigen is able to apply lazy evaluation wherever that is beneficial.

View File

@ -208,6 +208,8 @@ ALIASES = "only_for_vectors=This is only for vectors (either row-
"svd_module=This is defined in the %SVD module. \code #include <Eigen/SVD> \endcode" \ "svd_module=This is defined in the %SVD module. \code #include <Eigen/SVD> \endcode" \
"label=\bug" \ "label=\bug" \
"redstar=<a href='#warningarraymodule' style='color:red;text-decoration: none;'>*</a>" \ "redstar=<a href='#warningarraymodule' style='color:red;text-decoration: none;'>*</a>" \
"matrixworld=<a href='#matrixonly' style='color:green;text-decoration: none;'>*</a>" \
"arrayworld=<a href='#arrayonly' style='color:blue;text-decoration: none;'>*</a>" \
"nonstableyet=\warning This is not considered to be part of the stable public API yet. Changes may happen in future releases. See \ref Experimental \"Experimental parts of Eigen\"" \ "nonstableyet=\warning This is not considered to be part of the stable public API yet. Changes may happen in future releases. See \ref Experimental \"Experimental parts of Eigen\"" \
"note_about_arbitrary_choice_of_solution=If there exists more than one solution, this method will arbitrarily choose one." \ "note_about_arbitrary_choice_of_solution=If there exists more than one solution, this method will arbitrarily choose one." \
"note_about_using_kernel_to_study_multiple_solutions=If you need a complete analysis of the space of solutions, take the one solution obtained by this method and add to it elements of the kernel, as determined by kernel()." \ "note_about_using_kernel_to_study_multiple_solutions=If you need a complete analysis of the space of solutions, take the one solution obtained by this method and add to it elements of the kernel, as determined by kernel()." \

View File

@ -1,2 +1,2 @@
Vector3d v(1,-2,-3); Array3d v(1,-2,-3);
cout << v.cwise().abs() << endl; cout << v.abs() << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(1,-2,-3); Array3d v(1,-2,-3);
cout << v.cwise().abs2() << endl; cout << v.abs2() << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(M_PI, M_PI/2, M_PI/3); Array3d v(M_PI, M_PI/2, M_PI/3);
cout << v.cwise().cos() << endl; cout << v.cos() << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(2,3,4); Array3d v(2,3,4);
cout << v.cwise().cube() << endl; cout << v.cube() << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(1,2,3), w(3,2,1); Array3d v(1,2,3), w(3,2,1);
cout << (v.cwise()==w) << endl; cout << (v==w) << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(1,2,3); Array3d v(1,2,3);
cout << v.cwise().exp() << endl; cout << v.exp() << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(1,2,3), w(3,2,1); Array3d v(1,2,3), w(3,2,1);
cout << (v.cwise()>w) << endl; cout << (v>w) << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(1,2,3), w(3,2,1); Array3d v(1,2,3), w(3,2,1);
cout << (v.cwise()>=w) << endl; cout << (v>=w) << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(2,3,4); Array3d v(2,3,4);
cout << v.cwise().inverse() << endl; cout << v.inverse() << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(1,2,3), w(3,2,1); Array3d v(1,2,3), w(3,2,1);
cout << (v.cwise()<w) << endl; cout << (v<w) << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(1,2,3), w(3,2,1); Array3d v(1,2,3), w(3,2,1);
cout << (v.cwise()<=w) << endl; cout << (v<=w) << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(1,2,3); Array3d v(1,2,3);
cout << v.cwise().log() << endl; cout << v.log() << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(2,3,4), w(4,2,3); Array3d v(2,3,4), w(4,2,3);
cout << v.cwise().max(w) << endl; cout << v.max(w) << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(2,3,4), w(4,2,3); Array3d v(2,3,4), w(4,2,3);
cout << v.cwise().min(w) << endl; cout << v.min(w) << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(1,2,3); Array3d v(1,2,3);
cout << v.cwise()-5 << endl; cout << v-5 << endl;

View File

@ -1,3 +1,3 @@
Vector3d v(1,2,3); Array3d v(1,2,3);
v.cwise() -= 5; v -= 5;
cout << v << endl; cout << v << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(1,2,3), w(3,2,1); Array3d v(1,2,3), w(3,2,1);
cout << (v.cwise()!=w) << endl; cout << (v!=w) << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(1,2,3); Array3d v(1,2,3);
cout << v.cwise()+5 << endl; cout << v+5 << endl;

View File

@ -1,3 +1,3 @@
Vector3d v(1,2,3); Array3d v(1,2,3);
v.cwise() += 5; v += 5;
cout << v << endl; cout << v << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(8,27,64); Array3d v(8,27,64);
cout << v.cwise().pow(0.333333) << endl; cout << v.pow(0.333333) << endl;

View File

@ -1,4 +1,4 @@
Matrix3i a = Matrix3i::Random(), b = Matrix3i::Random(); Array33i a = Array33i::Random(), b = Array33i::Random();
Matrix3i c = a.cwise() * b; Array33i c = a * b;
cout << "a:\n" << a << "\nb:\n" << b << "\nc:\n" << c << endl; cout << "a:\n" << a << "\nb:\n" << b << "\nc:\n" << c << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(2,3,4), w(4,2,3); Array3d v(2,3,4), w(4,2,3);
cout << v.cwise()/w << endl; cout << v/w << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(M_PI, M_PI/2, M_PI/3); Array3d v(M_PI, M_PI/2, M_PI/3);
cout << v.cwise().sin() << endl; cout << v.sin() << endl;

View File

@ -1,4 +1,3 @@
Vector3d v(3,2,4); Array3d v(3,2,4), w(5,4,2);
Vector3d w(5,4,2); v /= w;
v.cwise() /= w;
cout << v << endl; cout << v << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(1,2,4); Array3d v(1,2,4);
cout << v.cwise().sqrt() << endl; cout << v.sqrt() << endl;

View File

@ -1,2 +1,2 @@
Vector3d v(2,3,4); Array3d v(2,3,4);
cout << v.cwise().square() << endl; cout << v.square() << endl;

View File

@ -1,4 +1,3 @@
Vector3d v(1,2,3); Array3d v(1,2,3), w(2,3,0);
Vector3d w(2,3,0); v *= w;
v.cwise() *= w;
cout << v << endl; cout << v << endl;

View File

@ -1,7 +1,7 @@
Vector3f boxMin(Vector3f::Zero()), boxMax(Vector3f::Ones()); Vector3f boxMin(Vector3f::Zero()), boxMax(Vector3f::Ones());
Vector3f p0 = Vector3f::Random(), p1 = Vector3f::Random().cwise().abs(); Vector3f p0 = Vector3f::Random(), p1 = Vector3f::Random().cwiseAbs();
// let's check if p0 and p1 are inside the axis aligned box defined by the corners boxMin,boxMax: // let's check if p0 and p1 are inside the axis aligned box defined by the corners boxMin,boxMax:
cout << "Is (" << p0.transpose() << ") inside the box: " cout << "Is (" << p0.transpose() << ") inside the box: "
<< ((boxMin.cwise()<p0).all() && (boxMax.cwise()>p0).all()) << endl; << ((boxMin.array()<p0.array()).all() && (boxMax.array()>p0.array()).all()) << endl;
cout << "Is (" << p1.transpose() << ") inside the box: " cout << "Is (" << p1.transpose() << ") inside the box: "
<< ((boxMin.cwise()<p1).all() && (boxMax.cwise()>p1).all()) << endl; << ((boxMin.array()<p1.array()).all() && (boxMax.array()>p1.array()).all()) << endl;

View File

@ -1,4 +1,4 @@
Vector3d v(1,2,3); Vector3d v(1,2,3);
v.cwise() += 3; v.array() += 3;
v.cwise() -= 2; v.array() -= 2;
cout << v << endl; cout << v << endl;

View File

@ -0,0 +1,4 @@
Vector3d v(-1,2,-3);
cout << "the absolute values:" << endl << v.array().abs() << endl;
cout << "the absolute values plus one:" << endl << v.array().abs()+1 << endl;
cout << "sum of the squares: " << v.array().square().sum() << endl;

View File

@ -2,4 +2,4 @@ Matrix3d m = Matrix3d::Random();
cout << "Here is the matrix m:" << endl << m << endl; 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 sum of each column:" << endl << m.colwise().sum() << endl;
cout << "Here is the maximum absolute value of each column:" cout << "Here is the maximum absolute value of each column:"
<< endl << m.cwise().abs().colwise().maxCoeff() << endl; << endl << m.cwiseAbs().colwise().maxCoeff() << endl;

View File

@ -1,4 +0,0 @@
Vector3d v(-1,2,-3);
cout << "the absolute values:" << endl << v.cwise().abs() << endl;
cout << "the absolute values plus one:" << endl << v.cwise().abs().cwise()+1 << endl;
cout << "sum of the squares: " << v.cwise().square().sum() << endl;

View File

@ -1,5 +0,0 @@
Matrix2d m; m << 1,2,3,4;
cout << (m*m).lazy().row(0) << endl;
// this computes only one row of the product. By contrast,
// if we did "(m*m).row(0);" then m*m would first be evaluated into
// a temporary, because the Product expression has the EvalBeforeNestingBit.

View File

@ -0,0 +1,3 @@
Matrix2d a, b, c; a << 1,2,3,4; b << 5,6,7,8;
c.noalias() = a * b; // this computes the product directly to c
cout << c << endl;

View File

@ -2,4 +2,4 @@ Matrix3d m = Matrix3d::Random();
cout << "Here is the matrix m:" << endl << m << endl; cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the sum of each row:" << endl << m.rowwise().sum() << endl; cout << "Here is the sum of each row:" << endl << m.rowwise().sum() << endl;
cout << "Here is the maximum absolute value of each row:" cout << "Here is the maximum absolute value of each row:"
<< endl << m.cwise().abs().rowwise().maxCoeff() << endl; << endl << m.cwiseAbs().rowwise().maxCoeff() << endl;

View File

@ -1,6 +1,6 @@
MatrixXi m(3, 3); MatrixXi m(3, 3);
m << 1, 2, 3, m << 1, 2, 3,
4, 5, 6, 4, 5, 6,
7, 8, 9; 7, 8, 9;
m = (m.cwise() >= 5).select(-m, m); m = (m.array() >= 5).select(-m, m);
cout << m << endl; cout << m << endl;

View File

@ -1,3 +1,3 @@
Matrix3d m = Matrix3d::Random(); Matrix3d m = Matrix3d::Random();
cout << "Here is the matrix m:" << endl << m << endl; cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the count of elements larger or equal than 0.5 of each row:" << endl << (m.cwise() >= 0.5).rowwise().count() << endl; cout << "Here is the count of elements larger or equal than 0.5 of each row:" << endl << (m.array() >= 0.5).rowwise().count() << endl;

View File

@ -4,8 +4,8 @@ namespace Eigen {
/** \defgroup Unsupported_modules Unsupported modules /** \defgroup Unsupported_modules Unsupported modules
* *
* The unsupported modules are contributions from various users. They are * The unsupported modules are contributions from various users. They are
* provided "as is", without any support. Nevertheless, they are subject to be * provided "as is", without any support. Nevertheless, some of them are
* included in Eigen in the future. * subject to be included in Eigen in the future.
*/ */
// please list here all unsupported modules // please list here all unsupported modules