/usr/share/axiom-20170501/src/algebra/ASP20.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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | )abbrev domain ASP20 Asp20
++ Author: Mike Dewar and Godfrey Nolan and Grant Keady
++ Date Created: Dec 1993
++ Date Last Updated: 6 October 1994
++ References:
++ Hawk95 Two more links to NAG numerics involving CA systems
++ Kead93 Production of Argument SubPrograms in the AXIOM -- NAG link
++ Description:
++ \spadtype{Asp20} produces Fortran for Type 20 ASPs, for example:
++
++ \tab{5}SUBROUTINE QPHESS(N,NROWH,NCOLH,JTHCOL,HESS,X,HX)\br
++ \tab{5}DOUBLE PRECISION HX(N),X(N),HESS(NROWH,NCOLH)\br
++ \tab{5}INTEGER JTHCOL,N,NROWH,NCOLH\br
++ \tab{5}HX(1)=2.0D0*X(1)\br
++ \tab{5}HX(2)=2.0D0*X(2)\br
++ \tab{5}HX(3)=2.0D0*X(4)+2.0D0*X(3)\br
++ \tab{5}HX(4)=2.0D0*X(4)+2.0D0*X(3)\br
++ \tab{5}HX(5)=2.0D0*X(5)\br
++ \tab{5}HX(6)=(-2.0D0*X(7))+(-2.0D0*X(6))\br
++ \tab{5}HX(7)=(-2.0D0*X(7))+(-2.0D0*X(6))\br
++ \tab{5}RETURN\br
++ \tab{5}END
Asp20(name) : SIG == CODE where
name : Symbol
FST ==> FortranScalarType
FT ==> FortranType
SYMTAB ==> SymbolTable
PI ==> PositiveInteger
UFST ==> Union(fst:FST,void:"void")
RSFC ==> Record(localSymbols:SymbolTable,code:List(FortranCode))
FRAC ==> Fraction
POLY ==> Polynomial
EXPR ==> Expression
INT ==> Integer
FLOAT ==> Float
VEC ==> Vector
MAT ==> Matrix
VF2 ==> VectorFunctions2
MFLOAT ==> MachineFloat
FEXPR ==> FortranExpression([],['X,'HESS],MFLOAT)
O ==> OutputForm
M2 ==> MatrixCategoryFunctions2
MF2a ==> M2(FRAC POLY INT,VEC FRAC POLY INT,VEC FRAC POLY INT,
MAT FRAC POLY INT,FEXPR,VEC FEXPR,VEC FEXPR,MAT FEXPR)
MF2b ==> M2(FRAC POLY FLOAT,VEC FRAC POLY FLOAT,VEC FRAC POLY FLOAT,
MAT FRAC POLY FLOAT, FEXPR,VEC FEXPR,VEC FEXPR,MAT FEXPR)
MF2c ==> M2(POLY INT,VEC POLY INT,VEC POLY INT,MAT POLY INT,
FEXPR,VEC FEXPR,VEC FEXPR,MAT FEXPR)
MF2d ==> M2(POLY FLOAT,VEC POLY FLOAT,VEC POLY FLOAT,
MAT POLY FLOAT, FEXPR,VEC FEXPR,VEC FEXPR,MAT FEXPR)
MF2e ==> M2(EXPR INT,VEC EXPR INT,VEC EXPR INT,MAT EXPR INT,
FEXPR,VEC FEXPR,VEC FEXPR,MAT FEXPR)
MF2f ==> M2(EXPR FLOAT,VEC EXPR FLOAT,VEC EXPR FLOAT,
MAT EXPR FLOAT, FEXPR,VEC FEXPR,VEC FEXPR,MAT FEXPR)
SIG ==> FortranMatrixFunctionCategory with
coerce : MAT FEXPR -> $
++coerce(f) takes objects from the appropriate instantiation of
++\spadtype{FortranExpression} and turns them into an ASP.
CODE ==> add
real : UFST := ["real"::FST]$UFST
syms : SYMTAB := empty()
declare!(N,fortranInteger(),syms)$SYMTAB
declare!(NROWH,fortranInteger(),syms)$SYMTAB
declare!(NCOLH,fortranInteger(),syms)$SYMTAB
declare!(JTHCOL,fortranInteger(),syms)$SYMTAB
hessType : FT := construct(real,[NROWH,NCOLH],false)$FT
declare!(HESS,hessType,syms)$SYMTAB
xType : FT := construct(real,[N],false)$FT
declare!(X,xType,syms)$SYMTAB
declare!(HX,xType,syms)$SYMTAB
Rep := FortranProgram(name,["void"]$UFST,
[N,NROWH,NCOLH,JTHCOL,HESS,X,HX],syms)
coerce(c:List FortranCode):$ == coerce(c)$Rep
coerce(r:RSFC):$ == coerce(r)$Rep
coerce(c:FortranCode):$ == coerce(c)$Rep
-- To help the poor old compiler!
fexpr2expr(u:FEXPR):EXPR MFLOAT == coerce(u)$FEXPR
localAssign(s:Symbol,j:VEC FEXPR):FortranCode ==
j' : VEC EXPR MFLOAT := map(fexpr2expr,j)$VF2(FEXPR,EXPR MFLOAT)
assign(s,j')$FortranCode
coerce(u:MAT FEXPR):$ ==
j:Integer
x:Symbol := X::Symbol
n := nrows(u)::PI
p:VEC FEXPR := [retract(subscript(x,[j::O])$Symbol)@FEXPR for j in 1..n]
prod:VEC FEXPR := u*p
([localAssign(HX,prod),returns()$FortranCode]$List(FortranCode))::$
retract(u:MAT FRAC POLY INT):$ ==
v : MAT FEXPR := map(retract,u)$MF2a
v::$
retractIfCan(u:MAT FRAC POLY INT):Union($,"failed") ==
v:Union(MAT FEXPR,"failed"):=map(retractIfCan,u)$MF2a
v case "failed" => "failed"
(v::MAT FEXPR)::$
retract(u:MAT FRAC POLY FLOAT):$ ==
v : MAT FEXPR := map(retract,u)$MF2b
v::$
retractIfCan(u:MAT FRAC POLY FLOAT):Union($,"failed") ==
v:Union(MAT FEXPR,"failed"):=map(retractIfCan,u)$MF2b
v case "failed" => "failed"
(v::MAT FEXPR)::$
retract(u:MAT EXPR INT):$ ==
v : MAT FEXPR := map(retract,u)$MF2e
v::$
retractIfCan(u:MAT EXPR INT):Union($,"failed") ==
v:Union(MAT FEXPR,"failed"):=map(retractIfCan,u)$MF2e
v case "failed" => "failed"
(v::MAT FEXPR)::$
retract(u:MAT EXPR FLOAT):$ ==
v : MAT FEXPR := map(retract,u)$MF2f
v::$
retractIfCan(u:MAT EXPR FLOAT):Union($,"failed") ==
v:Union(MAT FEXPR,"failed"):=map(retractIfCan,u)$MF2f
v case "failed" => "failed"
(v::MAT FEXPR)::$
retract(u:MAT POLY INT):$ ==
v : MAT FEXPR := map(retract,u)$MF2c
v::$
retractIfCan(u:MAT POLY INT):Union($,"failed") ==
v:Union(MAT FEXPR,"failed"):=map(retractIfCan,u)$MF2c
v case "failed" => "failed"
(v::MAT FEXPR)::$
retract(u:MAT POLY FLOAT):$ ==
v : MAT FEXPR := map(retract,u)$MF2d
v::$
retractIfCan(u:MAT POLY FLOAT):Union($,"failed") ==
v:Union(MAT FEXPR,"failed"):=map(retractIfCan,u)$MF2d
v case "failed" => "failed"
(v::MAT FEXPR)::$
coerce(u:$):O == coerce(u)$Rep
outputAsFortran(u):Void ==
p := checkPrecision()$NAGLinkSupportPackage
outputAsFortran(u)$Rep
p => restorePrecision()$NAGLinkSupportPackage
|