@@ -206,9 +206,9 @@ public GenSolvablePolynomial<C> rightBasePrimitivePart(GenSolvablePolynomial<C>
206
206
return P ;
207
207
}
208
208
if (P .ring .coFac .isField ()) { // make monic
209
- return P .multiplyLeft (d .inverse ()); // avoid the divisions
209
+ return P .multiply (d .inverse ()); // avoid the divisions
210
210
}
211
- GenSolvablePolynomial <C > pp = (GenSolvablePolynomial <C >) P .leftDivideCoeff (d ); // leftDivide TODO/done
211
+ GenSolvablePolynomial <C > pp = (GenSolvablePolynomial <C >) P .rightDivideCoeff (d ); // leftDivide TODO/done
212
212
if (debug ) {
213
213
GenSolvablePolynomial <C > p = pp .multiplyLeft (d );
214
214
if (!p .equals (P )) {
@@ -254,19 +254,15 @@ public GenSolvablePolynomial<C> recursiveContent(GenSolvablePolynomial<GenPolyno
254
254
if (P instanceof RecSolvablePolynomial ) {
255
255
RecSolvablePolynomialRing <C > rfac = (RecSolvablePolynomialRing <C >) P .ring ;
256
256
if (!rfac .coeffTable .isEmpty ()) {
257
- throw new IllegalArgumentException ( "P is a RecSolvablePolynomial, use recursiveContent() " );
257
+ throw new UnsupportedOperationException ( "RecSolvablePolynomial with non empty coeffTable " );
258
258
}
259
259
}
260
260
if (P .isZERO ()) {
261
261
return (GenSolvablePolynomial <C >) P .ring .getZEROCoefficient ();
262
262
}
263
- if (P .isONE ()) {
264
- return (GenSolvablePolynomial <C >) P .ring .getONECoefficient ();
265
- }
266
263
if (P .leadingBaseCoefficient ().isONE ()) {
267
264
return (GenSolvablePolynomial <C >) P .ring .getONECoefficient ();
268
265
}
269
- //GenSolvablePolynomial<GenPolynomial<C>> p = P;
270
266
GenSolvablePolynomial <C > d = null ;
271
267
for (GenPolynomial <C > cp : P .getMap ().values ()) {
272
268
GenSolvablePolynomial <C > c = (GenSolvablePolynomial <C >) cp ;
@@ -285,11 +281,11 @@ public GenSolvablePolynomial<C> recursiveContent(GenSolvablePolynomial<GenPolyno
285
281
286
282
287
283
/**
288
- * GenSolvablePolynomial right recursive content.
284
+ * GenSolvablePolynomial left recursive content.
289
285
* @param P recursive GenSolvablePolynomial.
290
- * @return cont(P) with pp (P)*cont (P) = P.
286
+ * @return cont(P) with cont (P)*pp (P) = P.
291
287
*/
292
- public GenSolvablePolynomial <C > rightRecursiveContent (GenSolvablePolynomial <GenPolynomial <C >> P ) {
288
+ public GenSolvablePolynomial <C > leftRecursiveContent (GenSolvablePolynomial <GenPolynomial <C >> P ) {
293
289
if (P == null ) {
294
290
throw new IllegalArgumentException ("P != null" );
295
291
}
@@ -299,18 +295,16 @@ public GenSolvablePolynomial<C> rightRecursiveContent(GenSolvablePolynomial<GenP
299
295
if (P .leadingBaseCoefficient ().isONE ()) {
300
296
return (GenSolvablePolynomial <C >) P .ring .getONECoefficient ();
301
297
}
302
- GenSolvablePolynomial <C > d = null , cs = null , x ;
303
- GenSolvablePolynomial <GenPolynomial <C >> Pr = P . rightRecursivePolynomial ();
304
- logger .info ("RI- recCont: P = {}, right (P) = {}" , P , Pr );
298
+ GenSolvablePolynomial <C > d = null , cs = null ;
299
+ GenSolvablePolynomial <GenPolynomial <C >> Pr = P ; //FDUtil.<C> rightRecursivePolynomial(P );
300
+ logger .info ("recCont: P = {}, left (P) = {}" , P , Pr );
305
301
for (GenPolynomial <C > c : Pr .getMap ().values ()) {
306
302
cs = (GenSolvablePolynomial <C >) c ;
307
303
if (d == null ) {
308
304
d = cs ;
309
305
} else {
310
- x = d ;
311
- d = leftGcd (d , cs ); // go to recursion, P = P'*gcd(P,S)
312
- ///d = rightGcd(d, cs); // go to recursion, P = gcd(P,S)*P'
313
- logger .info ("RI-recCont: d = {}, cs = {}, d = {}" , x , cs , d );
306
+ d = leftGcd (d , cs ); // go to recursion
307
+ logger .info ("recCont: cs = {}, d = {}" , cs , d );
314
308
}
315
309
if (d .isONE ()) {
316
310
return d ;
@@ -321,43 +315,11 @@ public GenSolvablePolynomial<C> rightRecursiveContent(GenSolvablePolynomial<GenP
321
315
322
316
323
317
/**
324
- * GenSolvablePolynomial right recursive primitive part.
325
- * @param P recursive GenSolvablePolynomial.
326
- * @return pp(P) with pp(P)*cont(P) = P.
327
- */
328
- public GenSolvablePolynomial <GenPolynomial <C >> rightRecursivePrimitivePart (
329
- GenSolvablePolynomial <GenPolynomial <C >> P ) {
330
- if (P == null ) {
331
- throw new IllegalArgumentException ("P == null" );
332
- }
333
- if (P .isZERO ()) {
334
- return P ;
335
- }
336
- GenSolvablePolynomial <C > d = rightRecursiveContent (P );
337
- if (d .isONE ()) {
338
- return P ;
339
- }
340
- GenSolvablePolynomial <GenPolynomial <C >> pp ;
341
- pp = FDUtil .<C > recursiveLeftDivide (P , d ); //RightEval
342
- if (debug ) { // not checkable
343
- if (!P .equals (pp .multiply (d ))) {
344
- System .out .println ("RI-ppart, P = " + P );
345
- System .out .println ("RI-ppart, cont(P) = " + d );
346
- System .out .println ("RI-ppart, pp(P) = " + pp );
347
- System .out .println ("RI-ppart, pp(P)c(P) = " + pp .multiply (d ));
348
- throw new RuntimeException ("RI-primitivePart: P != pp(P)*cont(P)" );
349
- }
350
- }
351
- return pp ;
352
- }
353
-
354
-
355
- /**
356
- * GenSolvablePolynomial left recursive content.
318
+ * GenSolvablePolynomial right recursive content.
357
319
* @param P recursive GenSolvablePolynomial.
358
- * @return cont(P) with cont (P)*pp (P) = P.
320
+ * @return cont(P) with pp (P)*cont (P) = P.
359
321
*/
360
- public GenSolvablePolynomial <C > leftRecursiveContent (GenSolvablePolynomial <GenPolynomial <C >> P ) {
322
+ public GenSolvablePolynomial <C > rightRecursiveContent (GenSolvablePolynomial <GenPolynomial <C >> P ) {
361
323
if (P == null ) {
362
324
throw new IllegalArgumentException ("P != null" );
363
325
}
@@ -367,23 +329,24 @@ public GenSolvablePolynomial<C> leftRecursiveContent(GenSolvablePolynomial<GenPo
367
329
if (P .leadingBaseCoefficient ().isONE ()) {
368
330
return (GenSolvablePolynomial <C >) P .ring .getONECoefficient ();
369
331
}
370
- GenSolvablePolynomial <C > d = null , cs = null ;
371
- GenSolvablePolynomial <GenPolynomial <C >> Pr = P ; //FDUtil.<C> rightRecursivePolynomial(P );
372
- logger .info ( " recCont: P = {}, right(P) = {}" , P , Pr );
332
+ GenSolvablePolynomial <C > d = null , cs = null , x ;
333
+ GenSolvablePolynomial <GenPolynomial <C >> Pr = P . rightRecursivePolynomial ();
334
+ logger .warn ( "RI- recCont: P = {}, right(P) = {}" , P , Pr );
373
335
for (GenPolynomial <C > c : Pr .getMap ().values ()) {
374
336
cs = (GenSolvablePolynomial <C >) c ;
375
337
if (d == null ) {
376
338
d = cs ;
377
339
} else {
378
- //d = rightGcd(d, cs); // go to recursion
379
- d = leftGcd (d , cs ); // go to recursion
380
- logger .info ("recCont: cs = {}, d = {}" , cs , d );
340
+ x = d ;
341
+ d = leftGcd (d , cs ); // go to recursion, P = P'*gcd(P,S)
342
+ ///d = rightGcd(d, cs); // go to recursion, P = gcd(P,S)*P'
343
+ logger .info ("RI-recCont: d = {}, cs = {}, d = {}" , x , cs , d );
381
344
}
382
345
if (d .isONE ()) {
383
346
return d ;
384
347
}
385
348
}
386
- return (GenSolvablePolynomial <C >) d .abs ();
349
+ return (GenSolvablePolynomial <C >) d .abs ();// todo: eval right ?
387
350
}
388
351
389
352
@@ -420,6 +383,38 @@ public GenSolvablePolynomial<GenPolynomial<C>> leftRecursivePrimitivePart(
420
383
}
421
384
422
385
386
+ /**
387
+ * GenSolvablePolynomial right recursive primitive part.
388
+ * @param P recursive GenSolvablePolynomial.
389
+ * @return pp(P) with pp(P)*cont(P) = P.
390
+ */
391
+ public GenSolvablePolynomial <GenPolynomial <C >> rightRecursivePrimitivePart (
392
+ GenSolvablePolynomial <GenPolynomial <C >> P ) {
393
+ if (P == null ) {
394
+ throw new IllegalArgumentException ("P == null" );
395
+ }
396
+ if (P .isZERO ()) {
397
+ return P ;
398
+ }
399
+ GenSolvablePolynomial <C > d = rightRecursiveContent (P );
400
+ if (d .isONE ()) {
401
+ return P ;
402
+ }
403
+ GenSolvablePolynomial <GenPolynomial <C >> pp ;
404
+ pp = FDUtil .<C > recursiveRightDivide (P , d ); //RightEval
405
+ if (debug ) { // not checkable
406
+ if (!P .equals (pp .multiply (d ))) {
407
+ System .out .println ("RI-ppart, P = " + P );
408
+ System .out .println ("RI-ppart, cont(P) = " + d );
409
+ System .out .println ("RI-ppart, pp(P) = " + pp );
410
+ System .out .println ("RI-ppart, pp(P)c(P) = " + pp .multiply (d ));
411
+ throw new RuntimeException ("RI-primitivePart: P != pp(P)*cont(P)" );
412
+ }
413
+ }
414
+ return pp ;
415
+ }
416
+
417
+
423
418
/**
424
419
* GenSolvablePolynomial base recursive content.
425
420
* @param P recursive GenSolvablePolynomial.
@@ -579,11 +574,11 @@ public abstract GenSolvablePolynomial<GenPolynomial<C>> rightRecursiveUnivariate
579
574
580
575
581
576
/**
582
- * GenSolvablePolynomial right content.
577
+ * GenSolvablePolynomial left content.
583
578
* @param P GenSolvablePolynomial.
584
- * @return cont(P) with pp (P)*cont (P) = P.
579
+ * @return cont(P) with cont (P)*pp (P) = P.
585
580
*/
586
- public GenSolvablePolynomial <C > rightContent (GenSolvablePolynomial <C > P ) {
581
+ public GenSolvablePolynomial <C > leftContent (GenSolvablePolynomial <C > P ) {
587
582
if (P == null ) {
588
583
throw new IllegalArgumentException ("P == null" );
589
584
}
@@ -597,17 +592,17 @@ public GenSolvablePolynomial<C> rightContent(GenSolvablePolynomial<C> P) {
597
592
598
593
GenSolvablePolynomial <GenPolynomial <C >> Pr = (RecSolvablePolynomial <C >) PolyUtil .<C > recursive (rfac ,
599
594
P );
600
- GenSolvablePolynomial <C > D = rightRecursiveContent (Pr );
595
+ GenSolvablePolynomial <C > D = leftRecursiveContent (Pr );
601
596
return D ;
602
597
}
603
598
604
599
605
600
/**
606
- * GenSolvablePolynomial right primitive part.
601
+ * GenSolvablePolynomial left primitive part.
607
602
* @param P GenSolvablePolynomial.
608
- * @return pp(P) with pp (P)*cont (P) = P.
603
+ * @return pp(P) with cont (P)*pp (P) = P.
609
604
*/
610
- public GenSolvablePolynomial <C > rightPrimitivePart (GenSolvablePolynomial <C > P ) {
605
+ public GenSolvablePolynomial <C > leftPrimitivePart (GenSolvablePolynomial <C > P ) {
611
606
if (P == null ) {
612
607
throw new IllegalArgumentException ("P == null" );
613
608
}
@@ -616,26 +611,26 @@ public GenSolvablePolynomial<C> rightPrimitivePart(GenSolvablePolynomial<C> P) {
616
611
}
617
612
GenSolvablePolynomialRing <C > pfac = P .ring ;
618
613
if (pfac .nvar <= 1 ) {
619
- return rightBasePrimitivePart (P );
614
+ return leftBasePrimitivePart (P );
620
615
}
621
616
GenSolvablePolynomialRing <GenPolynomial <C >> rfac = /*(RecSolvablePolynomialRing<C>)*/ pfac
622
617
.recursive (1 );
623
618
624
619
GenSolvablePolynomial <GenPolynomial <C >> Pr = (RecSolvablePolynomial <C >) PolyUtil .<C > recursive (rfac ,
625
620
P );
626
- GenSolvablePolynomial <GenPolynomial <C >> PP = rightRecursivePrimitivePart (Pr );
621
+ GenSolvablePolynomial <GenPolynomial <C >> PP = leftRecursivePrimitivePart (Pr );
627
622
628
623
GenSolvablePolynomial <C > D = (GenSolvablePolynomial <C >) PolyUtil .<C > distribute (pfac , PP );
629
624
return D ;
630
625
}
631
626
632
627
633
628
/**
634
- * GenSolvablePolynomial left content.
629
+ * GenSolvablePolynomial right content.
635
630
* @param P GenSolvablePolynomial.
636
- * @return cont(P) with cont (P)*pp (P) = P.
631
+ * @return cont(P) with pp (P)*cont (P) = P.
637
632
*/
638
- public GenSolvablePolynomial <C > leftContent (GenSolvablePolynomial <C > P ) {
633
+ public GenSolvablePolynomial <C > rightContent (GenSolvablePolynomial <C > P ) {
639
634
if (P == null ) {
640
635
throw new IllegalArgumentException ("P == null" );
641
636
}
@@ -649,17 +644,17 @@ public GenSolvablePolynomial<C> leftContent(GenSolvablePolynomial<C> P) {
649
644
650
645
GenSolvablePolynomial <GenPolynomial <C >> Pr = (RecSolvablePolynomial <C >) PolyUtil .<C > recursive (rfac ,
651
646
P );
652
- GenSolvablePolynomial <C > D = leftRecursiveContent (Pr );
647
+ GenSolvablePolynomial <C > D = rightRecursiveContent (Pr );
653
648
return D ;
654
649
}
655
650
656
651
657
652
/**
658
- * GenSolvablePolynomial left primitive part.
653
+ * GenSolvablePolynomial right primitive part.
659
654
* @param P GenSolvablePolynomial.
660
- * @return pp(P) with cont (P)*pp (P) = P.
655
+ * @return pp(P) with pp (P)*cont (P) = P.
661
656
*/
662
- public GenSolvablePolynomial <C > leftPrimitivePart (GenSolvablePolynomial <C > P ) {
657
+ public GenSolvablePolynomial <C > rightPrimitivePart (GenSolvablePolynomial <C > P ) {
663
658
if (P == null ) {
664
659
throw new IllegalArgumentException ("P == null" );
665
660
}
@@ -668,14 +663,14 @@ public GenSolvablePolynomial<C> leftPrimitivePart(GenSolvablePolynomial<C> P) {
668
663
}
669
664
GenSolvablePolynomialRing <C > pfac = P .ring ;
670
665
if (pfac .nvar <= 1 ) {
671
- return leftBasePrimitivePart (P );
666
+ return rightBasePrimitivePart (P );
672
667
}
673
668
GenSolvablePolynomialRing <GenPolynomial <C >> rfac = /*(RecSolvablePolynomialRing<C>)*/ pfac
674
669
.recursive (1 );
675
670
676
671
GenSolvablePolynomial <GenPolynomial <C >> Pr = (RecSolvablePolynomial <C >) PolyUtil .<C > recursive (rfac ,
677
672
P );
678
- GenSolvablePolynomial <GenPolynomial <C >> PP = leftRecursivePrimitivePart (Pr );
673
+ GenSolvablePolynomial <GenPolynomial <C >> PP = rightRecursivePrimitivePart (Pr );
679
674
680
675
GenSolvablePolynomial <C > D = (GenSolvablePolynomial <C >) PolyUtil .<C > distribute (pfac , PP );
681
676
return D ;
@@ -744,7 +739,7 @@ public C gcd(C a, C b) {
744
739
* @return gcd(a,b) with a = gcd(a,b)*a' and b = gcd(a,b)*b'.
745
740
*/
746
741
public C leftGcd (C a , C b ) {
747
- return gcd ( a , b );
742
+ return a . leftGcd ( b );
748
743
}
749
744
750
745
@@ -822,7 +817,7 @@ public C rightGcd(C a, C b) {
822
817
if (a == null || a .isZERO ()) {
823
818
return b ;
824
819
}
825
- return a .gcd (b ); // TODO
820
+ return a .rightGcd (b ); // TODO
826
821
}
827
822
828
823
0 commit comments