Esempio n. 1
0
 def __init__(self,modstr="",ring=None):
     '''Solvable module constructor.
     '''
     if ring == None:
        sr = StringReader( modstr );
        tok = GenPolynomialTokenizer(sr);
        self.mset = tok.nextSolvableSubModuleSet();
     else:
        self.mset = ModuleList(ring,None);
     self.ring = self.mset.ring;
Esempio n. 2
0
 def __init__(self,ring,ringstr="",list=None):
     '''Constructor for an ideal in a solvable polynomial ring.
     '''
     self.ring = ring;
     if list == None:
        sr = StringReader( ringstr );
        tok = GenPolynomialTokenizer(ring.ring,sr);
        self.list = tok.nextSolvablePolynomialList();
     else:
        self.list = pylist2arraylist(list);
     self.pset = OrderedPolynomialList(ring.ring,self.list);
Esempio n. 3
0
 def __init__(self,ringstr="",ring=None):
     '''Ring constructor.
     '''
     if ring == None:
        sr = StringReader( ringstr );
        tok = GenPolynomialTokenizer(sr);
        self.pset = tok.nextPolynomialSet();
        self.ring = self.pset.ring;
     else:
        self.ring = ring;
     self.engine = GCDFactory.getProxy(self.ring.coFac);
Esempio n. 4
0
 def __init__(self,ring,polystr="",list=None):
     '''Ideal constructor.
     '''
     self.ring = ring;
     if list == None:
        sr = StringReader( polystr );
        tok = GenPolynomialTokenizer(ring.pset.ring,sr);
        self.list = tok.nextPolynomialList();
     else:
        self.list = pylist2arraylist(list);
     self.pset = OrderedPolynomialList(ring.ring,self.list);
Esempio n. 5
0
 def __init__(self,ringstr="",ring=None):
     '''Solvable polynomial ring constructor.
     '''
     if ring == None:
        sr = StringReader( ringstr );
        tok = GenPolynomialTokenizer(sr);
        self.pset = tok.nextSolvablePolynomialSet();
        self.ring = self.pset.ring;
     else:
        self.ring = ring;
     if not self.ring.isAssociative():
        print "warning: ring is not associative";
Esempio n. 6
0
 def __init__(self,module,modstr="",list=None):
     '''Constructor for sub-module over a solvable polynomial ring.
     '''
     self.module = module;
     if list == None:
        sr = StringReader( modstr );
        tok = GenPolynomialTokenizer(module.ring,sr);
        self.list = tok.nextSolvableSubModuleList();
     else:
        self.list = pylist2arraylist(list);
     self.mset = OrderedModuleList(module.ring,self.list);
     self.cols = self.mset.cols;
     self.rows = self.mset.rows;
Esempio n. 7
0
    def __constructJasObject(self):
        #from types import StringType
        from jas import PolyRing, ZZ
        # set up the polynomial ring (Jas syntax)
        if 'hasParameters' in self.__dict__ and self.hasParameters != '':
            #K = 'K.<%s> = PolynomialRing(ZZ)' % self.hasParameters
            #R = K + '; R.<%s> = PolynomialRing(K)' % self.hasVariables
            K = PolyRing(ZZ(), str(self.hasParameters))
            R = PolyRing(K, str(self.hasVariables))
            gens = '%s,%s' % (self.hasParameters, self.hasVariables)
        else:
            #R = 'R.<%s> = PolynomialRing(ZZ)' % (self.hasVariables)
            R = PolyRing(ZZ(), str(self.hasVariables))
            gens = str(self.hasVariables)
        # translate Jas syntax to pure Python and execute
        #exec(preparse(R))
        Rg = "(one," + gens + ") = R.gens();"
        #print str(R)
        exec(str(Rg))  # safe here since R did evaluate
        #print "R = " + str(R)
        self.jasRing = R

        # avoid XSS: check if polynomials are clean
        from edu.jas.poly import GenPolynomialTokenizer
        vs = GenPolynomialTokenizer.expressionVariables(str(gens))
        vs = sorted(vs)
        #print "vs = " + str(vs)
        vsb = set()
        [
            vsb.update(GenPolynomialTokenizer.expressionVariables(str(s)))
            for s in self.basis
        ]
        vsb = sorted(list(vsb))
        #print "vsb = " + str(vsb)
        if vs != vsb:
            raise ValueError("invalid variables: expected " + str(vs) +
                             ", got " + str(vsb))
        # construct polynomials in the constructed ring from
        # the polynomial expressions
        self.jasBasis = []
        for ps in self.basis:
            #print "ps = " + str(ps)
            ps = str(ps)
            ps = ps.replace('^', '**')
            #exec(preparse("symbdata_ideal = %s" % ps))
            #exec("symbdata_poly = %s" % ps)
            pol = eval(ps)
            self.jasBasis.append(pol)
