Class JAS::SimIdeal
In: examples/jas.rb
Parent: Object

Represents a JAS polynomial ideal: PolynomialList and Ideal.

Methods for Groebner bases, ideal sum, intersection and others.

Methods

Attributes

list  [R] 
primary  [R] 
prime  [R] 
pset  [R] 
ring  [R] 
roots  [R] 

Public Class methods

SimIdeal constructor.

[Source]

      # File examples/jas.rb, line 1747
1747:     def initialize(ring,polystr="",list=nil)
1748:         @ring = ring;
1749:         if list == nil
1750:            sr = StringReader.new( polystr );
1751:            tok = GenPolynomialTokenizer.new(ring::ring,sr);
1752:            @list = tok.nextPolynomialList();
1753:         else
1754:            @list = rbarray2arraylist(list,rec=1);
1755:         end
1756:         @pset = OrderedPolynomialList.new(@ring.ring,@list);
1757:         @roots = nil;
1758:         @croots = nil;
1759:         @prime = nil;
1760:         @primary = nil;
1761:         #super(@ring::ring,@list) # non-sense, JRuby extends edu.jas.application.Ideal without beeing told
1762:     end

Public Instance methods

Compare two ideals.

[Source]

      # File examples/jas.rb, line 1774
1774:     def <=>(other)
1775:         s,o = self, other
1776:         return s.pset.compareTo( o.pset ); 
1777:     end

Compare two ideals.

[Source]

      # File examples/jas.rb, line 1782
1782:     def ===(other)
1783:         return (self <=> other) == 0; 
1784:     end

Compute a Characteristic Set.

[Source]

      # File examples/jas.rb, line 2221
2221:     def CS()
2222:         s = @pset;
2223:         cofac = s.ring.coFac;
2224:         ff = s.list;
2225:         t = System.currentTimeMillis();
2226:         if cofac.isField()
2227:             gg = CharacteristicSetWu.new().characteristicSet(ff);
2228:         else
2229:             puts "CS not implemented for coefficients #{cofac.toScriptFactory()}\n"; 
2230:             gg = nil;
2231:         end
2232:         t = System.currentTimeMillis() - t;
2233:         puts "sequential char set executed in #{t} ms\n"; 
2234:         return SimIdeal.new(@ring,"",gg);
2235:     end

Compute a Groebner base.

[Source]

      # File examples/jas.rb, line 1796
1796:     def GB()
1797:         s = @pset;
1798:         cofac = s.ring.coFac;
1799:         ff = s.list;
1800:         t = System.currentTimeMillis();
1801:         if cofac.isField()
1802:             #gg = GroebnerBaseSeq.new().GB(ff);
1803:             #gg = GroebnerBaseSeq.new(ReductionSeq.new(),OrderedPairlist.new()).GB(ff);
1804:             gg = GroebnerBaseSeq.new(ReductionSeq.new(),OrderedSyzPairlist.new()).GB(ff);
1805:         else
1806:             v = nil;
1807:             begin
1808:                 v = cofac.vars;
1809:             rescue
1810:                 #pass
1811:             end
1812:             if v == nil
1813:                 gg = GroebnerBasePseudoSeq.new(cofac).GB(ff);
1814:             else
1815:                 gg = GroebnerBasePseudoRecSeq.new(cofac).GB(ff);
1816:             end
1817:         end
1818:         t = System.currentTimeMillis() - t;
1819:         puts "sequential GB executed in #{t} ms\n"; 
1820:         return SimIdeal.new(@ring,"",gg);
1821:     end

Compute a normal form of this ideal with respect to reducer.

[Source]

      # File examples/jas.rb, line 2019
2019:     def NF(reducer)
2020:         s = @pset;
2021:         ff = s.list;
2022:         gg = reducer.list;
2023:         t = System.currentTimeMillis();
2024:         nn = ReductionSeq.new().normalform(gg,ff);
2025:         t = System.currentTimeMillis() - t;
2026:         puts "sequential NF executed in #{t} ms\n"; 
2027:         return SimIdeal.new(@ring,"",nn);
2028:     end

