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

◆ testRingPower()

template<typename T>
void testRingPower ( const T * R,
int ntrials )

Definition at line 201 of file RingTest.hpp.

202{
203 mpz_t gmp1;
204 mpz_init(gmp1);
206 for (int i = 0; i < ntrials; i++)
207 {
208 ring_elem a = gen.nextElement();
209 // TODO: what should the answer here be?
210 // EXPECT_TRUE(R->is_equal(R->power(a, 0), R->one())); // 0^0 == 1 too?
211 EXPECT_TRUE(R->is_equal(R->power(a, 1), a));
212
213 int e1 = rawRandomInt(10) + 1;
214 int e2 = rawRandomInt(10) + 1;
215 // std::cout << "(" << e1 << "," << e2 << ")" << std::endl;
216 ring_elem b = R->power(a, e1);
217 ring_elem c = R->power(a, e2);
218 ring_elem d = R->power(a, e1 + e2);
219 EXPECT_TRUE(R->is_equal(R->mult(b, c), d));
220
221 // Make sure that powers via mpz work (at least for small exponents)
222 mpz_set_si(gmp1, e1);
223 ring_elem b1 = R->power(a, gmp1);
224 EXPECT_TRUE(R->is_equal(b1, b));
225 }
226 mpz_clear(gmp1);
227}
const int ntrials
Definition ARingTest.hpp:42
int32_t rawRandomInt(int32_t max)
Definition random.cpp:44

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

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