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

◆ testAxioms()

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

Definition at line 186 of file ARingTest.hpp.

187{
189 typename T::ElementType a, b, c, d, e, f;
190 R.init(a);
191 R.init(b);
192 R.init(c);
193 R.init(d);
194 R.init(e);
195 R.init(f);
196 for (int i = 0; i < ntrials; i++)
197 {
198 gen.nextElement(a);
199 gen.nextElement(b);
200 gen.nextElement(c);
201
202 // Test commutativity
203 // test: a*b = b*a
204 // test: a+b == b+a
205 R.add(d, a, b);
206 R.add(e, b, a);
207 EXPECT_TRUE(R.is_equal(d, e));
208 R.mult(d, a, b);
209 R.mult(e, b, a);
210 EXPECT_TRUE(R.is_equal(d, e));
211
212 // Test associativity
213 // test: a+(b+c) == (a+b)+c
214 // test: a*(b*c) == (a*b)*c
215 R.add(d, b, c);
216 R.add(d, a, d);
217 R.add(e, a, b);
218 R.add(e, e, c);
219 EXPECT_TRUE(R.is_equal(d, e));
220 R.mult(d, b, c);
221 R.mult(d, a, d);
222 R.mult(e, a, b);
223 R.mult(e, e, c);
224 EXPECT_TRUE(R.is_equal(d, e));
225
226 // Test distributivity
227 // test: a*(b+c) == a*b + a*c
228 R.add(d, b, c);
229 R.mult(d, a, d);
230 R.mult(e, a, b);
231 R.mult(f, a, c);
232 R.add(e, e, f);
233 EXPECT_TRUE(R.is_equal(d, e));
234 }
235 R.clear(a);
236 R.clear(b);
237 R.clear(c);
238 R.clear(d);
239 R.clear(e);
240 R.clear(f);
241}
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(), TEST(), and testFiniteField().