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

◆ testRingAxioms()

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

Definition at line 164 of file RingTest.hpp.

165{
167 for (int i = 0; i < ntrials; i++)
168 {
169 ring_elem a = gen.nextElement();
170 ring_elem b = gen.nextElement();
171 ring_elem c = gen.nextElement();
172
173 // Test commutativity
174 // test: a*b = b*a
175 // test: a+b == b+a
176 ring_elem d = R->add(a, b);
177 ring_elem e = R->add(b, a);
178 EXPECT_TRUE(R->is_equal(d, e));
179 d = R->mult(a, b);
180 e = R->mult(b, a);
181 EXPECT_TRUE(R->is_equal(d, e));
182
183 // Test associativity
184 // test: a+(b+c) == (a+b)+c
185 // test: a*(b*c) == (a*b)*c
186 d = R->add(a, R->add(b, c));
187 e = R->add(R->add(a, b), c);
188 EXPECT_TRUE(R->is_equal(d, e));
189 d = R->mult(a, R->mult(b, c));
190 e = R->mult(R->mult(a, b), c);
191 EXPECT_TRUE(R->is_equal(d, e));
192
193 // Test distributivity
194 // test: a*(b+c) == a*b + a*c
195 d = R->mult(a, R->add(b, c));
196 e = R->add(R->mult(a, b), R->mult(a, c));
197 EXPECT_TRUE(R->is_equal(d, e));
198 }
199}
const int ntrials
Definition ARingTest.hpp:42

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

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