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

◆ TEST() [7/7]

TEST ( ARingCC ,
subtract  )

Definition at line 130 of file ARingCCTest.cpp.

131{
132 M2::ARingCC C;
133 auto nbits = C.get_precision();
135 M2::ARingCC::ElementType a, b, c, e;
136 C.init(a);
137 C.init(b);
138 C.init(c);
139 C.init(e);
140 for (int i = 0; i < ntrials; i++)
141 {
142 // test: (a-b) + (b) == a
143 gen.nextElement(a);
144 gen.nextElement(b);
145 C.subtract(c, a, b);
146 C.add(e, c, b); // should be a
147 EXPECT_TRUE(almostEqual(C, nbits - 2, a, e));
148 C.mult(e, a, b);
149 C.subtract_multiple(e, a, b);
150 EXPECT_TRUE(C.is_zero(e));
151 }
152 C.clear(e);
153 C.clear(c);
154 C.clear(b);
155 C.clear(a);
156}
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 subtract_multiple(ElementType &result, const ElementType &a, const ElementType &b) const
Definition aring-CC.hpp:293
void mult(ElementType &res, const ElementType &a, const RealElementType &b) const
Definition aring-CC.hpp:303
elem ElementType
Definition aring-CC.hpp:81
void add(ElementType &res, const ElementType &a, const ElementType &b) const
Definition aring-CC.hpp:255
bool is_zero(const ElementType &f) const
Definition aring-CC.hpp:103
void init(ElementType &result) const
Definition aring-CC.hpp:150
void subtract(ElementType &res, const ElementType &a, const ElementType &b) const
Definition aring-CC.hpp:283
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::is_zero(), M2::ARingCC::mult(), ARingElementGenerator< RingType >::nextElement(), ntrials, M2::ARingCC::subtract(), subtract(), and M2::ARingCC::subtract_multiple().