cxx11_tensor_roundings.cpp File Reference
#include "main.h"
#include <Eigen/CXX11/Tensor>

Functions

static void test_float_rounding ()
 
static void test_float_flooring ()
 
static void test_float_ceiling ()
 
 EIGEN_DECLARE_TEST (cxx11_tensor_roundings)
 

Function Documentation

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( cxx11_tensor_roundings  )
53  {
57 }
static void test_float_rounding()
Definition: cxx11_tensor_roundings.cpp:14
static void test_float_flooring()
Definition: cxx11_tensor_roundings.cpp:27
static void test_float_ceiling()
Definition: cxx11_tensor_roundings.cpp:40
#define CALL_SUBTEST(FUNC)
Definition: main.h:382

References CALL_SUBTEST, test_float_ceiling(), test_float_flooring(), and test_float_rounding().

◆ test_float_ceiling()

static void test_float_ceiling ( )
static
40  {
41  Tensor<float, 2> ftensor(20, 30);
42  ftensor = ftensor.random() * 100.f;
43 
44  Tensor<float, 2> result = ftensor.ceil();
45 
46  for (int i = 0; i < 20; ++i) {
47  for (int j = 0; j < 30; ++j) {
48  VERIFY_IS_EQUAL(result(i, j), numext::ceil(ftensor(i, j)));
49  }
50  }
51 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
The tensor class.
Definition: Tensor.h:68
#define VERIFY_IS_EQUAL(a, b)
Definition: main.h:367
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 ceil(const bfloat16 &a)
Definition: BFloat16.h:644
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References Eigen::bfloat16_impl::ceil(), i, j, and VERIFY_IS_EQUAL.

Referenced by EIGEN_DECLARE_TEST().

◆ test_float_flooring()

static void test_float_flooring ( )
static
27  {
28  Tensor<float, 2> ftensor(20, 30);
29  ftensor = ftensor.random() * 100.f;
30 
31  Tensor<float, 2> result = ftensor.floor();
32 
33  for (int i = 0; i < 20; ++i) {
34  for (int j = 0; j < 30; ++j) {
35  VERIFY_IS_EQUAL(result(i, j), numext::floor(ftensor(i, j)));
36  }
37  }
38 }
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 floor(const bfloat16 &a)
Definition: BFloat16.h:643

References Eigen::bfloat16_impl::floor(), i, j, and VERIFY_IS_EQUAL.

Referenced by EIGEN_DECLARE_TEST().

◆ test_float_rounding()

static void test_float_rounding ( )
static
14  {
15  Tensor<float, 2> ftensor(20, 30);
16  ftensor = ftensor.random() * 100.f;
17 
18  Tensor<float, 2> result = ftensor.round();
19 
20  for (int i = 0; i < 20; ++i) {
21  for (int j = 0; j < 30; ++j) {
22  VERIFY_IS_EQUAL(result(i, j), numext::round(ftensor(i, j)));
23  }
24  }
25 }
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 round(const bfloat16 &a)
Definition: BFloat16.h:646

References i, j, Eigen::bfloat16_impl::round(), and VERIFY_IS_EQUAL.

Referenced by EIGEN_DECLARE_TEST().