spielwiese
Last change
on this file since d83bbe1 was
d83bbe1,
checked in by Michael Brickenstein <bricken@…>, 19 years ago
|
*bricken: better
git-svn-id: file:///usr/local/Singular/svn/trunk@8634 2c84dea3-7e68-4137-9b89-c4e89433aadc
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | from Singular import * |
---|
2 | from interpreter import * |
---|
3 | from objects import * |
---|
4 | from polyd import DMPsym, SDMPsym, termsym, lpsym,dpsym,poly_ring_dsym, DMPLsym |
---|
5 | from fieldname1 import Qsym as Rationals |
---|
6 | singular=singular_globals_proxy() |
---|
7 | class SingularException(Exception): |
---|
8 | pass |
---|
9 | |
---|
10 | def encodePoly(p): |
---|
11 | terms=[encodeTerm(t) for t in p] |
---|
12 | return OMApply(SDMPsym,terms) |
---|
13 | |
---|
14 | def encodePolyWithRing(p): |
---|
15 | pe=encodePoly(p) |
---|
16 | r=encodeRing(p.ring()) |
---|
17 | return OMApply(DMPsym,[r,pe]) |
---|
18 | |
---|
19 | |
---|
20 | orderingTable={ |
---|
21 | "lp": lpsym, |
---|
22 | "dp": dpsym |
---|
23 | } |
---|
24 | def encodeOrdering(r): |
---|
25 | rl=singular.ringlist(r) |
---|
26 | return orderingTable[rl[2][0][0]] |
---|
27 | |
---|
28 | def encodeField(r): |
---|
29 | char=singular.char(r) |
---|
30 | if char==0 and singular.npars(r)==0: |
---|
31 | return Rationals |
---|
32 | else: |
---|
33 | raise SingularException("unknown field to encode") |
---|
34 | |
---|
35 | def encodeIdeal(i): |
---|
36 | """FIXME: uses only currentRing""" |
---|
37 | r=encodeRing(i.ring()) |
---|
38 | return OMApply(DMPLsym,[r]+[encodePoly(p) for p in i]) |
---|
39 | def encodeRing(r): |
---|
40 | nv=singular.nvars(r) |
---|
41 | f=encodeField(r) |
---|
42 | return OMApply(poly_ring_dsym,[f,OMint(nv)]) |
---|
43 | |
---|
44 | def encodeTerm(t): |
---|
45 | """FIXME: ugly because it uses slow interpreter interface and setting of rings for this should be automatically""" |
---|
46 | t.ring().set() |
---|
47 | exponents=singular.leadexp(t) |
---|
48 | c=singular.leadcoef(t) |
---|
49 | exponents=[OMint(i) for i in exponents] |
---|
50 | return OMApply(termsym,[OMint(str(c))]+exponents) |
---|
Note: See
TracBrowser
for help on using the repository browser.