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

◆ almostEqual()

bool almostEqual ( const M2::ARingRRi & R,
int nbits,
const M2::ARingRRi::ElementType & a,
const M2::ARingRRi::ElementType & b )

Definition at line 47 of file ARingRRiTest.cpp.

51{
52 mpfr_t epsilon;
53 mpfr_init2(epsilon, R.get_precision());
54 mpfr_set_ui_2exp(epsilon, 1, -nbits, MPFR_RNDN);
55
56 mpfr_t c,d;
57 mpfr_init2(c, R.get_precision());
58 mpfr_init2(d, R.get_precision());
59
60 mpfr_sub(c,&(a.left),&(b.left),MPFR_RNDN);
61 mpfr_sub(d,&(a.right),&(b.right),MPFR_RNDN);
62
63 bool retL = mpfr_cmpabs(c, epsilon) < 0,
64 retR = mpfr_cmpabs(d, epsilon) < 0;
65
66 mpfr_clear(d);
67 mpfr_clear(c);
68 mpfr_clear(epsilon);
69 return retL and retR;
70}
unsigned long get_precision() const
Definition aring-RRi.hpp:81

References M2::ARingRRi::get_precision().

Referenced by TEST(), and TEST().