Compute complex roots of 0-dim ideal.

[Source]

      # File examples/jas.rb, line 2144
2144:     def complexRoots()
2145:         ii = Ideal.new(@pset);
2146:         @croots = PolyUtilApp.complexAlgebraicRoots(ii);
2147:         for r in @croots
2148:             r.doDecimalApproximation();
2149:         end
2150:         return @croots;
2151:     end

Print decimal approximation of complex roots of 0-dim ideal.

[Source]

      # File examples/jas.rb, line 2156
2156:     def complexRootsPrint()
2157:         if @croots == nil
2158:             ii = Ideal.new(@pset);
2159:             @croots = PolyUtilApp.complexAlgebraicRoots(ii);
2160:             for r in @croots
2161:                 r.doDecimalApproximation();
2162:             end
2163:         end
2164:         for ic in @croots
2165:             for dc in ic.decimalApproximation()
2166:                 puts dc.to_s;
2167:             end
2168:             puts;
2169:         end
2170:     end

Compute a normal form of polynomial p with respect this characteristic set.

[Source]

      # File examples/jas.rb, line 2260
2260:     def csReduction(p)
2261:         s = @pset;
2262:         ff = s.list.clone();
2263:         Collections.reverse(ff); # todo
2264:         if p.is_a? RingElem
2265:             p = p.elem;
2266:         end
2267:         t = System.currentTimeMillis();
2268:         nn = CharacteristicSetWu.new().characteristicSetReduction(ff,p);
2269:         t = System.currentTimeMillis() - t;
2270:         #puts "sequential char set reduction executed in #{t} ms\n"; 
2271:         return RingElem.new(nn);
2272:     end

Compute an d-Groebner base.

[Source]

      # File examples/jas.rb, line 1890
1890:     def dGB()
1891:         s = @pset;
1892:         cofac = s.ring.coFac;
1893:         ff = s.list;
1894:         t = System.currentTimeMillis();
1895:         if cofac.isField()
1896:             gg = GroebnerBaseSeq.new().GB(ff);
1897:         else
1898:             gg = DGroebnerBaseSeq.new().GB(ff)
1899:         end
1900:         t = System.currentTimeMillis() - t;
1901:         puts "sequential d-GB executed in #{t} ms\n"; 
1902:         return SimIdeal.new(@ring,"",gg);
1903:     end

Compute irreducible decomposition of this ideal.

[Source]

      # File examples/jas.rb, line 2135
2135:     def decomposition()
2136:         ii = Ideal.new(@pset);
2137:         @irrdec = ii.decomposition();
2138:         return @irrdec;
2139:     end

Client for a distributed computation.

[Source]

      # File examples/jas.rb, line 1975
1975:     def distClient(port=4711)
1976:         s = @pset;
1977:         es = ExecutableServer.new( port );
1978:         es.init();
1979:         es = ExecutableServer.new( port+1 );
1980:         es.init();
1981:         return nil;
1982:     end

Compute on a distributed system a Groebner base.

[Source]

      # File examples/jas.rb, line 1956
1956:     def distGB(th=2,machine="examples/machines.localhost",port=55711)
1957:         s = @pset;
1958:         ff = s.list;
1959:         t = System.currentTimeMillis();
1960:         # old: gbd = GBDist.new(th,machine,port);
1961:         gbd = GroebnerBaseDistributedEC.new(machine,th,port);
1962:         #gbd = GroebnerBaseDistributedHybridEC.new(machine,th,3,port);
1963:         t1 = System.currentTimeMillis();
1964:         gg = gbd.GB(ff);
1965:         t1 = System.currentTimeMillis() - t1;
1966:         gbd.terminate(false);
1967:         t = System.currentTimeMillis() - t;
1968:         puts "distributed #{th} executed in #{t1} ms (#{t-t1} ms start-up)\n"; 
1969:         return SimIdeal.new(@ring,"",gg);
1970:     end

