diff options
author | Gabriel Dos Reis <gdr@axiomatics.org> | 2016-01-30 04:23:04 -0800 |
---|---|---|
committer | Gabriel Dos Reis <gdr@axiomatics.org> | 2016-01-30 04:23:04 -0800 |
commit | 18f925c1f6474349c4f808244c29cdf65fc0a70e (patch) | |
tree | 5adc829d82832035e7e5e5f84e5827967f820586 /src/algebra | |
parent | dac46336dff97cc6c3b12bcbb781c1cf18135a6d (diff) | |
download | open-axiom-18f925c1f6474349c4f808244c29cdf65fc0a70e.tar.gz |
FreeModule: Tidy implementation.
Diffstat (limited to 'src/algebra')
-rw-r--r-- | src/algebra/poly.spad.pamphlet | 66 |
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} |