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

◆ TEST() [2/2]

TEST ( DMatZZp ,
submatrix  )

Definition at line 55 of file DMatZZpTest.cpp.

56{
57 typedef M2::ARingZZp RingZZp;
58 typedef DMat<M2::ARingZZp> MatZZp;
59
60 RingZZp* R = new RingZZp(101);
61 MatZZp M(*R, 5, 5);
62
63 EXPECT_TRUE(&M.ring() == R);
64
65 RingZZp::ElementType a, b;
66 R->init(a);
67 R->init(b);
68
69 R->set_from_long(a, 13);
70 R->set(M.entry(0, 2), a);
71
72 R->set(b, M.entry(0, 2));
73 EXPECT_TRUE(R->is_equal(a, b));
74
75 // No check is done that there is no aliasing here...
76 // Should there be
77 submatrix(M, 0, 0, 1, 1) = submatrix(M, 0, 2, 1, 1);
78 R->set(b, M.entry(0, 0));
79 EXPECT_TRUE(R->is_equal(a, b));
80
81 submatrix(M, 0, 0, 2, 2) = 0;
82 EXPECT_FALSE(MatrixOps::isZero(M));
83
84 submatrix(M, 0, 2, 2, 2) = 0;
85 EXPECT_TRUE(MatrixOps::isZero(M));
86
87 R->set(M.entry(4, 4), a);
88 EXPECT_FALSE(MatrixOps::isZero(M));
89
90 submatrix(M) = 0;
91 EXPECT_TRUE(MatrixOps::isZero(M));
92
93 MatZZp N(*R, 2, 2);
94 R->set(N.entry(0, 0), a);
95 displayMat(N);
96 std::cout << std::endl;
97 displayMat(M);
98 std::cout << std::endl;
99 submatrix(M, 0, 1, 2, 2) = submatrix(N);
100 submatrix(M, 0, 0, 2, 2) += submatrix(N);
101 submatrix(M, 0, 0, 2, 2) *= a;
102 displayMat(M);
103 std::cout << std::endl;
104 EXPECT_FALSE(MatrixOps::isZero(M));
105
106 R->clear(a);
107 R->clear(b);
108}
Definition dmat.hpp:62
aring-style adapter for Z/p using a discrete-log (Zech) representation: every non-zero residue is its...
Definition aring-zzp.hpp:67
SubMatrix< MatType > submatrix(MatType &m)
void displayMat(buffer &o, const Mat &A)
Definition mat-util.hpp:43
bool isZero(const DMat< RT > &A)

References displayMat(), MatrixOps::isZero(), and submatrix().