In Files

Parent

JAS::Ring

Represents a JAS polynomial ring: GenPolynomialRing.

Methods to create ideals and ideals with parametric coefficients.

Attributes

auto_inject[RW]

inject variables into environment

auto_lowervar[RW]

avoid capital letter variables

engine[R]

the Java factoy object, gcd engine, sqf engine, factorization engine

factor[R]

the Java factoy object, gcd engine, sqf engine, factorization engine

ring[R]

the Java factoy object, gcd engine, sqf engine, factorization engine

sqf[R]

the Java factoy object, gcd engine, sqf engine, factorization engine

Public Class Methods

getEngineFactor(r) click to toggle source

Get the polynomial factorization engine implementation.

r is the given polynomial ring.

# File examples/jas.rb, line 1550
def Ring.getEngineFactor(r)
    if r.is_a? RingElem
        r = r.elem;
    end
    if r.getClass().getSimpleName() != "GenPolynomialRing"
       return nil;
    end
    begin 
       i = FactorFactory.getImplementation(r.coFac);
    rescue Exception => e
       i = nil
    end
    return i;
end
getEngineGcd(r) click to toggle source

Get the polynomial gcd engine implementation.

r is the given polynomial ring.

# File examples/jas.rb, line 1510
def Ring.getEngineGcd(r)
    if r.is_a? RingElem
        r = r.elem;
    end
    if r.getClass().getSimpleName() != "GenPolynomialRing"
       return nil;
    end
    begin
       i = GCDFactory.getProxy(r.coFac);
    rescue Exception => e
       i = nil
    end
    return i;
end
getEngineSqf(r) click to toggle source

Get the polynomial squarefree engine implementation.

r is the given polynomial ring.

# File examples/jas.rb, line 1530
def Ring.getEngineSqf(r)
    if r.is_a? RingElem
        r = r.elem;
    end
    if r.getClass().getSimpleName() != "GenPolynomialRing"
       return nil;
    end
    begin 
       i = SquarefreeFactory.getImplementation(r.coFac);
    rescue Exception => e
       i = nil
    end
    return i;
end
new(ringstr="",ring=nil) click to toggle source

Ring constructor.

ringstr string representation to be parsed. ring JAS ring object.

# File examples/jas.rb, line 1477
def initialize(ringstr="",ring=nil)
    if ring == nil
       sr = StringReader.new( ringstr );
       tok = RingFactoryTokenizer.new(sr);
       pfac = tok.nextPolynomialRing();
       #tok = GenPolynomialTokenizer.new(sr);
       #@pset = tok.nextPolynomialSet();
       @ring = pfac;
    else
       if ring.is_a? Ring
          @ring = ring.ring
       else 
          @ring = ring;
       end
    end
    # parameter ",fast=false" not possible w/o keyword params
    #if fast == true
    #   return
    #end
    @engine = Ring.getEngineGcd(@ring);
    @sqf = Ring.getEngineSqf(@ring);
    @factor = Ring.getEngineFactor(@ring);
    variable_generators()
    if self.class.auto_inject or self.class.superclass.auto_inject # sic!
       inject_variables();
    end
end

Public Instance Methods

===(other) click to toggle source

Test if two rings are equal.

# File examples/jas.rb, line 1615
def ===(other)
    if not other.is_a? Ring
       return false;
    end
    return @ring.equals(other.ring);
end
complexRoots(a,eps=nil) click to toggle source

Compute complex roots of univariate polynomial.

# File examples/jas.rb, line 1809
def complexRoots(a,eps=nil)
    if not a.is_a? RingElem
        a = RingElem.new(a);
    end
    return a.complexRoots(eps);
end
element(poly) click to toggle source

Create an element from a string or an object.

# File examples/jas.rb, line 1681
def element(poly)
    if not poly.is_a? String 
       begin
          if @ring == poly.ring 
             return RingElem.new(poly);
          end
       rescue Exception => e
          # pass
       end
       poly = str(poly);
    end
    i = SimIdeal.new( self, "( " + poly + " )" );
    list = i.pset.list;
    if list.size > 0
       return RingElem.new( list[0] );
    end
end
factors(a) click to toggle source

Compute irreducible factorization for modular, integer, rational number and algebriac number coefficients.

# File examples/jas.rb, line 1746
def factors(a)
    if a.is_a? RingElem
        a = a.elem;
    else
        a = element( a );
        a = a.elem;
    end
    begin
        cf = @ring.coFac;
        if cf.getClass().getSimpleName() == "GenPolynomialRing"
            e = @factor.recursiveFactors( a );
        else
            e = @factor.factors( a );
        end
        ll = {};
        for a in e.keySet()
            i = e.get(a);
            ll[ RingElem.new( a ) ] = i;
        end
        return ll;
    rescue Exception => e
        puts "error " + str(e)
        return nil
    end
end
factorsAbsolute(a) click to toggle source

Compute absolute irreducible factorization for (modular,) rational number coefficients.

