]> gitweb.factorcode.org Git - factor.git/blob - basis/math/vectors/vectors-docs.factor
Merge branch 'klazuka'
[factor.git] / basis / math / vectors / vectors-docs.factor
1 USING: help.markup help.syntax math math.functions sequences ;
2 IN: math.vectors
3
4 ARTICLE: "math-vectors-arithmetic" "Vector arithmetic"
5 "Vector/vector binary operations:"
6 { $subsections
7     v+
8     v-
9     v+-
10     v*
11     v/
12 }
13 "Vector unary operations:"
14 { $subsections
15     vneg
16     vabs
17     vsqrt
18     vfloor
19     vceiling
20     vtruncate
21 }
22 "Vector/scalar and scalar/vector binary operations:"
23 { $subsections
24     vneg
25     v*n
26     n*v
27     v/n
28     n/v
29     v+n
30     n+v
31     v-n
32     n-v
33 }
34 "Saturated arithmetic (only on " { $link "specialized-arrays" } "):"
35 { $subsections
36     vs+
37     vs-
38     vs*
39 }
40 "Inner product and norm:"
41 { $subsections
42     v.
43     norm
44     norm-sq
45     normalize
46 }
47 "Comparing entire vectors:"
48 { $subsections
49     distance
50     v~
51 } ;
52
53 ARTICLE: "math-vectors-shuffle" "Vector shuffling, packing, and unpacking"
54 { $notes
55 "These operations are primarily meant to be used with " { $vocab-link "math.vectors.simd" } " types. The software fallbacks for types not supported by hardware will not perform well."
56 }
57 $nl
58 { $subsection vshuffle }
59 { $subsection vbroadcast }
60 { $subsection hlshift } 
61 { $subsection hrshift } ;
62
63 ARTICLE: "math-vectors-logic" "Vector component- and bit-wise logic"
64 { $notes
65 "See " { $link "math-vectors-simd-logic" } " for notes about using comparison and logical operations with SIMD vector types."
66 }
67 $nl
68 "Element comparisons:"
69 { $subsections
70     v<
71     v<=
72     v=
73     v>=
74     v>
75     vunordered?
76     vmax
77     vmin
78     vsupremum
79     vinfimum
80 }
81 "Bitwise operations:"
82 { $subsections
83     vbitand
84     vbitandn
85     vbitor
86     vbitxor
87     vbitnot
88     vlshift
89     vrshift
90 }
91 "Element logical operations:"
92 { $subsections
93     vand
94     vandn
95     vor
96     vxor
97     vnot
98     v?
99 }
100 "Entire vector tests:"
101 { $subsections
102     vall?
103     vany?
104     vnone?
105 }
106 "Element shuffling:"
107 { $subsections vshuffle } ;
108
109 ARTICLE: "math-vectors-misc" "Miscellaneous vector functions"
110 { $subsections
111     trilerp
112     bilerp
113     vlerp
114     vnlerp
115     vbilerp
116 } ;
117
118 ARTICLE: "math-vectors-simd-logic" "Componentwise logic with SIMD vectors"
119 "Processor SIMD units supported by the " { $vocab-link "math.vectors.simd" } " vocabulary represent boolean values as bitmasks, where a true result's binary representation is all ones and a false representation is all zeroes. This is the format in which results from comparison words such as " { $link v= } " return their results and in which logic and test words such as " { $link vand } " and " { $link vall? } " take their inputs when working with SIMD types. For a float vector, false will manifest itself as " { $snippet "0.0" } " and true as a " { $link POSTPONE: NAN: } " literal with a string of set bits in its payload:"
120 { $example
121 """USING: math.vectors math.vectors.simd prettyprint ;
122 FROM: alien.c-types => float ;
123 SIMD: float
124
125 float-4{ 1.0 2.0 3.0 0/0. } float-4{ 1.0 -2.0 3.0 0/0. } v= ."""
126 """float-4{ NAN: fffffe0000000 0.0 NAN: fffffe0000000 0.0 }"""
127 }
128 "For an integer vector, false will manifest as " { $snippet "0" } " and true as " { $snippet "-1" } " (for signed vectors) or the largest representable value of the element type (for unsigned vectors):"
129 { $example
130 """USING: math.vectors math.vectors.simd prettyprint alien.c-types ;
131 SIMD: int
132 SIMD: uchar
133
134 int-4{ 1 2 3 0 } int-4{ 1 -2 3 4 } v=
135 uchar-16{  0  1  2  3  4  5 6 7 8 9 10 11 12 13 14 15 }
136 uchar-16{ 15 14 13 12 11 10 9 8 7 6  5  4  3  2  1  0 } v<
137 [ . ] bi@"""
138 """int-4{ -1 0 -1 0 }
139 uchar-16{ 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 }"""
140 }
141 "This differs from Factor's native representation of boolean values, where " { $link f } " is false and every other value (including " { $snippet "0" } " and " { $snippet "0.0" } ") is true. To make it easy to construct literal SIMD masks, " { $link t } " and " { $link f } " are accepted inside SIMD literal syntax and expand to the proper true or false representation for the underlying type:"
142 { $example
143 """USING: math.vectors math.vectors.simd prettyprint alien.c-types ;
144 SIMD: int
145
146 int-4{ f f t f } ."""
147 """int-4{ 0 0 -1 0 }""" }
148 "However, extracting an element from a boolean SIMD vector with " { $link nth } " will not yield a valid Factor boolean. This is not generally a problem, since the results of vector comparisons are meant to be consumed by subsequent vector logical and test operations, which will accept SIMD values in the native boolean format."
149 $nl
150 "Providing a SIMD boolean vector with element values other than the proper true and false representations as an input to the vector logical or test operations is undefined. Do not count on operations such as " { $link vall? } " or " { $link v? } " using bitwise operations to construct their results."
151 $nl
152 "This applies to the output of the following element comparison words: "
153 { $list
154 { $link v< }
155 { $link v<= }
156 { $link v= }
157 { $link v>= }
158 { $link v> }
159 { $link vunordered? }
160 }
161 "This likewise applies to the " { $snippet "mask" } " argument of " { $link v? } " and to the inputs and outputs of the following element logic words:"
162 { $list
163 { $link vand }
164 { $link vandn }
165 { $link vor }
166 { $link vxor }
167 { $link vnot }
168 }
169 "Finally, this applies to the inputs of these vector test words:"
170 { $list
171 { $link vall? }
172 { $link vany? }
173 { $link vnone? }
174 } ;
175
176 ARTICLE: "math-vectors" "Vector operations"
177 "Any Factor sequence can be used to represent a mathematical vector, however for best performance, the sequences defined by the " { $vocab-link "specialized-arrays" } " and " { $vocab-link "math.vectors.simd" } " vocabularies should be used."
178 { $subsections
179     "math-vectors-arithmetic"
180     "math-vectors-logic"
181     "math-vectors-shuffle"
182     "math-vectors-misc"
183 } ;
184
185 ABOUT: "math-vectors"
186
187 HELP: vneg
188 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } }
189 { $description "Negates each element of " { $snippet "u" } "." } ;
190
191 HELP: vabs
192 { $values { "u" "a sequence of numbers" } { "v" "a sequence of non-negative real numbers" } }
193 { $description "Takes the absolute value of each element of " { $snippet "u" } "." } ;
194
195 HELP: vsqrt
196 { $values { "u" "a sequence of non-negative real numbers" } { "v" "a sequence of non-negative real numbers" } }
197 { $description "Takes the square root of each element of " { $snippet "u" } "." }
198 { $warning "For performance reasons, this does not work with negative inputs, unlike " { $link sqrt } "." } ;
199
200 HELP: vfloor
201 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } }
202 { $description "Takes the " { $link floor } " of each element of " { $snippet "u" } "." } ;
203
204 HELP: vceiling
205 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } }
206 { $description "Takes the " { $link ceiling } " of each element of " { $snippet "u" } "." } ;
207
208 HELP: vtruncate
209 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } }
210 { $description "Truncates each element of " { $snippet "u" } "." } ;
211
212 HELP: n+v
213 { $values { "n" "a number" } { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } }
214 { $description "Adds " { $snippet "n" } " to each element of " { $snippet "u" } "." } ;
215
216 HELP: v+n
217 { $values { "u" "a sequence of numbers" } { "n" "a number" } { "v" "a sequence of numbers" } }
218 { $description "Adds " { $snippet "n" } " to each element of " { $snippet "u" } "." } ;
219
220 HELP: n-v
221 { $values { "n" "a number" } { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } }
222 { $description "Subtracts each element of " { $snippet "u" } " from " { $snippet "n" } "." } ;
223
224 HELP: v-n
225 { $values { "u" "a sequence of numbers" } { "n" "a number" } { "v" "a sequence of numbers" } }
226 { $description "Subtracts " { $snippet "n" } " from each element of " { $snippet "u" } "." } ;
227
228 HELP: n*v
229 { $values { "n" "a number" } { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } }
230 { $description "Multiplies each element of " { $snippet "u" } " by " { $snippet "n" } "." } ;
231
232 HELP: v*n
233 { $values { "u" "a sequence of numbers" } { "n" "a number" } { "v" "a sequence of numbers" } }
234 { $description "Multiplies each element of " { $snippet "u" } " by " { $snippet "n" } "." } ;
235
236 HELP: n/v
237 { $values { "n" "a number" } { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } }
238 { $description "Divides " { $snippet "n" } " by each element of " { $snippet "u" } "." }
239 { $errors "May throw an error if a division by zero occurs; see " { $link "division-by-zero" } "." } ;
240
241 HELP: v/n
242 { $values { "u" "a sequence of numbers" } { "n" "a number" } { "v" "a sequence of numbers" } }
243 { $description "Divides each element of " { $snippet "u" } " by " { $snippet "n" } "." }
244 { $errors "May throw an error if a division by zero occurs; see " { $link "division-by-zero" } "." } ;
245
246 HELP: v+
247 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
248 { $description "Adds " { $snippet "u" } " and " { $snippet "v" } " component-wise." } ;
249
250 HELP: v-
251 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
252 { $description "Subtracts " { $snippet "v" } " from " { $snippet "u" } " component-wise." } ;
253
254 HELP: v+-
255 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
256 { $description "Adds and subtracts alternate elements of " { $snippet "v" } " and " { $snippet "u" } " component-wise." }
257 { $examples
258     { $example
259         "USING: math.vectors prettyprint ;"
260         "{ 1 2 3 } { 2 3 2 } v+- ."
261         "{ -1 5 1 }"
262     }
263 } ;
264
265 HELP: [v-]
266 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } }
267 { $description "Subtracts " { $snippet "v" } " from " { $snippet "u" } " component-wise; any components which become negative are set to zero." } ;
268
269 HELP: v*
270 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
271 { $description "Multiplies " { $snippet "u" } " and " { $snippet "v" } " component-wise." } ;
272
273 HELP: v/
274 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
275 { $description "Divides " { $snippet "u" } " by " { $snippet "v" } " component-wise." }
276 { $errors "May throw an error if a division by zero occurs; see " { $link "division-by-zero" } "." } ;
277
278 HELP: vmax
279 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } }
280 { $description "Creates a sequence where each element is the maximum of the corresponding elements from " { $snippet "u" } " and " { $snippet "v" } "." }
281 { $examples { $example "USING: math.vectors prettyprint ;" "{ 1 2 5 } { -7 6 3 } vmax ." "{ 1 6 5 }" } } ;
282
283 HELP: vmin
284 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } }
285 { $description "Creates a sequence where each element is the minimum of the corresponding elements from " { $snippet "u" } " and " { $snippet "v" } "." }
286 { $examples { $example "USING: math.vectors prettyprint ;" "{ 1 2 5 } { -7 6 3 } vmin ." "{ -7 2 3 }" } } ;
287
288 HELP: v.
289 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "x" "a real number" } }
290 { $description "Computes the dot product of two vectors." } ;
291
292 HELP: vs+
293 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
294 { $description "Adds " { $snippet "u" } " and " { $snippet "v" } " component-wise with saturation." }
295 { $examples
296     "With saturation:"
297     { $example
298         "USING: alien.c-types math.vectors prettyprint specialized-arrays ;"
299         "SPECIALIZED-ARRAY: uchar"
300         "uchar-array{ 100 200 150 } uchar-array{ 70 70 70 } vs+ ."
301         "uchar-array{ 170 255 220 }"
302     }
303     "Without saturation:"
304     { $example
305         "USING: alien.c-types math.vectors prettyprint specialized-arrays ;"
306         "SPECIALIZED-ARRAY: uchar"
307         "uchar-array{ 100 200 150 } uchar-array{ 70 70 70 } v+ ."
308         "uchar-array{ 170 14 220 }"
309     }
310 } ;
311
312 HELP: vs-
313 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
314 { $description "Subtracts " { $snippet "v" } " from " { $snippet "u" } " component-wise with saturation." } ;
315
316 HELP: vs*
317 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
318 { $description "Multiplies " { $snippet "u" } " and " { $snippet "v" } " component-wise with saturation." } ;
319
320 HELP: vbitand
321 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } }
322 { $description "Takes the bitwise and of " { $snippet "u" } " and " { $snippet "v" } " component-wise." }
323 { $notes "Unlike " { $link bitand } ", this word may be used on a specialized array of floats or doubles, in which case the bitwise representation of the floating point numbers is operated upon." } ;
324
325 HELP: vbitandn
326 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } }
327 { $description "Takes the bitwise and-not of " { $snippet "u" } " and " { $snippet "v" } " component-wise, where " { $snippet "x and-not y" } " is defined as " { $snippet "not(x) and y" } "." }
328 { $notes "This word may be used on a specialized array of floats or doubles, in which case the bitwise representation of the floating point numbers is operated upon." } ;
329
330 HELP: vbitor
331 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } }
332 { $description "Takes the bitwise or of " { $snippet "u" } " and " { $snippet "v" } " component-wise." }
333 { $notes "Unlike " { $link bitor } ", this word may be used on a specialized array of floats or doubles, in which case the bitwise representation of the floating point numbers is operated upon." } ;
334
335 HELP: vbitxor
336 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } }
337 { $description "Takes the bitwise exclusive or of " { $snippet "u" } " and " { $snippet "v" } " component-wise." }
338 { $notes "Unlike " { $link bitxor } ", this word may be used on a specialized array of floats or doubles, in which case the bitwise representation of the floating point numbers is operated upon." } ;
339
340 HELP: vlshift
341 { $values { "u" "a sequence of integers" } { "n" "a non-negative integer" } { "w" "a sequence of integers" } }
342 { $description "Shifts each element of " { $snippet "u" } " to the left by " { $snippet "n" } " bits." }
343 { $notes "Undefined behavior will result if " { $snippet "n" } " is negative." } ;
344
345 HELP: vrshift
346 { $values { "u" "a sequence of integers" } { "n" "a non-negative integer" } { "w" "a sequence of integers" } }
347 { $description "Shifts each element of " { $snippet "u" } " to the right by " { $snippet "n" } " bits." }
348 { $notes "Undefined behavior will result if " { $snippet "n" } " is negative." } ;
349
350 HELP: hlshift
351 { $values { "u" "a SIMD array" } { "n" "a non-negative integer" } { "w" "a SIMD array" } }
352 { $description "Shifts the entire SIMD array to the left by " { $snippet "n" } " bytes, filling the vacated right-hand bits with zeroes. This word may only be used in a context where the compiler can statically infer that the input is a SIMD array." } ;
353
354 HELP: hrshift
355 { $values { "u" "a SIMD array" } { "n" "a non-negative integer" } { "w" "a SIMD array" } }
356 { $description "Shifts the entire SIMD array to the right by " { $snippet "n" } " bytes, filling the vacated left-hand bits with zeroes. This word may only be used in a context where the compiler can statically infer that the input is a SIMD array." } ;
357
358 HELP: vbroadcast
359 { $values { "u" "a SIMD array" } { "n" "a non-negative integer" } { "v" "a SIMD array" } }
360 { $description "Outputs a new SIMD array of the same type as " { $snippet "u" } " where every element is equal to the " { $snippet "n" } "th element of " { $snippet "u" } "." }
361 { $examples
362     { $example
363         "USING: alien.c-types math.vectors math.vectors.simd" "prettyprint ;"
364         "SIMD: int"
365         "int-4{ 69 42 911 13 } 2 vbroadcast ."
366         "int-4{ 911 911 911 911 }"
367     }
368 } ;
369
370 HELP: vshuffle
371 { $values { "u" "a SIMD array" } { "perm" "an array of integers" } { "v" "a SIMD array" } }
372 { $description "Permutes the elements of a SIMD array. Duplicate entries are allowed in the permutation." }
373 { $examples
374     { $example
375         "USING: alien.c-types math.vectors math.vectors.simd" "prettyprint ;"
376         "SIMD: int"
377         "int-4{ 69 42 911 13 } { 1 3 2 3 } vshuffle ."
378         "int-4{ 42 13 911 13 }"
379     }
380 } ;
381
382 HELP: norm-sq
383 { $values { "v" "a sequence of numbers" } { "x" "a non-negative real number" } }
384 { $description "Computes the squared length of a mathematical vector." } ;
385
386 HELP: norm
387 { $values { "v" "a sequence of numbers" } { "x" "a non-negative real number" } }
388 { $description "Computes the length of a mathematical vector." } ;
389
390 HELP: normalize
391 { $values { "u" "a sequence of numbers, not all zero" } { "v" "a sequence of numbers" } }
392 { $description "Outputs a vector with the same direction as " { $snippet "u" } " but length 1." } ;
393
394 HELP: distance
395 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "x" "a non-negative real number" } }
396 { $description "Outputs the Euclidean distance between two vectors." } ;
397
398 HELP: set-axis
399 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "axis" "a sequence of 0/1" } { "w" "a sequence of numbers" } }
400 { $description "Using " { $snippet "w" } " as a template, creates a new sequence containing corresponding elements from " { $snippet "u" } " in place of 0, and corresponding elements from " { $snippet "v" } " in place of 1." }
401 { $examples { $example "USING: math.vectors prettyprint ;" "{ 1 2 3 } { 4 5 6 } { 0 1 0 } set-axis ." "{ 1 5 3 }" } } ;
402
403 HELP: v<
404 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of booleans" } }
405 { $description "Compares each corresponding element of " { $snippet "u" } " and " { $snippet "v" } ", returning " { $link t } " in the result vector when the former is less than the latter or " { $link f } " otherwise." }
406 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean results when using SIMD types." } ;
407
408 HELP: v<=
409 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of booleans" } }
410 { $description "Compares each corresponding element of " { $snippet "u" } " and " { $snippet "v" } ", returning " { $link t } " in the result vector when the former is less than or equal to the latter or " { $link f } " otherwise." }
411 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean results when using SIMD types." } ;
412
413 HELP: v=
414 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of booleans" } }
415 { $description "Compares each corresponding element of " { $snippet "u" } " and " { $snippet "v" } ", returning " { $link t } " in the result vector when they are equal or " { $link f } " otherwise." }
416 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean results when using SIMD types." } ;
417
418 HELP: v>
419 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of booleans" } }
420 { $description "Compares each corresponding element of " { $snippet "u" } " and " { $snippet "v" } ", returning " { $link t } " in the result vector when the former is greater than the latter or " { $link f } " otherwise." }
421 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean results when using SIMD types." } ;
422
423 HELP: v>=
424 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of booleans" } }
425 { $description "Compares each corresponding element of " { $snippet "u" } " and " { $snippet "v" } ", returning " { $link t } " in the result vector when the former is greater than or equal to the latter or " { $link f } " otherwise." }
426 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean results when using SIMD types." } ;
427
428 HELP: vunordered?
429 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of booleans" } }
430 { $description "Compares each corresponding element of " { $snippet "u" } " and " { $snippet "v" } ", returning " { $link t } " in the result vector when either value is Not-a-Number or " { $link f } " otherwise." }
431 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean results when using SIMD types." } ;
432
433 HELP: vand
434 { $values { "u" "a sequence of booleans" } { "v" "a sequence of booleans" } { "w" "a sequence of booleans" } }
435 { $description "Takes the logical AND of each corresponding element of " { $snippet "u" } " and " { $snippet "v" } "." }
436 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types." } ;
437
438 HELP: vandn
439 { $values { "u" "a sequence of booleans" } { "v" "a sequence of booleans" } { "w" "a sequence of booleans" } }
440 { $description "Takes the logical AND-NOT of each corresponding element of " { $snippet "u" } " and " { $snippet "v" } ", where " { $snippet "x AND-NOT y" } " is defined as " { $snippet "NOT(x) AND y" } "." }
441 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types." } ;
442
443 HELP: vor
444 { $values { "u" "a sequence of booleans" } { "v" "a sequence of booleans" } { "w" "a sequence of booleans" } }
445 { $description "Takes the logical OR of each corresponding element of " { $snippet "u" } " and " { $snippet "v" } "." }
446 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types." } ;
447
448 HELP: vxor
449 { $values { "u" "a sequence of booleans" } { "v" "a sequence of booleans" } { "w" "a sequence of booleans" } }
450 { $description "Takes the logical XOR of each corresponding element of " { $snippet "u" } " and " { $snippet "v" } "." }
451 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types." } ;
452
453 HELP: vnot
454 { $values { "u" "a sequence of booleans" } { "w" "a sequence of booleans" } }
455 { $description "Takes the logical NOT of each element of " { $snippet "u" } "." }
456 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types." } ;
457
458 HELP: v?
459 { $values { "mask" "a sequence of booleans" } { "true" "a sequence of numbers" } { "false" "a sequence of numbers" } { "w" "a sequence of numbers" } }
460 { $description "Creates a new sequence by selecting elements from the " { $snippet "true" } " and " { $snippet "false" } " sequences based on whether the corresponding bits of the " { $snippet "mask" } " sequence are set or not." }
461 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types." } ;
462
463 HELP: vany?
464 { $values { "v" "a sequence of booleans" } { "?" "a boolean" } }
465 { $description "Returns true if any element of " { $snippet "v" } " is true." }
466 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs when using SIMD types." } ;
467
468 HELP: vall?
469 { $values { "v" "a sequence of booleans" } { "?" "a boolean" } }
470 { $description "Returns true if every element of " { $snippet "v" } " is true." }
471 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs when using SIMD types." } ;
472
473 HELP: vnone?
474 { $values { "v" "a sequence of booleans" } { "?" "a boolean" } }
475 { $description "Returns true if every element of " { $snippet "v" } " is false." }
476 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs when using SIMD types." } ;
477
478 { 2map v+ v- v* v/ } related-words
479
480 { 2reduce v. } related-words
481
482 { vs+ vs- vs* } related-words
483
484 { v< v<= v= v> v>= vunordered? vand vor vxor vnot vany? vall? vnone? v? } related-words
485
486 { vbitand vbitandn vbitor vbitxor vbitnot } related-words