Ticket #57: jacobson.tst

File jacobson.tst, 2.9 KB (added by Oleksandr , 15 years ago)

my tests for jacobson.lib

Line 
1  option(prot);
2
3  proc TestJ(matrix m, list #)
4  {
5  "/////////////////////////////////////////////////";
6  "// m: ";
7  print(m);
8  "// #: [", string(#), "]";
9  def J = jacobson(m, #);   
10 
11  "typeof (result): [", typeof(J), "], size(J): [", size(J), "]!";
12 
13  "//  a Jacobson Form D for m: ";
14  print(J[2]);   
15  "// Check: ";
16  print(J[1]*m*J[3] - J[2]); // check that U*M*V = D
17 
18 
19  }
20
21
22  proc Test(matrix m)
23  {
24  TestJ(m));   
25
26  TestJ(m,-1);
27  TestJ(m, 0);
28  TestJ(m, 1);
29  TestJ(m, 2);
30
31
32  TestJ(m, "a");
33
34/*
35  TestJ(m,-1, "a");
36  TestJ(m, 0, "a");
37  TestJ(m, 1, "a");
38  TestJ(m, 2, "a");
39
40
41  TestJ(m, 0, 2, "a");
42  TestJ(m,-1, 2, "a");
43  TestJ(m, 1, 2, "a");
44  TestJ(m, 2, 2, "a");
45
46  TestJ(m,-1, 0);
47  TestJ(m, 0, 0);
48  TestJ(m, 1, 0);
49  TestJ(m, 2, 0);
50*/ 
51
52
53
54 
55  }
56 
57  LIB "jacobson.lib";
58  printlevel = 1;  echo = 2;
59
60
61
62  ring r = 0,(x,d),Dp;
63
64  Test(0);
65//  Test(matrix());
66  Test(matrix(0));
67
68  matrix m[2][2] = d,x,0,d;
69  print(m);
70  Test(m);
71
72  def R = nc_algebra(1,1);   setring R; // the 1st Weyl algebra
73
74  Test(0);
75//  Test(matrix());
76  Test(matrix(0));
77
78  matrix m[2][2] = d,x,0,d; print(m);
79 
80  Test(m);
81 
82  list J = jacobson(m); // returns a list with 3 entries
83  print(J[2]); // a Jacobson Form D for m
84  print(J[1]*m*J[3] - J[2]); // check that U*M*V = D
85  /*   now, let us do the same for the shift algebra  */
86
87  kill R, r;
88
89  ring r2 = 0,(x,s),Dp;
90
91  matrix m[2][2] = s,x,0,s; print(m); // matrix of the same for as above
92  Test(m);
93
94  def R2 = nc_algebra(1,s);   setring R2; // the 1st shift algebra
95 
96  Test(0);
97//  Test(matrix());
98  Test(matrix(0));
99 
100  matrix m[2][2] = s,x,0,s; print(m); // matrix of the same for as above
101 
102  Test(m);
103  list J = jacobson(m);
104  print(J[2]); // a Jacobson Form D, quite different from above
105  print(J[1]*m*J[3] - J[2]); // check that U*M*V = D
106
107  kill R2, r2;
108
109  //////////////////////////////////////////////////////////////////////
110
111  ring r = 0,(x,d),Dp;
112  def R=nc_algebra(1,1); setring R;
113  R; // the Weyl algebra in x and d
114 
115  Test(matrix(0)); // TODO: BUG HERE!!!
116
117  matrix m[2][2]=d,x,0,d;
118  print(m);
119  Test(m);
120  list J = jacobson(m); // returns a list with 3 entries
121  print(J[2]); // a Jacobson Form D
122  // TODO: ARE U AND V REALLY UNIMODULAR?
123  J[1]; // U
124  J[3]; // V
125
126  print(J[1]*m*J[3] - J[2]); // check that U*M*V = D
127
128  matrix m[3][2]=x, x^4+x^2+21, x^4+x^2+x, x^3+x, 4*x^2+x, x;
129  print(m); // M
130  Test(m);
131  list JJ = jacobson(m); // returns a list with 3 entries
132
133  // TODO: BUG: WHY THE FOLLOWING JACOBSON FORM IS NOT DIAGONAL???!
134  print(JJ[2]); // a Jacobson Form D
135  print(JJ[1]*m*JJ[3] - JJ[2]); // check that U*M*V = D
136
137  // TODO: ARE U AND V REALLY UNIMODULAR?
138  JJ[1]; // U
139  JJ[3]; // V
140
141  list S=smith(m,1);
142
143  print(S[2]); // Smith Normal Form S of M
144  print(S[1]*m*S[3] - S[2]); // check that U*M*V = S
145
146  // TODO: ARE U AND V REALLY UNIMODULAR?
147  S[1]; // U
148  S[3]; // V
149
150
151$$$