001/* 002 * $Id: ReductionTest.java 5863 2018-07-20 11:13:34Z kredel $ 003 */ 004 005package edu.jas.gbufd; 006 007import java.util.List; 008import java.util.ArrayList; 009import java.util.Map; 010 011import junit.framework.Test; 012import junit.framework.TestCase; 013import junit.framework.TestSuite; 014 015 016import edu.jas.structure.RingFactory; 017import edu.jas.arith.BigInteger; 018import edu.jas.arith.BigRational; 019import edu.jas.arith.BigComplex; 020import edu.jas.arith.Product; 021import edu.jas.arith.ProductRing; 022import edu.jas.poly.ExpVector; 023import edu.jas.poly.GenPolynomial; 024import edu.jas.poly.GenPolynomialRing; 025import edu.jas.poly.PolynomialList; 026 027 028/** 029 * Reduction tests with JUnit. 030 * @author Heinz Kredel 031 */ 032 033public class ReductionTest extends TestCase { 034 035 /** 036 * main 037 */ 038 public static void main (String[] args) { 039 junit.textui.TestRunner.run( suite() ); 040 } 041 042 /** 043 * Constructs a <CODE>ReductionTest</CODE> object. 044 * @param name String 045 */ 046 public ReductionTest(String name) { 047 super(name); 048 } 049 050 /** 051 * suite. 052 * @return a test suite. 053 */ 054 public static Test suite() { 055 TestSuite suite= new TestSuite(ReductionTest.class); 056 return suite; 057 } 058 059 060 GenPolynomialRing<BigRational> fac; 061 062 GenPolynomial<BigRational> a, b, c, d, e; 063 064 List<GenPolynomial<BigRational>> L; 065 PolynomialList<BigRational> F, G; 066 067 //ReductionSeq<BigRational> red; 068 //Reduction<BigRational> redpar; 069 070 int rl = 4; 071 int kl = 10; 072 int ll = 11; 073 int el = 5; 074 float q = 0.6f; 075 076 protected void setUp() { 077 a = b = c = d = e = null; 078 fac = new GenPolynomialRing<BigRational>( new BigRational(0), rl ); 079 //red = new ReductionSeq<BigRational>(); 080 //redpar = new ReductionPar<BigRational>(); 081 } 082 083 protected void tearDown() { 084 a = b = c = d = e = null; 085 fac = null; 086 //red = null; 087 //redpar = null; 088 } 089 090 091 /** 092 * Test rational coefficient r-reduction. 093 */ 094 public void testRationalRReduction() { 095 RingFactory<BigRational> bi = new BigRational(0); 096 ProductRing<BigRational> pr = new ProductRing<BigRational>(bi,3); 097 098 GenPolynomialRing<Product<BigRational>> fac 099 = new GenPolynomialRing<Product<BigRational>>( pr, rl ); 100 101 RReductionSeq<Product<BigRational>> rred 102 = new RReductionSeq<Product<BigRational>>(); 103 104 GenPolynomial<Product<BigRational>> a = fac.random(kl, ll, el, q ); 105 GenPolynomial<Product<BigRational>> b = fac.random(kl, ll, el, q ); 106 GenPolynomial<Product<BigRational>> d; 107 108 while ( a.isZERO() ) { 109 a = fac.random(kl, ll, el, q ); 110 } 111 while ( b.isZERO() ) { 112 b = fac.random(kl, ll, el, q ); 113 } 114 115 assertTrue("not isZERO( a )", !a.isZERO() ); 116 117 List<GenPolynomial<Product<BigRational>>> L 118 = new ArrayList<GenPolynomial<Product<BigRational>>>(); 119 L.add(a); 120 121 GenPolynomial<Product<BigRational>> e 122 = rred.normalform( L, a ); 123 //System.out.println("a = " + a); 124 //System.out.println("e = " + e); 125 assertTrue("isNF( e )", rred.isNormalform(L,e) ); 126 127 assertTrue("not isZERO( b )", !b.isZERO() ); 128 129 L.add(b); 130 e = rred.normalform( L, a ); 131 //System.out.println("b = " + b); 132 //System.out.println("e = " + e); 133 assertTrue("isNF( e )", rred.isNormalform(L,e) ); 134 135 GenPolynomial<Product<BigRational>> c = fac.getONE(); 136 a = a.sum(c); 137 e = rred.normalform( L, a ); 138 //System.out.println("a = " + a); 139 //System.out.println("e = " + e); 140 assertTrue("isNF( e )", rred.isNormalform(L,e) ); 141 142 L = new ArrayList<GenPolynomial<Product<BigRational>>>(); 143 L.add( a ); 144 assertTrue("isTopRed( a )", rred.isTopReducible(L,a) ); 145 assertTrue("isRed( a )", rred.isReducible(L,a) ); 146 //b = fac.random(kl, ll, el, q ); 147 L.add( b ); 148 assertTrue("isTopRed( b )", rred.isTopReducible(L,b) ); 149 assertTrue("isRed( b )", rred.isReducible(L,b) ); 150 c = fac.random(kl, ll, el, q ); 151 e = rred.normalform( L, c ); 152 assertTrue("isNF( e )", rred.isNormalform(L,e) ); 153 154 c = rred.booleanClosure(a); 155 //System.out.println("a = " + a); 156 //System.out.println("c = " + c); 157 assertTrue("isBC( c )", rred.isBooleanClosed(c) ); 158 159 b = a.subtract(c); 160 //System.out.println("b = " + b); 161 d = rred.booleanRemainder(a); 162 //System.out.println("d = " + d); 163 assertEquals("a-BC(a)=BR(a)", b, d ); 164 165 e = c.sum(d); 166 //System.out.println("e = " + e); 167 assertEquals("a==BC(a)+BR(a)", a, e ); 168 169 List<GenPolynomial<Product<BigRational>>> B; 170 List<GenPolynomial<Product<BigRational>>> Br; 171 L = new ArrayList<GenPolynomial<Product<BigRational>>>(); 172 L.add( a ); 173 B = rred.booleanClosure(L); 174 Br = rred.reducedBooleanClosure(L); 175 //System.out.println("L = " + L); 176 //System.out.println("B = " + B); 177 //System.out.println("Br = " + Br); 178 assertTrue("isBC( B )", rred.isBooleanClosed(B) ); 179 assertTrue("isBC( Br )", rred.isReducedBooleanClosed(Br) ); 180 assertTrue("isBC( Br )", rred.isBooleanClosed(Br) ); 181 //not always: assertEquals("B == Br", B, Br ); 182 183 L.add( b ); 184 B = rred.booleanClosure(L); 185 Br = rred.reducedBooleanClosure(L); 186 //System.out.println("L = " + L); 187 //System.out.println("B = " + B); 188 //System.out.println("Br = " + Br); 189 assertTrue("isBC( B )", rred.isBooleanClosed(B) ); 190 assertTrue("isBC( Br )", rred.isReducedBooleanClosed(Br) ); 191 assertTrue("isBC( Br )", rred.isBooleanClosed(Br) ); 192 //not always: assertEquals("B == Br", B, Br ); 193 194 while ( c.isZERO() ) { 195 c = fac.random(kl, ll, el, q ); 196 } 197 L.add( c ); 198 B = rred.booleanClosure(L); 199 Br = rred.reducedBooleanClosure(L); 200 //System.out.println("L = " + L); 201 //System.out.println("B = " + B); 202 //System.out.println("Br = " + Br); 203 assertTrue("isBC( B )", rred.isBooleanClosed(B) ); 204 assertTrue("isBC( Br )", rred.isReducedBooleanClosed(Br) ); 205 assertTrue("isBC( Br )", rred.isBooleanClosed(Br) ); 206 //not always: assertEquals("B == Br", B, Br ); 207 208 while ( d.isZERO() ) { 209 d = fac.random(kl, ll, el, q ); 210 } 211 L.add( d ); 212 B = rred.booleanClosure(L); 213 Br = rred.reducedBooleanClosure(L); 214 //System.out.println("L = " + L); 215 //System.out.println("B = " + B); 216 //System.out.println("Br = " + Br); 217 assertTrue("isBC( B )", rred.isBooleanClosed(B) ); 218 assertTrue("isBC( Br )", rred.isReducedBooleanClosed(Br) ); 219 assertTrue("isBC( Br )", rred.isBooleanClosed(Br) ); 220 //not always: assertEquals("B == Br", B, Br ); 221 } 222 223 224 /** 225 * Test rational coefficient r-reduction with recording. 226 */ 227 public void testRatRReductionRecording() { 228 RingFactory<BigRational> bi = new BigRational(0); 229 ProductRing<BigRational> pr = new ProductRing<BigRational>(bi,3); 230 231 GenPolynomialRing<Product<BigRational>> fac 232 = new GenPolynomialRing<Product<BigRational>>( pr, rl ); 233 234 RReductionSeq<Product<BigRational>> rred 235 = new RReductionSeq<Product<BigRational>>(); 236 237 GenPolynomial<Product<BigRational>> a = fac.random(kl, ll, el, q ); 238 GenPolynomial<Product<BigRational>> b = fac.random(kl, ll, el, q ); 239 GenPolynomial<Product<BigRational>> c, d, e; 240 241 while ( a.isZERO() ) { 242 a = fac.random(kl, ll, el, q ); 243 } 244 while ( b.isZERO() ) { 245 b = fac.random(kl, ll, el, q ); 246 } 247 c = fac.random(kl, ll, el, q ); 248 d = fac.random(kl, ll, el, q ); 249 250 List<GenPolynomial<Product<BigRational>>> row = null; 251 List<GenPolynomial<Product<BigRational>>> L; 252 253 assertTrue("not isZERO( a )", !a.isZERO() ); 254 assertTrue("not isZERO( b )", !b.isZERO() ); 255 256 L = new ArrayList<GenPolynomial<Product<BigRational>>>(); 257 258 L.add(a); 259 row = new ArrayList<GenPolynomial<Product<BigRational>>>( L.size() ); 260 for ( int m = 0; m < L.size(); m++ ) { 261 row.add(null); 262 } 263 e = rred.normalform( row, L, a ); 264 //not for regular rings: assertTrue("isZERO( e )", e.isZERO() ); 265 266 //System.out.println("row = " + row); 267 //System.out.println("L = " + L); 268 //System.out.println("a = " + a); 269 //System.out.println("e = " + e); 270 271 assertTrue("is Reduction ", rred.isReductionNF(row,L,a,e) ); 272 273 L.add(b); 274 row = new ArrayList<GenPolynomial<Product<BigRational>>>( L.size() ); 275 for ( int m = 0; m < L.size(); m++ ) { 276 row.add(null); 277 } 278 e = rred.normalform( row, L, b ); 279 assertTrue("is Reduction ", rred.isReductionNF(row,L,b,e) ); 280 281 L.add(c); 282 row = new ArrayList<GenPolynomial<Product<BigRational>>>( L.size() ); 283 for ( int m = 0; m < L.size(); m++ ) { 284 row.add(null); 285 } 286 e = rred.normalform( row, L, c ); 287 assertTrue("is Reduction ", rred.isReductionNF(row,L,c,e) ); 288 289 L.add(d); 290 row = new ArrayList<GenPolynomial<Product<BigRational>>>( L.size() ); 291 for ( int m = 0; m < L.size(); m++ ) { 292 row.add(null); 293 } 294 e = rred.normalform( row, L, d ); 295 assertTrue("is Reduction ", rred.isReductionNF(row,L,d,e) ); 296 } 297 298 299 /** 300 * Test integer coefficient pseudo-reduction. 301 */ 302 public void testIntegerPseudoReduction() { 303 BigInteger bi = new BigInteger(0); 304 GenPolynomialRing<BigInteger> fac 305 = new GenPolynomialRing<BigInteger>( bi, rl ); 306 307 PseudoReductionSeq<BigInteger> pred = new PseudoReductionSeq<BigInteger>(); 308 309 GenPolynomial<BigInteger> a = fac.random(kl, ll, el, q ); 310 GenPolynomial<BigInteger> b = fac.random(kl, ll, el, q ); 311 312 if ( a.isZERO() || b.isZERO() ) { 313 return; 314 } 315 316 assertTrue("not isZERO( a )", !a.isZERO() ); 317 318 List<GenPolynomial<BigInteger>> L 319 = new ArrayList<GenPolynomial<BigInteger>>(); 320 L.add(a); 321 322 GenPolynomial<BigInteger> e; 323 e = pred.normalform( L, a ); 324 //System.out.println("a = " + a); 325 //System.out.println("e = " + e); 326 assertTrue("isZERO( e )", e.isZERO() ); 327 328 assertTrue("not isZERO( b )", !b.isZERO() ); 329 330 L.add(b); 331 e = pred.normalform( L, a ); 332 //System.out.println("b = " + b); 333 //System.out.println("e = " + e); 334 assertTrue("isZERO( e ) some times", e.isZERO() ); 335 336 337 GenPolynomial<BigInteger> c = fac.getONE(); 338 a = a.sum(c); 339 e = pred.normalform( L, a ); 340 //System.out.println("b = " + b); 341 //System.out.println("e = " + e); 342 assertTrue("isConstant( e ) some times", e.isConstant() ); 343 344 L = new ArrayList<GenPolynomial<BigInteger>>(); 345 a = c.multiply( bi.fromInteger(4) ); 346 b = c.multiply( bi.fromInteger(5) ); 347 L.add( a ); 348 e = pred.normalform( L, b ); 349 //System.out.println("a = " + a); 350 //System.out.println("b = " + b); 351 //System.out.println("e = " + e); 352 assertTrue("isZERO( e )", e.isZERO() ); 353 354 a = fac.random(kl, ll, el, q ); //.abs(); 355 b = fac.random(kl, ll, el, q ); //.abs(); 356 //System.out.println("a = " + a); 357 //System.out.println("b = " + b); 358 359 L = new ArrayList<GenPolynomial<BigInteger>>(); 360 L.add( a ); 361 assertTrue("isTopRed( a )", pred.isTopReducible(L,a) ); 362 assertTrue("isRed( a )", pred.isReducible(L,a) ); 363 b = fac.random(kl, ll, el, q ); 364 L.add( b ); 365 assertTrue("isTopRed( b )", pred.isTopReducible(L,b) ); 366 assertTrue("isRed( b )", pred.isReducible(L,b) ); 367 c = fac.random(kl, ll, el, q ); 368 e = pred.normalform( L, c ); 369 assertTrue("isNF( e )", pred.isNormalform(L,e) ); 370 } 371 372 373 /** 374 * Test integer pseudo coefficient reduction with recording. 375 */ 376 public void testIntReductionRecording() { 377 BigInteger bi = new BigInteger(0); 378 GenPolynomialRing<BigInteger> fac 379 = new GenPolynomialRing<BigInteger>( bi, rl ); 380 381 PseudoReductionSeq<BigInteger> pred = new PseudoReductionSeq<BigInteger>(); 382 383 GenPolynomial<BigInteger> a = fac.random(kl, ll, el, q ); 384 GenPolynomial<BigInteger> b = fac.random(kl, ll, el, q ); 385 GenPolynomial<BigInteger> c, d, e, f; 386 387 if ( a.isZERO() || b.isZERO() ) { 388 return; 389 } 390 c = fac.random(kl, ll, el+1, q ); 391 d = fac.random(kl, ll, el+2, q ); 392 393 // ------------ 394 //a = fac.parse(" 1803 x0 * x1^4 - 299 x0^3 * x1^2 - 464 x1^4 + 648 x1^3 + 383 x0^3 + 1633 "); 395 //b = fac.parse(" 593 x0^4 * x1^4 - 673 x0^3 * x1^4 + 36 x0^4 + 627 x1^2 + 617 x1 + 668 x0 + 168 "); 396 //b = b.multiply( fac.parse(" 10567759154481 " ) ); 397 //c = a.multiply( fac.parse(" 593 x0^3 - 938267 x0^2 - 435355888 x0 - 202005132032 ") ); 398 399 //d = a.multiply( fac.parse(" 3475696715811 x0^3 - 3050126808003 x0^2 - 784946666064 x0 - 202005132032 ") ); 400 401 //------------- 402 403 List<GenPolynomial<BigInteger>> row = null; 404 List<GenPolynomial<BigInteger>> L; 405 406 PseudoReductionEntry<BigInteger> mf; 407 408 assertTrue("not isZERO( a )", !a.isZERO() ); 409 assertTrue("not isZERO( b )", !b.isZERO() ); 410 411 L = new ArrayList<GenPolynomial<BigInteger>>(); 412 413 L.add(a); 414 row = new ArrayList<GenPolynomial<BigInteger>>( L.size() ); 415 for ( int m = 0; m < L.size(); m++ ) { 416 row.add(null); 417 } 418 mf = pred.normalformFactor( L, a ); 419 e = mf.pol; 420 f = a.multiply( mf.multiplicator ); 421 e = pred.normalform( row, L, f ); 422 assertTrue("isZERO( e )", e.isZERO() ); 423 assertTrue("is Reduction ", pred.isNormalform(L,e) ); 424 assertTrue("is ReductionNF ", pred.isReductionNF(row,L,f,e) ); 425 426 L.add(b); 427 row = new ArrayList<GenPolynomial<BigInteger>>( L.size() ); 428 for ( int m = 0; m < L.size(); m++ ) { 429 row.add(null); 430 } 431 mf = pred.normalformFactor( L, a ); 432 e = mf.pol; 433 f = a.multiply( mf.multiplicator ); 434 e = pred.normalform( row, L, f ); 435 assertTrue("is Reduction ", pred.isNormalform(L,e) ); 436 assertTrue("is ReductionNF ", pred.isReductionNF(row,L,f,e) ); 437 438 L.add(c); 439 row = new ArrayList<GenPolynomial<BigInteger>>( L.size() ); 440 for ( int m = 0; m < L.size(); m++ ) { 441 row.add(null); 442 } 443 mf = pred.normalformFactor( L, a ); 444 e = mf.pol; 445 f = a.multiply( mf.multiplicator ); 446 e = pred.normalform( row, L, f ); 447 assertTrue("is Reduction ", pred.isNormalform(L,e) ); 448 assertTrue("is ReductionNF ", pred.isReductionNF(row,L,f,e) ); 449 450 L.add(d); 451 row = new ArrayList<GenPolynomial<BigInteger>>( L.size() ); 452 for ( int m = 0; m < L.size(); m++ ) { 453 row.add(null); 454 } 455 mf = pred.normalformFactor( L, a ); 456 e = mf.pol; 457 f = a.multiply( mf.multiplicator ); 458 e = pred.normalform( row, L, f ); 459 assertTrue("is Reduction ", pred.isNormalform(L,e) ); 460 assertTrue("is ReductionNF ", pred.isReductionNF(row,L,f,e) ); 461 } 462 463 464 /** 465 * Test integer coefficient pseudo r-reduction. 466 */ 467 public void testIntegerRReduction() { 468 RingFactory<BigInteger> bi = new BigInteger(0); 469 ProductRing<BigInteger> pr = new ProductRing<BigInteger>(bi,3); 470 471 GenPolynomialRing<Product<BigInteger>> fac 472 = new GenPolynomialRing<Product<BigInteger>>( pr, rl ); 473 474 RReductionSeq<Product<BigInteger>> rpred 475 = new RPseudoReductionSeq<Product<BigInteger>>(); 476 477 GenPolynomial<Product<BigInteger>> a = fac.random(kl, ll, el, q ); 478 GenPolynomial<Product<BigInteger>> b = fac.random(kl, ll, el, q ); 479 GenPolynomial<Product<BigInteger>> c, d, e; 480 481 while ( a.isZERO() ) { 482 a = fac.random(kl, ll, el, q ); 483 } 484 while ( b.isZERO() ) { 485 b = fac.random(kl, ll, el, q ); 486 } 487 488 assertTrue("not isZERO( a )", !a.isZERO() ); 489 490 List<GenPolynomial<Product<BigInteger>>> L 491 = new ArrayList<GenPolynomial<Product<BigInteger>>>(); 492 L.add(a); 493 494 e = rpred.normalform( L, a ); 495 //System.out.println("a = " + a); 496 //System.out.println("e = " + e); 497 assertTrue("isNF( e )", rpred.isNormalform(L,e) ); 498 499 assertTrue("not isZERO( b )", !b.isZERO() ); 500 501 L.add(b); 502 e = rpred.normalform( L, a ); 503 assertTrue("isNF( e )", rpred.isNormalform(L,e) ); 504 505 c = fac.getONE(); 506 a = a.sum(c); 507 e = rpred.normalform( L, a ); 508 assertTrue("isNF( e )", rpred.isNormalform(L,e) ); 509 510 L = new ArrayList<GenPolynomial<Product<BigInteger>>>(); 511 L.add( a ); 512 assertTrue("isTopRed( a )", rpred.isTopReducible(L,a) ); 513 assertTrue("isRed( a )", rpred.isReducible(L,a) ); 514 //b = fac.random(kl, ll, el, q ); 515 L.add( b ); 516 assertTrue("isTopRed( b )", rpred.isTopReducible(L,b) ); 517 assertTrue("isRed( b )", rpred.isReducible(L,b) ); 518 c = fac.random(kl, ll, el, q ); 519 e = rpred.normalform( L, c ); 520 assertTrue("isNF( e )", rpred.isNormalform(L,e) ); 521 522 c = rpred.booleanClosure(a); 523 //System.out.println("\nboolean closure"); 524 //System.out.println("a = " + a); 525 //System.out.println("c = " + c); 526 assertTrue("isBC( c )", rpred.isBooleanClosed(c) ); 527 528 b = a.subtract(c); 529 //System.out.println("b = " + b); 530 d = rpred.booleanRemainder(a); 531 //System.out.println("d = " + d); 532 assertEquals("a-BC(a)=BR(a)", b, d ); 533 534 e = c.sum(d); 535 //System.out.println("e = " + e); 536 assertEquals("a==BC(a)+BR(a)", a, e ); 537 538 List<GenPolynomial<Product<BigInteger>>> B; 539 List<GenPolynomial<Product<BigInteger>>> Br; 540 L = new ArrayList<GenPolynomial<Product<BigInteger>>>(); 541 L.add( a ); 542 B = rpred.booleanClosure(L); 543 Br = rpred.reducedBooleanClosure(L); 544 assertTrue("isBC( B )", rpred.isBooleanClosed(B) ); 545 assertTrue("isBC( Br )", rpred.isReducedBooleanClosed(Br) ); 546 assertTrue("isBC( Br )", rpred.isBooleanClosed(Br) ); 547 //not always: assertEquals("B == Br", B, Br ); 548 549 L.add( b ); 550 B = rpred.booleanClosure(L); 551 Br = rpred.reducedBooleanClosure(L); 552 assertTrue("isBC( B )", rpred.isBooleanClosed(B) ); 553 assertTrue("isBC( Br )", rpred.isReducedBooleanClosed(Br) ); 554 assertTrue("isBC( Br )", rpred.isBooleanClosed(Br) ); 555 //not always: assertEquals("B == Br", B, Br ); 556 557 L.add( c ); 558 B = rpred.booleanClosure(L); 559 Br = rpred.reducedBooleanClosure(L); 560 assertTrue("isBC( B )", rpred.isBooleanClosed(B) ); 561 assertTrue("isBC( Br )", rpred.isReducedBooleanClosed(Br) ); 562 assertTrue("isBC( Br )", rpred.isBooleanClosed(Br) ); 563 //not always: assertEquals("B == Br", B, Br ); 564 565 while ( d.isZERO() ) { 566 d = fac.random(kl, ll, el, q ); 567 } 568 L.add( d ); 569 B = rpred.booleanClosure(L); 570 Br = rpred.reducedBooleanClosure(L); 571 assertTrue("isBC( B )", rpred.isBooleanClosed(B) ); 572 assertTrue("isBC( Br )", rpred.isReducedBooleanClosed(Br) ); 573 assertTrue("isBC( Br )", rpred.isBooleanClosed(Br) ); 574 //not always: assertEquals("B == Br", B, Br ); 575 } 576 577 578 /** 579 * Test integer pseudo coefficient r-reduction with recording. 580 */ 581 public void testIntRReductionRecording() { 582 RingFactory<BigInteger> bi = new BigInteger(0); 583 ProductRing<BigInteger> pr = new ProductRing<BigInteger>(bi,3); 584 585 GenPolynomialRing<Product<BigInteger>> fac 586 = new GenPolynomialRing<Product<BigInteger>>( pr, rl ); 587 588 RPseudoReductionSeq<Product<BigInteger>> rpred 589 = new RPseudoReductionSeq<Product<BigInteger>>(); 590 591 GenPolynomial<Product<BigInteger>> a = fac.random(kl, ll, el, q ); 592 GenPolynomial<Product<BigInteger>> b = fac.random(kl, ll, el, q ); 593 GenPolynomial<Product<BigInteger>> c, d, e, f; 594 595 while ( a.isZERO() ) { 596 a = fac.random(kl, ll, el, q ); 597 } 598 while ( b.isZERO() ) { 599 b = fac.random(kl, ll, el, q ); 600 } 601 assertTrue("not isZERO( a )", !a.isZERO() ); 602 assertTrue("not isZERO( b )", !b.isZERO() ); 603 604 c = fac.random(kl, ll, el, q ); 605 d = fac.random(kl, ll, el, q ); 606 607 List<GenPolynomial<Product<BigInteger>>> row = null; 608 List<GenPolynomial<Product<BigInteger>>> L; 609 610 PseudoReductionEntry<Product<BigInteger>> mf; 611 612 L = new ArrayList<GenPolynomial<Product<BigInteger>>>(); 613 614 L.add(a); 615 row = new ArrayList<GenPolynomial<Product<BigInteger>>>( L.size() ); 616 for ( int m = 0; m < L.size(); m++ ) { 617 row.add(null); 618 } 619 mf = rpred.normalformFactor( L, a ); 620 e = mf.pol; 621 f = a.multiply( mf.multiplicator ); 622 e = rpred.normalform( row, L, f ); 623 //not for regular rings: assertTrue("isZERO( e )", e.isZERO() ); 624 assertTrue("is Reduction ", rpred.isNormalform(L,e) ); 625 assertTrue("is ReductionNF ", rpred.isReductionNF(row,L,f,e) ); 626 627 L.add(b); 628 row = new ArrayList<GenPolynomial<Product<BigInteger>>>( L.size() ); 629 for ( int m = 0; m < L.size(); m++ ) { 630 row.add(null); 631 } 632 mf = rpred.normalformFactor( L, a ); 633 e = mf.pol; 634 f = a.multiply( mf.multiplicator ); 635 e = rpred.normalform( row, L, f ); 636 assertTrue("is Reduction ", rpred.isNormalform(L,e) ); 637 assertTrue("is ReductionNF ", rpred.isReductionNF(row,L,f,e) ); 638 639 L.add(c); 640 row = new ArrayList<GenPolynomial<Product<BigInteger>>>( L.size() ); 641 for ( int m = 0; m < L.size(); m++ ) { 642 row.add(null); 643 } 644 mf = rpred.normalformFactor( L, a ); 645 e = mf.pol; 646 f = a.multiply( mf.multiplicator ); 647 e = rpred.normalform( row, L, f ); 648 assertTrue("is Reduction ", rpred.isNormalform(L,e) ); 649 assertTrue("is ReductionNF ", rpred.isReductionNF(row,L,f,e) ); 650 651 L.add(d); 652 row = new ArrayList<GenPolynomial<Product<BigInteger>>>( L.size() ); 653 for ( int m = 0; m < L.size(); m++ ) { 654 row.add(null); 655 } 656 mf = rpred.normalformFactor( L, a ); 657 e = mf.pol; 658 f = a.multiply( mf.multiplicator ); 659 e = rpred.normalform( row, L, f ); 660 assertTrue("is Reduction ", rpred.isNormalform(L,e) ); 661 assertTrue("is ReductionNF ", rpred.isReductionNF(row,L,f,e) ); 662 } 663 664}