This file is indexed.

/usr/share/axiom-20170501/src/algebra/EP.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
228
229
230
231
232
233
234
235
236
237
)abbrev package EP EigenPackage
++ Author: P. Gianni
++ Date Created: summer 1986
++ Date Last Updated: October 1992
++ Description:
++ This is a package for the exact computation of eigenvalues and eigenvectors.
++ This package can be made to work for matrices with coefficients which are
++ rational functions over a ring where we can factor polynomials.
++ Rational eigenvalues are always explicitly computed while the
++ non-rational ones are expressed in terms of their minimal
++ polynomial.
-- Functions for the numeric computation of eigenvalues and eigenvectors
-- are in numeigen spad.

EigenPackage(R) : SIG == CODE where
  R : GcdDomain

  P     ==> Polynomial R
  F     ==> Fraction P
  SE    ==> Symbol()
  SUP   ==> SparseUnivariatePolynomial(P)
  SUF   ==> SparseUnivariatePolynomial(F)
  M     ==> Matrix(F)
  NNI   ==> NonNegativeInteger
  ST    ==> SuchThat(SE,P)

  Eigenvalue  ==> Union(F,ST)
  EigenForm   ==> Record(eigval:Eigenvalue,eigmult:NNI,eigvec : List M)
  GenEigen    ==> Record(eigval:Eigenvalue,geneigvec:List M)

  SIG ==> with

     characteristicPolynomial : (M,Symbol) -> P
       ++ characteristicPolynomial(m,var) returns the
       ++ characteristicPolynomial of the matrix m using
       ++ the symbol var as the main variable.

     characteristicPolynomial : M -> P
       ++ characteristicPolynomial(m) returns the
       ++ characteristicPolynomial of the matrix m using
       ++ a new generated symbol symbol as the main variable.

     eigenvalues : M -> List Eigenvalue
       ++ eigenvalues(m) returns the
       ++ eigenvalues of the matrix m which are expressible
       ++ as rational functions over the rational numbers.

     eigenvector : (Eigenvalue,M) -> List M
       ++ eigenvector(eigval,m) returns the
       ++ eigenvectors belonging to the eigenvalue eigval
       ++ for the matrix m.

     generalizedEigenvector : (Eigenvalue,M,NNI,NNI) -> List M
       ++ generalizedEigenvector(alpha,m,k,g)
       ++ returns the generalized eigenvectors
       ++ of the matrix relative to the eigenvalue alpha.
       ++ The integers k and g are respectively the algebraic and the
       ++ geometric multiplicity of tye eigenvalue alpha.
       ++ alpha can be either rational or not.
       ++ In the seconda case apha is the minimal polynomial of the
       ++ eigenvalue.

     generalizedEigenvector : (EigenForm,M) -> List M
       ++ generalizedEigenvector(eigen,m)
       ++ returns the generalized eigenvectors
       ++ of the matrix relative to the eigenvalue eigen, as 
       ++ returned by the function eigenvectors.

     generalizedEigenvectors : M -> List GenEigen
       ++ generalizedEigenvectors(m)
       ++ returns the generalized eigenvectors
       ++ of the matrix m.

     eigenvectors : M -> List(EigenForm)
       ++ eigenvectors(m) returns the eigenvalues and eigenvectors
       ++ for the matrix m.
       ++ The rational eigenvalues and the correspondent eigenvectors
       ++ are explicitely computed, while the non rational ones
       ++ are given via their minimal polynomial and the corresponding
       ++ eigenvectors are expressed in terms of a "generic" root of
       ++ such a polynomial.

  CODE ==> add

     PI       ==> PositiveInteger

     MF  := GeneralizedMultivariateFactorize(SE,IndexedExponents SE,R,R,P)
     UPCF2:= UnivariatePolynomialCategoryFunctions2(P,SUP,F,SUF)

                 ----  Local  Functions  ----
     tff              :  (SUF,SE)      ->  F
     fft              :  (SUF,SE)      ->  F
     charpol          :   (M,SE)       ->   F
     intRatEig        :  (F,M,NNI)    ->   List M
     intAlgEig        :  (ST,M,NNI)    ->   List M 
     genEigForm       : (EigenForm,M)  ->   GenEigen

    ---- next functions needed for defining  ModularField ----
     reduction(u:SUF,p:SUF):SUF == u rem p

     merge(p:SUF,q:SUF):Union(SUF,"failed") ==
         p = q => p
         p = 0 => q
         q = 0 => p
         "failed"

     exactquo(u:SUF,v:SUF,p:SUF):Union(SUF,"failed") ==
        val:=extendedEuclidean(v,p,u)
        val case "failed" => "failed"
        val.coef1

               ----  functions for conversions  ----
     fft(t:SUF,x:SE):F ==
       n:=degree(t)
       cf:=monomial(1,x,n)$P :: F
       cf * leadingCoefficient t

     tff(p:SUF,x:SE) : F ==
       degree p=0 => leadingCoefficient p
       r:F:=0$F
       while p^=0 repeat
         r:=r+fft(p,x)
         p := reductum p
       r

      ---- generalized eigenvectors associated to a given eigenvalue ---       
     genEigForm(eigen : EigenForm,A:M) : GenEigen ==
       alpha:=eigen.eigval
       k:=eigen.eigmult
       g:=#(eigen.eigvec)
       k = g  => [alpha,eigen.eigvec]
       [alpha,generalizedEigenvector(alpha,A,k,g)]

           ---- characteristic polynomial  ----
     charpol(A:M,x:SE) : F ==
       dimA :PI := (nrows A):PI
       dimA ^= ncols A => error " The matrix is not square"
       B:M:=zero(dimA,dimA)
       for i in 1..dimA repeat
         for j in 1..dimA repeat  B(i,j):=A(i,j)
         B(i,i) := B(i,i) - monomial(1$P,x,1)::F
       determinant B

          --------  EXPORTED  FUNCTIONS  --------
   
            ----  characteristic polynomial of a matrix A ----
     characteristicPolynomial(A:M):P ==
       x:SE:=new()$SE
       numer charpol(A,x)

            ----  characteristic polynomial of a matrix A ----
     characteristicPolynomial(A:M,x:SE) : P == numer charpol(A,x)
     
                ----  Eigenvalues of the matrix A  ----
     eigenvalues(A:M): List Eigenvalue  ==
       x:=new()$SE
       pol:= charpol(A,x)
       lrat:List F :=empty()
       lsym:List ST :=empty()
       for eq in solve(pol,x)$SystemSolvePackage(R) repeat
         alg:=numer lhs eq
         degree(alg, x)=1 => lrat:=cons(rhs eq,lrat)
         lsym:=cons([x,alg],lsym)
       append([lr::Eigenvalue for lr in lrat],
              [ls::Eigenvalue for ls in lsym])

          ----  Eigenvectors belonging to a given eigenvalue  ----
                ----  the eigenvalue must be exact  ----
     eigenvector(alpha:Eigenvalue,A:M) : List M  ==
       alpha case F => intRatEig(alpha::F,A,1$NNI)
       intAlgEig(alpha::ST,A,1$NNI)

   ----  Eigenvectors belonging to a given rational eigenvalue  ----
                ---- Internal function -----
     intRatEig(alpha:F,A:M,m:NNI) : List M  ==
       n:=nrows A
       B:M := zero(n,n)$M
       for i in 1..n repeat
         for j in 1..n repeat B(i,j):=A(i,j)
         B(i,i):= B(i,i) - alpha
       [v::M for v in nullSpace(B**m)]
   
   ----  Eigenvectors belonging to a given algebraic eigenvalue  ----
         ------   Internal  Function  -----
     intAlgEig(alpha:ST,A:M,m:NNI) : List M  ==
       n:=nrows A
       MM := ModularField(SUF,SUF,reduction,merge,exactquo)
       AM:=Matrix MM
       x:SE:=lhs alpha
       pol:SUF:=unitCanonical map(coerce,univariate(rhs alpha,x))$UPCF2
       alg:MM:=reduce(monomial(1,1),pol)
       B:AM := zero(n,n)
       for i in 1..n repeat
         for j in 1..n repeat B(i,j):=reduce(A(i,j)::SUF,pol)
         B(i,i):= B(i,i) - alg
       sol: List M :=empty()
       for vec in nullSpace(B**m) repeat
         w:M:=zero(n,1)
         for i in 1..n repeat w(i,1):=tff((vec.i)::SUF,x)
         sol:=cons(w,sol)
       sol

     ----  Generalized Eigenvectors belonging to a given eigenvalue  ----
     generalizedEigenvector(alpha:Eigenvalue,A:M,k:NNI,g:NNI) : List M  ==
       alpha case F => intRatEig(alpha::F,A,(1+k-g)::NNI)
       intAlgEig(alpha::ST,A,(1+k-g)::NNI)

     ----  Generalized Eigenvectors belonging to a given eigenvalue  ----
     generalizedEigenvector(eigen :EigenForm,A:M) : List M  ==
       generalizedEigenvector(eigen.eigval,A,eigen.eigmult,# eigen.eigvec)

          ----  Generalized Eigenvectors -----
     generalizedEigenvectors(A:M) : List GenEigen  ==
       n:= nrows A
       leig:=eigenvectors A
       [genEigForm(leg,A) for leg in leig]
         
                 ----  eigenvectors and eigenvalues  ----
     eigenvectors(A:M):List(EigenForm) ==
       n:=nrows A
       x:=new()$SE
       p:=numer charpol(A,x)
       MM := ModularField(SUF,SUF,reduction,merge,exactquo)
       AM:=Matrix(MM)
       ratSol : List EigenForm := empty()
       algSol : List EigenForm := empty()
       lff:=factors factor  p
       for fact in lff repeat
         pol:=fact.factor   
         degree(pol,x)=1 =>
           vec:F :=-coefficient(pol,x,0)/coefficient(pol,x,degree(pol,x))
           ratSol:=cons([vec,fact.exponent :: NNI,
                         intRatEig(vec,A,1$NNI)]$EigenForm,ratSol)
         alpha:ST:=[x,pol]     
         algSol:=cons([alpha,fact.exponent :: NNI,
                       intAlgEig(alpha,A,1$NNI)]$EigenForm,algSol)
       append(ratSol,algSol)