Esempio n. 8
0
File: sdjas.py Progetto: rjolly/jas
    def __constructJasObject(self):
        #from types import StringType
        from jas import PolyRing, ZZ
        # set up the polynomial ring (Jas syntax)
        if 'hasParameters' in self.__dict__ and self.hasParameters != '':
            #K = 'K.<%s> = PolynomialRing(ZZ)' % self.hasParameters
            #R = K + '; R.<%s> = PolynomialRing(K)' % self.hasVariables
            K = PolyRing(ZZ(), str(self.hasParameters) )
            R = PolyRing(K, str(self.hasVariables))
            gens = '%s,%s' % (self.hasParameters, self.hasVariables)
        else:
            #R = 'R.<%s> = PolynomialRing(ZZ)' % (self.hasVariables)
            R = PolyRing(ZZ(), str(self.hasVariables) )
            gens = str(self.hasVariables)
        # translate Jas syntax to pure Python and execute
        #exec(preparse(R))
        Rg = "(one," + gens + ") = R.gens();"
        #print str(R)
        exec(str(Rg)) # safe here since R did evaluate
        #print "R = " + str(R)
        self.jasRing = R;

        # avoid XSS: check if polynomials are clean
        from edu.jas.poly import GenPolynomialTokenizer
        vs = GenPolynomialTokenizer.expressionVariables(str(gens))
        vs = sorted(vs)
        #print "vs = " + str(vs)
        vsb = set()
        [ vsb.update(GenPolynomialTokenizer.expressionVariables(str(s))) for s in self.basis]
        vsb = sorted(list(vsb)) 
        #print "vsb = " + str(vsb)
        if vs != vsb:
           raise ValueError("invalid variables: expected " + str(vs) + ", got " + str(vsb))
        # construct polynomials in the constructed ring from
        # the polynomial expressions
        self.jasBasis = []
        for ps in self.basis:
            #print "ps = " + str(ps)
            ps = str(ps)
            ps = ps.replace('^', '**')
            #exec(preparse("symbdata_ideal = %s" % ps))
            #exec("symbdata_poly = %s" % ps)
            pol = eval(ps)
            self.jasBasis.append(pol)
Esempio n. 9
0
 def __init__(self,ringstr="",truncate=None,ring=None,cofac=None,name="z"):
     '''Ring constructor.
     '''
     if ring == None:
         if len(ringstr) > 0:
             sr = StringReader( ringstr );
             tok = GenPolynomialTokenizer(sr);
             pset = tok.nextPolynomialSet();
             ring = pset.ring;
             vname = ring.vars;
             name = vname[0];
             cofac = ring.coFac;
         if isinstance(cofac,RingElem):
             cofac = cofac.elem;
         if truncate == None:
             self.ring = UnivPowerSeriesRing(cofac,name);
         else:
             self.ring = UnivPowerSeriesRing(cofac,truncate,name);
     else:
        self.ring = ring;