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

◆ TEST() [1/9]

TEST ( RingRRR ,
add  )

Definition at line 82 of file RingRRRTest.cpp.

83{
84 RingRRR *R = RingRRR::create(std::make_unique<M2::ARingRRR>(100));
86
87 for (int i = 0; i < ntrials; i++)
88 {
89 // test: (a+b) + (-b) == a
90 ring_elem a = gen.nextElement();
91 ring_elem b = gen.nextElement();
92 ring_elem c = R->add(a, b);
93 ring_elem d = R->negate(b);
94 ring_elem e = R->add(c, d); // should be a
95 EXPECT_TRUE(almostEqual(R, 98, a, e));
96 }
97}
const int ntrials
Definition ARingTest.hpp:42
M2::ConcreteRing< M2::ARingRRR > RingRRR
bool almostEqual(const RingRRR *R, int nbits, ring_elem a, ring_elem b)
virtual ring_elem negate(const ring_elem f) const
static ConcreteRing< M2::ARingRRR > * create(std::unique_ptr< M2::ARingRRR > R)
virtual ring_elem add(const ring_elem f, const ring_elem g) const

References M2::ConcreteRing< RingType >::add(), almostEqual(), M2::ConcreteRing< M2::ARingRRR >::create(), M2::ConcreteRing< RingType >::negate(), RingElementGenerator< RingType >::nextElement(), and ntrials.