Compute an e-Groebner base.

[Source]

      # File examples/jas.rb, line 1854
1854:     def eGB()
1855:         s = @pset;
1856:         cofac = s.ring.coFac;
1857:         ff = s.list;
1858:         t = System.currentTimeMillis();
1859:         if cofac.isField()
1860:             gg = GroebnerBaseSeq.new().GB(ff);
1861:         else
1862:             gg = EGroebnerBaseSeq.new().GB(ff)
1863:         end
1864:         t = System.currentTimeMillis() - t;
1865:         puts "sequential e-GB executed in #{t} ms\n"; 
1866:         return SimIdeal.new(@ring,"",gg);
1867:     end

Compute a e-normal form of p with respect to this ideal.

[Source]

      # File examples/jas.rb, line 2003
2003:     def eReduction(p)
2004:         s = @pset;
2005:         gg = s.list;
2006:         if p.is_a? RingElem
2007:             p = p.elem;
2008:         end
2009:         t = System.currentTimeMillis();
2010:         n = EReductionSeq.new().normalform(gg,p);
2011:         t = System.currentTimeMillis() - t;
2012:         puts "sequential eReduction executed in " + str(t) + " ms"; 
2013:         return RingElem.new(n);
2014:     end

Compute the elimination ideal of this and the given polynomial ring.

[Source]

      # File examples/jas.rb, line 2053
2053:     def eliminateRing(ring)
2054:         s = Ideal.new(@pset);
2055:         nn = s.eliminate(ring.ring);
2056:         r = Ring.new( "", nn.getRing() );
2057:         return SimIdeal.new(r,"",nn.getList());
2058:     end

Compute the intersection of this and the given ideal.

[Source]

      # File examples/jas.rb, line 2043
2043:     def intersect(id2)
2044:         s1 = Ideal.new(@pset);
2045:         s2 = Ideal.new(id2.pset);
2046:         nn = s1.intersect(s2);
2047:         return SimIdeal.new(@ring,"",nn.getList());
2048:     end

Compute the intersection of this and the given polynomial ring.

[Source]

      # File examples/jas.rb, line 2034
2034:     def intersectRing(ring)
2035:         s = Ideal.new(@pset);
2036:         nn = s.intersect(ring.ring);
2037:         return SimIdeal.new(ring,"",nn.getList());
2038:     end

Test for Characteristic Set.

[Source]

      # File examples/jas.rb, line 2240
2240:     def isCS()
2241:         s = @pset;
2242:         cofac = s.ring.coFac;
2243:         ff = s.list.clone();
2244:         Collections.reverse(ff); # todo
2245:         t = System.currentTimeMillis();
2246:         if cofac.isField()
2247:             b = CharacteristicSetWu.new().isCharacteristicSet(ff);
2248:         else
2249:             puts "isCS not implemented for coefficients #{cofac.toScriptFactory()}\n"; 
2250:             b = false;
2251:         end
2252:         t = System.currentTimeMillis() - t;
2253:         #puts "sequential is char set executed in #{t} ms\n"; 
2254:         return b;
2255:     end

Test if this is a Groebner base.

[Source]

      # File examples/jas.rb, line 1826
1826:     def isGB()
1827:         s = @pset;
1828:         cofac = s.ring.coFac;
1829:         ff = s.list;
1830:         t = System.currentTimeMillis();
1831:         if cofac.isField()
1832:             b = GroebnerBaseSeq.new().isGB(ff);
1833:         else
1834:             v = nil;
1835:             begin
1836:                 v = cofac.vars;
1837:             rescue
1838:                 #pass
1839:             end
1840:             if v == nil
1841:                 b = GroebnerBasePseudoSeq.new(cofac).isGB(ff);
1842:             else
1843:                 b = GroebnerBasePseudoRecSeq.new(cofac).isGB(ff);
1844:             end
1845:         end
1846:         t = System.currentTimeMillis() - t;
1847:         puts "isGB executed in #{t} ms\n"; 
1848:         return b;
1849:     end

