1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
// Copyright 2013 Michael E. Stillman
#include "RingTest.hpp"
#include "ZZp.hpp"
template <>
ring_elem getElement<Z_mod>(const Z_mod& R, int index)
{
ring_elem a = getElement<RingZZ>(*globalZZ, index);
return R.from_int(a.get_mpz());
}
TEST(RingZZmod32003, fromStream)
{
std::istringstream i("+1234 +345 -235*a");
Z_mod* R = Z_mod::create(32003);
ring_elem a;
while (fromStream(i, *R, a))
{
buffer o;
R->elem_text_out(o, a);
std::cout << o.str() << " peek: "
<< "." << static_cast<char>(i.peek()) << "." << std::endl;
}
}
///////////////////////////////////////////////
TEST(RingZZmod101, create)
{
Ring* R = Z_mod::create(101);
EXPECT_TRUE(R != 0);
EXPECT_TRUE(dynamic_cast<const Z_mod*>(R) != 0);
EXPECT_EQ(R->coefficient_type(), Ring::COEFF_BASIC);
EXPECT_FALSE(R->is_ZZ());
EXPECT_EQ(ringName(*R), "ZZ/101");
}
TEST(RingZZmod101, ones)
{
Z_mod* R = Z_mod::create(101);
EXPECT_TRUE(R->is_equal(R->one(), R->from_long(1)));
EXPECT_TRUE(R->is_equal(R->minus_one(), R->from_long(-1)));
EXPECT_TRUE(R->is_equal(R->zero(), R->from_long(0)));
EXPECT_TRUE(R->is_zero(R->from_long(0)));
}
TEST(RingZZmod101, negate)
{
Z_mod* R = Z_mod::create(101);
testRingNegate(R, ntrials);
}
TEST(RingZZmod101, add)
{
Z_mod* R = Z_mod::create(101);
testRingAdd(R, ntrials);
}
TEST(RingZZmod101, subtract)
{
Z_mod* R = Z_mod::create(101);
testRingSubtract(R, ntrials);
}
TEST(RingZZmod101, multDivide)
{
Z_mod* R = Z_mod::create(101);
testRingDivide(R, ntrials);
}
TEST(RingZZmod101, axioms)
{
Z_mod* R = Z_mod::create(101);
testRingAxioms(R, ntrials);
}
TEST(RingZZmod101, power)
{
Z_mod* R = Z_mod::create(101);
testRingPower(R, ntrials);
}
TEST(RingZZmod101, syzygy)
{
Z_mod* R = Z_mod::create(101);
testRingSyzygy(R, ntrials);
}
//////////////////////////////////////////////////////////
TEST(RingZZmod2, create)
{
Ring* R = Z_mod::create(2);
EXPECT_TRUE(R != 0);
EXPECT_TRUE(dynamic_cast<const Z_mod*>(R) != 0);
EXPECT_EQ(R->coefficient_type(), Ring::COEFF_BASIC);
EXPECT_FALSE(R->is_ZZ());
EXPECT_EQ(ringName(*R), "ZZ/2");
}
TEST(RingZZmod2, ones)
{
Z_mod* R = Z_mod::create(2);
EXPECT_TRUE(R->is_equal(R->one(), R->from_long(1)));
EXPECT_TRUE(R->is_equal(R->minus_one(), R->from_long(-1)));
EXPECT_TRUE(R->is_equal(R->zero(), R->from_long(0)));
EXPECT_TRUE(R->is_zero(R->from_long(0)));
}
TEST(RingZZmod2, negate)
{
Z_mod* R = Z_mod::create(2);
testRingNegate(R, ntrials);
}
TEST(RingZZmod2, add)
{
Z_mod* R = Z_mod::create(2);
testRingAdd(R, ntrials);
}
TEST(RingZZmod2, subtract)
{
Z_mod* R = Z_mod::create(2);
testRingSubtract(R, ntrials);
}
TEST(RingZZmod2, multDivide)
{
Z_mod* R = Z_mod::create(2);
testRingDivide(R, ntrials);
}
TEST(RingZZmod2, axioms)
{
Z_mod* R = Z_mod::create(2);
testRingAxioms(R, ntrials);
}
TEST(RingZZmod2, power)
{
Z_mod* R = Z_mod::create(2);
testRingPower(R, ntrials);
}
TEST(RingZZmod2, syzygy)
{
Z_mod* R = Z_mod::create(2);
testRingSyzygy(R, ntrials);
}
// Local Variables:
// compile-command: "make -C $M2BUILDDIR/Macaulay2/e/unit-tests check "
// indent-tabs-mode: nil
// End:
|