Annotation of OpenXM/src/k097/debug/asir0.k, Revision 1.4
1.1 maekawa 1:
2:
3: /* SSWork/yacc/debug/asir0.k, 1997, 3/5 cf. debug/asir1.ccc */
4: if (K00_verbose) {
1.2 takayama 5: Println("debug/asir0.k you need ox_asir module. ");
6: }
7:
8: def loadOXasir() {
9: Load_sm1(["oxasir.sm1",AddString([GetEnv("OpenXM_HOME"),
10: "/lib/sm1/oxasir.sm1"])],
11: "oxasir.sm1.loaded");
1.1 maekawa 12: }
13:
14: /* x = Poly("x");
15: f = (x+2)^10;
16: Println(f); */
17:
18: def Factor(f) {
1.2 takayama 19: loadOXasir();
20: sm1(f, " f fctr /FunctionValue set");
1.1 maekawa 21: }
1.2 takayama 22: HelpAdd(["Factor",["Factor a given polynomial."]]);
1.1 maekawa 23:
24: def Cancel(f) {
1.2 takayama 25: local tmp,den,num,r;
26: loadOXasir();
1.1 maekawa 27: if (IsRational(f)) {
28: den = Cancel(Denominator(f));
29: num = Cancel(Numerator(f));
30: if (IsInteger(den) && IsInteger(num)) {
31: return(CancelNumber(num/den));
32: }
33: if (IsInteger(den)) {
34: tmp = sm1("[(divByN) ",num, den," ] gbext ");
35: if (tmp[1] == Poly("0")) {
36: return(Cancel(tmp[0]));
37: }else{
38: return(f);
39: }
40: }
41: }
42: if (IsInteger(f)) return(f);
43: if (IsPolynomial(f)) {
44: if (f == Poly("0")) return(0);
1.4 ! takayama 45: if (Characteristic(GetRing(f)) != 0) return(f);
1.1 maekawa 46: if (IsConstant(f)) return(DC(f,"integer"));
47: return(f);
48: }
1.2 takayama 49: sm1("[[num den]] reduceByAsir /r set ");
50: if (IsInteger(r[1])) {
51: if (r[1] == 1) return(r[0]);
52: }
53: return(r[0]/r[1]);
1.1 maekawa 54: }
1.2 takayama 55: HelpAdd(["Cancel",["Cancel the greatest common multiple of the denominators and the numerator. "]]);
1.1 maekawa 56:
57:
58:
1.3 takayama 59: /* BUG: It has not yet been rewritten.
1.1 maekawa 60: def Primadec(f,g) {
61: sm1(f,g," primadec /FunctionValue set");
62: sm1(" clean-workfiles ");
63: }
64: HelpAdd(["Primadec",[" Not Yet. <<need asir, start k0 with -f option.>>"]]);
1.3 takayama 65: */
1.1 maekawa 66:
67:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>