Test if this is a d-Groebner base.

[Source]

      # File examples/jas.rb, line 1908
1908:     def isdGB()
1909:         s = @pset;
1910:         cofac = s.ring.coFac;
1911:         ff = s.list;
1912:         t = System.currentTimeMillis();
1913:         if cofac.isField()
1914:             b = GroebnerBaseSeq.new().isGB(ff);
1915:         else
1916:             b = DGroebnerBaseSeq.new().isGB(ff)
1917:         end
1918:         t = System.currentTimeMillis() - t;
1919:         puts "is d-GB test executed in #{t} ms\n"; 
1920:         return b;
1921:     end

Test if this is an e-Groebner base.

[Source]

      # File examples/jas.rb, line 1872
1872:     def iseGB()
1873:         s = @pset;
1874:         cofac = s.ring.coFac;
1875:         ff = s.list;
1876:         t = System.currentTimeMillis();
1877:         if cofac.isField()
1878:             b = GroebnerBaseSeq.new().isGB(ff);
1879:         else
1880:             b = EGroebnerBaseSeq.new().isGB(ff)
1881:         end
1882:         t = System.currentTimeMillis() - t;
1883:         puts "is e-GB test executed in #{t} ms\n"; 
1884:         return b;
1885:     end

Optimize the term order on the variables.

[Source]

      # File examples/jas.rb, line 2085
2085:     def optimize()
2086:         p = @pset;
2087:         o = TermOrderOptimization.optimizeTermOrder(p);
2088:         r = Ring.new("",o.ring);
2089:         return SimIdeal.new(r,"",o.list);
2090:     end

Compute in parallel a Groebner base.

[Source]

      # File examples/jas.rb, line 1941
1941:     def parGB(th)
1942:         s = @pset;
1943:         ff = s.list;
1944:         bbpar = GroebnerBaseParallel.new(th);
1945:         t = System.currentTimeMillis();
1946:         gg = bbpar.GB(ff);
1947:         t = System.currentTimeMillis() - t;
1948:         bbpar.terminate();
1949:         puts "parallel #{th} executed in #{t} ms\n"; 
1950:         return SimIdeal.new(@ring,"",gg);
1951:     end

Compute in parallel a Groebner base.

[Source]

      # File examples/jas.rb, line 1926
1926:     def parUnusedGB(th)
1927:         s = @pset;
1928:         ff = s.list;
1929:         bbpar = GroebnerBaseSeqPairParallel.new(th);
1930:         t = System.currentTimeMillis();
1931:         gg = bbpar.GB(ff);
1932:         t = System.currentTimeMillis() - t;
1933:         bbpar.terminate();
1934:         puts "parallel-old #{th} executed in #{t} ms\n"; 
1935:         return SimIdeal.new(@ring,"",gg);
1936:     end

Create an ideal in a polynomial ring with parameter coefficients.

[Source]

      # File examples/jas.rb, line 1789
1789:     def paramideal()
1790:         return ParamIdeal.new(@ring,"",@list);
1791:     end

Compute primary decomposition of this ideal.

[Source]

      # File examples/jas.rb, line 2184
2184:     def primaryDecomp()
2185:         ii = Ideal.new(@pset);
2186: ##         if @prime == nil:
2187: ##             @prime = I.primeDecomposition();
2188:         @primary = ii.primaryDecomposition();
2189:         return @primary;
2190:     end

Compute prime decomposition of this ideal.

[Source]

      # File examples/jas.rb, line 2175
2175:     def primeDecomp()
2176:         ii = Ideal.new(@pset);
2177:         @prime = ii.primeDecomposition();
2178:         return @prime;
2179:     end