# File examples/jas.rb, line 1776
    def factorsAbsolute(a)
        if a.is_a? RingElem
            a = a.elem;
        else
            a = element( a );
            a = a.elem;
        end
        begin
            ll = @factor.factorsAbsolute( a );
##             ll = {};
##             for a in e.keySet()
##                 i = e.get(a);
##                 ll[ RingElem.new( a ) ] = i;
            return ll;
        rescue Exception => e
            puts "error in factorsAbsolute " + str(e)
            return nil
        end
    end
gcd(a,b) click to toggle source

Compute the greatest common divisor of a and b.

# File examples/jas.rb, line 1702
def gcd(a,b)
    if a.is_a? RingElem
        a = a.elem;
    else
        a = element( a );
        a = a.elem;
    end
    if b.is_a? RingElem
        b = b.elem;
    else
        b = element( b );
        b = b.elem;
    end
    return RingElem.new( @engine.gcd(a,b) );
end
gens() click to toggle source

Get list of generators of the polynomial ring.

# File examples/jas.rb, line 1647
def gens()
    ll = @ring.generators();
    n = ll.map{ |e| RingElem.new(e) };
    return n;
end
ideal(ringstr="",list=nil) click to toggle source

Create an ideal.

# File examples/jas.rb, line 1625
def ideal(ringstr="",list=nil)
    return JAS::SimIdeal.new(self,ringstr,list);
end
inject_variables() click to toggle source

Inject variables for generators in top level environment.

# File examples/jas.rb, line 1593
def inject_variables() 
    begin 
       require "irb/frame" # must be placed here
       bin = IRB::Frame.bottom(0);
       env = eval "self", bin;
       #puts "env = " + str(env)
       inject_gens(env)
    rescue Exception => e
       puts "error: 'irb/frame' not found, e = " + str(e);
    end
end
integrate(a) click to toggle source

Integrate rational function or power series.

# File examples/jas.rb, line 1819
def integrate(a)
    if not a.is_a? RingElem
        a = RingElem.new(a);
    end
    return a.integrate();
end
one() click to toggle source

Get the one of the polynomial ring.

# File examples/jas.rb, line 1656
def one()
    return RingElem.new( @ring.getONE() );
end
paramideal(ringstr="",list=nil,gbsys=nil) click to toggle source

Create an ideal in a polynomial ring with parameter coefficients.

# File examples/jas.rb, line 1632
def paramideal(ringstr="",list=nil,gbsys=nil)
    return ParamIdeal.new(self,ringstr,list,gbsys);
end
powerseriesRing() click to toggle source

Get a power series ring from this ring.

# File examples/jas.rb, line 1639
def powerseriesRing()
    pr = MultiVarPowerSeriesRing.new(@ring);
    return MultiSeriesRing.new("",nil,pr);
end
random(k=5,l=7,d=3,q=0.3) click to toggle source

Get a random polynomial.

# File examples/jas.rb, line 1670
def random(k=5,l=7,d=3,q=0.3)
    r = @ring.random(k,l,d,q);
    if @ring.coFac.isField()
        r = r.monic();
    end
    return RingElem.new( r );
end
realRoots(a,eps=nil) click to toggle source

Compute real roots of univariate polynomial.

# File examples/jas.rb, line 1799
def realRoots(a,eps=nil)
    if not a.is_a? RingElem
        a = RingElem.new(a);
    end
    return a.realRoots(eps);
end
squarefreeFactors(a) click to toggle source

Compute squarefree factors of polynomial.

# File examples/jas.rb, line 1721
def squarefreeFactors(a)
    if a.is_a? RingElem
        a = a.elem;
    else
        a = element( a );
        a = a.elem;
    end
    cf = @ring.coFac;
    if cf.getClass().getSimpleName() == "GenPolynomialRing"
        e = @sqf.recursiveSquarefreeFactors( a );
    else
        e = @sqf.squarefreeFactors( a );
    end
    ll = {};
    for a in e.keySet()
        i = e.get(a);
        ll[ RingElem.new( a ) ] = i;
    end
    return ll;
end
to_s() click to toggle source

Create a string representation.

# File examples/jas.rb, line 1608
def to_s()
    return @ring.toScript();
end
variable_generators() click to toggle source

Define instance variables for generators.

# File examples/jas.rb, line 1568
def variable_generators() 
   Ring.instance_eval( "attr_accessor :generators;" )
   @generators = {};
   for i in self.gens()
      begin 
         ivs = nameFromValue(i);
         if ivs != nil
            #puts "string: #{ivs} = " + ivs.class.to_s;
            if @generators[ ivs ] != nil
               puts "redefining local variable #{ivs}";
            end
            @generators[ ivs ] = i;
            self.instance_eval( "def #{ivs}; @generators[ '#{ivs}' ]; end" )
         end
      rescue Exception => e
         puts "ring error: #{ivs} = " + i.to_s + ", e = " + str(e);
         #pass
      end
   end
puts "locally defined generators: " + @generators.keys().join(", ");  
end
zero() click to toggle source

Get the zero of the polynomial ring.

# File examples/jas.rb, line 1663
def zero()
    return RingElem.new( @ring.getZERO() );
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.