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

◆ TEST() [1/7]

TEST ( ARingRRR ,
add  )

Definition at line 115 of file ARingRRRTest.cpp.

116{
117 M2::ARingRRR R(100);
119 M2::ARingRRR::ElementType a, b, c, d, e;
120 R.init(a);
121 R.init(b);
122 R.init(c);
123 R.init(d);
124 R.init(e);
125 for (int i = 0; i < ntrials; i++)
126 {
127 // test: (a+b) + (-b) == a
128 gen.nextElement(a);
129 gen.nextElement(b);
130 R.add(c, a, b);
131 R.negate(d, b);
132 R.add(e, c, d); // should be a
133 EXPECT_TRUE(almostEqual(R, 98, a, e));
134 }
135 R.clear(e);
136 R.clear(d);
137 R.clear(c);
138 R.clear(b);
139 R.clear(a);
140}
bool almostEqual(const M2::ARingRRR &R, int nbits, const M2::ARingRRR::ElementType &a, const M2::ARingRRR::ElementType &b)
const int ntrials
Definition ARingTest.hpp:42
aring-style adapter for arbitrary-precision real numbers, backed by MPFR.
Definition aring-RRR.hpp:70

References M2::ARingRRR::add(), almostEqual(), M2::ARingRRR::clear(), M2::ARingRRR::init(), M2::ARingRRR::negate(), ARingElementGenerator< RingType >::nextElement(), and ntrials.