aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Dos Reis <gdr@axiomatics.org>2016-01-30 04:23:04 -0800
committerGabriel Dos Reis <gdr@axiomatics.org>2016-01-30 04:23:04 -0800
commit18f925c1f6474349c4f808244c29cdf65fc0a70e (patch)
tree5adc829d82832035e7e5e5f84e5827967f820586
parentdac46336dff97cc6c3b12bcbb781c1cf18135a6d (diff)
downloadopen-axiom-18f925c1f6474349c4f808244c29cdf65fc0a70e.tar.gz
FreeModule: Tidy implementation.
-rw-r--r--src/algebra/poly.spad.pamphlet66
1 files changed, 29 insertions, 37 deletions
diff --git a/src/algebra/poly.spad.pamphlet b/src/algebra/poly.spad.pamphlet
index e6162aa6..6b7b19d7 100644
--- a/src/algebra/poly.spad.pamphlet
+++ b/src/algebra/poly.spad.pamphlet
@@ -31,43 +31,35 @@ FreeModule(R:Ring,S:OrderedType):
Join(BiModule(R,R),IndexedDirectProductCategory(R,S)) with
if R has CommutativeRing then Module(R)
== IndexedDirectProductAbelianGroup(R,S) add
- --representations
- Term:= Record(k:S,c:R)
- Rep:= List Term
- --define
- if R has EntireRing then
- r:R * x:% ==
- zero? r => 0
- one? r => x
- --map(r*#1,x)
- [[u.k,r*u.c] for u in x ]
- else
- r:R * x:% ==
- zero? r => 0
- one? r => x
- --map(r*#1,x)
- [[u.k,a] for u in x | (a:=r*u.c) ~= 0$R]
- if R has EntireRing then
- x:% * r:R ==
- zero? r => 0
- one? r => x
- --map(r*#1,x)
- [[u.k,u.c*r] for u in x ]
- else
- x:% * r:R ==
- zero? r => 0
- one? r => x
- --map(r*#1,x)
- [[u.k,a] for u in x | (a:=u.c*r) ~= 0$R]
-
- if S has CoercibleTo OutputForm then
- coerce(x) : OutputForm ==
- null x => (0$R) :: OutputForm
- le : List OutputForm := nil
- for rec in reverse x repeat
- rec.c = 1 => le := cons(rec.k :: OutputForm, le)
- le := cons(rec.c :: OutputForm * rec.k :: OutputForm, le)
- reduce("+",le)
+ if R has EntireRing then
+ r:R * x:% ==
+ zero? r => 0$%
+ one? r => x
+ convert [term(index u, r * coefficient u) for u in terms x ]
+ else
+ r:R * x:% ==
+ zero? r => 0$%
+ one? r => x
+ convert [term(index u,a) for u in terms x | not zero?(a := r * coefficient u)]
+ if R has EntireRing then
+ x:% * r:R ==
+ zero? r => 0$%
+ one? r => x
+ convert [term(index u, coefficient(u) * r) for u in terms x ]
+ else
+ x:% * r:R ==
+ zero? r => 0$%
+ one? r => x
+ convert [term(index u,a) for u in terms x | not zero?(a := coefficient(u) * r)]
+
+ if S has CoercibleTo OutputForm then
+ coerce(x) : OutputForm ==
+ zero? x => (0$R) :: OutputForm
+ le : List OutputForm := nil
+ for rec in reverse terms x repeat
+ one? coefficient rec => le := cons(index rec :: OutputForm, le)
+ le := cons(coefficient rec :: OutputForm * index rec :: OutputForm, le)
+ reduce("+",le)
@
\section{domain PR PolynomialRing}