]> gitweb.factorcode.org Git - factor.git/blob - extra/math/blas/vectors/vectors-docs.factor
Merge branch 'master' into experimental (untested!)
[factor.git] / extra / math / blas / vectors / vectors-docs.factor
1 USING: alien byte-arrays help.markup help.syntax math sequences ;
2 IN: math.blas.vectors
3
4 ARTICLE: "math.blas.vectors" "BLAS interface vector operations"
5 "Slicing vectors:"
6 { $subsection Vsub }
7 "Taking the norm (magnitude) of a vector:"
8 { $subsection Vnorm }
9 "Summing and taking the maximum of elements:"
10 { $subsection Vasum }
11 { $subsection Viamax }
12 { $subsection Vamax }
13 "Scalar-vector products:"
14 { $subsection n*V! }
15 { $subsection n*V }
16 { $subsection V*n }
17 { $subsection V/n }
18 { $subsection Vneg }
19 "Vector addition:" 
20 { $subsection n*V+V! }
21 { $subsection n*V+V }
22 { $subsection V+ }
23 { $subsection V- }
24 "Vector inner products:"
25 { $subsection V. }
26 { $subsection V.conj } ;
27
28 ABOUT: "math.blas.vectors"
29
30 HELP: blas-vector-base
31 { $class-description "The base class for all BLAS vector types. Objects of this type should not be created directly; instead, instantiate one of the typed subclasses:"
32 { $list
33     { { $link float-blas-vector } }
34     { { $link double-blas-vector } }
35     { { $link float-complex-blas-vector } }
36     { { $link double-complex-blas-vector } }
37 }
38 "All of these subclasses share the same tuple layout:"
39 { $list
40     { { $snippet "underlying" } " contains an alien pointer referencing or byte-array containing a packed array of float, double, float complex, or double complex values;" }
41     { { $snippet "length" } " indicates the length of the vector;" }
42     { "and " { $snippet "inc" } " indicates the distance, in elements, between elements." }
43 } } ;
44
45 HELP: float-blas-vector
46 { $class-description "A vector of single-precision floating-point values. For details on the tuple layout, see " { $link blas-vector-base } "." } ;
47 HELP: double-blas-vector
48 { $class-description "A vector of double-precision floating-point values. For details on the tuple layout, see " { $link blas-vector-base } "." } ;
49 HELP: float-complex-blas-vector
50 { $class-description "A vector of single-precision floating-point complex values. Complex values are stored in memory as two consecutive float values, real part then imaginary part. For details on the tuple layout, see " { $link blas-vector-base } "." } ;
51 HELP: double-complex-blas-vector
52 { $class-description "A vector of single-precision floating-point complex values. Complex values are stored in memory as two consecutive float values, real part then imaginary part. For details on the tuple layout, see " { $link blas-vector-base } "." } ;
53
54 HELP: n*V+V!
55 { $values { "alpha" number } { "x" blas-vector-base } { "y" blas-vector-base } { "y=alpha*x+y" blas-vector-base } }
56 { $description "Calculate the vector sum " { $snippet "αx + y" } " and replace the existing contents of y with the result. Corresponds to the xAXPY routines in BLAS." }
57 { $side-effects "y" } ;
58
59 HELP: n*V!
60 { $values { "alpha" number } { "x" blas-vector-base } { "x=alpha*x" blas-vector-base } }
61 { $description "Calculate the scalar-vector product " { $snippet "αx" } " and replace the existing contents of x with the result. Corresponds to the xSCAL routines in BLAS." }
62 { $side-effects "x" } ;
63
64 HELP: V.
65 { $values { "x" blas-vector-base } { "y" blas-vector-base } { "x.y" number } }
66 { $description "Calculate the inner product " { $snippet "x⋅y" } ". Corresponds to the xDOT and xDOTU routines in BLAS." } ;
67
68 HELP: V.conj
69 { $values { "x" blas-vector-base } { "y" blas-vector-base } { "xconj.y" number } }
70 { $description "Calculate the conjugate inner product " { $snippet "x̅⋅y" } ". Corresponds to the xDOTC routines in BLAS." } ;
71
72 HELP: Vnorm
73 { $values { "x" blas-vector-base } { "norm" number } }
74 { $description "Calculate the norm-2, i.e., the magnitude or absolute value, of " { $snippet "x" } " (" { $snippet "‖x‖₂" } "). Corresponds to the xNRM2 routines in BLAS." } ;
75
76 HELP: Vasum
77 { $values { "x" blas-vector-base } { "sum" number } }
78 { $description "Calculate the sum of the norm-1s of the elements of " { $snippet "x" } " (" { $snippet "Σ ‖xᵢ‖₁" } "). Corresponds to the xASUM routines in BLAS." } ;
79
80 HELP: Vswap
81 { $values { "x" blas-vector-base } { "y" blas-vector-base } { "x=y" blas-vector-base } { "y=x" blas-vector-base } }
82 { $description "Swap the contents of " { $snippet "x" } " and " { $snippet "y" } " in place. Corresponds to the xSWAP routines in BLAS." }
83 { $side-effects "x" "y" } ;
84
85 HELP: Viamax
86 { $values { "x" blas-vector-base } { "max-i" integer } }
87 { $description "Return the index of the element in " { $snippet "x" } " with the largest norm-1. If more than one element has the same norm-1, returns the smallest index. Corresponds to the IxAMAX routines in BLAS." } ;
88
89 HELP: Vamax
90 { $values { "x" blas-vector-base } { "max" number } }
91 { $description "Return the value of the element in " { $snippet "x" } " with the largest norm-1. If more than one element has the same norm-1, returns the first element. Corresponds to the IxAMAX routines in BLAS." } ;
92
93 { Viamax Vamax } related-words
94
95 HELP: <zero-vector>
96 { $values { "exemplar" blas-vector-base } { "zero" blas-vector-base } }
97 { $description "Return a vector of zeros with the same length and element type as " { $snippet "v" } ". The vector is constructed with an " { $snippet "inc" } " of zero, so it is not suitable for receiving results from BLAS functions; it is intended to be used as a term in other vector calculations. To construct an empty vector that can be used to receive results, see " { $link <empty-vector> } "." } ;
98
99 HELP: n*V+V
100 { $values { "alpha" number } { "x" blas-vector-base } { "y" blas-vector-base } { "alpha*x+y" blas-vector-base } }
101 { $description "Calculate the vector sum " { $snippet "αx + y" } " and return a freshly-allocated vector with the same length as " { $snippet "x" } " and " { $snippet "y" } " containing the result. Corresponds to the xAXPY routines in BLAS." } ;
102
103 HELP: n*V
104 { $values { "alpha" "a number" } { "x" blas-vector-base } { "alpha*x" blas-vector-base } }
105 { $description "Calculate the scalar-vector product " { $snippet "αx" } " and return a freshly-allocated vector with the same length as " { $snippet "x" } " containing the result. Corresponds to the xSCAL routines in BLAS." } ;
106
107 HELP: V+
108 { $values { "x" blas-vector-base } { "y" blas-vector-base } { "x+y" blas-vector-base } }
109 { $description "Calculate the vector sum " { $snippet "x + y" } " and return a freshly-allocated vector with the same length as " { $snippet "x" } " and " { $snippet "y" } " containing the result. Corresponds to the xAXPY routines in BLAS." } ;
110
111 HELP: V-
112 { $values { "x" blas-vector-base } { "y" blas-vector-base } { "x-y" blas-vector-base } }
113 { $description "Calculate the vector difference " { $snippet "x – y" } " and return a freshly-allocated vector with the same length as " { $snippet "x" } " and " { $snippet "y" } " containing the result. Corresponds to the xAXPY routines in BLAS." } ;
114
115 HELP: Vneg
116 { $values { "x" blas-vector-base } { "-x" blas-vector-base } }
117 { $description "Negate the elements of " { $snippet "x" } " and return a freshly-allocated vector with the same length as " { $snippet "x" } " containing the result." } ;
118
119 HELP: V*n
120 { $values { "x" blas-vector-base } { "alpha" number } { "x*alpha" blas-vector-base } }
121 { $description "Calculate the scalar-vector product " { $snippet "αx" } " and return a freshly-allocated vector with the same length as " { $snippet "x" } " containing the result. Corresponds to the xSCAL routines in BLAS." } ;
122
123 HELP: V/n
124 { $values { "x" blas-vector-base } { "alpha" number } { "x/alpha" blas-vector-base } }
125 { $description "Calculate the scalar-vector product " { $snippet "(1/α)x" } " and return a freshly-allocated vector with the same length as " { $snippet "x" } " containing the result. Corresponds to the xSCAL routines in BLAS." } ;
126
127 { n*V+V! n*V! n*V+V n*V V+ V- Vneg V*n V/n } related-words
128
129 HELP: Vsub
130 { $values { "v" blas-vector-base } { "start" integer } { "length" integer } { "sub" blas-vector-base } }
131 { $description "Slice a subvector out of " { $snippet "v" } " starting at " { $snippet "start" } " with the given " { $snippet "length" } ". The subvector will share storage with the parent vector." } ;