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

◆ testRingSyzygy()

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

Definition at line 273 of file RingTest.hpp.

274{
276 for (int i = 0; i < ntrials; i++)
277 {
278 ring_elem u, v;
279 ring_elem a = gen.nextElement();
280 ring_elem b = gen.nextElement();
281 if (R->is_zero(b)) continue;
282
283 // special cases (note: b != 0 for rest of routine)
284 // syzygy(0,b) returns (1,0)
285 R->syzygy(R->zero(), b, u, v);
286 EXPECT_TRUE(R->is_equal(u, R->one()));
287 EXPECT_TRUE(R->is_equal(v, R->zero()));
288 // syzygy(a,1) returns (1,-a)
289 R->syzygy(a, R->one(), u, v);
290 EXPECT_TRUE(R->is_equal(u, R->one()));
291 EXPECT_TRUE(R->is_equal(v, R->negate(a)));
292 // syzygy(a,-1) returns (1,a)
293 R->syzygy(a, R->minus_one(), u, v);
294 EXPECT_TRUE(R->is_equal(u, R->one()));
295 EXPECT_TRUE(R->is_equal(v, a));
296
297 R->syzygy(a, b, u, v);
298 ring_elem result = R->add(R->mult(a, u), R->mult(b, v));
299#if 0
300 buffer o;
301 o << "a=";
302 R->elem_text_out(o,a);
303 o << " b=";
304 R->elem_text_out(o,b);
305 o << " u=";
306 R->elem_text_out(o,u);
307 o << " v=";
308 R->elem_text_out(o,v);
309 std::cout << o.str() << std::endl;
310#endif
311 EXPECT_TRUE(R->is_zero(result));
312 }
313
314 // over ZZ:
315 // syzygy(a,b) returns (b/c, -a/c), where c = +- gcd(a,b), with same sign as b
316}
const int ntrials
Definition ARingTest.hpp:42
char * str()
Definition buffer.hpp:72
VALGRIND_MAKE_MEM_DEFINED & result(result)

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

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