Eigen::test Namespace Reference

Classes

struct  runall< Scalar, PacketType, false, false >
 
struct  runall< Scalar, PacketType, false, true >
 
struct  runall< Scalar, PacketType, true, false >
 
struct  packet_helper
 
struct  packet_helper< false, Packet >
 
struct  runall
 
struct  runner
 
struct  runner< Scalar, PacketType, true, true >
 
struct  runner< Scalar, PacketType, true, false >
 
struct  runner< Scalar, PacketType, false, false >
 

Functions

template<typename T , std::enable_if_t< NumTraits< T >::IsSigned, bool > = true>
T negate (const T &x)
 
template<typename T >
Map< const Array< unsigned char, sizeof(T), 1 > > bits (const T &x)
 
template<typename T >
bool biteq (T a, T b)
 
template<typename Scalar >
EIGEN_DONT_INLINE bool isApproxAbs (const Scalar &a, const Scalar &b, const typename NumTraits< Scalar >::Real &refvalue)
 
template<typename Scalar >
void print_mismatch (const Scalar *ref, const Scalar *vec, int size)
 
template<typename Scalar >
bool areApproxAbs (const Scalar *a, const Scalar *b, int size, const typename NumTraits< Scalar >::Real &refvalue)
 
template<typename Scalar >
bool areApprox (const Scalar *a, const Scalar *b, int size)
 
template<typename Scalar >
bool areEqual (const Scalar *a, const Scalar *b, int size)
 
template<typename Scalar >
bool areApprox (const Scalar *a, const Scalar *b, int size, const typename NumTraits< Scalar >::Real &precision)
 

Function Documentation

◆ areApprox() [1/2]

