12 template<
typename ArrayType>
void array(
const ArrayType&
m)
22 ArrayType
m1 = ArrayType::Random(rows, cols),
23 m2 = ArrayType::Random(rows, cols),
28 ColVectorType cv1 = ColVectorType::Random(rows);
29 RowVectorType rv1 = RowVectorType::Random(cols);
31 Scalar s1 = internal::random<Scalar>(),
32 s2 = internal::random<Scalar>();
50 ArrayType::Map(m1.data(), m1.rows(), m1.cols()) -= ArrayType::Map(
m2.data(),
m2.rows(),
m2.cols());
54 ArrayType::Map(m1.data(), m1.rows(), m1.cols()) += ArrayType::Map(
m2.data(),
m2.rows(),
m2.cols());
58 ArrayType::Map(m1.data(), m1.rows(), m1.cols()) *= ArrayType::Map(
m2.data(),
m2.rows(),
m2.cols());
62 m2 = ArrayType::Random(rows,cols);
63 m2 = (m2==0).select(1,m2);
64 ArrayType::Map(m1.data(), m1.rows(), m1.cols()) /= ArrayType::Map(m2.data(), m2.rows(), m2.cols());
75 VERIFY_IS_APPROX(m1.colwise().sum(), m1.colwise().redux(internal::scalar_sum_op<Scalar,Scalar>()));
90 VERIFY_IS_APPROX((m3.topLeftCorner(rows,cols) = 1), ArrayType::Constant(rows,cols,1));
92 ArrayType::RowsAtCompileTime==
Dynamic?2:ArrayType::RowsAtCompileTime,
93 ArrayType::ColsAtCompileTime==
Dynamic?2:ArrayType::ColsAtCompileTime,
94 ArrayType::Options> FixedArrayType;
95 FixedArrayType
f1(s1);
102 FixedArrayType
f4(f1.data());
112 ArrayType exponents = ArrayType::Constant(rows, cols,
RealScalar(2));
123 OneDArrayType o1(rows);
125 OneDArrayType o4((
int)rows);
138 Index r = internal::random<Index>(0, rows-1),
139 c = internal::random<Index>(0, cols-1);
141 ArrayType
m1 = ArrayType::Random(rows, cols),
142 m2 = ArrayType::Random(rows, cols),
146 m4 = (m4.abs()==
Scalar(0)).select(1,m4);
154 VERIFY(! (m1 < m3).all() );
155 VERIFY(! (m1 > m3).all() );
158 VERIFY((m1 <= m2 || m1 >=
m2).all());
175 Scalar mid = (m1.cwiseAbs().minCoeff() + m1.cwiseAbs().maxCoeff())/
Scalar(2);
180 .select(ArrayType::Zero(rows,cols),
m1), m3);
195 RealScalar
a = m1.abs().mean();
196 VERIFY( (m1<-a || m1>a).count() == (m1.abs()>
a).count());
215 ArrayType
m1 = ArrayType::Random(rows, cols),
216 m2 = ArrayType::Random(rows, cols),
220 m4 = (m4.abs()==
Scalar(0)).select(1,m4);
222 Scalar s1 = internal::random<Scalar>();
306 m1 += ArrayType::Constant(rows,cols,
Scalar(tiny));
311 m3.transposeInPlace();
313 m3.transposeInPlace();
325 ArrayType
m1 = ArrayType::Random(rows, cols),
334 for (
Index i = 0;
i < m.rows(); ++
i)
335 for (
Index j = 0;
j < m.cols(); ++
j)
369 for (
Index i = 0;
i < m.rows(); ++
i)
370 for (
Index j = 0;
j < m.cols(); ++
j)
374 std::complex<RealScalar>
zero(0.0,0.0);
406 Scalar s1 = internal::random<Scalar>();
409 m1 += ArrayType::Constant(rows,cols,
Scalar(tiny));
414 m2.transposeInPlace();
416 m2.transposeInPlace();
421 template<
typename ArrayType>
void min_max(
const ArrayType&
m)
428 ArrayType
m1 = ArrayType::Random(rows, cols);
431 Scalar maxM1 = m1.maxCoeff();
432 Scalar minM1 = m1.minCoeff();
434 VERIFY_IS_APPROX(ArrayType::Constant(rows,cols, minM1), (m1.min)(ArrayType::Constant(rows,cols, minM1)));
437 VERIFY_IS_APPROX(ArrayType::Constant(rows,cols, maxM1), (m1.max)(ArrayType::Constant(rows,cols, maxM1)));
453 CALL_SUBTEST_2(
array(Array22f()) );
454 CALL_SUBTEST_3(
array(Array44d()) );
468 CALL_SUBTEST_2(
min_max(Array22f()) );
469 CALL_SUBTEST_3(
min_max(Array44d()) );
friend const mpreal sum(const mpreal tab[], const unsigned long int n, int &status, mp_rnd_t rnd_mode)
void comparisons(const ArrayType &m)
EIGEN_DEVICE_FUNC bool isMuchSmallerThan(const Scalar &x, const OtherScalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
EIGEN_DEVICE_FUNC const ExpReturnType exp() const
EIGEN_DONT_INLINE Scalar zero()
EIGEN_DEVICE_FUNC const TanhReturnType tanh() const
EIGEN_DEVICE_FUNC const LogReturnType log() const
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
EIGEN_DEVICE_FUNC const CoshReturnType cosh() const
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
double f2(const Vector2 &x)
void min_max(const ArrayType &m)
EIGEN_DEVICE_FUNC const RoundReturnType round() const
EIGEN_DEVICE_FUNC const CosReturnType cos() const
EIGEN_DEVICE_FUNC const CeilReturnType ceil() const
internal::enable_if< !(internal::is_same< typename Derived::Scalar, ScalarExponent >::value)&&EIGEN_SCALAR_BINARY_SUPPORTED(pow, typename Derived::Scalar, ScalarExponent), const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived, ScalarExponent, pow) >::type pow(const Eigen::ArrayBase< Derived > &x, const ScalarExponent &exponent)
#define VERIFY_IS_APPROX(a, b)
EIGEN_DEVICE_FUNC const SignReturnType sign() const
EIGEN_DEVICE_FUNC const Log1pReturnType log1p() const
EIGEN_DEVICE_FUNC const SinhReturnType sinh() const
void array_real(const ArrayType &m)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
EIGEN_DEVICE_FUNC const AtanReturnType atan() const
const mpreal sum(const mpreal tab[], const unsigned long int n, int &status, mp_rnd_t mode=mpreal::get_default_rnd())
EIGEN_DEVICE_FUNC const TanReturnType tan() const
Base class for all 1D and 2D array, and related expressions.
NumTraits< Scalar >::Real RealScalar
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Abs2ReturnType abs2() const
Jet< T, N > atan2(const Jet< T, N > &g, const Jet< T, N > &f)
#define VERIFY_IS_MUCH_SMALLER_THAN(a, b)
EIGEN_DEVICE_FUNC const AcosReturnType acos() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArgReturnType arg() const
EIGEN_DEVICE_FUNC const CubeReturnType cube() const
void array_complex(const ArrayType &m)
EIGEN_DEVICE_FUNC const FloorReturnType floor() const
void array(const ArrayType &m)
#define EIGEN_TEST_MAX_SIZE
Point2 f1(const Point3 &p, OptionalJacobian< 2, 3 > H)
double f4(double x, double y, double z)
General-purpose arrays with easy API for coefficient-wise operations.
double f3(double x1, double x2)
EIGEN_DEVICE_FUNC const ImagReturnType imag() const
EIGEN_DEVICE_FUNC const Log10ReturnType log10() const
#define VERIFY_IS_NOT_APPROX(a, b)
internal::nested_eval< T, 1 >::type eval(const T &xpr)
EIGEN_DEVICE_FUNC const SinReturnType sin() const
Jet< T, N > pow(const Jet< T, N > &f, double g)
Generic expression where a coefficient-wise unary operator is applied to an expression.
EIGEN_DEVICE_FUNC const InverseReturnType inverse() const
EIGEN_DEVICE_FUNC const RsqrtReturnType rsqrt() const
EIGEN_DEVICE_FUNC const AsinReturnType asin() const
EIGEN_DEVICE_FUNC const SquareReturnType square() const
ScalarWithExceptions conj(const ScalarWithExceptions &x)