This file is indexed.

/usr/share/axiom-20170501/src/algebra/SD.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
)abbrev domain SD StochasticDifferential
++ Author: Wilfrid S. Kendall
++ Last Last Updated: July 26, 1999
++ Related Domains: BasicStochasticDifferential
++ References: Ito (1975), Kendall (1991a,b; 1993a,b).
++ Description:
++ A basic implementation of StochasticDifferential(R) using the
++ associated domain BasicStochasticDifferential in the underlying 
++ representation as sparse multivariate polynomials. The domain is 
++ a module over Expression(R), and is a ring without identity 
++ (AXIOM term is "Rng"). Note that separate instances, for example 
++ using R=Integer and R=Float, have different hidden structure 
++ (multiplication and drift tables).

StochasticDifferential(R) :  SIG == CODE where
  R : Join(OrderedSet, IntegralDomain)

  ER ==> Expression(R)
  PR ==> Polynomial(R)
  FR ==> Fraction(PR)
  BSD ==> BasicStochasticDifferential
  PI ==> PositiveInteger
  NNI ==> NonNegativeInteger
  OF  ==> OutputForm

  SIG ==> Join(Rng, Module(ER)) with

   RetractableTo(BSD)

   alterQuadVar! : (BSD,BSD,%) -> Union(%,"failed")
    ++ alterQuadVar! adds multiplication formula for a
    ++ pair of stochastic differentials to a private table.
    ++ Failure occurs if
    ++  (a) either of first or second arguments is not basic
    ++  (b) third argument is not exactly of first degree

   alterDrift! : (BSD,%) -> Union(%,"failed")
    ++ alterDrift! adds drift formula for a 
    ++ stochastic differential to a private table.
    ++ Failure occurs if
    ++  (a) first arguments is not basic
    ++  (b) second argument is not exactly of first degree

   drift : % -> %
    ++ drift(dx) returns the drift of \axiom{dx}

   freeOf? : (%,BSD) -> Boolean
    ++ freeOf?(sd,dX) checks whether \axiom{dX} occurs in
    ++ \axiom{sd} as a module element

   coefficient : (%,BSD) -> ER
    ++ coefficient(sd,dX) returns the coefficient of \axiom{dX}
    ++ in the stochastic differential \axiom{sd}

   listSD : (%) -> List BSD
    ++ listSD(dx) returns a list of all \axiom{BSD} involved
    ++ in the generation of \axiom{dx} as a module element

   equation : (%,R) -> Union(Equation %,"failed")
    ++ equation(dx,0) allows RHS of Equation % to be zero
   equation:(R,%) -> Union(Equation %,"failed")
    ++ equation(0,dx) allows LHS of Equation % to be zero

   copyDrift : () -> Table(%,%)
    ++ copyDrift returns private table of drifts 
    ++ of basic stochastic differentials for inspection

   copyQuadVar : () -> Table(%,%)
    ++ copyQuadVar returns private multiplication table
    ++ of basic stochastic differentials for inspection

   "/" : (%, ER) -> %
      ++ dx/y divides the stochastic differential dx 
      ++ by the previsible function y.

   "**" : (%, PI) -> %
      ++ dx**n is dx multiplied by itself n times.

   "^" : (%, PI) -> %
      ++ dx^n is dx multiplied by itself n times.

   statusIto : () -> OF
    ++ statusIto() displays the current state of \axiom{setBSD},
    ++ \axiom{tableDrift}, and \axiom{tableQuadVar}. Question
    ++ marks are printed instead of undefined entries
    ++
    ++X dt:=introduce!(t,dt)
    ++X dX:=introduce!(X,dX)
    ++X dY:=introduce!(Y,dY)
    ++X copyBSD()
    ++X copyIto()
    ++X copyhQuadVar()
    ++X statusIto()

   uncorrelated? : (%,%) -> Boolean
    ++ uncorrelated?(dx,dy) checks whether its two arguments
    ++ have zero quadratic co-variation.

   uncorrelated? : (List %,List %) -> Boolean
    ++ uncorrelated?(l1,l2) checks whether its two arguments
    ++ are lists of stochastic differentials of zero inter-list
    ++ quadratic co-variation.

   uncorrelated? : (List List %) -> Boolean
    ++ uncorrelated?(ll) checks whether its argument is a list
    ++ of lists of stochastic differentials of zero inter-list
    ++ quadratic co-variation.

  CODE ==> SparseMultivariatePolynomial(ER,BSD) add

   Rep:=SparseMultivariatePolynomial(ER,BSD)

   (v:% / s:ER):% == inv(s) * v

   tableQuadVar:Table(%,%)  := table()

   tableDrift:Table(%,%) := table()

   alterQuadVar!(da:BSD,db:BSD,dXdY:%):Union(%,"failed") ==
    -- next two lines for security only!
    1 < totalDegree(dXdY)                => "failed"
    0 ~= coefficient(dXdY,degree(1)$Rep) => "failed"
    not(0::% = (dXdY*dXdY)::%) => "failed"
    setelt(tableQuadVar,((da::Rep)*(db::Rep))$Rep,dXdY)$Table(%,%)
    -- We have to take care here to avoid a bad
    -- recursion on \axiom{*:(%,%)->%}

   alterDrift!(da:BSD,dx:%):Union(%,"failed") ==
    1 < totalDegree(dx)                => "failed"
    0 ~= coefficient(dx,degree(1)$Rep) => "failed"
    not(0::% = (dx*dx)::%) => "failed"
    setelt(tableDrift,da::Rep,dx)$Table(%,%)

   multSDOrError(dm:%):% ==
    c := leadingCoefficient dm
    (dmm := search(dm/c,tableQuadVar)) 
      case "failed" =>
       print hconcat(message("ERROR IN ")$OF,(dm/c)::OF)
       error "Above product of sd's is not defined"
    c*dmm

   (dx:% * dy:%) : % ==
    1 < totalDegree(dx) =>
     print hconcat(message("ERROR IN ")$OF,dx::OF)
     error "bad sd in lhs of sd product"
    1 < totalDegree(dy) =>
     print hconcat(message("ERROR IN ")$OF,dy::OF)
     error "bad sd in rhs of sd product"
    reduce("+",map(multSDOrError,monomials((dx*dy)$Rep)),0)
    -- We have to take care here to avoid a bad 
    -- recursion on \axiom{*:(%,%)->%}

   (dx:% ** n:PI) : % ==
    n = 1 => dx
    n = 2 => dx*dx
    n > 2 => 0::%

   (dx:% ^ n:PI) : % == dx**n

   driftSDOrError(dm:%):% ==
    c := leadingCoefficient dm
    (dmm := search(dm/c,tableDrift)) 
      case "failed" =>
       print hconcat(message("ERROR IN ")$OF,(dm/c)::OF)
       error "drift of sd is not defined"
    c*dmm

   drift(dx:%):% ==
    reduce("+",map(driftSDOrError,monomials(dx)),0)

   freeOf?(sd,dX) == (0 = coefficient(sd,dX,1))

   coefficient(sd:%,dX:BSD):ER == 
    retract(coefficient(sd,dX,1))@ER

   listSD(sd) == 
    [retract(dX)@BSD for dX in primitiveMonomials(sd)]

   equation(dx:%,zero:R):Union(Equation %,"failed") ==
    not(0 = zero) => "failed"
    equation(dx,0::%)

   equation(zero:R,dx:%):Union(Equation %,"failed") ==
    not(0 = zero) => "failed"
    equation(0::%,dx)

   copyDrift() == tableDrift
   copyQuadVar() == tableQuadVar

   xDrift(dx:BSD):OF ==
    (xdx := search(dx::Rep,tableDrift)) case "failed" => "?"::OF
    xdx::OF

   xQV(dx:BSD,dy:BSD):OF ==
    (xdxdy := search((dx::% * dy::%)$Rep,tableQuadVar)) 
      case "failed" => "?"::Symbol::OF
    xdxdy::OF

   statusIto():OF ==
    bsd  := copyBSD()$BSD
    bsdo := [dx::OF for dx in bsd]
    blank:= ""::Symbol::OF
    colon:= ":"::Symbol::OF
    bsdh := "B S D "::Symbol::OF
    dfth := "drift "::Symbol::OF
    qvh  := "*"::Symbol::OF
    head := append([bsdh,colon],bsdo)
    drift:= append([dfth,colon],[xDrift dx for dx in bsd])
    space:= append([qvh ,blank],[blank for dx in bsd])
    qv   := [append([dy::OF,colon],[xQV(dx,dy) for dx in bsd]) 
                                               for dy in bsd]
    matrix(append([head,drift,space],qv))$OF

   uncorrelated?(dx:%,dy:%): Boolean == (0::% = dx*dy)

   uncorrelated?(l1:List %,l2:List %): Boolean ==
    reduce("and", [ 
     reduce("and",[uncorrelated?(dx,dy) for dy in l2],true) 
      for dx in l1 ],true)

   uncorrelated1?(l1:List %,ll:List List %): Boolean ==
    reduce("and",[uncorrelated?(l1,l2) for l2 in ll],true)

   uncorrelated?(ll:List List %): Boolean ==
    (0$Integer = # ll) => true
    (1 = # ll) => true
    uncorrelated1?(first ll,rest ll) and uncorrelated?(rest ll)