Annotation of OpenXM/src/k097/debug/pgcd.k, Revision 1.1
1.1 ! maekawa 1:
! 2:
! 3: /* polynomial gcd.k */
! 4:
! 5: class Pgcd extends Object {
! 6: pzero = Poly("0");
! 7: def gcd0(f,g,xx) {
! 8: local tmp,r;
! 9: if (Degree(g,xx) > Degree(f,xx)) {
! 10: tmp = f; f = g; g = tmp;
! 11: }
! 12: while (!IsConstant(g)) {
! 13: r = Reduction(f,[g]);
! 14: Println([f,g,r[1]]);
! 15: r = r[0];
! 16: f = g;
! 17: g = r;
! 18: }
! 19: if (g == pzero) return(f);
! 20: else return(g);
! 21: }
! 22: def gcd(f,g,xx) {
! 23: local tmp,r;
! 24: if (Degree(g,xx) > Degree(f,xx)) {
! 25: tmp = f; f = g; g = tmp;
! 26: }
! 27: while (!IsConstant(g)) {
! 28: r = pseudoRemainder(f,g,xx);
! 29: f = g;
! 30: g = r;
! 31: }
! 32: if (g == pzero) return(f);
! 33: else return(g);
! 34: }
! 35: def pseudoRemainder(f,g,xx) {
! 36: local c,r;
! 37: c = Init(g);
! 38: Println([c,xx]);
! 39: c = Coefficients(c,xx);
! 40: c = c[1,0];
! 41: r = Reduction(c^(Degree(f,xx)-Degree(g,xx)+1)*f,[g]);
! 42: Println([f,g,r[1]]);
! 43: return(r[0]);
! 44: }
! 45: }
! 46:
! 47:
! 48:
! 49:
! 50:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>