1 | //(GMG/BM, last modified 22.06.96) |
---|
2 | /////////////////////////////////////////////////////////////////////////////// |
---|
3 | version="$Id: ringgb.lib,v 1.16 2001/01/16 13:48:40 Singular Exp $"; |
---|
4 | category="Beta Testing"; |
---|
5 | info=" |
---|
6 | LIBRARY: ringgb.lib Examples and tests for ringgb development |
---|
7 | |
---|
8 | PROCEDURES: |
---|
9 | findZeroPoly(f); finds a zero polynomial for reducing f |
---|
10 | zeroReduce(f); normal form of f concerning the ideal of zero polynomials |
---|
11 | zeroReduceProt(f); normal form of f concerning the ideal of zero polynomials |
---|
12 | "; |
---|
13 | |
---|
14 | LIB "general.lib"; |
---|
15 | /////////////////////////////////////////////////////////////////////////////// |
---|
16 | |
---|
17 | proc findZeroPoly (poly f) |
---|
18 | "USAGE: findZeroPoly(f); f - a polynomial |
---|
19 | RETURN: zero polynomial with the same leading term as f if exists, otherwise 0 |
---|
20 | NOTE: just a wrapper |
---|
21 | EXAMPLE: example findZeroPoly; shows an example |
---|
22 | " |
---|
23 | { |
---|
24 | return(system("findZeroPoly", f)); |
---|
25 | } |
---|
26 | example |
---|
27 | { "EXAMPLE:"; echo = 2; |
---|
28 | option(teach); |
---|
29 | ring r = 65536, (y,x), dp; |
---|
30 | poly f = 1024*x^8*y^2+11264*x^8*y+28672*x^8+45056*x^7*y^2+36864*x^7*y+16384*x^7+40960*x^6*y^2+57344*x^6*y+32768*x^6+30720*x^5*y^2+10240*x^5*y+8192*x^5+35840*x^4*y^2+1024*x^4*y+20480*x^4+30720*x^3*y^2+10240*x^3*y+8192*x^3+4096*x^2*y^2+45056*x^2*y+49152*x^2+40960*x*y^2+57344*x*y+32768*x; |
---|
31 | findZeroPoly(f); |
---|
32 | } |
---|
33 | |
---|
34 | proc zeroReduceExt (poly f , int i) |
---|
35 | "USAGE: zeroReduceExt(f, i); f - a polynomial, i - noisy level |
---|
36 | RETURN: reduced normal form of f modulo zero polynomials |
---|
37 | EXAMPLE: example zeroReduceExt; shows an example |
---|
38 | " |
---|
39 | { |
---|
40 | poly h = f; |
---|
41 | poly n = 0; |
---|
42 | poly g = findZeroPoly(h); |
---|
43 | while ( h <> 0 ) { |
---|
44 | while ( g <> 0 ) { |
---|
45 | h = h - g; |
---|
46 | if (i == 1) { |
---|
47 | printf("reduce with: %s", g); |
---|
48 | printf("to: %s", h); |
---|
49 | } |
---|
50 | g = findZeroPoly(h); |
---|
51 | } |
---|
52 | n = lead(h) + n; |
---|
53 | h = h - lead(h); |
---|
54 | g = findZeroPoly(h); |
---|
55 | } |
---|
56 | return(n); |
---|
57 | } |
---|
58 | example |
---|
59 | { "EXAMPLE:"; echo = 2; |
---|
60 | option(teach); |
---|
61 | ring r = 65536, (y,x), dp; |
---|
62 | poly f = 1024*x^8*y^2+11264*x^8*y+28672*x^8+45056*x^7*y^2+36864*x^7*y+16384*x^7+40960*x^6*y^2+57344*x^6*y+32768*x^6+30720*x^5*y^2+10240*x^5*y+8192*x^5+35840*x^4*y^2+1024*x^4*y+20480*x^4+30720*x^3*y^2+10240*x^3*y+8192*x^3+4096*x^2*y^2+45056*x^2*y+49152*x^2+40960*x*y^2+57344*x*y+32768*x; |
---|
63 | zeroReduceExt(f,0); |
---|
64 | zeroReduceExt(f,1); |
---|
65 | } |
---|
66 | |
---|
67 | proc zeroReduce (poly f) |
---|
68 | "USAGE: zeroReduce(f); f - a polynomial |
---|
69 | RETURN: reduced normal form of f modulo zero polynomials |
---|
70 | EXAMPLE: example zeroReduce; shows an example |
---|
71 | " |
---|
72 | { |
---|
73 | return(zeroReduceExt(f, 0)); |
---|
74 | } |
---|
75 | example |
---|
76 | { "EXAMPLE:"; echo = 2; |
---|
77 | option(teach); |
---|
78 | ring r = 65536, (y,x), dp; |
---|
79 | poly f = 1024*x^8*y^2+11264*x^8*y+28672*x^8+45056*x^7*y^2+36864*x^7*y+16384*x^7+40960*x^6*y^2+57344*x^6*y+32768*x^6+30720*x^5*y^2+10240*x^5*y+8192*x^5+35840*x^4*y^2+1024*x^4*y+20480*x^4+30720*x^3*y^2+10240*x^3*y+8192*x^3+4096*x^2*y^2+45056*x^2*y+49152*x^2+40960*x*y^2+57344*x*y+32768*x; |
---|
80 | zeroReduce(f); |
---|
81 | } |
---|
82 | |
---|
83 | proc zeroReduceProt (poly f) |
---|
84 | "USAGE: zeroReduceProt(f); f - a polynomial |
---|
85 | RETURN: reduced normal form of f modulo zero polynomials and describes the way *g* |
---|
86 | EXAMPLE: example zeroReduceProt; shows an example |
---|
87 | " |
---|
88 | { |
---|
89 | return(zeroReduceExt(f, 1)); |
---|
90 | } |
---|
91 | example |
---|
92 | { "EXAMPLE:"; echo = 2; |
---|
93 | option(teach); |
---|
94 | ring r = 65536, (y,x), dp; |
---|
95 | poly f = 1024*x^8*y^2+11264*x^8*y+28672*x^8+45056*x^7*y^2+36864*x^7*y+16384*x^7+40960*x^6*y^2+57344*x^6*y+32768*x^6+30720*x^5*y^2+10240*x^5*y+8192*x^5+35840*x^4*y^2+1024*x^4*y+20480*x^4+30720*x^3*y^2+10240*x^3*y+8192*x^3+4096*x^2*y^2+45056*x^2*y+49152*x^2+40960*x*y^2+57344*x*y+32768*x; |
---|
96 | zeroReduceProt(f); |
---|
97 | } |
---|