001/* 002 * $Id$ 003 */ 004 005package edu.jas.gbufd; 006 007 008import java.io.IOException; 009import java.io.Reader; 010import java.io.StringReader; 011import java.util.ArrayList; 012import java.util.List; 013 014import junit.framework.Test; 015import junit.framework.TestCase; 016import junit.framework.TestSuite; 017 018 019import edu.jas.arith.BigRational; 020import edu.jas.arith.BigQuaternion; 021import edu.jas.arith.BigQuaternionRing; 022import edu.jas.gb.SolvableGroebnerBaseAbstract; 023import edu.jas.gb.SolvableGroebnerBase; 024import edu.jas.gb.SolvableGroebnerBaseSeq; 025import edu.jas.gbufd.SGBFactory; 026import edu.jas.gbufd.SolvableSyzygyAbstract; 027import edu.jas.gbufd.SolvableSyzygySeq; 028import edu.jas.poly.GenPolynomialTokenizer; 029import edu.jas.poly.GenSolvablePolynomial; 030import edu.jas.poly.GenSolvablePolynomialRing; 031import edu.jas.poly.ModuleList; 032import edu.jas.poly.PolynomialList; 033import edu.jas.poly.RelationGenerator; 034import edu.jas.poly.RelationTable; 035import edu.jas.poly.TermOrder; 036import edu.jas.poly.WeylRelations; 037import edu.jas.poly.WeylRelationsIterated; 038 039 040/** 041 * SolvableSyzygy tests with JUnit. 042 * @author Heinz Kredel 043 */ 044 045public class SolvableSyzygyTest extends TestCase { 046 047 048 /** 049 * main. 050 */ 051 public static void main(String[] args) { 052 junit.textui.TestRunner.run(suite()); 053 } 054 055 056 /** 057 * Constructs a <CODE>SolvableSyzygyTest</CODE> object. 058 * @param name String. 059 */ 060 public SolvableSyzygyTest(String name) { 061 super(name); 062 } 063 064 065 /** 066 */ 067 public static Test suite() { 068 TestSuite suite = new TestSuite(SolvableSyzygyTest.class); 069 return suite; 070 } 071 072 073 BigRational cfac; 074 075 076 GenSolvablePolynomialRing<BigRational> fac; 077 078 079 PolynomialList<BigRational> F; 080 081 082 List<GenSolvablePolynomial<BigRational>> G; 083 084 085 GenSolvablePolynomial<BigRational> a, b, c, d, e; 086 087 088 GenSolvablePolynomial<BigRational> zero, one; 089 090 091 TermOrder tord; 092 093 094 RelationTable table; 095 096 097 List<GenSolvablePolynomial<BigRational>> L; 098 099 100 List<List<GenSolvablePolynomial<BigRational>>> K; 101 102 103 List<GenSolvablePolynomial<BigRational>> V; 104 105 106 List<List<GenSolvablePolynomial<BigRational>>> W; 107 108 109 ModuleList<BigRational> M, N, Z; 110 111 112 SolvableGroebnerBaseAbstract<BigRational> sbb; 113 114 115 SolvableGroebnerBase<BigRational> msbb; 116 117 118 SolvableSyzygyAbstract<BigRational> ssz; 119 120 121 int rl = 4; //4; //3; 122 123 124 int kl = 3; 125 126 127 int ll = 7; 128 129 130 int el = 2; 131 132 133 float q = 0.3f; //0.4f 134 135 136 @Override 137 protected void setUp() { 138 cfac = new BigRational(1); 139 tord = new TermOrder(); 140 String[] vars = new String[]{ "w", "x", "y", "z" }; 141 fac = new GenSolvablePolynomialRing<BigRational>(cfac, tord, vars); 142 //RelationGenerator<BigRational> wl = new WeylRelations<BigRational>(); 143 //wl.generate(fac); 144 table = fac.table; 145 a = b = c = d = e = null; 146 L = null; 147 K = null; 148 V = null; 149 do { 150 a = fac.random(kl, ll, el, q); 151 } while (a.isZERO()); 152 do { 153 b = fac.random(kl, ll, el, q); 154 } while (b.isZERO()); 155 do { 156 c = fac.random(kl, ll, el, q); 157 } while (c.isZERO()); 158 do { 159 d = fac.random(kl, ll, el, q); 160 } while (d.isZERO()); 161 e = d; //fac.random(kl, ll, el, q ); 162 one = fac.getONE(); 163 zero = fac.getZERO(); 164 sbb = SGBFactory.getImplementation(cfac); 165 msbb = new SolvableGroebnerBaseSeq<BigRational>(); //cfac); 166 ssz = new SolvableSyzygySeq<BigRational>(cfac); 167 } 168 169 170 @Override 171 protected void tearDown() { 172 a = b = c = d = e = null; 173 L = null; 174 K = null; 175 V = null; 176 fac = null; 177 tord = null; 178 table = null; 179 sbb = null; 180 msbb = null; 181 ssz = null; 182 } 183 184 185 /** 186 * Test sequential SolvableSyzygy. 187 */ 188 public void testSequentialSolvableSyzygy() { 189 L = new ArrayList<GenSolvablePolynomial<BigRational>>(); 190 191 assertTrue("not isZERO( a )", !a.isZERO()); 192 L.add(a); 193 assertTrue("isGB( { a } )", sbb.isLeftGB(L)); 194 K = ssz.leftZeroRelations(L); 195 assertTrue("is ZR( { a } )", ssz.isLeftZeroRelation(K, L)); 196 197 assertTrue("not isZERO( b )", !b.isZERO()); 198 L.add(b); 199 L = sbb.leftGB(L); 200 assertTrue("isGB( { a, b } )", sbb.isLeftGB(L)); 201 //System.out.println("\nL = " + L ); 202 K = ssz.leftZeroRelations(L); 203 //System.out.println("\nK = " + K ); 204 assertTrue("is ZR( { a, b } )", ssz.isLeftZeroRelation(K, L)); 205 206 assertTrue("not isZERO( c )", !c.isZERO()); 207 L.add(c); 208 L = sbb.leftGB(L); 209 //System.out.println("\nL = " + L ); 210 assertTrue("isGB( { a, b, c } )", sbb.isLeftGB(L)); 211 K = ssz.leftZeroRelations(L); 212 //System.out.println("\nK = " + K ); 213 assertTrue("is ZR( { a, b, c } )", ssz.isLeftZeroRelation(K, L)); 214 215 assertTrue("not isZERO( d )", !d.isZERO()); 216 L.add(d); 217 L = sbb.leftGB(L); 218 //System.out.println("\nL = " + L ); 219 assertTrue("isGB( { a, b, c, d } )", sbb.isLeftGB(L)); 220 K = ssz.leftZeroRelations(L); 221 //System.out.println("\nK = " + K ); 222 assertTrue("is ZR( { a, b, c, d } )", ssz.isLeftZeroRelation(K, L)); 223 } 224 225 226 /** 227 * Test sequential Weyl SolvableSyzygy. 228 */ 229 public void testSequentialWeylSolvableSyzygy() { 230 int rloc = 4; 231 fac = new GenSolvablePolynomialRing<BigRational>(cfac, rloc); 232 233 RelationGenerator<BigRational> wl = new WeylRelations<BigRational>(); 234 wl.generate(fac); 235 table = fac.table; 236 237 a = fac.random(kl, ll, el, q); 238 b = fac.random(kl, ll, el, q); 239 c = fac.random(kl, ll, el, q); 240 d = fac.random(kl, ll, el, q); 241 e = d; //fac.random(kl, ll, el, q ); 242 243 L = new ArrayList<GenSolvablePolynomial<BigRational>>(); 244 245 assertTrue("not isZERO( a )", !a.isZERO()); 246 L.add(a); 247 assertTrue("isGB( { a } )", sbb.isLeftGB(L)); 248 K = ssz.leftZeroRelations(L); 249 assertTrue("is ZR( { a } )", ssz.isLeftZeroRelation(K, L)); 250 251 assertTrue("not isZERO( b )", !b.isZERO()); 252 L.add(b); 253 L = sbb.leftGB(L); 254 assertTrue("isGB( { a, b } )", sbb.isLeftGB(L)); 255 //System.out.println("\nL = " + L ); 256 K = ssz.leftZeroRelations(L); 257 //System.out.println("\nK = " + K ); 258 assertTrue("is ZR( { a, b } )", ssz.isLeftZeroRelation(K, L)); 259 260 // useless since 1 in GB 261 assertTrue("not isZERO( c )", !c.isZERO()); 262 L.add(c); 263 L = sbb.leftGB(L); 264 //System.out.println("\nL = " + L ); 265 assertTrue("isGB( { a, b, c } )", sbb.isLeftGB(L)); 266 K = ssz.leftZeroRelations(L); 267 //System.out.println("\nK = " + K ); 268 assertTrue("is ZR( { a, b, c } )", ssz.isLeftZeroRelation(K, L)); 269 270 // useless since 1 in GB 271 assertTrue("not isZERO( d )", !d.isZERO()); 272 L.add(d); 273 L = sbb.leftGB(L); 274 //System.out.println("\nL = " + L ); 275 assertTrue("isGB( { a, b, c, d } )", sbb.isLeftGB(L)); 276 K = ssz.leftZeroRelations(L); 277 //System.out.println("\nK = " + K ); 278 assertTrue("is ZR( { a, b, c, d } )", ssz.isLeftZeroRelation(K, L)); 279 } 280 281 282 /** 283 * Test sequential module SolvableSyzygy. 284 */ 285 public void testSequentialModSolvableSyzygy() { 286 W = new ArrayList<List<GenSolvablePolynomial<BigRational>>>(); 287 288 assertTrue("not isZERO( a )", !a.isZERO()); 289 V = new ArrayList<GenSolvablePolynomial<BigRational>>(); 290 V.add(a); 291 V.add(zero); 292 V.add(one); 293 W.add(V); 294 M = new ModuleList<BigRational>(fac, W); 295 assertTrue("isGB( { (a,0,1) } )", msbb.isLeftGB(M)); 296 297 N = msbb.leftGB(M); 298 assertTrue("isGB( { (a,0,1) } )", msbb.isLeftGB(N)); 299 300 Z = ssz.leftZeroRelations(N); 301 //System.out.println("Z = " + Z); 302 assertTrue("is ZR( { a) } )", ssz.isLeftZeroRelation(Z, N)); 303 304 assertTrue("not isZERO( b )", !b.isZERO()); 305 V = new ArrayList<GenSolvablePolynomial<BigRational>>(); 306 V.add(b); 307 V.add(one); 308 V.add(zero); 309 W.add(V); 310 M = new ModuleList<BigRational>(fac, W); 311 //System.out.println("W = " + W.size() ); 312 313 N = msbb.leftGB(M); 314 assertTrue("isGB( { a, b } )", msbb.isLeftGB(N)); 315 316 Z = ssz.leftZeroRelations(N); 317 //System.out.println("Z = " + Z); 318 assertTrue("is ZR( { a, b } )", ssz.isLeftZeroRelation(Z, N)); 319 320 assertTrue("not isZERO( c )", !c.isZERO()); 321 V = new ArrayList<GenSolvablePolynomial<BigRational>>(); 322 V.add(c); 323 V.add(one); 324 V.add(zero); 325 W.add(V); 326 M = new ModuleList<BigRational>(fac, W); 327 //System.out.println("W = " + W.size() ); 328 329 N = msbb.leftGB(M); 330 //System.out.println("GB(M) = " + N); 331 assertTrue("isGB( { a,b,c) } )", msbb.isLeftGB(N)); 332 333 Z = ssz.leftZeroRelations(N); 334 //System.out.println("Z = " + Z); 335 //boolean b = ssz.isLeftZeroRelation(Z,N); 336 //System.out.println("boolean = " + b); 337 assertTrue("is ZR( { a,b,c } )", ssz.isLeftZeroRelation(Z, N)); 338 } 339 340 341 /** 342 * Test sequential arbitrary base Syzygy. 343 */ 344 public void testSequentialArbitrarySyzygy() { 345 L = new ArrayList<GenSolvablePolynomial<BigRational>>(); 346 347 assertTrue("not isZERO( a )", !a.isZERO()); 348 L.add(a); 349 assertTrue("isGB( { a } )", sbb.isLeftGB(L)); 350 K = ssz.leftZeroRelationsArbitrary(L); 351 assertTrue("is ZR( { a } )", ssz.isLeftZeroRelation(K, L)); 352 353 assertTrue("not isZERO( b )", !b.isZERO()); 354 L.add(b); 355 K = ssz.leftZeroRelationsArbitrary(L); 356 //System.out.println("\nN = " + N ); 357 assertTrue("is ZR( { a, b } )", ssz.isLeftZeroRelation(K, L)); 358 359 assertTrue("not isZERO( c )", !c.isZERO()); 360 L.add(c); 361 K = ssz.leftZeroRelationsArbitrary(L); 362 //System.out.println("\nN = " + N ); 363 assertTrue("is ZR( { a, b, c } )", ssz.isLeftZeroRelation(K, L)); 364 365 assertTrue("not isZERO( d )", !d.isZERO()); 366 L.add(d); 367 K = ssz.leftZeroRelationsArbitrary(L); 368 //System.out.println("\nN = " + N ); 369 assertTrue("is ZR( { a, b, c, d } )", ssz.isLeftZeroRelation(K, L)); 370 } 371 372 373 /** 374 * Test sequential arbitrary base Syzygy, ex CLO 2, p 214 ff. 375 */ 376 @SuppressWarnings("unchecked") 377 public void testSequentialArbitrarySyzygyCLO() { 378 PolynomialList<BigRational> F = null; 379 380 String exam = "Rat(x,y) G " + "( " + "( x y + x ), " + "( y^2 + 1 ) " + ") "; 381 Reader source = new StringReader(exam); 382 GenPolynomialTokenizer parser = new GenPolynomialTokenizer(source); 383 try { 384 F = (PolynomialList<BigRational>) parser.nextSolvablePolynomialSet(); 385 } catch (ClassCastException e) { 386 fail("" + e); 387 } catch (IOException e) { 388 fail("" + e); 389 } 390 //System.out.println("F = " + F); 391 392 L = F.castToSolvableList(); 393 K = ssz.leftZeroRelationsArbitrary(L); 394 assertTrue("is ZR( { a, b } )", ssz.isLeftZeroRelation(K, L)); 395 } 396 397 398 /** 399 * Test sequential arbitrary base Syzygy, ex WA_32. 400 */ 401 @SuppressWarnings("unchecked") 402 public void testSequentialArbitrarySyzygyWA32() { 403 PolynomialList<BigRational> F = null; 404 405 String exam = "Rat(e1,e2,e3) L " + "RelationTable " + "( " + " ( e3 ), ( e1 ), ( e1 e3 - e1 ), " 406 + " ( e3 ), ( e2 ), ( e2 e3 - e2 ) " + ")" + "( " + " ( e1 e3^3 + e2^2 ), " 407 + " ( e1^3 e2^2 + e3 ), " + " ( e3^3 + e3^2 ) " + ") "; 408 Reader source = new StringReader(exam); 409 GenPolynomialTokenizer parser = new GenPolynomialTokenizer(source); 410 try { 411 F = (PolynomialList<BigRational>) parser.nextSolvablePolynomialSet(); 412 } catch (ClassCastException e) { 413 fail("" + e); 414 } catch (IOException e) { 415 fail("" + e); 416 } 417 //System.out.println("F = " + F); 418 419 L = F.castToSolvableList(); 420 K = ssz.leftZeroRelationsArbitrary(L); 421 assertTrue("is ZR( { a, b } )", ssz.isLeftZeroRelation(K, L)); 422 } 423 424 425 /** 426 * Test sequential arbitrary module SolvableSyzygy. 427 */ 428 public void testSequentialArbitraryModSolvableSyzygy() { 429 W = new ArrayList<List<GenSolvablePolynomial<BigRational>>>(); 430 431 assertTrue("not isZERO( a )", !a.isZERO()); 432 V = new ArrayList<GenSolvablePolynomial<BigRational>>(); 433 V.add(a); 434 V.add(zero); 435 V.add(one); 436 W.add(V); 437 M = new ModuleList<BigRational>(fac, W); 438 assertTrue("isGB( { (a,0,1) } )", msbb.isLeftGB(M)); 439 440 Z = ssz.leftZeroRelationsArbitrary(M); 441 //System.out.println("Z = " + Z); 442 assertTrue("is ZR( { a) } )", ssz.isLeftZeroRelation(Z, M)); 443 444 assertTrue("not isZERO( b )", !b.isZERO()); 445 V = new ArrayList<GenSolvablePolynomial<BigRational>>(); 446 V.add(b); 447 V.add(one); 448 V.add(zero); 449 W.add(V); 450 M = new ModuleList<BigRational>(fac, W); 451 //System.out.println("W = " + W.size() ); 452 453 Z = ssz.leftZeroRelationsArbitrary(M); 454 //System.out.println("Z = " + Z); 455 assertTrue("is ZR( { a, b } )", ssz.isLeftZeroRelation(Z, M)); 456 457 assertTrue("not isZERO( c )", !c.isZERO()); 458 V = new ArrayList<GenSolvablePolynomial<BigRational>>(); 459 V.add(c); 460 V.add(one); 461 V.add(zero); 462 W.add(V); 463 M = new ModuleList<BigRational>(fac, W); 464 //System.out.println("W = " + W.size() ); 465 466 Z = ssz.leftZeroRelationsArbitrary(M); 467 //System.out.println("Z = " + Z); 468 //boolean b = ssz.isLeftZeroRelation(Z,N); 469 //System.out.println("boolean = " + b); 470 assertTrue("is ZR( { a,b,c } )", ssz.isLeftZeroRelation(Z, M)); 471 } 472 473 474 /** 475 * Test Ore conditions. 476 */ 477 public void testOreConditions() { 478 RelationGenerator<BigRational> wl = new WeylRelations<BigRational>(); 479 wl.generate(fac); 480 do { 481 a = fac.random(kl, ll - 1, el, q); 482 } while (a.isZERO()); 483 do { 484 b = fac.random(kl, ll - 1, el, q); 485 } while (b.isZERO()); 486 //System.out.println("a = " + a); 487 //System.out.println("b = " + b); 488 489 GenSolvablePolynomial<BigRational>[] oc = ssz.leftOreCond(a, b); 490 //System.out.println("oc[0] = " + oc[0]); 491 //System.out.println("oc[1] = " + oc[1]); 492 c = oc[0].multiply(a); 493 d = oc[1].multiply(b); 494 //System.out.println("c = " + c); 495 //System.out.println("d = " + d); 496 assertEquals("c_0 * a = c_1 * b: ", c, d); 497 assertTrue("left Ore condition: ", ssz.isLeftOreCond(a, b, oc)); 498 499 oc = ssz.rightOreCond(a, b); 500 //System.out.println("oc[0] = " + oc[0]); 501 //System.out.println("oc[1] = " + oc[1]); 502 c = a.multiply(oc[0]); 503 d = b.multiply(oc[1]); 504 //System.out.println("c = " + c); 505 //System.out.println("d = " + d); 506 assertEquals("a * c_0 = b * c_1: ", c, d); 507 assertTrue("right Ore condition: ", ssz.isRightOreCond(a, b, oc)); 508 } 509 510 511 /** 512 * Test Ore conditions for residues. 513 */ 514 public void testResidueOreConditions() { 515 RelationGenerator<BigRational> wl = new WeylRelations<BigRational>(); 516 wl.generate(fac); 517 518 // construct ideal { x_i^2 - i, ... } for generators x_i 519 F = new PolynomialList<BigRational>(fac, fac.generators()); 520 //System.out.println("F = " + F); 521 List<GenSolvablePolynomial<BigRational>> gens = F.castToSolvableList(); 522 //System.out.println("gens = " + gens); 523 L = new ArrayList<GenSolvablePolynomial<BigRational>>(gens.size() - 1); 524 long i = 2; 525 for (GenSolvablePolynomial<BigRational> g : gens) { 526 if (g.isONE()) { 527 continue; 528 } 529 GenSolvablePolynomial<BigRational> p = g.multiply(g); 530 p = (GenSolvablePolynomial<BigRational>) p.subtract(fac.fromInteger(i++)); 531 L.add(p); 532 } 533 //System.out.println("L = " + L); 534 535 do { 536 a = fac.random(kl, ll - 2, el, q); 537 } while (a.isZERO()); 538 do { 539 b = fac.random(kl, ll - 2, el, q); 540 } while (b.isZERO()); 541 //System.out.println("a = " + a); 542 //System.out.println("b = " + b); 543 544 GenSolvablePolynomial<BigRational>[] oc = ssz.leftOreCond(a, b); 545 //System.out.println("oc[0] = " + oc[0]); 546 //System.out.println("oc[1] = " + oc[1]); 547 c = oc[0].multiply(a); 548 d = oc[1].multiply(b); 549 //System.out.println("c = " + c); 550 //System.out.println("d = " + d); 551 assertEquals("c_0 * a = c_1 * b: ", c, d); 552 assertTrue("left Ore condition: ", ssz.isLeftOreCond(a, b, oc)); 553 554 // now mod ideal(L): 555 GenSolvablePolynomial<BigRational> ar, br, cr, dr, or0, or1; 556 ar = sbb.sred.leftNormalform(L, a); 557 br = sbb.sred.leftNormalform(L, b); 558 //System.out.println("ar = " + ar); 559 //System.out.println("br = " + br); 560 cr = oc[0].multiply(ar); 561 dr = oc[1].multiply(br); 562 //System.out.println("cr = " + cr); 563 //System.out.println("dr = " + dr); 564 //this is not true: assertEquals("c_0 * a = c_1 * b: ", cr, dr); 565 cr = sbb.sred.leftNormalform(L, cr); 566 dr = sbb.sred.leftNormalform(L, dr); 567 //System.out.println("cr = " + cr); 568 //System.out.println("dr = " + dr); 569 assertEquals("cr_0 * ar = cr_1 * br: ", cr, dr); 570 571 or0 = sbb.sred.leftNormalform(L, oc[0]); 572 or1 = sbb.sred.leftNormalform(L, oc[1]); 573 //System.out.println("oc0 = " + oc[0]); 574 //System.out.println("oc1 = " + oc[1]); 575 //System.out.println("or0 = " + or0); 576 //System.out.println("or1 = " + or1); 577 cr = or0.multiply(ar); 578 dr = or1.multiply(br); 579 //okay w/o: cr = sbb.sred.leftNormalform(L,cr); 580 //okay w/o: dr = sbb.sred.leftNormalform(L,dr); 581 //System.out.println("cr = " + cr); 582 //System.out.println("dr = " + dr); 583 //not okay: assertEquals("cr_0 * ar = cr_1 * br: ", cr, dr); 584 oc[0] = or0; 585 oc[1] = or1; 586 //not okay: assertTrue("left Ore condition: ", ssz.isLeftOreCond(ar,br,oc)); 587 588 //System.out.println("new Ore Condition:"); 589 oc = ssz.leftOreCond(ar, br); 590 //System.out.println("oc[0] = " + oc[0]); 591 //System.out.println("oc[1] = " + oc[1]); 592 cr = oc[0].multiply(ar); 593 dr = oc[1].multiply(br); 594 //System.out.println("cr = " + cr); 595 //System.out.println("dr = " + dr); 596 //this is true: 597 assertEquals("c_0 * a = c_1 * b: ", cr, dr); 598 cr = sbb.sred.leftNormalform(L, cr); 599 dr = sbb.sred.leftNormalform(L, dr); 600 //System.out.println("cr = " + cr); 601 //System.out.println("dr = " + dr); 602 assertEquals("cr_0 * ar = cr_1 * br: ", cr, dr); 603 604 /* not okay: 605 or0 = sbb.sred.leftNormalform(L,oc[0]); 606 or1 = sbb.sred.leftNormalform(L,oc[1]); 607 //System.out.println("oc0 = " + oc[0]); 608 //System.out.println("oc1 = " + oc[1]); 609 //System.out.println("or0 = " + or0); 610 //System.out.println("or1 = " + or1); 611 cr = or0.multiply(ar); 612 dr = or1.multiply(br); 613 //okay w/o: cr = sbb.sred.leftNormalform(L,cr); 614 //okay w/o: dr = sbb.sred.leftNormalform(L,dr); 615 //System.out.println("cr = " + cr); 616 //System.out.println("dr = " + dr); 617 assertEquals("cr_0 * ar = cr_1 * br: ", cr, dr); 618 oc[0] = or0; 619 oc[1] = or1; 620 assertTrue("left Ore condition: ", ssz.isLeftOreCond(ar,br,oc)); 621 */ 622 } 623 624 625 /** 626 * Test Ore conditions quaternion coefficients and commutative variables. 627 */ 628 public void testOreConditionsQuat() { 629 BigQuaternionRing qri = new BigQuaternionRing(); 630 GenSolvablePolynomialRing<BigQuaternion> qfac = new GenSolvablePolynomialRing<BigQuaternion>(qri, fac); 631 SolvableSyzygyAbstract<BigQuaternion> ssz = new SolvableSyzygySeq<BigQuaternion>(qri); 632 //System.out.println("qfac = " + qfac.toScript()); 633 634 GenSolvablePolynomial<BigQuaternion> a, b, c, d; 635 do { 636 a = qfac.random(1, 3, el, q); 637 //a = qfac.parse(" z - 1i1/2j-1k0 "); // wrong parse of starting - 638 } while (a.isZERO()); 639 do { 640 b = qfac.random(1, 3, el, q); 641 //b = qfac.parse(" 1i1/2j0k1/2 x * z + 1i1/2j-1k0 ").monic(); // wrong parse of starting - 642 } while (b.isZERO()); 643 //System.out.println("a = " + a); 644 //System.out.println("b = " + b); 645 646 GenSolvablePolynomial<BigQuaternion>[] oc = ssz.leftOreCond(a, b); 647 //System.out.println("oc[0] = " + oc[0]); 648 //System.out.println("oc[1] = " + oc[1]); 649 c = oc[0].multiply(a); 650 d = oc[1].multiply(b); 651 //System.out.println("c_l = " + c); 652 //System.out.println("d_l = " + d); 653 assertTrue("left Ore condition: false", ssz.isLeftOreCond(a, b, oc)); 654 assertEquals("c_0 * a = c_1 * b: " + qfac.toScript(), c, d); 655 656 oc = ssz.rightOreCond(a, b); 657 //System.out.println("oc[0] = " + oc[0]); 658 //System.out.println("oc[1] = " + oc[1]); 659 c = a.multiply(oc[0]); 660 d = b.multiply(oc[1]); 661 //System.out.println("c_r = " + c); 662 //System.out.println("d_r = " + d); 663 assertTrue("right Ore condition: false", ssz.isRightOreCond(a, b, oc)); 664 assertEquals("a * c_0 = b * c_1: " + qfac.toScript(), c, d); 665 } 666 667 668 /** 669 * Test Ore conditions quaternion coefficients and Weyl relations. 670 */ 671 public void testOreConditionsQuatWeyl() { 672 BigQuaternionRing qri = new BigQuaternionRing(); 673 GenSolvablePolynomialRing<BigQuaternion> qfac = new GenSolvablePolynomialRing<BigQuaternion>(qri, fac); 674 SolvableSyzygyAbstract<BigQuaternion> ssz = new SolvableSyzygySeq<BigQuaternion>(qri); 675 676 RelationGenerator<BigQuaternion> wl = new WeylRelations<BigQuaternion>(); 677 //RelationGenerator<BigQuaternion> wl = new WeylRelationsIterated<BigQuaternion>(); 678 wl.generate(qfac); 679 //System.out.println("qfac = " + qfac.toScript()); 680 681 GenSolvablePolynomial<BigQuaternion> a, b, c, d; 682 do { 683 a = qfac.random(1, 3, el, q); 684 //a = qfac.parse(" -1i1j-2k-1 "); // wrong parse of starting - 685 //a = qfac.parse(" 1/2i0j1k-1/2 z "); // wrong parse of starting - 686 //todo: a = qfac.parse(" 1i-1/2j0k1/2 y * z + 1i0j1k0 x + 1i1j0k0 "); // wrong parse of starting - 687 } while (a.isZERO()); 688 do { 689 b = qfac.random(1, 3, el, q); 690 //b = qfac.parse(" -1i1/2j1k-1/2 x + 3/2i1j-1/2k1 "); // wrong parse of starting - 691 //b = qfac.parse(" 1i-1j0k-1/2 w * x * z + 1i-1/2j-1/2k0 y "); // wrong parse of starting - 692 //todo: b = qfac.parse(" 0i1j0k1 y - 0i1j-1k-1 "); // wrong parse of starting - 693 } while (b.isZERO()); 694 //System.out.println("a = " + a); 695 //System.out.println("b = " + b); 696 697 GenSolvablePolynomial<BigQuaternion>[] oc = ssz.leftOreCond(a, b); 698 //System.out.println("oc[0] = " + oc[0]); 699 //System.out.println("oc[1] = " + oc[1]); 700 c = oc[0].multiply(a); 701 d = oc[1].multiply(b); 702 //System.out.println("c_l = " + c); 703 //System.out.println("d_l = " + d); 704 assertTrue("left Ore condition: false", ssz.isLeftOreCond(a, b, oc)); 705 assertEquals("c_0 * a = c_1 * b: " + qfac.toScript(), c, d); 706 707 oc = ssz.rightOreCond(a, b); 708 //System.out.println("oc[0] = " + oc[0]); 709 //System.out.println("oc[1] = " + oc[1]); 710 c = a.multiply(oc[0]); 711 d = b.multiply(oc[1]); 712 //System.out.println("c_r = " + c); 713 //System.out.println("d_r = " + d); 714 assertTrue("right Ore condition: false", ssz.isRightOreCond(a, b, oc)); 715 assertEquals("a * c_0 = b * c_1: " + qfac.toScript(), c, d); 716 } 717 718}