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