Skip to content

Commit 3f5d6fc

Browse files
Oleksandr Motsakmohamed-barakat
authored andcommitted
FIX: printing vs. typing of a quotient ring
ADD: tests for printing vs typing for qrings & non-commutative algebras
1 parent 4a7108c commit 3f5d6fc

3 files changed

Lines changed: 83 additions & 2 deletions

File tree

Tst/New/print_nc_relations.tst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
LIB "tst.lib"; tst_init();
2+
3+
proc TestRingPrinting(def r, string n)
4+
{
5+
def save = basering;
6+
7+
setring r;
8+
9+
"VVVVVVVVVVVV[", n, "]VVVVVVVVVVVV";
10+
11+
"r == currRing (the following type and print should yield the same output!): ";
12+
"type: "; r;
13+
"print(ring): "; print(r);
14+
15+
ring @temp = 2,@a,ds; setring @temp;
16+
17+
"r != currRing (the following type and print may be different!): ";
18+
"type: "; r;
19+
"print(ring): "; print(r);
20+
21+
"^^^^^^^^^^^^[", n, "]^^^^^^^^^^^^";
22+
kill @temp;
23+
24+
setring save;
25+
}
26+
27+
ring r;
28+
29+
TestRingPrinting(r, "default commutative polynomial ring");
30+
31+
def g = nc_algebra(-1, 1);
32+
33+
TestRingPrinting(g, "NC G-Algebra");
34+
35+
setring g;
36+
37+
qring gr = twostd(ideal(var(1)^2));
38+
39+
40+
TestRingPrinting(gr, "NC GR-Algebra (quotient algebra!)");
41+
42+
tst_status(1);$

Tst/New/print_qring.tst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
LIB "tst.lib"; tst_init();
2+
3+
proc TestRingPrinting(def r, string n)
4+
{
5+
def save = basering;
6+
7+
setring r;
8+
9+
"VVVVVVVVVVVV[", n, "]VVVVVVVVVVVV";
10+
11+
"r == currRing (the following type and print should yield the same output!): ";
12+
"type: "; r;
13+
"print(ring): "; print(r);
14+
15+
ring @temp = 2,@a,ds; setring @temp;
16+
17+
"r != currRing (the following type and print may be different!): ";
18+
"type: "; r;
19+
"print(ring): "; print(r);
20+
21+
"^^^^^^^^^^^^[", n, "]^^^^^^^^^^^^";
22+
kill @temp;
23+
24+
setring save;
25+
}
26+
27+
ring r;
28+
29+
TestRingPrinting(r, "default commutative polynomial ring");
30+
31+
qring q = std(ideal(x2));
32+
33+
TestRingPrinting(q, "quotient ring");
34+
35+
tst_status(1);$

libpolys/polys/monomials/ring.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,12 @@ void rWrite(ring r, BOOLEAN details)
402402
#endif
403403
if (r->qideal!=NULL)
404404
{
405-
PrintS("\n// quotient ring from ideal\n");
406-
iiWriteMatrix((matrix)r->qideal,"_",1,r);
405+
PrintS("\n// quotient ring from ideal");
406+
if( details )
407+
{
408+
PrintLn();
409+
iiWriteMatrix((matrix)r->qideal,"_",1,r);
410+
} else PrintS(" ...");
407411
}
408412
}
409413

0 commit comments

Comments
 (0)