14 #include <Eigen/CXX11/Tensor> 24 vec1(0) = 4.0; vec2(0) = 0.0;
25 vec1(1) = 8.0; vec2(1) = 1.0;
26 vec1(2) = 15.0; vec2(2) = 2.0;
27 vec1(3) = 16.0; vec2(3) = 3.0;
28 vec1(4) = 23.0; vec2(4) = 4.0;
29 vec1(5) = 42.0; vec2(5) = 5.0;
118 for (
int i = 0;
i < 2; ++
i) {
119 for (
int j = 0;
j < 3; ++
j) {
120 for (
int k = 0; k < 7; ++k) {
133 mat5 = mat1.inverse().log();
135 mat6 = mat2.pow(0.5
f) * 3.14f;
137 mat7 = mat1.cwiseMax(mat5 * 2.0
f).exp();
139 mat8 = (-mat2).
exp() * 3.14f;
143 mat10 = mat2 - 3.14f;
145 mat11 = mat2 / 3.14f;
148 for (
int i = 0;
i < 2; ++
i) {
149 for (
int j = 0;
j < 3; ++
j) {
150 for (
int k = 0; k < 7; ++k) {
173 for (
int i = 0;
i < 2; ++
i) {
174 for (
int j = 0;
j < 3; ++
j) {
175 for (
int k = 0; k < 7; ++k) {
181 mat2 = mat1.constant(3.14
f);
182 mat3 = mat1.cwiseMax(7.3
f).exp();
185 for (
int i = 0;
i < 2; ++
i) {
186 for (
int j = 0;
j < 3; ++
j) {
187 for (
int k = 0; k < 7; ++k) {
198 const int kSize = 31;
200 std::iota(vec.
data(), vec.
data() + kSize, 0);
203 Tensor<bool, 1> bool1 = vec < vec.constant(1) || vec > vec.constant(4);
204 for (
int i = 0;
i < kSize; ++
i) {
211 for (
int i = 0;
i < kSize; ++
i) {
221 bool3 = vec < vec.constant(4) && bool2;
231 for (
int i = 0;
i < 2; ++
i) {
232 for (
int j = 0;
j < 3; ++
j) {
233 for (
int k = 0; k < 7; ++k) {
239 mat2 = mat1.inverse().unaryExpr(&asinf);
240 mat3 = mat1.unaryExpr(&tanhf);
243 for (
int i = 0;
i < 2; ++
i) {
244 for (
int j = 0;
j < 3; ++
j) {
245 for (
int k = 0; k < 7; ++k) {
262 mat3 = mat1.cast<
double>();
263 for (
int i = 0;
i < 2; ++
i) {
264 for (
int j = 0;
j < 3; ++
j) {
265 for (
int k = 0; k < 7; ++k) {
271 mat3 = mat2.cast<
double>();
272 for (
int i = 0;
i < 2; ++
i) {
273 for (
int j = 0;
j < 3; ++
j) {
274 for (
int k = 0; k < 7; ++k) {
291 result = (selector > selector.constant(0.5
f)).select(mat1, mat2);
293 for (
int i = 0;
i < 2; ++
i) {
294 for (
int j = 0;
j < 3; ++
j) {
295 for (
int k = 0; k < 7; ++k) {
302 template <
typename Scalar>
305 const Scalar kNaN = std::numeric_limits<Scalar>::quiet_NaN();
306 const Scalar kInf = std::numeric_limits<Scalar>::infinity();
314 vec_one_nan(
size/2) = kNaN;
317 for (
int i = 0;
i <
size; ++
i) {
323 for (
int i = 0;
i <
size; ++
i) {
333 verify_all_nan(vec_all_nan.template cwiseMax<PropagateNaN>(kNaN));
334 verify_all_nan(vec_all_nan.template cwiseMax<PropagateNaN>(vec_all_nan));
335 verify_all_nan(vec_all_nan.template cwiseMax<PropagateNaN>(kZero));
336 verify_all_nan(vec_all_nan.template cwiseMax<PropagateNaN>(vec_zero));
337 verify_all_nan(vec_zero.template cwiseMax<PropagateNaN>(kNaN));
338 verify_all_nan(vec_zero.template cwiseMax<PropagateNaN>(vec_all_nan));
339 verify_all_zero(vec_zero.template cwiseMax<PropagateNaN>(kZero));
340 verify_all_zero(vec_zero.template cwiseMax<PropagateNaN>(vec_zero));
347 verify_all_nan(vec_all_nan.template cwiseMax<PropagateNumbers>(kNaN));
348 verify_all_nan(vec_all_nan.template cwiseMax<PropagateNumbers>(vec_all_nan));
349 verify_all_zero(vec_all_nan.template cwiseMax<PropagateNumbers>(kZero));
350 verify_all_zero(vec_all_nan.template cwiseMax<PropagateNumbers>(vec_zero));
351 verify_all_zero(vec_zero.template cwiseMax<PropagateNumbers>(kNaN));
352 verify_all_zero(vec_zero.template cwiseMax<PropagateNumbers>(vec_all_nan));
353 verify_all_zero(vec_zero.template cwiseMax<PropagateNumbers>(kZero));
354 verify_all_zero(vec_zero.template cwiseMax<PropagateNumbers>(vec_zero));
361 verify_all_nan(vec_all_nan.template cwiseMin<PropagateNaN>(kNaN));
362 verify_all_nan(vec_all_nan.template cwiseMin<PropagateNaN>(vec_all_nan));
363 verify_all_nan(vec_all_nan.template cwiseMin<PropagateNaN>(kZero));
364 verify_all_nan(vec_all_nan.template cwiseMin<PropagateNaN>(vec_zero));
365 verify_all_nan(vec_zero.template cwiseMin<PropagateNaN>(kNaN));
366 verify_all_nan(vec_zero.template cwiseMin<PropagateNaN>(vec_all_nan));
367 verify_all_zero(vec_zero.template cwiseMin<PropagateNaN>(kZero));
368 verify_all_zero(vec_zero.template cwiseMin<PropagateNaN>(vec_zero));
375 verify_all_nan(vec_all_nan.template cwiseMin<PropagateNumbers>(kNaN));
376 verify_all_nan(vec_all_nan.template cwiseMin<PropagateNumbers>(vec_all_nan));
377 verify_all_zero(vec_all_nan.template cwiseMin<PropagateNumbers>(kZero));
378 verify_all_zero(vec_all_nan.template cwiseMin<PropagateNumbers>(vec_zero));
379 verify_all_zero(vec_zero.template cwiseMin<PropagateNumbers>(kNaN));
380 verify_all_zero(vec_zero.template cwiseMin<PropagateNumbers>(vec_all_nan));
381 verify_all_zero(vec_zero.template cwiseMin<PropagateNumbers>(kZero));
382 verify_all_zero(vec_zero.template cwiseMin<PropagateNumbers>(vec_zero));
386 val = vec_zero.minimum();
388 val = vec_zero.template minimum<PropagateNaN>();
390 val = vec_zero.template minimum<PropagateNumbers>();
392 val = vec_zero.maximum();
394 val = vec_zero.template maximum<PropagateNaN>();
396 val = vec_zero.template maximum<PropagateNumbers>();
400 val = vec_all_nan.template minimum<PropagateNaN>();
402 val = vec_all_nan.template minimum<PropagateNumbers>();
404 val = vec_all_nan.template maximum<PropagateNaN>();
406 val = vec_all_nan.template maximum<PropagateNumbers>();
410 val = vec_one_nan.template minimum<PropagateNaN>();
412 val = vec_one_nan.template minimum<PropagateNumbers>();
414 val = vec_one_nan.template maximum<PropagateNaN>();
416 val = vec_one_nan.template maximum<PropagateNumbers>();
435 vec_clipped = vec.clip(kMin, kMax);
436 for (
int i = 0;
i < 6; ++
i) {
443 test_minmax_nan_propagation_templ<float>();
444 test_minmax_nan_propagation_templ<double>();
461 #if !EIGEN_ARCH_ARM_OR_ARM64
static void test_type_casting()
static void test_functors()
static void test_select()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor< Scalar_, NumIndices_, Options_, IndexType_ > & setRandom()
MatrixXd mat1(size, size)
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T maxi(const T &x, const T &y)
static void test_minmax_nan_propagation()
EIGEN_DEVICE_FUNC const ExpReturnType exp() const
#define VERIFY_IS_APPROX(a, b)
static void test_constants()
#define VERIFY_IS_EQUAL(a, b)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor< Scalar_, NumIndices_, Options_, IndexType_ > & setConstant(const Scalar &val)
A tensor expression mapping an existing array of data.
Array< int, Dynamic, 1 > v
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
static SO4::VectorN2 vec4(const Matrix4 &Q)
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
static const Vector kZero
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar * data()
#define CALL_SUBTEST(FUNC)
static Vector9 vec3(const Matrix3 &R)
EIGEN_DECLARE_TEST(cxx11_tensor_expr)
static void test_boolean()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor< Scalar_, NumIndices_, Options_, IndexType_ > & setZero()
void test_minmax_nan_propagation_templ()