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

◆ TEST() [4/7]

TEST ( ARingCC ,
multDivide  )

Definition at line 158 of file ARingCCTest.cpp.

159{
160 M2::ARingCC C;
161 auto nbits = C.get_precision();
163 M2::ARingCC::ElementType a, b, c, d;
164 C.init(a);
165 C.init(b);
166 C.init(c);
167 C.init(d);
168 for (int i = 0; i < ntrials; i++)
169 {
170 // test: (a*b) // b == a
171 gen.nextElement(a);
172 gen.nextElement(b);
173 C.mult(c, a, b);
174 if (C.is_zero(b))
175 EXPECT_TRUE(C.is_zero(c));
176 else
177 {
178 C.divide(d, c, b);
179 EXPECT_TRUE(almostEqual(C, nbits - 6, d, a));
180 }
181 }
182 C.clear(d);
183 C.clear(c);
184 C.clear(b);
185 C.clear(a);
186}
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 mult(ElementType &res, const ElementType &a, const RealElementType &b) const
Definition aring-CC.hpp:303
elem ElementType
Definition aring-CC.hpp:81
bool is_zero(const ElementType &f) const
Definition aring-CC.hpp:103
void init(ElementType &result) const
Definition aring-CC.hpp:150
unsigned long get_precision() const
Definition aring-CC.hpp:88
void divide(ElementType &res, const ElementType &a, const RealElementType &b) const
Definition aring-CC.hpp:319
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 almostEqual(), M2::ARingCC::clear(), M2::ARingCC::divide(), M2::ARingCC::get_precision(), M2::ARingCC::init(), M2::ARingCC::is_zero(), M2::ARingCC::mult(), ARingElementGenerator< RingType >::nextElement(), and ntrials.