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