/usr/share/axiom-20170501/src/algebra/VECTCAT.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 | )abbrev category VECTCAT VectorCategory
++ Description:
++ \spadtype{VectorCategory} represents the type of vector like objects,
++ that is, finite sequences indexed by some finite segment of the
++ integers. The operations available on vectors depend on the structure
++ of the underlying components. Many operations from the component domain
++ are defined for vectors componentwise. It can by assumed that extraction or
++ updating components can be done in constant time.
VectorCategory(R) : Category == SIG where
R : Type
SIG ==> OneDimensionalArrayAggregate R with
if R has AbelianSemiGroup then
_+ : (%, %) -> %
++ x + y returns the component-wise sum of the vectors x and y.
++ Error: if x and y are not of the same length.
if R has AbelianMonoid then
zero : NonNegativeInteger -> %
++ zero(n) creates a zero vector of length n.
if R has AbelianGroup then
_- : % -> %
++ -x negates all components of the vector x.
_- : (%, %) -> %
++ x - y returns the component-wise difference of the vectors x and y.
++ Error: if x and y are not of the same length.
_* : (Integer, %) -> %
++ n * y multiplies each component of the vector y by the integer n.
if R has Monoid then
_* : (R, %) -> %
++ r * y multiplies the element r times each component of the vector y.
_* : (%, R) -> %
++ y * r multiplies each component of the vector y by the element r.
if R has Ring then
dot : (%, %) -> R
++ dot(x,y) computes the inner product of the two vectors x and y.
++ Error: if x and y are not of the same length.
outerProduct : (%, %) -> Matrix R
++ outerProduct(u,v) constructs the matrix whose (i,j)'th element is
++ u(i)*v(j).
cross : (%, %) -> %
++ cross(u,v) constructs the cross product of u and v.
++ Error: if u and v are not of length 3.
if R has RadicalCategory and R has Ring then
length : % -> R
++ length(v) computes the sqrt(dot(v,v)), that is, the magnitude
magnitude : % -> R
++ magnitude(v) computes the sqrt(dot(v,v)), that is, the length
add
if R has AbelianSemiGroup then
u + v ==
(n := #u) ^= #v => error "Vectors must be of the same length"
map(_+ , u, v)
if R has AbelianMonoid then
zero n == new(n, 0)
if R has AbelianGroup then
- u == map(x +-> -x, u)
n:Integer * u:% == map(x +-> n * x, u)
u - v == u + (-v)
if R has Monoid then
u:% * r:R == map(x +-> x * r, u)
r:R * u:% == map(x +-> r * x, u)
if R has Ring then
dot(u, v) ==
#u ^= #v => error "Vectors must be of the same length"
_+/[qelt(u, i) * qelt(v, i) for i in minIndex u .. maxIndex u]
outerProduct(u, v) ==
matrix [[qelt(u, i) * qelt(v,j) for i in minIndex u .. maxIndex u] _
for j in minIndex v .. maxIndex v]
cross(u, v) ==
#u ^= 3 or #v ^= 3 => error "Vectors must be of length 3"
construct [qelt(u, 2)*qelt(v, 3) - qelt(u, 3)*qelt(v, 2) , _
qelt(u, 3)*qelt(v, 1) - qelt(u, 1)*qelt(v, 3) , _
qelt(u, 1)*qelt(v, 2) - qelt(u, 2)*qelt(v, 1) ]
if R has RadicalCategory and R has Ring then
length p ==
sqrt(dot(p,p))
magnitude p ==
sqrt(dot(p,p))
|