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

◆ TEST() [4/7]

TEST ( ARingRR ,
multDivide  )

Definition at line 170 of file ARingRRTest.cpp.

171{
172 std::cout.precision(30);
173 M2::ARingRR R;
174 auto nbits = R.get_precision();
176 M2::ARingRR::ElementType a, b, c, d;
177 R.init(a);
178 R.init(b);
179 R.init(c);
180 R.init(d);
181 for (int i = 0; i < ntrials; i++)
182 {
183 // test: (a*b) // b == a
184 gen.nextElement(a);
185 gen.nextElement(b);
186 R.mult(c, a, b);
187 if (R.is_zero(b))
188 EXPECT_TRUE(R.is_zero(c));
189 else
190 {
191 R.divide(d, c, b);
192 // std::cout << a << " " << b << " " << c << " " << d << " " << d-a <<
193 // std::endl;
194 EXPECT_TRUE(almostEqual(R, nbits - 2, d, a));
195 }
196 }
197 R.clear(d);
198 R.clear(c);
199 R.clear(b);
200 R.clear(a);
201}
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
void mult(ElementType &result, const ElementType &a, const ElementType &b) const
Definition aring-RR.hpp:203
void divide(ElementType &result, const ElementType &a, const ElementType &b) const
Definition aring-RR.hpp:210
elem ElementType
Definition aring-RR.hpp:68
bool is_zero(const ElementType &f) const
Definition aring-RR.hpp:86
static void clear(ElementType &result)
Definition aring-RR.hpp:128
unsigned long get_precision() const
Definition aring-RR.hpp:73
aring-style adapter for double-precision real numbers.
Definition aring-RR.hpp:62

References almostEqual(), M2::ARingRR::clear(), M2::ARingRR::divide(), M2::ARingRR::get_precision(), M2::ARingRR::init(), M2::ARingRR::is_zero(), M2::ARingRR::mult(), ARingElementGenerator< RingType >::nextElement(), and ntrials.