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