template<typename Scalar >
bool Eigen::test::areApprox ( const Scalar a,
const Scalar b,
int  size 
)
71  {
72  for (int i = 0; i < size; ++i) {
73  if (numext::not_equal_strict(a[i], b[i]) && !internal::isApprox(a[i], b[i]) &&
74  !((numext::isnan)(a[i]) && (numext::isnan)(b[i]))) {
76  std::cout << std::setprecision(16) << "Values differ in position " << i << ": " << a[i] << " vs " << b[i]
77  << std::endl;
78  return false;
79  }
80  }
81  return true;
82 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
Scalar * b
Definition: benchVecAdd.cpp:17
const Scalar * a
Definition: level2_cplx_impl.h:32
#define isnan(X)
Definition: main.h:109
EIGEN_DEVICE_FUNC bool isApprox(const Scalar &x, const Scalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
Definition: MathFunctions.h:1923
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool not_equal_strict(const X &x, const Y &y)
Definition: Meta.h:606
void print_mismatch(const Scalar *ref, const Scalar *vec, int size)
Definition: packetmath_test_shared.h:52

References a, b, i, Eigen::internal::isApprox(), Eigen::numext::isnan(), Eigen::numext::not_equal_strict(), print_mismatch(), and size.

Referenced by packetmath(), packetmath_complex(), packetmath_notcomplex(), packetmath_real(), test_cast_helper< SrcPacket, TgtPacket, SrcCoeffRatio, TgtCoeffRatio, true >::run(), and test_conj_helper().

◆ areApprox() [2/2]

template<typename Scalar >
bool Eigen::test::areApprox ( const Scalar a,
const Scalar b,
int  size,
const typename NumTraits< Scalar >::Real precision 
)
98  {
99  for (int i = 0; i < size; ++i) {
100  if (numext::not_equal_strict(a[i], b[i]) && !internal::isApprox(a[i], b[i], precision) &&
101  !((numext::isnan)(a[i]) && (numext::isnan)(b[i]))) {
102  print_mismatch(a, b, size);
103  std::cout << std::setprecision(16) << "Values differ in position " << i << ": " << a[i] << " vs " << b[i]
104  << std::endl;
105  return false;
106  }
107  }
108  return true;
109 }

References a, b, i, Eigen::internal::isApprox(), Eigen::numext::isnan(), Eigen::numext::not_equal_strict(), print_mismatch(), and size.

◆ areApproxAbs()

template<typename Scalar >
bool Eigen::test::areApproxAbs ( const Scalar a,
const Scalar b,
int  size,
const typename NumTraits< Scalar >::Real refvalue 
)
58  {
59  for (int i = 0; i < size; ++i) {
60  if (!isApproxAbs(a[i], b[i], refvalue)) {
62  std::cout << std::setprecision(16) << "Values differ in position " << i << ": " << a[i] << " vs " << b[i]
63  << std::endl;
64  return false;
65  }
66  }
67  return true;
68 }
EIGEN_DONT_INLINE bool isApproxAbs(const Scalar &a, const Scalar &b, const typename NumTraits< Scalar >::Real &refvalue)
Definition: packetmath_test_shared.h:47

References a, b, i, isApproxAbs(), print_mismatch(), and size.

◆ areEqual()

template<typename Scalar >
bool Eigen::test::areEqual ( const Scalar a,
const Scalar b,
int  size 
)
85  {
86  for (int i = 0; i < size; ++i) {
87  if (numext::not_equal_strict(a[i], b[i]) && !((numext::isnan)(a[i]) && (numext::isnan)(b[i]))) {
89  std::cout << std::setprecision(16) << "Values differ in position " << i << ": " << a[i] << " vs " << b[i]
90  << std::endl;
91  return false;
92  }
93  }
94  return true;
95 }

References a, b, i, Eigen::numext::isnan(), Eigen::numext::not_equal_strict(), print_mismatch(), and size.

◆ biteq()

template<typename T >
bool Eigen::test::biteq ( T  a,
T  b 
)
41  {
42  return (bits(a) == bits(b)).all();
43 }
Map< const Array< unsigned char, sizeof(T), 1 > > bits(const T &x)
Definition: packetmath_test_shared.h:36

References a, b, and bits().

Referenced by packetmath_real().

◆ bits()

template<typename T >
Map<const Array<unsigned char, sizeof(T), 1> > Eigen::test::bits ( const T x)
36  {
37  return Map<const Array<unsigned char, sizeof(T), 1> >(reinterpret_cast<const unsigned char*>(&x));
38 }
Eigen::Triplet< double > T
Definition: EigenUnitTest.cpp:11
General-purpose arrays with easy API for coefficient-wise operations.
Definition: Array.h:48
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:96
list x
Definition: plotDoE.py:28

References plotDoE::x.

Referenced by biteq(), Eigen::internal::count_bits_impl< BitsType, EnableIf >::clz(), Eigen::internal::clz(), Eigen::internal::count_bits_impl< BitsType, EnableIf >::ctz(), Eigen::internal::ctz(), packetmath_real(), and saveAsBitmap().

◆ isApproxAbs()

template<typename Scalar >
EIGEN_DONT_INLINE bool Eigen::test::isApproxAbs ( const Scalar a,
const Scalar b,
const typename NumTraits< Scalar >::Real refvalue 
)
47  {
48  return internal::isMuchSmallerThan(a - b, refvalue);
49 }
EIGEN_DEVICE_FUNC bool isMuchSmallerThan(const Scalar &x, const OtherScalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
Definition: MathFunctions.h:1916

References a, b, and Eigen::internal::isMuchSmallerThan().

Referenced by areApproxAbs(), packetmath(), and packetmath_scatter_gather().

◆ negate()

template<typename T , std::enable_if_t< NumTraits< T >::IsSigned, bool > = true>
T Eigen::test::negate ( const T x)

◆ print_mismatch()

template<typename Scalar >
void Eigen::test::print_mismatch ( const Scalar ref,
const Scalar vec,
int  size 
)
inline
52  {
53  std::cout << "ref: [" << Map<const Matrix<Scalar, 1, Dynamic> >(ref, size) << "]"
54  << " != vec: [" << Map<const Matrix<Scalar, 1, Dynamic> >(vec, size) << "]\n";
55 }
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186

References size.

Referenced by areApprox(), areApproxAbs(), and areEqual().