Compute radical decomposition of this ideal.

[Source]

      # File examples/jas.rb, line 2126
2126:     def radicalDecomp()
2127:         ii = Ideal.new(@pset);
2128:         @radical = ii.radicalDecomposition();
2129:         return @radical;
2130:     end

Compute real roots of 0-dim ideal.

[Source]

      # File examples/jas.rb, line 2095
2095:     def realRoots()
2096:         ii = Ideal.new(@pset);
2097:         @roots = PolyUtilApp.realAlgebraicRoots(ii);
2098:         for r in @roots
2099:             r.doDecimalApproximation();
2100:         end
2101:         return @roots;
2102:     end

Print decimal approximation of real roots of 0-dim ideal.

[Source]

      # File examples/jas.rb, line 2107
2107:     def realRootsPrint()
2108:         if @roots == nil
2109:             ii = Ideal.new(@pset);
2110:             @roots = PolyUtilApp.realAlgebraicRoots(ii);
2111:             for r in @roots
2112:                 r.doDecimalApproximation();
2113:             end
2114:         end
2115:         for ir in @roots
2116:             for dr in ir.decimalApproximation()
2117:                 puts dr.to_s;
2118:             end
2119:             puts;
2120:         end
2121:     end

Compute a normal form of p with respect to this ideal.

[Source]

      # File examples/jas.rb, line 1987
1987:     def reduction(p)
1988:         s = @pset;
1989:         gg = s.list;
1990:         if p.is_a? RingElem
1991:             p = p.elem;
1992:         end
1993:         t = System.currentTimeMillis();
1994:         n = ReductionSeq.new().normalform(gg,p);
1995:         t = System.currentTimeMillis() - t;
1996:         puts "sequential reduction executed in " + str(t) + " ms"; 
1997:         return RingElem.new(n);
1998:     end

Compute the saturation of this and the given ideal.

[Source]

      # File examples/jas.rb, line 2063
2063:     def sat(id2)
2064:         s1 = Ideal.new(@pset);
2065:         s2 = Ideal.new(id2.pset);
2066:         #nn = s1.infiniteQuotient(s2);
2067:         nn = s1.infiniteQuotientRab(s2);
2068:         mm = nn.getList(); #PolyUtil.monicRec(nn.getList());
2069:         return SimIdeal.new(@ring,"",mm);
2070:     end

Compute the sum of this and the ideal.

[Source]

      # File examples/jas.rb, line 2075
2075:     def sum(other)
2076:         s = Ideal.new(@pset);
2077:         t = Ideal.new(other.pset);
2078:         nn = s.sum( t );
2079:         return SimIdeal.new(@ring,"",nn.getList());
2080:     end

Convert rational coefficients to integer coefficients.

[Source]

      # File examples/jas.rb, line 2195
2195:     def toInteger()
2196:         p = @pset;
2197:         l = p.list;
2198:         r = p.ring;
2199:         ri = GenPolynomialRing.new( BigInteger.new(), r.nvar, r.tord, r.vars );
2200:         pi = PolyUtil.integerFromRationalCoefficients(ri,l);
2201:         r = Ring.new("",ri);
2202:         return SimIdeal.new(r,"",pi);
2203:     end

Convert integer coefficients to modular coefficients.

[Source]

      # File examples/jas.rb, line 2208
2208:     def toModular(mf)
2209:         p = @pset;
2210:         l = p.list;
2211:         r = p.ring;
2212:         rm = GenPolynomialRing.new( mf, r.nvar, r.tord, r.vars );
2213:         pm = PolyUtil.fromIntegerCoefficients(rm,l);
2214:         r = Ring.new("",rm);
2215:         return SimIdeal.new(r,"",pm);
2216:     end

Create a string representation.

[Source]

      # File examples/jas.rb, line 1767
1767:     def to_s()
1768:         return @pset.toScript();
1769:     end

[Validate]