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

◆ TEST() [7/7]

TEST ( ARingCCC ,
subtract  )

Definition at line 136 of file ARingCCCTest.cpp.

137{
138 M2::ARingCCC C(100);
140 M2::ARingCCC::ElementType a, b, c, e;
141 C.init(a);
142 C.init(b);
143 C.init(c);
144 C.init(e);
145 for (int i = 0; i < ntrials; i++)
146 {
147 // test: (a-b) + (b) == a
148 gen.nextElement(a);
149 gen.nextElement(b);
150 C.subtract(c, a, b);
151 C.add(e, c, b); // should be a
152 EXPECT_TRUE(almostEqual(C, 98, a, e));
153 C.mult(e, a, b);
154 C.subtract_multiple(e, a, b);
155 EXPECT_TRUE(C.is_zero(e));
156 }
157 C.clear(e);
158 C.clear(c);
159 C.clear(b);
160 C.clear(a);
161}
bool almostEqual(const M2::ARingCCC &C, int nbits, const M2::ARingCCC::ElementType &a, const M2::ARingCCC::ElementType &b)
const int ntrials
Definition ARingTest.hpp:42
aring-style adapter for arbitrary-precision complex numbers, stored as (MPFR, MPFR) pairs.
Definition aring-CCC.hpp:71

References M2::ARingCCC::add(), almostEqual(), M2::ARingCCC::clear(), M2::ARingCCC::init(), M2::ARingCCC::is_zero(), M2::ARingCCC::mult(), ARingElementGenerator< RingType >::nextElement(), ntrials, M2::ARingCCC::subtract(), subtract(), and M2::ARingCCC::subtract_multiple().