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

◆ testReciprocal()

template<typename T>
void testReciprocal ( const T & R,
int ntrials )

Definition at line 371 of file ARingTest.hpp.

372{
374 typename T::ElementType a, b, c, one;
375 R.init(a);
376 R.init(b);
377 R.init(c);
378 R.init(one);
379 R.set_from_long(one, 1);
380 for (int i = 0; i < ntrials; i++)
381 {
382 // c = 1/a
383 // 1/a * a == 1
384 gen.nextElement(a);
385 if (R.is_zero(a)) continue;
386 R.invert(b, a);
387 R.mult(c, b, a);
388 EXPECT_TRUE(R.is_equal(c, one));
389 }
390 R.clear(a);
391 R.clear(b);
392 R.clear(c);
393 R.clear(one);
394}
const int ntrials
Definition ARingTest.hpp:42

References ARingElementGenerator< RingType >::nextElement(), ntrials, and T.

Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and testFiniteField().