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

◆ TEST() [1/7]

TEST ( ARingRR ,
add  )

Definition at line 112 of file ARingRRTest.cpp.

113{
114 M2::ARingRR R;
116 M2::ARingRR::ElementType a, b, c, d, e;
117 R.init(a);
118 R.init(b);
119 R.init(c);
120 R.init(d);
121 R.init(e);
122 for (int i = 0; i < ntrials; i++)
123 {
124 // test: (a+b) + (-b) == a
125 gen.nextElement(a);
126 gen.nextElement(b);
127 R.add(c, a, b);
128 R.negate(d, b);
129 R.add(e, c, d); // should be a
130 EXPECT_TRUE(almostEqual(R, R.get_precision() - 2, a, e));
131 }
132 R.clear(e);
133 R.clear(d);
134 R.clear(c);
135 R.clear(b);
136 R.clear(a);
137}
bool almostEqual(const M2::ARingRR &R, unsigned long nbits, const M2::ARingRR::ElementType &a, const M2::ARingRR::ElementType &b)
const int ntrials
Definition ARingTest.hpp:42
void init(ElementType &result) const
Definition aring-RR.hpp:124
elem ElementType
Definition aring-RR.hpp:68
void negate(ElementType &result, const ElementType &a) const
Definition aring-RR.hpp:168
static void clear(ElementType &result)
Definition aring-RR.hpp:128
unsigned long get_precision() const
Definition aring-RR.hpp:73
void add(ElementType &result, const ElementType &a, const ElementType &b) const
Definition aring-RR.hpp:175
aring-style adapter for double-precision real numbers.
Definition aring-RR.hpp:62

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