/usr/share/axiom-20170501/src/algebra/FM.spad is in axiom-source 20170501-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | )abbrev domain FM FreeModule
++ Author: Dave Barton, James Davenport, Barry Trager
++ Description:
++ A bi-module is a free module
++ over a ring with generators indexed by an ordered set.
++ Each element can be expressed as a finite linear combination of
++ generators. Only non-zero terms are stored.
FreeModule(R,S) : SIG == CODE where
R : Ring
S : OrderedSet
SIG ==> Join(BiModule(R,R),IndexedDirectProductCategory(R,S)) with
if R has CommutativeRing then Module(R)
CODE ==> IndexedDirectProductAbelianGroup(R,S) add
--representations
Term:= Record(k:S,c:R)
Rep:= List Term
--declarations
x,y: %
r: R
n: Integer
f: R -> R
s: S
--define
if R has EntireRing then
r * x ==
zero? r => 0
(r = 1) => x
--map(r*#1,x)
[[u.k,r*u.c] for u in x ]
else
r * x ==
zero? r => 0
(r = 1) => 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 ==
zero? r => 0
(r = 1) => x
--map(r*#1,x)
[[u.k,u.c*r] for u in x ]
else
x * r ==
zero? r => 0
(r = 1) => x
--map(r*#1,x)
[[u.k,a] for u in x | (a:=u.c*r) ^= 0$R]
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)
|