001/* 002 * $Id$ 003 */ 004 005package edu.jas.gbufd; 006 007 008import java.util.ArrayList; 009import java.util.List; 010 011import edu.jas.arith.BigInteger; 012import edu.jas.gb.SolvableGroebnerBaseAbstract; 013import edu.jas.kern.ComputerThreads; 014import edu.jas.poly.GenSolvablePolynomial; 015import edu.jas.poly.GenSolvablePolynomialRing; 016import edu.jas.poly.PolynomialList; 017import edu.jas.poly.RelationGenerator; 018import edu.jas.poly.RelationTable; 019import edu.jas.poly.TermOrder; 020import edu.jas.poly.WeylRelations; 021 022import junit.framework.Test; 023import junit.framework.TestCase; 024import junit.framework.TestSuite; 025 026 027/** 028 * Solvable Groebner base pseudo sequential tests with JUnit. 029 * @author Heinz Kredel 030 */ 031 032public class SolvableGroebnerBasePseudoSeqTest extends TestCase { 033 034 035 /** 036 * main. 037 */ 038 public static void main(String[] args) { 039 junit.textui.TestRunner.run(suite()); 040 ComputerThreads.terminate(); 041 } 042 043 044 /** 045 * Constructs a <CODE>SolvableGroebnerBasePseudoSeqTest</CODE> object. 046 * @param name String. 047 */ 048 public SolvableGroebnerBasePseudoSeqTest(String name) { 049 super(name); 050 } 051 052 053 /** 054 * suite. 055 */ 056 public static Test suite() { 057 TestSuite suite = new TestSuite(SolvableGroebnerBasePseudoSeqTest.class); 058 return suite; 059 } 060 061 062 GenSolvablePolynomial<BigInteger> a, b, c, d, e; 063 064 065 List<GenSolvablePolynomial<BigInteger>> L; 066 067 068 PolynomialList<BigInteger> F, G; 069 070 071 GenSolvablePolynomialRing<BigInteger> ring; 072 073 074 SolvableGroebnerBaseAbstract<BigInteger> sbb; 075 076 077 BigInteger cfac; 078 079 080 TermOrder tord; 081 082 083 RelationTable<BigInteger> table; 084 085 086 int rl = 4; //4; //3; 087 088 089 int kl = 2; 090 091 092 int ll = 3; 093 094 095 int el = 3; 096 097 098 float q = 0.2f; //0.4f 099 100 101 @Override 102 protected void setUp() { 103 cfac = new BigInteger(9); 104 tord = new TermOrder(); 105 String[] vars = new String[] { "w", "x", "y", "z" }; 106 ring = new GenSolvablePolynomialRing<BigInteger>(cfac, tord, vars); 107 table = ring.table; 108 a = b = c = d = e = null; 109 sbb = new SolvableGroebnerBasePseudoSeq<BigInteger>(cfac); 110 111 a = ring.random(kl, ll, el, q); 112 b = ring.random(kl, ll, el, q); 113 c = ring.random(kl, ll, el, q); 114 d = ring.random(kl, ll, el, q); 115 e = d; //ring.random(kl, ll, el, q ); 116 } 117 118 119 @Override 120 protected void tearDown() { 121 a = b = c = d = e = null; 122 ring = null; 123 tord = null; 124 table = null; 125 cfac = null; 126 sbb = null; 127 } 128 129 130 /** 131 * Test sequential GBase. 132 */ 133 public void testSequentialGBase() { 134 L = new ArrayList<GenSolvablePolynomial<BigInteger>>(); 135 136 L.add(a); 137 L = sbb.leftGB(L); 138 assertTrue("isLeftGB( { a } )", sbb.isLeftGB(L)); 139 140 L.add(b); 141 //System.out.println("L = " + L.size() ); 142 L = sbb.leftGB(L); 143 assertTrue("isLeftGB( { a, b } )", sbb.isLeftGB(L)); 144 145 L.add(c); 146 L = sbb.leftGB(L); 147 assertTrue("isLeftGB( { a, b, c } )", sbb.isLeftGB(L)); 148 149 L.add(d); 150 L = sbb.leftGB(L); 151 assertTrue("isLeftGB( { a, b, c, d } )", sbb.isLeftGB(L)); 152 153 L.add(e); 154 L = sbb.leftGB(L); 155 assertTrue("isLeftGB( { a, b, c, d, e } )", sbb.isLeftGB(L)); 156 } 157 158 159 /** 160 * Test Weyl sequential GBase. 161 */ 162 public void testWeylSequentialGBase() { 163 //int rloc = 4; 164 //ring = new GenSolvablePolynomialRing<BigInteger>(cfac,rloc); 165 166 RelationGenerator<BigInteger> wl = new WeylRelations<BigInteger>(); 167 wl.generate(ring); 168 table = ring.table; 169 170 a = ring.random(kl, ll, el, q); 171 b = ring.random(kl, ll, el, q); 172 c = ring.random(kl, ll, el, q); 173 d = ring.random(kl, ll, el, q); 174 e = d; //ring.random(kl, ll, el, q ); 175 176 L = new ArrayList<GenSolvablePolynomial<BigInteger>>(); 177 178 L.add(a); 179 L = sbb.leftGB(L); 180 assertTrue("isLeftGB( { a } )", sbb.isLeftGB(L)); 181 182 L.add(b); 183 //System.out.println("L = " + L.size() ); 184 L = sbb.leftGB(L); 185 assertTrue("isLeftGB( { a, b } )", sbb.isLeftGB(L)); 186 187 L.add(c); 188 L = sbb.leftGB(L); 189 assertTrue("isLeftGB( { a, b, c } )", sbb.isLeftGB(L)); 190 191 L.add(d); 192 L = sbb.leftGB(L); 193 assertTrue("isLeftGB( { a, b, c, d } )", sbb.isLeftGB(L)); 194 195 L.add(e); 196 L = sbb.leftGB(L); 197 assertTrue("isLeftGB( { a, b, c, d, e } )", sbb.isLeftGB(L)); 198 } 199 200 201 /** 202 * Test sequential twosided GBase. 203 */ 204 public void testSequentialTSGBase() { 205 L = new ArrayList<GenSolvablePolynomial<BigInteger>>(); 206 207 L.add(a); 208 L = sbb.twosidedGB(L); 209 //System.out.println("L = " + L.size() ); 210 assertTrue("isTwosidedGB( { a } )", sbb.isTwosidedGB(L)); 211 212 L.add(b); 213 L = sbb.twosidedGB(L); 214 //System.out.println("L = " + L.size() ); 215 assertTrue("isTwosidedGB( { a, b } )", sbb.isTwosidedGB(L)); 216 217 L.add(c); 218 L = sbb.twosidedGB(L); 219 //System.out.println("L = " + L.size() ); 220 assertTrue("isTwosidedGB( { a, b, c } )", sbb.isTwosidedGB(L)); 221 222 L.add(d); 223 L = sbb.twosidedGB(L); 224 //System.out.println("L = " + L.size() ); 225 assertTrue("isTwosidedGB( { a, b, c, d } )", sbb.isTwosidedGB(L)); 226 227 L.add(e); 228 L = sbb.twosidedGB(L); 229 //System.out.println("L = " + L.size() ); 230 assertTrue("isTwosidedGB( { a, b, c, d, e } )", sbb.isTwosidedGB(L)); 231 } 232 233 234 /** 235 * Test Weyl sequential twosided GBase is always 1. 236 */ 237 public void testWeylSequentialTSGBase() { 238 //int rloc = 4; 239 //ring = new GenSolvablePolynomialRing<BigInteger>(cfac,rloc); 240 241 RelationGenerator<BigInteger> wl = new WeylRelations<BigInteger>(); 242 wl.generate(ring); 243 table = ring.table; 244 245 a = ring.random(kl, ll, el, q); 246 b = ring.random(kl, ll, el, q); 247 c = ring.random(kl, ll, el, q); 248 d = ring.random(kl, ll, el, q); 249 e = d; //ring.random(kl, ll, el, q ); 250 251 L = new ArrayList<GenSolvablePolynomial<BigInteger>>(); 252 253 L.add(a); 254 //System.out.println("La = " + L ); 255 L = sbb.twosidedGB(L); 256 //System.out.println("L = " + L ); 257 assertTrue("isTwosidedGB( { a } )", sbb.isTwosidedGB(L)); 258 259 L.add(b); 260 L = sbb.twosidedGB(L); 261 //System.out.println("L = " + L ); 262 assertTrue("isTwosidedGB( { a, b } )", sbb.isTwosidedGB(L)); 263 264 L.add(c); 265 L = sbb.twosidedGB(L); 266 //System.out.println("L = " + L ); 267 assertTrue("isTwosidedGB( { a, b, c } )", sbb.isTwosidedGB(L)); 268 269 L.add(d); 270 L = sbb.twosidedGB(L); 271 //System.out.println("L = " + L ); 272 assertTrue("isTwosidedGB( { a, b, c, d } )", sbb.isTwosidedGB(L)); 273 274 L.add(e); 275 L = sbb.twosidedGB(L); 276 //System.out.println("L = " + L ); 277 assertTrue("isTwosidedGB( { a, b, c, d, e } )", sbb.isTwosidedGB(L)); 278 } 279 280 281 /* 282 * Test sequential extended GBase. 283 public void testSequentialExtendedGBase() { 284 L = new ArrayList<GenSolvablePolynomial<BigInteger>>(); 285 286 SolvableExtendedGB<BigInteger> exgb; 287 288 L.add(a); 289 //System.out.println("L = " + L ); 290 291 exgb = sbb.extLeftGB( L ); 292 //System.out.println("exgb = " + exgb ); 293 assertTrue("isLeftGB( { a } )", sbb.isLeftGB(exgb.G) ); 294 assertTrue("isLeftRmat( { a } )", sbb.isLeftReductionMatrix(exgb) ); 295 296 L.add(b); 297 //System.out.println("L = " + L ); 298 exgb = sbb.extLeftGB( L ); 299 //System.out.println("exgb = " + exgb ); 300 assertTrue("isLeftGB( { a, b } )", sbb.isLeftGB(exgb.G) ); 301 assertTrue("isLeftRmat( { a, b } )", sbb.isLeftReductionMatrix(exgb) ); 302 303 L.add(c); 304 exgb = sbb.extLeftGB( L ); 305 //System.out.println("exgb = " + exgb ); 306 assertTrue("isLeftGB( { a, b, c } )", sbb.isLeftGB(exgb.G) ); 307 assertTrue("isLeftRmat( { a, b, c } )", sbb.isLeftReductionMatrix(exgb) ); 308 309 L.add(d); 310 exgb = sbb.extLeftGB( L ); 311 //System.out.println("exgb = " + exgb ); 312 assertTrue("isLeftGB( { a, b, c, d } )", sbb.isLeftGB(exgb.G) ); 313 assertTrue("isLeftRmat( { a, b, c, d } )", sbb.isLeftReductionMatrix(exgb) ); 314 315 L.add(e); 316 exgb = sbb.extLeftGB( L ); 317 //System.out.println("exgb = " + exgb ); 318 assertTrue("isLeftGB( { a, b, c, d, e } )", sbb.isLeftGB(exgb.G) ); 319 assertTrue("isLeftRmat( { a, b, c, d, e } )", sbb.isLeftReductionMatrix(exgb) ); 320 } 321 */ 322 323 324 /* 325 * Test Weyl sequential extended GBase. 326 public void testWeylSequentialExtendedGBase() { 327 //int rloc = 4; 328 //ring = new GenSolvablePolynomialRing<BigInteger>(cfac,rloc); 329 330 RelationGenerator<BigInteger> wl = new WeylRelations<BigInteger>(); 331 wl.generate(ring); 332 table = ring.table; 333 334 a = ring.random(kl, ll, el, q ); 335 b = ring.random(kl, ll, el, q ); 336 c = ring.random(kl, ll, el, q ); 337 d = ring.random(kl, ll, el, q ); 338 e = d; //ring.random(kl, ll, el, q ); 339 340 SolvableExtendedGB<BigInteger> exgb; 341 342 L = new ArrayList<GenSolvablePolynomial<BigInteger>>(); 343 344 L.add(a); 345 exgb = sbb.extLeftGB( L ); 346 // System.out.println("exgb = " + exgb ); 347 assertTrue("isLeftGB( { a } )", sbb.isLeftGB(exgb.G) ); 348 assertTrue("isRmat( { a } )", sbb.isLeftReductionMatrix(exgb) ); 349 350 L.add(b); 351 //System.out.println("L = " + L.size() ); 352 exgb = sbb.extLeftGB( L ); 353 //System.out.println("exgb = " + exgb ); 354 assertTrue("isLeftGB( { a, b } )", sbb.isLeftGB(exgb.G) ); 355 assertTrue("isRmat( { a, b } )", sbb.isLeftReductionMatrix(exgb) ); 356 357 L.add(c); 358 exgb = sbb.extLeftGB( L ); 359 //System.out.println("exgb = " + exgb ); 360 assertTrue("isLeftGB( { a, b, c } )", sbb.isLeftGB(exgb.G) ); 361 assertTrue("isRmat( { a, b, c } )", sbb.isLeftReductionMatrix(exgb) ); 362 363 L.add(d); 364 exgb = sbb.extLeftGB( L ); 365 //System.out.println("exgb = " + exgb ); 366 assertTrue("isLeftGB( { a, b, c, d } )", sbb.isLeftGB(exgb.G) ); 367 assertTrue("isRmat( { a, b, c, d } )", sbb.isLeftReductionMatrix(exgb) ); 368 369 L.add(e); 370 exgb = sbb.extLeftGB( L ); 371 //System.out.println("exgb = " + exgb ); 372 assertTrue("isLeftGB( { a, b, c, d, e } )", sbb.isLeftGB(exgb.G) ); 373 assertTrue("isRmat( { a, b, c, d, e } )", sbb.isLeftReductionMatrix(exgb) ); 374 } 375 */ 376 377}