Macaulay2 Engine
Loading...
Searching...
No Matches

◆ almostEqual()

bool almostEqual ( const M2::ARingRR & R,
unsigned long nbits,
const M2::ARingRR::ElementType & a,
const M2::ARingRR::ElementType & b )

Definition at line 46 of file ARingRRTest.cpp.

50{
51 M2::ARingRR::ElementType epsilon = pow(2, static_cast<double>(-nbits));
53 R.subtract(c, a, b);
54 // std::cout << "a = " << a << ", b = " << b << ", c = " << c << ", a-b = " <<
55 // a-b;
56 R.abs(c, c);
57 // std::cout << ", |c| = " << c << ", epsilon = " << epsilon << std::endl;
58 return R.compare_elems(c, epsilon) < 0;
59}
int compare_elems(const ElementType &f, const ElementType &g) const
Definition aring-RR.hpp:92
elem ElementType
Definition aring-RR.hpp:68
void abs(ElementType &result, const ElementType &a) const
Definition aring-RR.hpp:222
void subtract(ElementType &result, const ElementType &a, const ElementType &b) const
Definition aring-RR.hpp:189
const mpreal pow(const mpreal &a, const unsigned int b, mp_rnd_t rnd_mode=mpreal::get_default_rnd())
Definition mpreal.h:2962

References M2::ARingRR::abs(), M2::ARingRR::compare_elems(), and M2::ARingRR::subtract().

Referenced by TEST(), TEST(), TEST(), TEST(), and TEST().