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