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