/usr/share/axiom-20170501/src/algebra/COMPLEX.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 | )abbrev domain COMPLEX Complex
++ Author: Mark Botch
++ References:
++ Corl00 According to Abramowitz and Stegun or arccoth needn't be Uncouth
++ Fate01a A Critique of OpenMath and Thoughts on Encoding Mathematics
++ Description:
++ \spadtype{Complex(R)} creates the domain of elements of the form
++ \spad{a + b * i} where \spad{a} and b come from the ring R,
++ and i is a new element such that \spad{i**2 = -1}.
Complex(R) : SIG == CODE where
R : CommutativeRing
SIG ==> ComplexCategory(R) with
if R has OpenMath then OpenMath
CODE ==> add
Rep := Record(real:R, imag:R)
if R has OpenMath then
writeOMComplex(dev: OpenMathDevice, x: %): Void ==
OMputApp(dev)
OMputSymbol(dev, "complex1", "complex__cartesian")
OMwrite(dev, real x)
OMwrite(dev, imag x)
OMputEndApp(dev)
OMwrite(x: %): String ==
s: String := ""
sp := OM_-STRINGTOSTRINGPTR(s)$Lisp
dev: OpenMathDevice := OMopenString(sp pretend String, OMencodingXML)
OMputObject(dev)
writeOMComplex(dev, x)
OMputEndObject(dev)
OMclose(dev)
s := OM_-STRINGPTRTOSTRING(sp)$Lisp pretend String
s
OMwrite(x: %, wholeObj: Boolean): String ==
s: String := ""
sp := OM_-STRINGTOSTRINGPTR(s)$Lisp
dev: OpenMathDevice := OMopenString(sp pretend String, OMencodingXML)
if wholeObj then
OMputObject(dev)
writeOMComplex(dev, x)
if wholeObj then
OMputEndObject(dev)
OMclose(dev)
s := OM_-STRINGPTRTOSTRING(sp)$Lisp pretend String
s
OMwrite(dev: OpenMathDevice, x: %): Void ==
OMputObject(dev)
writeOMComplex(dev, x)
OMputEndObject(dev)
OMwrite(dev: OpenMathDevice, x: %, wholeObj: Boolean): Void ==
if wholeObj then
OMputObject(dev)
writeOMComplex(dev, x)
if wholeObj then
OMputEndObject(dev)
0 == [0, 0]
1 == [1, 0]
zero? x == zero?(x.real) and zero?(x.imag)
one? x == ((x.real) = 1) and zero?(x.imag)
coerce(r:R):% == [r, 0]
complex(r, i) == [r, i]
real x == x.real
imag x == x.imag
x + y == [x.real + y.real, x.imag + y.imag]
-- by re-defining this here, we save 5 fn calls
x:% * y:% ==
[x.real * y.real - x.imag * y.imag,
x.imag * y.real + y.imag * x.real] -- here we save nine!
if R has IntegralDomain then
_exquo(x:%, y:%) == -- to correct bad defaulting problem
zero? y.imag => x exquo y.real
x * conjugate(y) exquo norm(y)
|