![]() |
Eigen
3.3.3
|
Base class for all 1D and 2D array, and related expressions.
An array is similar to a dense vector or matrix. While matrices are mathematical objects with well defined linear algebra operators, an array is just a collection of scalar values arranged in a one or two dimensionnal fashion. As the main consequence, all operations applied to an array are performed coefficient wise. Furthermore, arrays support scalar math functions of the c++ standard library (e.g., std::sin(x)), and convenient constructors allowing to easily write generic code working for both scalar values and arrays.
This class is the base that is inherited by all array expression types.
Derived | is the derived type, e.g., an array or an expression type. |
This class can be extended with the help of the plugin mechanism described on the page Extending MatrixBase (and other classes) by defining the preprocessor symbol EIGEN_ARRAYBASE_PLUGIN
.
Public Member Functions | |
const AbsReturnType | abs () const |
const Abs2ReturnType | abs2 () const |
const AcosReturnType | acos () const |
const ArgReturnType | arg () const |
const AsinReturnType | asin () const |
const AtanReturnType | atan () const |
template<typename CustomBinaryOp , typename OtherDerived > | |
const CwiseBinaryOp < CustomBinaryOp, const Derived, const OtherDerived > | binaryExpr (const Eigen::ArrayBase< OtherDerived > &other, const CustomBinaryOp &func=CustomBinaryOp()) const |
template<typename NewType > | |
CastXpr< NewType >::Type | cast () const |
const CeilReturnType | ceil () const |
ConjugateReturnType | conjugate () const |
const CosReturnType | cos () const |
const CoshReturnType | cosh () const |
const CubeReturnType | cube () const |
const CwiseAbsReturnType | cwiseAbs () const |
const CwiseAbs2ReturnType | cwiseAbs2 () const |
template<typename OtherDerived > | |
const CwiseBinaryOp < std::equal_to< Scalar > , const Derived, const OtherDerived > | cwiseEqual (const Eigen::ArrayBase< OtherDerived > &other) const |
const CwiseScalarEqualReturnType | cwiseEqual (const Scalar &s) const |
const CwiseInverseReturnType | cwiseInverse () const |
template<typename OtherDerived > | |
const CwiseBinaryOp < internal::scalar_max_op < Scalar, Scalar >, const Derived, const OtherDerived > | cwiseMax (const Eigen::ArrayBase< OtherDerived > &other) const |
const CwiseBinaryOp < internal::scalar_max_op < Scalar, Scalar >, const Derived, const ConstantReturnType > | cwiseMax (const Scalar &other) const |
template<typename OtherDerived > | |
const CwiseBinaryOp < internal::scalar_min_op < Scalar, Scalar >, const Derived, const OtherDerived > | cwiseMin (const Eigen::ArrayBase< OtherDerived > &other) const |
const CwiseBinaryOp < internal::scalar_min_op < Scalar, Scalar >, const Derived, const ConstantReturnType > | cwiseMin (const Scalar &other) const |
template<typename OtherDerived > | |
const CwiseBinaryOp < std::not_equal_to< Scalar > , const Derived, const OtherDerived > | cwiseNotEqual (const Eigen::ArrayBase< OtherDerived > &other) const |
template<typename OtherDerived > | |
const CwiseBinaryOp < internal::scalar_product_op < Derived::Scalar, OtherDerived::Scalar >, const Derived, const OtherDerived > | cwiseProduct (const Eigen::ArrayBase< OtherDerived > &other) const |
template<typename OtherDerived > | |
const CwiseBinaryOp < internal::scalar_quotient_op < Scalar >, const Derived, const OtherDerived > | cwiseQuotient (const Eigen::ArrayBase< OtherDerived > &other) const |
const CwiseSignReturnType | cwiseSign () const |
const CwiseSqrtReturnType | cwiseSqrt () const |
const DigammaReturnType | digamma () const |
const ErfReturnType | erf () const |
const ErfcReturnType | erfc () const |
const ExpReturnType | exp () const |
const FloorReturnType | floor () const |
const ImagReturnType | imag () const |
NonConstImagReturnType | imag () |
const InverseReturnType | inverse () const |
const IsFiniteReturnType | isFinite () const |
const IsInfReturnType | isInf () const |
const IsNaNReturnType | isNaN () const |
const LgammaReturnType | lgamma () const |
const LogReturnType | log () const |
const Log10ReturnType | log10 () const |
const Log1pReturnType | log1p () const |
MatrixWrapper< Derived > | matrix () |
template<typename OtherDerived > | |
const CwiseBinaryOp< max < Scalar >, const Derived, const OtherDerived > | max (const Eigen::ArrayBase< OtherDerived > &other) const |
const CwiseBinaryOp < internal::scalar_max_op < Scalar, Scalar >, const Derived, const CwiseNullaryOp < internal::scalar_constant_op < Scalar >, PlainObject > > | max (const Scalar &other) const |
template<typename OtherDerived > | |
const CwiseBinaryOp< min < Scalar >, const Derived, const OtherDerived > | min (const Eigen::ArrayBase< OtherDerived > &other) const |
const CwiseBinaryOp < internal::scalar_min_op < Scalar, Scalar >, const Derived, const CwiseNullaryOp < internal::scalar_constant_op < Scalar >, PlainObject > > | min (const Scalar &other) const |
const BooleanNotReturnType | operator! () const |
template<typename OtherDerived > | |
const CwiseBinaryOp < internal::scalar_boolean_and_op, const Derived, const OtherDerived > | operator&& (const Eigen::ArrayBase< OtherDerived > &other) const |
template<typename OtherDerived > | |
const CwiseBinaryOp < internal::scalar_product_op < Derived::Scalar, OtherDerived::Scalar >, const Derived, const OtherDerived > | operator* (const Eigen::ArrayBase< OtherDerived > &other) const |
template<typename T > | |
const CwiseBinaryOp < internal::scalar_product_op < Scalar, T >, Derived, Constant< T > > | operator* (const T &scalar) const |
template<typename OtherDerived > | |
Derived & | operator*= (const ArrayBase< OtherDerived > &other) |
template<typename OtherDerived > | |
const CwiseBinaryOp< sum < Scalar >, const Derived, const OtherDerived > | operator+ (const Eigen::ArrayBase< OtherDerived > &other) const |
template<typename T > | |
const CwiseBinaryOp < internal::scalar_sum_op < Scalar, T >, Derived, Constant< T > > | operator+ (const T &scalar) const |
template<typename OtherDerived > | |
Derived & | operator+= (const ArrayBase< OtherDerived > &other) |
template<typename OtherDerived > | |
const CwiseBinaryOp < difference< Scalar >, const Derived, const OtherDerived > | operator- (const Eigen::ArrayBase< OtherDerived > &other) const |
const NegativeReturnType | operator- () const |
template<typename T > | |
const CwiseBinaryOp < internal::scalar_difference_op < Scalar, T >, Derived, Constant< T > > | operator- (const T &scalar) const |
template<typename OtherDerived > | |
Derived & | operator-= (const ArrayBase< OtherDerived > &other) |
template<typename OtherDerived > | |
const CwiseBinaryOp < internal::scalar_quotient_op < Scalar, typename OtherDerived::Scalar >, const Derived, const OtherDerived > | operator/ (const Eigen::ArrayBase< OtherDerived > &other) const |
template<typename T > | |
const CwiseBinaryOp < internal::scalar_quotient_op < Scalar, T >, Derived, Constant< T > > | operator/ (const T &scalar) const |
template<typename OtherDerived > | |
Derived & | operator/= (const ArrayBase< OtherDerived > &other) |
Derived & | operator= (const ArrayBase &other) |
Derived & | operator= (const Scalar &value) |
template<typename OtherDerived > | |
const CwiseBinaryOp < internal::scalar_boolean_xor_op, const Derived, const OtherDerived > | operator^ (const Eigen::ArrayBase< OtherDerived > &other) const |
template<typename OtherDerived > | |
const CwiseBinaryOp < internal::scalar_boolean_or_op, const Derived, const OtherDerived > | operator|| (const Eigen::ArrayBase< OtherDerived > &other) const |
template<typename OtherDerived > | |
const CwiseBinaryOp< pow < Scalar >, const Derived, const OtherDerived > | pow (const Eigen::ArrayBase< OtherDerived > &other) const |
template<typename T > | |
const CwiseBinaryOp < internal::scalar_pow_op < Scalar, T >, Derived, Constant< T > > | pow (const T &exponent) const |
RealReturnType | real () const |
NonConstRealReturnType | real () |
const RoundReturnType | round () const |
const RsqrtReturnType | rsqrt () const |
const SignReturnType | sign () const |
const SinReturnType | sin () const |
const SinhReturnType | sinh () const |
const SqrtReturnType | sqrt () const |
const SquareReturnType | square () const |
const TanReturnType | tan () const |
const TanhReturnType | tanh () const |
template<typename CustomUnaryOp > | |
const CwiseUnaryOp < CustomUnaryOp, const Derived > | unaryExpr (const CustomUnaryOp &func=CustomUnaryOp()) const |
Apply a unary operator coefficient-wise. | |
template<typename CustomViewOp > | |
const CwiseUnaryView < CustomViewOp, const Derived > | unaryViewExpr (const CustomViewOp &func=CustomViewOp()) const |
template<typename DerivedQ > | |
const CwiseBinaryOp < internal::scalar_zeta_op < Scalar >, const Derived, const DerivedQ > | zeta (const Eigen::ArrayBase< DerivedQ > &q) const |
Friends | |
template<typename T > | |
const CwiseBinaryOp < internal::scalar_product_op < T, Scalar >, Constant< T > , Derived > | operator* (const T &scalar, const StorageBaseType &expr) |
template<typename T > | |
const CwiseBinaryOp < internal::scalar_sum_op< T, Scalar >, Constant< T > , Derived > | operator+ (const T &scalar, const StorageBaseType &expr) |
template<typename T > | |
const CwiseBinaryOp < internal::scalar_difference_op < T, Scalar >, Constant< T > , Derived > | operator- (const T &scalar, const StorageBaseType &expr) |
template<typename T > | |
const CwiseBinaryOp < internal::scalar_quotient_op < T, Scalar >, Constant< T > , Derived > | operator/ (const T &s, const StorageBaseType &a) |
Component-wise division of the scalar s by array elements of a. | |
Related Functions | |
(Note that these are not member functions.) | |
template<typename Derived , typename ScalarExponent > | |
const CwiseBinaryOp < internal::scalar_pow_op < Derived::Scalar, ScalarExponent >, Derived, Constant< ScalarExponent > > | pow (const Eigen::ArrayBase< Derived > &x, const ScalarExponent &exponent) |
template<typename Derived , typename ExponentDerived > | |
const Eigen::CwiseBinaryOp < Eigen::internal::scalar_pow_op < typename Derived::Scalar, typename ExponentDerived::Scalar > , const Derived, const ExponentDerived > | pow (const Eigen::ArrayBase< Derived > &x, const Eigen::ArrayBase< ExponentDerived > &exponents) |
template<typename Scalar , typename Derived > | |
const CwiseBinaryOp < internal::scalar_pow_op < Scalar, Derived::Scalar > , Constant< Scalar >, Derived > | pow (const Scalar &x, const Eigen::ArrayBase< Derived > &x) |
const AbsReturnType Eigen::ArrayBase< Derived >::abs | ( | ) | const [inline] |
*this
Example:
Array3d v(1,-2,-3); cout << v.abs() << endl;
Output:
1 2 3
const Abs2ReturnType Eigen::ArrayBase< Derived >::abs2 | ( | ) | const [inline] |
*this
Example:
Array3d v(1,-2,-3); cout << v.abs2() << endl;
Output:
1 4 9
const AcosReturnType Eigen::ArrayBase< Derived >::acos | ( | ) | const [inline] |
Example:
Array3d v(0, sqrt(2.)/2, 1); cout << v.acos() << endl;
Output:
1.57 0.785 0
const ArgReturnType Eigen::ArrayBase< Derived >::arg | ( | ) | const [inline] |
*this
Example:
ArrayXcf v = ArrayXcf::Random(3); cout << v << endl << endl; cout << arg(v) << endl;
Output:
(-0.211,0.68) (0.597,0.566) (-0.605,0.823) 1.87 0.759 2.2
const AsinReturnType Eigen::ArrayBase< Derived >::asin | ( | ) | const [inline] |
Example:
Array3d v(0, sqrt(2.)/2, 1); cout << v.asin() << endl;
Output:
0 0.785 1.57
const AtanReturnType Eigen::ArrayBase< Derived >::atan | ( | ) | const [inline] |
Example:
ArrayXd v = ArrayXd::LinSpaced(5,0,1); cout << v.atan() << endl;
Output:
0 0.245 0.464 0.644 0.785
const CwiseBinaryOp<CustomBinaryOp, const Derived, const OtherDerived> Eigen::ArrayBase< Derived >::binaryExpr | ( | const Eigen::ArrayBase< OtherDerived > & | other, |
const CustomBinaryOp & | func = CustomBinaryOp() |
||
) | const [inline] |
The template parameter CustomBinaryOp is the type of the functor of the custom operator (see class CwiseBinaryOp for an example)
Here is an example illustrating the use of custom functors:
#include <Eigen/Core> #include <iostream> using namespace Eigen; using namespace std; // define a custom template binary functor template<typename Scalar> struct MakeComplexOp { EIGEN_EMPTY_STRUCT_CTOR(MakeComplexOp) typedef complex<Scalar> result_type; complex<Scalar> operator()(const Scalar& a, const Scalar& b) const { return complex<Scalar>(a,b); } }; int main(int, char**) { Matrix4d m1 = Matrix4d::Random(), m2 = Matrix4d::Random(); cout << m1.binaryExpr(m2, MakeComplexOp<double>()) << endl; return 0; }
Output:
(0.68,0.271) (0.823,-0.967) (-0.444,-0.687) (-0.27,0.998) (-0.211,0.435) (-0.605,-0.514) (0.108,-0.198) (0.0268,-0.563) (0.566,-0.717) (-0.33,-0.726) (-0.0452,-0.74) (0.904,0.0259) (0.597,0.214) (0.536,0.608) (0.258,-0.782) (0.832,0.678)
CastXpr<NewType>::Type Eigen::ArrayBase< Derived >::cast | ( | ) | const [inline] |
*this
with the Scalar type casted to NewScalar.The template parameter NewScalar is the type we are casting the scalars to.
const CeilReturnType Eigen::ArrayBase< Derived >::ceil | ( | ) | const [inline] |
Example:
ArrayXd v = ArrayXd::LinSpaced(7,-2,2); cout << v << endl << endl; cout << ceil(v) << endl;
Output:
-2 -1.33 -0.667 0 0.667 1.33 2 -2 -1 -0 0 1 2 2
ConjugateReturnType Eigen::ArrayBase< Derived >::conjugate | ( | ) | const [inline] |
*this
. const CosReturnType Eigen::ArrayBase< Derived >::cos | ( | ) | const [inline] |
This function computes the coefficient-wise cosine. The function MatrixBase::cos() in the unsupported module MatrixFunctions computes the matrix cosine.
Example:
Array3d v(M_PI, M_PI/2, M_PI/3); cout << v.cos() << endl;
Output:
-1 6.12e-17 0.5
const CoshReturnType Eigen::ArrayBase< Derived >::cosh | ( | ) | const [inline] |
Example:
ArrayXd v = ArrayXd::LinSpaced(5,0,1); cout << cosh(v) << endl;
Output:
1 1.03 1.13 1.29 1.54
const CubeReturnType Eigen::ArrayBase< Derived >::cube | ( | ) | const [inline] |
Example:
Array3d v(2,3,4); cout << v.cube() << endl;
Output:
8 27 64
const CwiseAbsReturnType Eigen::ArrayBase< Derived >::cwiseAbs | ( | ) | const [inline] |
*this
Example:
MatrixXd m(2,3); m << 2, -4, 6, -5, 1, 0; cout << m.cwiseAbs() << endl;
Output:
2 4 6 5 1 0
const CwiseAbs2ReturnType Eigen::ArrayBase< Derived >::cwiseAbs2 | ( | ) | const [inline] |
*this
Example:
MatrixXd m(2,3); m << 2, -4, 6, -5, 1, 0; cout << m.cwiseAbs2() << endl;
Output:
4 16 36 25 1 0
const CwiseBinaryOp<std::equal_to<Scalar>, const Derived, const OtherDerived> Eigen::ArrayBase< Derived >::cwiseEqual | ( | const Eigen::ArrayBase< OtherDerived > & | other | ) | const [inline] |
Example:
MatrixXi m(2,2); m << 1, 0, 1, 1; cout << "Comparing m with identity matrix:" << endl; cout << m.cwiseEqual(MatrixXi::Identity(2,2)) << endl; int count = m.cwiseEqual(MatrixXi::Identity(2,2)).count(); cout << "Number of coefficients that are equal: " << count << endl;
Output:
Comparing m with identity matrix: 1 1 0 1 Number of coefficients that are equal: 3
const CwiseScalarEqualReturnType Eigen::ArrayBase< Derived >::cwiseEqual | ( | const Scalar & | s | ) | const [inline] |
*this
and a scalar s const CwiseInverseReturnType Eigen::ArrayBase< Derived >::cwiseInverse | ( | ) | const [inline] |
Example:
MatrixXd m(2,3); m << 2, 0.5, 1, 3, 0.25, 1; cout << m.cwiseInverse() << endl;
Output:
0.5 2 1 0.333 4 1
const CwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar>, const Derived, const OtherDerived> Eigen::ArrayBase< Derived >::cwiseMax | ( | const Eigen::ArrayBase< OtherDerived > & | other | ) | const [inline] |
Example:
Output:
4 3 4
const CwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar>, const Derived, const ConstantReturnType> Eigen::ArrayBase< Derived >::cwiseMax | ( | const Scalar & | other | ) | const [inline] |
const CwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar>, const Derived, const OtherDerived> Eigen::ArrayBase< Derived >::cwiseMin | ( | const Eigen::ArrayBase< OtherDerived > & | other | ) | const [inline] |
Example:
Output:
2 2 3
const CwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar>, const Derived, const ConstantReturnType> Eigen::ArrayBase< Derived >::cwiseMin | ( | const Scalar & | other | ) | const [inline] |
const CwiseBinaryOp<std::not_equal_to<Scalar>, const Derived, const OtherDerived> Eigen::ArrayBase< Derived >::cwiseNotEqual | ( | const Eigen::ArrayBase< OtherDerived > & | other | ) | const [inline] |
Example:
MatrixXi m(2,2); m << 1, 0, 1, 1; cout << "Comparing m with identity matrix:" << endl; cout << m.cwiseNotEqual(MatrixXi::Identity(2,2)) << endl; int count = m.cwiseNotEqual(MatrixXi::Identity(2,2)).count(); cout << "Number of coefficients that are not equal: " << count << endl;
Output:
Comparing m with identity matrix: 0 0 1 0 Number of coefficients that are not equal: 1
const CwiseBinaryOp< internal::scalar_product_op < Derived ::Scalar, OtherDerived ::Scalar>, const Derived , const OtherDerived > Eigen::ArrayBase< Derived >::cwiseProduct | ( | const Eigen::ArrayBase< OtherDerived > & | other | ) | const [inline] |
Example:
Matrix3i a = Matrix3i::Random(), b = Matrix3i::Random(); Matrix3i c = a.cwiseProduct(b); cout << "a:\n" << a << "\nb:\n" << b << "\nc:\n" << c << endl;
Output:
a: 7 6 -3 -2 9 6 6 -6 -5 b: 1 -3 9 0 0 3 3 9 5 c: 7 -18 -27 0 0 18 18 -54 -25
const CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived> Eigen::ArrayBase< Derived >::cwiseQuotient | ( | const Eigen::ArrayBase< OtherDerived > & | other | ) | const [inline] |
Example:
Output:
0.5 1.5 1.33
const CwiseSignReturnType Eigen::ArrayBase< Derived >::cwiseSign | ( | ) | const [inline] |
Example:
MatrixXd m(2,3); m << 2, -4, 6, -5, 1, 0; cout << m.cwiseSign() << endl;
Output:
1 -1 1 -1 1 0
const CwiseSqrtReturnType Eigen::ArrayBase< Derived >::cwiseSqrt | ( | ) | const [inline] |
Example:
Vector3d v(1,2,4); cout << v.cwiseSqrt() << endl;
Output:
1 1.41 2
const DigammaReturnType Eigen::ArrayBase< Derived >::digamma | ( | ) | const [inline] |
This is defined in the unsupported SpecialFunctions module.
#include <Eigen/SpecialFunctions>
const ErfReturnType Eigen::ArrayBase< Derived >::erf | ( | ) | const [inline] |
[c++11]
This is defined in the unsupported SpecialFunctions module.
#include <Eigen/SpecialFunctions>
Example:
#include <Eigen/Core> #include <unsupported/Eigen/SpecialFunctions> #include <iostream> using namespace Eigen; int main() { Array4d v(-0.5,2,0,-7); std::cout << v.erf() << std::endl; }
Output:
-0.52 0.995 0 -1
const ErfcReturnType Eigen::ArrayBase< Derived >::erfc | ( | ) | const [inline] |
[c++11]
This is defined in the unsupported SpecialFunctions module.
#include <Eigen/SpecialFunctions>
Example:
#include <Eigen/Core> #include <unsupported/Eigen/SpecialFunctions> #include <iostream> using namespace Eigen; int main() { Array4d v(-0.5,2,0,-7); std::cout << v.erfc() << std::endl; }
Output:
1.52 0.00468 1 2
const ExpReturnType Eigen::ArrayBase< Derived >::exp | ( | ) | const [inline] |
This function computes the coefficient-wise exponential. The function MatrixBase::exp() in the unsupported module MatrixFunctions computes the matrix exponential.
Example:
Array3d v(1,2,3); cout << v.exp() << endl;
Output:
2.72 7.39 20.1
const FloorReturnType Eigen::ArrayBase< Derived >::floor | ( | ) | const [inline] |
Example:
ArrayXd v = ArrayXd::LinSpaced(7,-2,2); cout << v << endl << endl; cout << floor(v) << endl;
Output:
-2 -1.33 -0.667 0 0.667 1.33 2 -2 -2 -1 0 0 1 2
const ImagReturnType Eigen::ArrayBase< Derived >::imag | ( | ) | const [inline] |
*this
. NonConstImagReturnType Eigen::ArrayBase< Derived >::imag | ( | ) | [inline] |
*this
. const InverseReturnType Eigen::ArrayBase< Derived >::inverse | ( | ) | const [inline] |
Example:
Array3d v(2,3,4); cout << v.inverse() << endl;
Output:
0.5 0.333 0.25
const IsFiniteReturnType Eigen::ArrayBase< Derived >::isFinite | ( | ) | const [inline] |
Example:
Array3d v(1,2,3); v(1) *= 0.0/0.0; v(2) /= 0.0; cout << v << endl << endl; cout << isfinite(v) << endl;
Output:
1 -nan inf 1 0 0
const IsInfReturnType Eigen::ArrayBase< Derived >::isInf | ( | ) | const [inline] |
Example:
Array3d v(1,2,3); v(1) *= 0.0/0.0; v(2) /= 0.0; cout << v << endl << endl; cout << isinf(v) << endl;
Output:
1 -nan inf 0 0 1
const IsNaNReturnType Eigen::ArrayBase< Derived >::isNaN | ( | ) | const [inline] |
Example:
Array3d v(1,2,3); v(1) *= 0.0/0.0; v(2) /= 0.0; cout << v << endl << endl; cout << isnan(v) << endl;
Output:
1 -nan inf 0 1 0
const LgammaReturnType Eigen::ArrayBase< Derived >::lgamma | ( | ) | const [inline] |
[c++11]
This is defined in the unsupported SpecialFunctions module.
#include <Eigen/SpecialFunctions>
Example:
#include <Eigen/Core> #include <unsupported/Eigen/SpecialFunctions> #include <iostream> using namespace Eigen; int main() { Array4d v(0.5,10,0,-1); std::cout << v.lgamma() << std::endl; }
Output:
0.572 12.8 inf inf
const LogReturnType Eigen::ArrayBase< Derived >::log | ( | ) | const [inline] |
This function computes the coefficient-wise logarithm. The function MatrixBase::log() in the unsupported module MatrixFunctions computes the matrix logarithm.
Example:
Array3d v(1,2,3); cout << v.log() << endl;
Output:
0 0.693 1.1
const Log10ReturnType Eigen::ArrayBase< Derived >::log10 | ( | ) | const [inline] |
This function computes the coefficient-wise base-10 logarithm.
Example:
Array4d v(-1,0,1,2); cout << log10(v) << endl;
Output:
nan -inf 0 0.301
const Log1pReturnType Eigen::ArrayBase< Derived >::log1p | ( | ) | const [inline] |
*this
.In exact arithmetic, x.log()
is equivalent to (x+1).log(), however, with finite precision, this function is much more accurate when
x
is close to zero.
MatrixWrapper<Derived> Eigen::ArrayBase< Derived >::matrix | ( | ) | [inline] |
const CwiseBinaryOp< max <Scalar>, const Derived, const OtherDerived> Eigen::ArrayBase< Derived >::max | ( | const Eigen::ArrayBase< OtherDerived > & | other | ) | const |
const CwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar>, const Derived, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> > Eigen::ArrayBase< Derived >::max | ( | const Scalar & | other | ) | const [inline] |
*this
and scalar other const CwiseBinaryOp< min <Scalar>, const Derived, const OtherDerived> Eigen::ArrayBase< Derived >::min | ( | const Eigen::ArrayBase< OtherDerived > & | other | ) | const |
const CwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar>, const Derived, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> > Eigen::ArrayBase< Derived >::min | ( | const Scalar & | other | ) | const [inline] |
*this
and scalar other const BooleanNotReturnType Eigen::ArrayBase< Derived >::operator! | ( | ) | const [inline] |
Example:
Array3d v(1,2,3); v(1) *= 0.0/0.0; v(2) /= 0.0; cout << v << endl << endl; cout << !isfinite(v) << endl;
Output:
1 -nan inf 0 1 1
const CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived> Eigen::ArrayBase< Derived >::operator&& | ( | const Eigen::ArrayBase< OtherDerived > & | other | ) | const [inline] |
*this
and other Example:
Output:
0 0 0
const CwiseBinaryOp< internal::scalar_product_op < Derived ::Scalar, OtherDerived ::Scalar>, const Derived , const OtherDerived > Eigen::ArrayBase< Derived >::operator* | ( | const Eigen::ArrayBase< OtherDerived > & | other | ) | const [inline] |
*this
and other const CwiseBinaryOp<internal::scalar_product_op<Scalar,T>,Derived,Constant<T> > Eigen::ArrayBase< Derived >::operator* | ( | const T & | scalar | ) | const |
*this
scaled by the scalar factor scalar T | is the scalar type of scalar. It must be compatible with the scalar type of the given expression. |
Derived & Eigen::ArrayBase< Derived >::operator*= | ( | const ArrayBase< OtherDerived > & | other | ) | [inline] |
replaces *this
by *this
* other coefficient wise.
*this
const CwiseBinaryOp< sum <Scalar>, const Derived, const OtherDerived> Eigen::ArrayBase< Derived >::operator+ | ( | const Eigen::ArrayBase< OtherDerived > & | other | ) | const |
*this
and other const CwiseBinaryOp<internal::scalar_sum_op<Scalar,T>,Derived,Constant<T> > Eigen::ArrayBase< Derived >::operator+ | ( | const T & | scalar | ) | const |
Example:
Output:
1 0 0
Example:
Output:
1 1 0
Example:
Output:
0 0 1
Example:
Output:
0 1 1
Example:
Output:
0 1 0
Example:
Output:
1 0 1
*this
with each coeff incremented by the constant scalar T | is the scalar type of scalar. It must be compatible with the scalar type of the given expression. |
Example:
Array3d v(1,2,3); cout << v+5 << endl;
Output:
6 7 8
Derived & Eigen::ArrayBase< Derived >::operator+= | ( | const ArrayBase< OtherDerived > & | other | ) | [inline] |
replaces *this
by *this
+ other.
*this
const CwiseBinaryOp< difference <Scalar>, const Derived, const OtherDerived> Eigen::ArrayBase< Derived >::operator- | ( | const Eigen::ArrayBase< OtherDerived > & | other | ) | const |
*this
and other const NegativeReturnType Eigen::ArrayBase< Derived >::operator- | ( | ) | const [inline] |
*this
const CwiseBinaryOp<internal::scalar_difference_op<Scalar,T>,Derived,Constant<T> > Eigen::ArrayBase< Derived >::operator- | ( | const T & | scalar | ) | const |
*this
with each coeff decremented by the constant scalar T | is the scalar type of scalar. It must be compatible with the scalar type of the given expression. |
Example:
Array3d v(1,2,3); cout << v-5 << endl;
Output:
-4 -3 -2
Derived & Eigen::ArrayBase< Derived >::operator-= | ( | const ArrayBase< OtherDerived > & | other | ) | [inline] |
replaces *this
by *this
- other.
*this
const CwiseBinaryOp<internal::scalar_quotient_op<Scalar,typename OtherDerived::Scalar>, const Derived, const OtherDerived> Eigen::ArrayBase< Derived >::operator/ | ( | const Eigen::ArrayBase< OtherDerived > & | other | ) | const [inline] |
*this
and other const CwiseBinaryOp<internal::scalar_quotient_op<Scalar,T>,Derived,Constant<T> > Eigen::ArrayBase< Derived >::operator/ | ( | const T & | scalar | ) | const |
*this
divided by the scalar value scalar T | is the scalar type of scalar. It must be compatible with the scalar type of the given expression. |
Derived & Eigen::ArrayBase< Derived >::operator/= | ( | const ArrayBase< OtherDerived > & | other | ) | [inline] |
replaces *this
by *this
/ other coefficient wise.
*this
Derived& Eigen::ArrayBase< Derived >::operator= | ( | const ArrayBase< Derived > & | other | ) | [inline] |
Special case of the template operator=, in order to prevent the compiler from generating a default operator= (issue hit with g++ 4.1)
Derived& Eigen::ArrayBase< Derived >::operator= | ( | const Scalar & | value | ) | [inline] |
Set all the entries to value.
Reimplemented in Eigen::Array< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols >.
const CwiseBinaryOp<internal::scalar_boolean_xor_op, const Derived, const OtherDerived> Eigen::ArrayBase< Derived >::operator^ | ( | const Eigen::ArrayBase< OtherDerived > & | other | ) | const [inline] |
Example:
Output:
1 0 1
const CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived> Eigen::ArrayBase< Derived >::operator|| | ( | const Eigen::ArrayBase< OtherDerived > & | other | ) | const [inline] |
*this
and other Example:
Output:
1 0 1
const CwiseBinaryOp< pow <Scalar>, const Derived, const OtherDerived> Eigen::ArrayBase< Derived >::pow | ( | const Eigen::ArrayBase< OtherDerived > & | other | ) | const |
*this
to the given array of exponents.This function computes the coefficient-wise power.
Example:
Array<double,1,3> x(8,25,3), e(1./3.,0.5,2.); cout << "[" << x << "]^[" << e << "] = " << x.pow(e) << endl; // using ArrayBase::pow cout << "[" << x << "]^[" << e << "] = " << pow(x,e) << endl; // using Eigen::pow
Output:
[ 8 25 3]^[0.333 0.5 2] = 2 5 9 [ 8 25 3]^[0.333 0.5 2] = 2 5 9
const CwiseBinaryOp<internal::scalar_pow_op<Scalar,T>,Derived,Constant<T> > Eigen::ArrayBase< Derived >::pow | ( | const T & | exponent | ) | const |
*this
rasied to the constant power exponent T | is the scalar type of exponent. It must be compatible with the scalar type of the given expression. |
This function computes the coefficient-wise power. The function MatrixBase::pow() in the unsupported module MatrixFunctions computes the matrix power.
Example:
Array3d v(8,27,64); cout << v.pow(0.333333) << endl;
Output:
2 3 4
RealReturnType Eigen::ArrayBase< Derived >::real | ( | ) | const [inline] |
*this
. NonConstRealReturnType Eigen::ArrayBase< Derived >::real | ( | ) | [inline] |
*this
. const RoundReturnType Eigen::ArrayBase< Derived >::round | ( | ) | const [inline] |
Example:
ArrayXd v = ArrayXd::LinSpaced(7,-2,2); cout << v << endl << endl; cout << round(v) << endl;
Output:
-2 -1.33 -0.667 0 0.667 1.33 2 -2 -1 -1 -0 1 1 2
const RsqrtReturnType Eigen::ArrayBase< Derived >::rsqrt | ( | ) | const [inline] |
const SignReturnType Eigen::ArrayBase< Derived >::sign | ( | ) | const [inline] |
const SinReturnType Eigen::ArrayBase< Derived >::sin | ( | ) | const [inline] |
This function computes the coefficient-wise sine. The function MatrixBase::sin() in the unsupported module MatrixFunctions computes the matrix sine.
Example:
Array3d v(M_PI, M_PI/2, M_PI/3); cout << v.sin() << endl;
Output:
1.22e-16 1 0.866
const SinhReturnType Eigen::ArrayBase< Derived >::sinh | ( | ) | const [inline] |
Example:
ArrayXd v = ArrayXd::LinSpaced(5,0,1); cout << sinh(v) << endl;
Output:
0 0.253 0.521 0.822 1.18
const SqrtReturnType Eigen::ArrayBase< Derived >::sqrt | ( | ) | const [inline] |
This function computes the coefficient-wise square root. The function MatrixBase::sqrt() in the unsupported module MatrixFunctions computes the matrix square root.
Example:
Array3d v(1,2,4); cout << v.sqrt() << endl;
Output:
1 1.41 2
const SquareReturnType Eigen::ArrayBase< Derived >::square | ( | ) | const [inline] |
Example:
Array3d v(2,3,4); cout << v.square() << endl;
Output:
4 9 16
const TanReturnType Eigen::ArrayBase< Derived >::tan | ( | ) | const [inline] |
Example:
Array3d v(M_PI, M_PI/2, M_PI/3); cout << v.tan() << endl;
Output:
-1.22e-16 1.63e+16 1.73
const TanhReturnType Eigen::ArrayBase< Derived >::tanh | ( | ) | const [inline] |
Example:
ArrayXd v = ArrayXd::LinSpaced(5,0,1); cout << tanh(v) << endl;
Output:
0 0.245 0.462 0.635 0.762
const CwiseUnaryOp<CustomUnaryOp, const Derived> Eigen::ArrayBase< Derived >::unaryExpr | ( | const CustomUnaryOp & | func = CustomUnaryOp() | ) | const [inline] |
Apply a unary operator coefficient-wise.
[in] | func | Functor implementing the unary operator |
CustomUnaryOp | Type of func |
The function ptr_fun()
from the C++ standard library can be used to make functors out of normal functions.
Example:
#include <Eigen/Core> #include <iostream> using namespace Eigen; using namespace std; // define function to be applied coefficient-wise double ramp(double x) { if (x > 0) return x; else return 0; } int main(int, char**) { Matrix4d m1 = Matrix4d::Random(); cout << m1 << endl << "becomes: " << endl << m1.unaryExpr(ptr_fun(ramp)) << endl; return 0; }
Output:
0.68 0.823 -0.444 -0.27 -0.211 -0.605 0.108 0.0268 0.566 -0.33 -0.0452 0.904 0.597 0.536 0.258 0.832 becomes: 0.68 0.823 0 0 0 0 0.108 0.0268 0.566 0 0 0.904 0.597 0.536 0.258 0.832
Genuine functors allow for more possibilities, for instance it may contain a state.
Example:
#include <Eigen/Core> #include <iostream> using namespace Eigen; using namespace std; // define a custom template unary functor template<typename Scalar> struct CwiseClampOp { CwiseClampOp(const Scalar& inf, const Scalar& sup) : m_inf(inf), m_sup(sup) {} const Scalar operator()(const Scalar& x) const { return x<m_inf ? m_inf : (x>m_sup ? m_sup : x); } Scalar m_inf, m_sup; }; int main(int, char**) { Matrix4d m1 = Matrix4d::Random(); cout << m1 << endl << "becomes: " << endl << m1.unaryExpr(CwiseClampOp<double>(-0.5,0.5)) << endl; return 0; }
Output:
0.68 0.823 -0.444 -0.27 -0.211 -0.605 0.108 0.0268 0.566 -0.33 -0.0452 0.904 0.597 0.536 0.258 0.832 becomes: 0.5 0.5 -0.444 -0.27 -0.211 -0.5 0.108 0.0268 0.5 -0.33 -0.0452 0.5 0.5 0.5 0.258 0.5
const CwiseUnaryView<CustomViewOp, const Derived> Eigen::ArrayBase< Derived >::unaryViewExpr | ( | const CustomViewOp & | func = CustomViewOp() | ) | const [inline] |
The template parameter CustomUnaryOp is the type of the functor of the custom unary operator.
Example:
#include <Eigen/Core> #include <iostream> using namespace Eigen; using namespace std; // define a custom template unary functor template<typename Scalar> struct CwiseClampOp { CwiseClampOp(const Scalar& inf, const Scalar& sup) : m_inf(inf), m_sup(sup) {} const Scalar operator()(const Scalar& x) const { return x<m_inf ? m_inf : (x>m_sup ? m_sup : x); } Scalar m_inf, m_sup; }; int main(int, char**) { Matrix4d m1 = Matrix4d::Random(); cout << m1 << endl << "becomes: " << endl << m1.unaryExpr(CwiseClampOp<double>(-0.5,0.5)) << endl; return 0; }
Output:
0.68 0.823 -0.444 -0.27 -0.211 -0.605 0.108 0.0268 0.566 -0.33 -0.0452 0.904 0.597 0.536 0.258 0.832 becomes: 0.5 0.5 -0.444 -0.27 -0.211 -0.5 0.108 0.0268 0.5 -0.33 -0.0452 0.5 0.5 0.5 0.258 0.5
const CwiseBinaryOp<internal::scalar_zeta_op<Scalar>, const Derived, const DerivedQ> Eigen::ArrayBase< Derived >::zeta | ( | const Eigen::ArrayBase< DerivedQ > & | q | ) | const [inline] |
This is defined in the unsupported SpecialFunctions module.
#include <Eigen/SpecialFunctions>
It returns the Riemann zeta function of two arguments *this
and q:
*this | is the exposent, it must be > 1 |
q | is the shift, it must be > 0 |
This method is an alias for zeta(*this,q);
const CwiseBinaryOp<internal::scalar_product_op<T,Scalar>,Constant<T>,Derived> operator* | ( | const T & | scalar, |
const StorageBaseType & | expr | ||
) | [friend] |
T | is the scalar type of scalar. It must be compatible with the scalar type of the given expression. |
const CwiseBinaryOp<internal::scalar_sum_op<T,Scalar>,Constant<T>,Derived> operator+ | ( | const T & | scalar, |
const StorageBaseType & | expr | ||
) | [friend] |
T | is the scalar type of scalar. It must be compatible with the scalar type of the given expression. |
const CwiseBinaryOp<internal::scalar_difference_op<T,Scalar>,Constant<T>,Derived> operator- | ( | const T & | scalar, |
const StorageBaseType & | expr | ||
) | [friend] |
T | is the scalar type of scalar. It must be compatible with the scalar type of the given expression. |
const CwiseBinaryOp<internal::scalar_quotient_op<T,Scalar>,Constant<T>,Derived> operator/ | ( | const T & | s, |
const StorageBaseType & | a | ||
) | [friend] |
Component-wise division of the scalar s by array elements of a.
Scalar | is the scalar type of x. It must be compatible with the scalar type of the given array expression (Derived::Scalar ). |
const CwiseBinaryOp< internal::scalar_pow_op< Derived::Scalar, ScalarExponent >, Derived, Constant< ScalarExponent > > pow | ( | const Eigen::ArrayBase< Derived > & | x, |
const ScalarExponent & | exponent | ||
) | [related] |
ScalarExponent | is the scalar type of exponent. It must be compatible with the scalar type of the given expression (Derived::Scalar ). |
const Eigen::CwiseBinaryOp< Eigen::internal::scalar_pow_op< typename Derived::Scalar, typename ExponentDerived::Scalar >, const Derived, const ExponentDerived > pow | ( | const Eigen::ArrayBase< Derived > & | x, |
const Eigen::ArrayBase< ExponentDerived > & | exponents | ||
) | [related] |
This function computes the coefficient-wise power.
Example:
Array<double,1,3> x(8,25,3), e(1./3.,0.5,2.); cout << "[" << x << "]^[" << e << "] = " << x.pow(e) << endl; // using ArrayBase::pow cout << "[" << x << "]^[" << e << "] = " << pow(x,e) << endl; // using Eigen::pow
Output:
[ 8 25 3]^[0.333 0.5 2] = 2 5 9 [ 8 25 3]^[0.333 0.5 2] = 2 5 9
const CwiseBinaryOp< internal::scalar_pow_op< Scalar, Derived::Scalar >, Constant< Scalar >, Derived > pow | ( | const Scalar & | x, |
const Eigen::ArrayBase< Derived > & | x | ||
) | [related] |
This function computes the coefficient-wise power between a scalar and an array of exponents.
Scalar | is the scalar type of x. It must be compatible with the scalar type of the given array expression (Derived::Scalar ). |
Example:
Array<double,1,3> e(2,-3,1./3.); cout << "10^[" << e << "] = " << pow(10,e) << endl;
Output:
10^[ 2 -3 0.333] = 100 0.001 2.15