This file is indexed.

/usr/share/axiom-20170501/src/algebra/QUATCAT.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
)abbrev category QUATCAT QuaternionCategory
++ Author: Robert S. Sutor
++ Date Created: 23 May 1990
++ Change History:  10 September 1990
++ Description:
++ \spadtype{QuaternionCategory} describes the category of quaternions
++ and implements functions that are not representation specific.
 
QuaternionCategory(R) : Category == SIG where
  R : CommutativeRing

  AL    ==> Algebra(R)
  FRT   ==> FullyRetractableTo(R)
  DE    ==> DifferentialExtension(R)
  FEO   ==> FullyEvalableOver(R)
  FLERO ==> FullyLinearlyExplicitRingOver(R)

  SIG ==> Join(AL,FRT,DE,FEO,FLERO) with
 
    conjugate : $ -> $
      ++ conjugate(q) negates the imaginary parts of quaternion \spad{q}.

    imagI : $ -> R
      ++ imagI(q) extracts the imaginary i part of quaternion \spad{q}.

    imagJ : $ -> R
      ++ imagJ(q) extracts the imaginary j part of quaternion \spad{q}.

    imagK : $ -> R
      ++ imagK(q) extracts the imaginary k part of quaternion \spad{q}.

    norm : $ -> R
      ++ norm(q) computes the norm of \spad{q} (the sum of the
      ++ squares of the components).

    quatern : (R,R,R,R) -> $
      ++ quatern(r,i,j,k) constructs a quaternion from scalars.

    real : $ -> R
      ++ real(q) extracts the real part of quaternion \spad{q}.
 
    if R has EntireRing then EntireRing

    if R has OrderedSet then OrderedSet

    if R has Field then DivisionRing

    if R has ConvertibleTo InputForm then ConvertibleTo InputForm

    if R has CharacteristicZero then CharacteristicZero

    if R has CharacteristicNonZero then CharacteristicNonZero

    if R has RealNumberSystem then

      abs : $ -> R
        ++ abs(q) computes the absolute value of quaternion \spad{q}
        ++ (sqrt of norm).

    if R has IntegerNumberSystem then

      rational? : $ -> Boolean
        ++ rational?(q) returns {\it true} if all the imaginary
        ++ parts of \spad{q} are zero and the real part can be
        ++ converted into a rational number, and {\it false}
        ++ otherwise.

      rational : $ -> Fraction Integer
        ++ rational(q) tries to convert \spad{q} into a
        ++ rational number. Error: if this is not
        ++ possible. If \spad{rational?(q)} is true, the
        ++ conversion will be done and the rational number returned.

      rationalIfCan : $ -> Union(Fraction Integer, "failed")
        ++ rationalIfCan(q) returns \spad{q} as a rational number,
        ++ or "failed" if this is not possible.
        ++ Note that if \spad{rational?(q)} is true, the conversion
        ++ can be done and the rational number will be returned.
 
   add
 
     characteristic() ==
       characteristic()$R

     conjugate x      ==
       quatern(real x, - imagI x, - imagJ x, - imagK x)

     map(fn, x)       ==
       quatern(fn real x, fn imagI x, fn imagJ x, fn imagK x)

     norm x ==
       real x * real x + imagI x * imagI x +
         imagJ x * imagJ x + imagK x * imagK x

     x = y ==
       (real x = real y) and (imagI x = imagI y) and
         (imagJ x = imagJ y) and (imagK x = imagK y)

     x + y ==
       quatern(real x + real y, imagI x + imagI y,
         imagJ x + imagJ y, imagK x + imagK y)

     x - y ==
       quatern(real x - real y, imagI x - imagI y,
         imagJ x - imagJ y, imagK x - imagK y)

     - x ==
       quatern(- real x, - imagI x, - imagJ x, - imagK x)

     r:R * x:$ ==
       quatern(r * real x, r * imagI x, r * imagJ x, r * imagK x)

     n:Integer * x:$  ==
       quatern(n * real x, n * imagI x, n * imagJ x, n * imagK x)

     differentiate(x:$, d:R -> R) ==
       quatern(d real x, d imagI x, d imagJ x, d imagK x)

     coerce(r:R) ==
       quatern(r,0$R,0$R,0$R)

     coerce(n:Integer) ==
       quatern(n :: R,0$R,0$R,0$R)

     one? x ==
       (real x) = 1 and zero? imagI x and
         zero? imagJ x and zero? imagK x

     zero? x ==
       zero? real x and zero? imagI x and
         zero? imagJ x and zero? imagK x

     retract(x):R ==
       not (zero? imagI x and zero? imagJ x and zero? imagK x) =>
         error "Cannot retract quaternion."
       real x

     retractIfCan(x):Union(R,"failed") ==
       not (zero? imagI x and zero? imagJ x and zero? imagK x) =>
         "failed"
       real x
 
     coerce(x:$):OutputForm ==
       part,z : OutputForm
       y : $
       zero? x => (0$R) :: OutputForm
       not zero?(real x) =>
         y := quatern(0$R,imagI(x),imagJ(x),imagK(x))
         zero? y => real(x) :: OutputForm
         (real(x) :: OutputForm) + (y :: OutputForm)
       -- we know that the real part is 0
       not zero?(imagI(x)) =>
         y := quatern(0$R,0$R,imagJ(x),imagK(x))
         z :=
           part := "i"::Symbol::OutputForm
           (imagI(x) = 1) => part
           (imagI(x) :: OutputForm) * part
         zero? y => z
         z + (y :: OutputForm)
       -- we know that the real part and i part are 0
       not zero?(imagJ(x)) =>
         y := quatern(0$R,0$R,0$R,imagK(x))
         z :=
           part := "j"::Symbol::OutputForm
           (imagJ(x) = 1) => part
           (imagJ(x) :: OutputForm) * part
         zero? y => z
         z + (y :: OutputForm)
       -- we know that the real part and i and j parts are 0
       part := "k"::Symbol::OutputForm
       (imagK(x) = 1) => part
       (imagK(x) :: OutputForm) * part

     if R has Field then

       inv x ==
         norm x = 0 => error "This quaternion is not invertible."
         (inv norm x) * conjugate x
 
     if R has ConvertibleTo InputForm then

       convert(x:$):InputForm ==
         l : List InputForm := [convert("quatern" :: Symbol),
           convert(real x)$R, convert(imagI x)$R, convert(imagJ x)$R,
             convert(imagK x)$R]
         convert(l)$InputForm
 
     if R has OrderedSet then

       x < y ==
         real x = real y =>
           imagI x = imagI y =>
             imagJ x = imagJ y =>
               imagK x < imagK y
             imagJ x < imagJ y
           imagI x < imagI y
         real x < real y
 
     if R has RealNumberSystem then

       abs x == sqrt norm x
 
     if R has IntegerNumberSystem then

       rational? x ==
         (zero? imagI x) and (zero? imagJ x) and (zero? imagK x)

       rational  x ==
         rational? x => rational real x
         error "Not a rational number"

       rationalIfCan x ==
         rational? x => rational real x
         "failed"