/usr/share/axiom-20170501/src/algebra/RMCAT2.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 | )abbrev package RMCAT2 RectangularMatrixCategoryFunctions2
++ Author: Clifton J. Williamson
++ Date Created: 21 November 1989
++ Date Last Updated: 12 June 1991
++ Description:
++ \spadtype{RectangularMatrixCategoryFunctions2} provides functions between
++ two matrix domains. The functions provided are \spadfun{map} and
++ \spadfun{reduce}.
RectangularMatrixCategoryFunctions2(m,n,R1,Row1,Col1,M1,R2,Row2,Col2,M2) :
SIG == CODE where
m,n : NonNegativeInteger
R1 : Ring
Row1 : DirectProductCategory(n, R1)
Col1 : DirectProductCategory(m, R1)
M1 : RectangularMatrixCategory(m,n,R1,Row1,Col1)
R2 : Ring
Row2 : DirectProductCategory(n, R2)
Col2 : DirectProductCategory(m, R2)
M2 : RectangularMatrixCategory(m,n,R2,Row2,Col2)
SIG ==> with
map : (R1 -> R2,M1) -> M2
++ \spad{map(f,m)} applies the function \spad{f} to the elements of the
++ matrix \spad{m}.
reduce : ((R1,R2) -> R2,M1,R2) -> R2
++ \spad{reduce(f,m,r)} returns a matrix \spad{n} where
++ \spad{n[i,j] = f(m[i,j],r)} for all indices spad{i} and \spad{j}.
CODE ==> add
minr ==> minRowIndex
maxr ==> maxRowIndex
minc ==> minColIndex
maxc ==> maxColIndex
map(f,mat) ==
ans : M2 := new(m,n,0)$Matrix(R2) pretend M2
for i in minr(mat)..maxr(mat) for k in minr(ans)..maxr(ans) repeat
for j in minc(mat)..maxc(mat) for l in minc(ans)..maxc(ans) repeat
qsetelt_!(ans pretend Matrix R2,k,l,f qelt(mat,i,j))
ans
reduce(f,mat,ident) ==
s := ident
for i in minr(mat)..maxr(mat) repeat
for j in minc(mat)..maxc(mat) repeat
s := f(qelt(mat,i,j),s)
s
|