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

◆ TEST() [1/7]

TEST ( ARingCC ,
add  )

Definition at line 102 of file ARingCCTest.cpp.

103{
104 M2::ARingCC C;
105 auto nbits = C.get_precision();
107 M2::ARingCC::ElementType a, b, c, d, e;
108 C.init(a);
109 C.init(b);
110 C.init(c);
111 C.init(d);
112 C.init(e);
113 for (int i = 0; i < ntrials; i++)
114 {
115 // test: (a+b) + (-b) == a
116 gen.nextElement(a);
117 gen.nextElement(b);
118 C.add(c, a, b);
119 C.negate(d, b);
120 C.add(e, c, d); // should be a
121 EXPECT_TRUE(almostEqual(C, nbits - 2, a, e));
122 }
123 C.clear(e);
124 C.clear(d);
125 C.clear(c);
126 C.clear(b);
127 C.clear(a);
128}
bool almostEqual(const M2::ARingCC &C, unsigned long nbits, const M2::ARingCC::ElementType &a, const M2::ARingCC::ElementType &b)
const int ntrials
Definition ARingTest.hpp:42
void negate(ElementType &result, const ElementType &a) const
Definition aring-CC.hpp:228
elem ElementType
Definition aring-CC.hpp:81
void add(ElementType &res, const ElementType &a, const ElementType &b) const
Definition aring-CC.hpp:255
void init(ElementType &result) const
Definition aring-CC.hpp:150
unsigned long get_precision() const
Definition aring-CC.hpp:88
static void clear(ElementType &result)
Definition aring-CC.hpp:164
aring-style adapter for double-precision complex numbers, stored as (double, double) pairs.
Definition aring-CC.hpp:72

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