14 template<
typename Scalar>
25 const Scalar denorm_min = std::numeric_limits<Scalar>::denorm_min();
43 const int abs_cases = 13;
44 const int num_cases = 2*abs_cases * 2*abs_cases;
46 const int num_repeats = 32;
50 for (
int i = 0;
i < abs_cases; ++
i) {
51 const Scalar abs_x = abs_vals[
i];
52 for (
int sign_x = 0; sign_x < 2; ++sign_x) {
53 Scalar x_case = sign_x == 0 ? -abs_x : abs_x;
54 for (
int j = 0;
j < abs_cases; ++
j) {
55 const Scalar abs_y = abs_vals[
j];
56 for (
int sign_y = 0; sign_y < 2; ++sign_y) {
57 Scalar y_case = sign_y == 0 ? -abs_y : abs_y;
69 const Scalar tol = test_precision<Scalar>();
71 for (
int i = 0;
i < 1; ++
i) {
72 for (
int j = 0;
j < num_cases; ++
j) {
78 std::cout <<
"pow(" <<
x(
i,
j) <<
"," <<
y(
i,
j) <<
") = " << a <<
" != " << e << std::endl;
85 template<
typename ArrayType>
void array(
const ArrayType&
m)
95 ArrayType
m1 = ArrayType::Random(rows, cols),
96 m2 = ArrayType::Random(rows, cols),
101 ColVectorType cv1 = ColVectorType::Random(rows);
102 RowVectorType rv1 = RowVectorType::Random(cols);
104 Scalar s1 = internal::random<Scalar>(),
105 s2 = internal::random<Scalar>();
123 ArrayType::Map(m1.data(), m1.rows(), m1.cols()) -= ArrayType::Map(
m2.data(),
m2.rows(),
m2.cols());
127 ArrayType::Map(m1.data(), m1.rows(), m1.cols()) += ArrayType::Map(
m2.data(),
m2.rows(),
m2.cols());
131 ArrayType::Map(m1.data(), m1.rows(), m1.cols()) *= ArrayType::Map(
m2.data(),
m2.rows(),
m2.cols());
135 m2 = ArrayType::Random(rows,cols);
136 m2 = (m2==0).select(1,m2);
137 ArrayType::Map(m1.data(), m1.rows(), m1.cols()) /= ArrayType::Map(m2.data(), m2.rows(), m2.cols());
148 VERIFY_IS_APPROX(m1.colwise().sum(), m1.colwise().redux(internal::scalar_sum_op<Scalar,Scalar>()));
163 VERIFY_IS_APPROX((m3.topLeftCorner(rows,cols) = 1), ArrayType::Constant(rows,cols,1));
165 ArrayType::RowsAtCompileTime==
Dynamic?2:ArrayType::RowsAtCompileTime,
166 ArrayType::ColsAtCompileTime==
Dynamic?2:ArrayType::ColsAtCompileTime,
167 ArrayType::Options> FixedArrayType;
169 FixedArrayType
f1(s1);
176 FixedArrayType
f4(f1.data());
181 FixedArrayType
f1{s1};
188 FixedArrayType
f4{
f1.data()};
212 OneDArrayType o1(rows);
214 OneDArrayType o2(static_cast<int>(rows));
219 OneDArrayType o1{rows};
221 OneDArrayType o4{
int(rows)};
229 TwoDArrayType o1(rows,cols);
232 TwoDArrayType o2(static_cast<int>(rows),static_cast<int>(cols));
236 ArrayType2 o3(rows,cols);
238 ArrayType2 o4(static_cast<int>(rows),static_cast<int>(cols));
243 TwoDArrayType o1{
rows,cols};
246 TwoDArrayType o2{
int(rows),
int(cols)};
250 ArrayType2 o3{
rows,cols};
252 ArrayType2 o4{
int(rows),
int(cols)};
267 Index r = internal::random<Index>(0, rows-1),
268 c = internal::random<Index>(0, cols-1);
270 ArrayType
m1 = ArrayType::Random(rows, cols),
271 m2 = ArrayType::Random(rows, cols),
275 m4 = (m4.abs()==
Scalar(0)).select(1,m4);
304 Scalar mid = (m1.cwiseAbs().minCoeff() + m1.cwiseAbs().maxCoeff())/
Scalar(2);
309 .select(ArrayType::Zero(rows,cols),
m1), m3);
324 RealScalar
a = m1.abs().mean();
325 VERIFY( (m1<-a || m1>a).count() == (m1.abs()>
a).count());
344 ArrayType
m1 = ArrayType::Random(rows, cols),
345 m2 = ArrayType::Random(rows, cols),
351 Scalar s1 = internal::random<Scalar>();
363 #if EIGEN_HAS_CXX11_MATH 459 m1 += ArrayType::Constant(rows,cols,
Scalar(tiny));
464 m3.transposeInPlace();
466 m3.transposeInPlace();
478 ArrayType
m1 = ArrayType::Random(rows, cols),
487 for (
Index i = 0;
i < m.rows(); ++
i)
488 for (
Index j = 0;
j < m.cols(); ++
j)
530 for (
Index i = 0;
i < m.rows(); ++
i)
531 for (
Index j = 0;
j < m.cols(); ++
j)
535 std::complex<RealScalar>
zero(0.0,0.0);
568 Scalar s1 = internal::random<Scalar>();
571 m1 += ArrayType::Constant(rows,cols,
Scalar(tiny));
576 m2.transposeInPlace();
578 m2.transposeInPlace();
581 ArrayType m5 = ArrayType::Random(131, 131);
583 m6.transposeInPlace();
587 template<
typename ArrayType>
void min_max(
const ArrayType&
m)
594 ArrayType
m1 = ArrayType::Random(rows, cols);
597 Scalar maxM1 = m1.maxCoeff();
598 Scalar minM1 = m1.minCoeff();
600 VERIFY_IS_APPROX(ArrayType::Constant(rows,cols, minM1), (m1.min)(ArrayType::Constant(rows,cols, minM1)));
603 VERIFY_IS_APPROX(ArrayType::Constant(rows,cols, maxM1), (m1.max)(ArrayType::Constant(rows,cols, maxM1)));
617 maxM1 = m1.template maxCoeff<PropagateNaN>();
618 minM1 = m1.template minCoeff<PropagateNaN>();
622 maxM1 = m1.template maxCoeff<PropagateNumbers>();
623 minM1 = m1.template minCoeff<PropagateNumbers>();
631 template<
typename Scalar>
639 template<
typename Scalar>
650 ArrayType
m1 = ArrayType::Random(rows, cols),
653 m2 = m1.template shiftLeft<2>();
655 m2 = m1.template shiftLeft<9>();
658 m2 = m1.template shiftRight<2>();
660 m2 = m1.template shiftRight<9>();
EIGEN_DEVICE_FUNC const Log1pReturnType log1p() const
Scalar operator()(const Scalar &v) const
EIGEN_DEVICE_FUNC bool isMuchSmallerThan(const Scalar &x, const OtherScalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
#define CALL_SUBTEST_6(FUNC)
#define CALL_SUBTEST_4(FUNC)
Jet< T, N > cos(const Jet< T, N > &f)
void array_real(const ArrayType &m)
static const Eigen::internal::all_t all
EIGEN_DECLARE_TEST(array_cwise)
void array_integer(const ArrayType &m)
#define CALL_SUBTEST_3(FUNC)
EIGEN_DONT_INLINE Scalar zero()
#define CALL_SUBTEST_7(FUNC)
void comparisons(const ArrayType &m)
Jet< T, N > acos(const Jet< T, N > &f)
EIGEN_DEVICE_FUNC const TanhReturnType tanh() const
Jet< T, N > sin(const Jet< T, N > &f)
DerType::Scalar imag(const AutoDiffScalar< DerType > &)
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)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
double f2(const Vector2 &x)
void array(const ArrayType &m)
EIGEN_DEVICE_FUNC const SinhReturnType sinh() const
EIGEN_DEVICE_FUNC const LogReturnType log() const
EIGEN_DEVICE_FUNC const InverseReturnType inverse() const
EIGEN_DEVICE_FUNC const CubeReturnType cube() const
AnnoyingScalar conj(const AnnoyingScalar &x)
EIGEN_DEVICE_FUNC const AtanReturnType atan() const
EIGEN_DEVICE_FUNC const ExpReturnType exp() const
void array_complex(const ArrayType &m)
EIGEN_DEVICE_FUNC const FloorReturnType floor() const
#define VERIFY_IS_APPROX(a, b)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Abs2ReturnType abs2() const
EIGEN_DEVICE_FUNC const SquareReturnType square() const
EIGEN_DEVICE_FUNC const Expm1ReturnType expm1() const
#define CALL_SUBTEST_1(FUNC)
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 log2(const bfloat16 &a)
EIGEN_DEVICE_FUNC const RintReturnType rint() const
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArgReturnType arg() const
Array< int, Dynamic, 1 > v
EIGEN_DEVICE_FUNC const SignReturnType sign() const
#define CALL_SUBTEST_8(FUNC)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Base class for all 1D and 2D array, and related expressions.
NumTraits< Scalar >::Real RealScalar
EIGEN_DEVICE_FUNC const RsqrtReturnType rsqrt() const
EIGEN_DEVICE_FUNC const Eigen::ArrayBase< Derived > & exponents
AnnoyingScalar atan2(const AnnoyingScalar &y, const AnnoyingScalar &x)
#define VERIFY_IS_MUCH_SMALLER_THAN(a, b)
void min_max(const ArrayType &m)
#define CALL_SUBTEST_5(FUNC)
Scalar operator()(const Scalar &v) const
#define EIGEN_TEST_MAX_SIZE
EIGEN_DEVICE_FUNC const Log10ReturnType log10() const
Point2 f1(const Point3 &p, OptionalJacobian< 2, 3 > H)
double f4(double x, double y, double z)
EIGEN_DEVICE_FUNC const TanReturnType tan() const
General-purpose arrays with easy API for coefficient-wise operations.
double f3(double x1, double x2)
EIGEN_DEVICE_FUNC const ImagReturnType imag() const
#define VERIFY_IS_NOT_APPROX(a, b)
#define CALL_SUBTEST_2(FUNC)
internal::nested_eval< T, 1 >::type eval(const T &xpr)
Jet< T, N > sqrt(const Jet< T, N > &f)
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 LogisticReturnType logistic() const
EIGEN_DEVICE_FUNC bool isApprox(const Scalar &x, const Scalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
EIGEN_DEVICE_FUNC const CoshReturnType cosh() const
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
const AutoDiffScalar< DerType > & real(const AutoDiffScalar< DerType > &x)
EIGEN_DEVICE_FUNC const AsinReturnType asin() const
EIGEN_DEVICE_FUNC const CeilReturnType ceil() const
constexpr array< t, n > repeat(t v)
EIGEN_DEVICE_FUNC const RoundReturnType round() const