/usr/share/singular/LIB/util.py is in singular-data 1:4.1.0-p3+ds-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | from Singular import *
from interpreter import *
singular=SingularGlobalsProxy()
def create_ring(char=0, nvars=1, varNames=None, ordering="dp", degvec=None, register=None):
if not varNames:
varNames=["x("+str(i)+")" for i in xrange(1,nvars+1)]
else:
nvars=len(varNames)
if not degvec:
degvec=IntVector()
for i in xrange(0,nvars):
degvec.append(1)
modulweights=IntVector()
modulweights.append(0)
l=[char,varNames,[[ordering,degvec],["C",modulweights]], Ideal()]
res=singular.ring(l)
if register is None:
return res
else:
old_ring=Ring()
res.set()
for i in range(nvars):
v=singular.var(i+1)
register[str(v)]=v
old_ring.set()
return res
class EquivalenceRelation(object):
"""this class represents an equivalent relation,
which is implemented by repeated evaluatation of a map
c[n]=m means that n is equivalent to m"""
def __init__(self):
self.mydict={}
def canonical(self,var):
while var in self.mydict:
var=self.mydict[var]
return var
def isCanonical(self,var):
if self.canonical(var)==var:
return True
else:
return False
def all_rewritings(self,var):
pass
def rewrite(self, a,b):
a=self.canonical(a)
b=self.canonical(b)
if not a==b:
self.mydict[a]=b
def __getitem__(self,key):
return self.canonical(key)
def __setitem__(self, val, key):
self.rewrite(val,key)
class chaintrans(object):
def __init__(self, chain,full):
self.table={}
self.i=1
full=list(full)
for c in full:
if not c in chain.mydict:
self.insert(c)
for c in full:
self.table[c]=self.table[chain[c]]
def __getitem__(self, key):
return self.table[key]
def insert(self,key):
self.table[key]=self.i
self.i=self.i+1
def __str__(self):
return str(self.table)
|