]> gitweb.factorcode.org Git - factor.git/blob - basis/math/vectors/vectors-docs.factor
Merge branch 'master' of git://factorcode.org/git/factor into 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 <<<<<<< HEAD:basis/math/vectors/vectors-docs.factor
93 { $subsections
94     vand
95     vandn
96     vor
97     vxor
98     vnot
99     v?
100 }
101 "Entire vector tests:"
102 { $subsections
103     vall?
104     vany?
105     vnone?
106 }
107 "Element shuffling:"
108 { $subsections vshuffle } ;
109 =======
110 { $subsection vand }
111 { $subsection vandn }
112 { $subsection vor }
113 { $subsection vxor }
114 { $subsection vnot }
115 { $subsection v? }
116 "Vector tests:"
117 { $subsection vall? }
118 { $subsection vany? }
119 { $subsection vnone? } ;
120 >>>>>>> 271e6ddde513aa3de68337c67127a2a6da5ef6f4:basis/math/vectors/vectors-docs.factor
121
122 ARTICLE: "math-vectors-misc" "Miscellaneous vector functions"
123 { $subsections
124     trilerp
125     bilerp
126     vlerp
127     vnlerp
128     vbilerp
129 } ;
130
131 ARTICLE: "math-vectors-simd-logic" "Componentwise logic with SIMD vectors"
132 "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:"
133 { $example
134 """USING: math.vectors math.vectors.simd prettyprint ;
135 FROM: alien.c-types => float ;
136 SIMD: float
137
138 float-4{ 1.0 2.0 3.0 0/0. } float-4{ 1.0 -2.0 3.0 0/0. } v= ."""
139 """float-4{ NAN: fffffe0000000 0.0 NAN: fffffe0000000 0.0 }"""
140 }
141 "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):"
142 { $example
143 """USING: math.vectors math.vectors.simd prettyprint alien.c-types ;
144 SIMD: int
145 SIMD: uchar
146
147 int-4{ 1 2 3 0 } int-4{ 1 -2 3 4 } v=
148 uchar-16{  0  1  2  3  4  5 6 7 8 9 10 11 12 13 14 15 }
149 uchar-16{ 15 14 13 12 11 10 9 8 7 6  5  4  3  2  1  0 } v<
150 [ . ] bi@"""
151 """int-4{ -1 0 -1 0 }
152 uchar-16{ 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 }"""
153 }
154 "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:"
155 { $example
156 """USING: math.vectors math.vectors.simd prettyprint alien.c-types ;
157 SIMD: int
158
159 int-4{ f f t f } ."""
160 """int-4{ 0 0 -1 0 }""" }
161 "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."
162 $nl
163 "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."
164 $nl
165 "This applies to the output of the following element comparison words: "
166 { $list
167 { $link v< }
168 { $link v<= }
169 { $link v= }
170 { $link v>= }
171 { $link v> }
172 { $link vunordered? }
173 }
174 "This likewise applies to the " { $snippet "mask" } " argument of " { $link v? } " and to the inputs and outputs of the following element logic words:"
175 { $list
176 { $link vand }
177 { $link vandn }
178 { $link vor }
179 { $link vxor }
180 { $link vnot }
181 }
182 "Finally, this applies to the inputs of these vector test words:"
183 { $list
184 { $link vall? }
185 { $link vany? }
186 { $link vnone? }
187 } ;
188
189 ARTICLE: "math-vectors" "Vector operations"
190 "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."
191 <<<<<<< HEAD:basis/math/vectors/vectors-docs.factor
192 { $subsections
193     "math-vectors-arithmetic"
194     "math-vectors-logic"
195     "math-vectors-misc"
196 } ;
197 =======
198 { $subsection "math-vectors-arithmetic" }
199 { $subsection "math-vectors-logic" }
200 { $subsection "math-vectors-shuffle" }
201 { $subsection "math-vectors-misc" } ;
202 >>>>>>> 271e6ddde513aa3de68337c67127a2a6da5ef6f4:basis/math/vectors/vectors-docs.factor
203
204 ABOUT: "math-vectors"
205
206 HELP: vneg
207 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } }
208 { $description "Negates each element of " { $snippet "u" } "." } ;
209
210 HELP: vabs
211 { $values { "u" "a sequence of numbers" } { "v" "a sequence of non-negative real numbers" } }
212 { $description "Takes the absolute value of each element of " { $snippet "u" } "." } ;
213
214 HELP: vsqrt
215 { $values { "u" "a sequence of non-negative real numbers" } { "v" "a sequence of non-negative real numbers" } }
216 { $description "Takes the square root of each element of " { $snippet "u" } "." }
217 { $warning "For performance reasons, this does not work with negative inputs, unlike " { $link sqrt } "." } ;
218
219 HELP: vfloor
220 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } }
221 { $description "Takes the " { $link floor } " of each element of " { $snippet "u" } "." } ;
222
223 HELP: vceiling
224 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } }
225 { $description "Takes the " { $link ceiling } " of each element of " { $snippet "u" } "." } ;
226
227 HELP: vtruncate
228 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } }
229 { $description "Truncates each element of " { $snippet "u" } "." } ;
230
231 HELP: n+v
232 { $values { "n" "a number" } { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } }
233 { $description "Adds " { $snippet "n" } " to each element of " { $snippet "u" } "." } ;
234
235 HELP: v+n
236 { $values { "u" "a sequence of numbers" } { "n" "a number" } { "v" "a sequence of numbers" } }
237 { $description "Adds " { $snippet "n" } " to each element of " { $snippet "u" } "." } ;
238
239 HELP: n-v
240 { $values { "n" "a number" } { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } }
241 { $description "Subtracts each element of " { $snippet "u" } " from " { $snippet "n" } "." } ;
242
243 HELP: v-n
244 { $values { "u" "a sequence of numbers" } { "n" "a number" } { "v" "a sequence of numbers" } }
245 { $description "Subtracts " { $snippet "n" } " from each element of " { $snippet "u" } "." } ;
246
247 HELP: n*v
248 { $values { "n" "a number" } { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } }
249 { $description "Multiplies each element of " { $snippet "u" } " by " { $snippet "n" } "." } ;
250
251 HELP: v*n
252 { $values { "u" "a sequence of numbers" } { "n" "a number" } { "v" "a sequence of numbers" } }
253 { $description "Multiplies each element of " { $snippet "u" } " by " { $snippet "n" } "." } ;
254
255 HELP: n/v
256 { $values { "n" "a number" } { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } }
257 { $description "Divides " { $snippet "n" } " by each element of " { $snippet "u" } "." }
258 { $errors "May throw an error if a division by zero occurs; see " { $link "division-by-zero" } "." } ;
259
260 HELP: v/n
261 { $values { "u" "a sequence of numbers" } { "n" "a number" } { "v" "a sequence of numbers" } }
262 { $description "Divides each element of " { $snippet "u" } " by " { $snippet "n" } "." }
263 { $errors "May throw an error if a division by zero occurs; see " { $link "division-by-zero" } "." } ;
264
265 HELP: v+
266 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
267 { $description "Adds " { $snippet "u" } " and " { $snippet "v" } " component-wise." } ;
268
269 HELP: v-
270 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
271 { $description "Subtracts " { $snippet "v" } " from " { $snippet "u" } " 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 "Adds and subtracts alternate elements of " { $snippet "v" } " and " { $snippet "u" } " component-wise." }
276 { $examples
277     { $example
278         "USING: math.vectors prettyprint ;"
279         "{ 1 2 3 } { 2 3 2 } v+- ."
280         "{ -1 5 1 }"
281     }
282 } ;
283
284 HELP: [v-]
285 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } }
286 { $description "Subtracts " { $snippet "v" } " from " { $snippet "u" } " component-wise; any components which become negative are set to zero." } ;
287
288 HELP: v*
289 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
290 { $description "Multiplies " { $snippet "u" } " and " { $snippet "v" } " component-wise." } ;
291
292 HELP: v/
293 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
294 { $description "Divides " { $snippet "u" } " by " { $snippet "v" } " component-wise." }
295 { $errors "May throw an error if a division by zero occurs; see " { $link "division-by-zero" } "." } ;
296
297 HELP: vmax
298 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } }
299 { $description "Creates a sequence where each element is the maximum of the corresponding elements from " { $snippet "u" } " and " { $snippet "v" } "." }
300 { $examples { $example "USING: math.vectors prettyprint ;" "{ 1 2 5 } { -7 6 3 } vmax ." "{ 1 6 5 }" } } ;
301
302 HELP: vmin
303 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } }
304 { $description "Creates a sequence where each element is the minimum of the corresponding elements from " { $snippet "u" } " and " { $snippet "v" } "." }
305 { $examples { $example "USING: math.vectors prettyprint ;" "{ 1 2 5 } { -7 6 3 } vmin ." "{ -7 2 3 }" } } ;
306
307 HELP: v.
308 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "x" "a real number" } }
309 { $description "Computes the dot product of two vectors." } ;
310
311 HELP: vs+
312 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
313 { $description "Adds " { $snippet "u" } " and " { $snippet "v" } " component-wise with saturation." }
314 { $examples
315     "With saturation:"
316     { $example
317         "USING: alien.c-types math.vectors prettyprint specialized-arrays ;"
318         "SPECIALIZED-ARRAY: uchar"
319         "uchar-array{ 100 200 150 } uchar-array{ 70 70 70 } vs+ ."
320         "uchar-array{ 170 255 220 }"
321     }
322     "Without saturation:"
323     { $example
324         "USING: alien.c-types math.vectors prettyprint specialized-arrays ;"
325         "SPECIALIZED-ARRAY: uchar"
326         "uchar-array{ 100 200 150 } uchar-array{ 70 70 70 } v+ ."
327         "uchar-array{ 170 14 220 }"
328     }
329 } ;
330
331 HELP: vs-
332 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
333 { $description "Subtracts " { $snippet "v" } " from " { $snippet "u" } " component-wise with saturation." } ;
334
335 HELP: vs*
336 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
337 { $description "Multiplies " { $snippet "u" } " and " { $snippet "v" } " component-wise with saturation." } ;
338
339 HELP: vbitand
340 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } }
341 { $description "Takes the bitwise and of " { $snippet "u" } " and " { $snippet "v" } " component-wise." }
342 { $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." } ;
343
344 HELP: vbitandn
345 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } }
346 { $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" } "." }
347 { $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." } ;
348
349 HELP: vbitor
350 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } }
351 { $description "Takes the bitwise or of " { $snippet "u" } " and " { $snippet "v" } " component-wise." }
352 { $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." } ;
353
354 HELP: vbitxor
355 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } }
356 { $description "Takes the bitwise exclusive or of " { $snippet "u" } " and " { $snippet "v" } " component-wise." }
357 { $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." } ;
358
359 HELP: vlshift
360 { $values { "u" "a sequence of integers" } { "n" "a non-negative integer" } { "w" "a sequence of integers" } }
361 { $description "Shifts each element of " { $snippet "u" } " to the left by " { $snippet "n" } " bits." }
362 { $notes "Undefined behavior will result if " { $snippet "n" } " is negative." } ;
363
364 HELP: vrshift
365 { $values { "u" "a sequence of integers" } { "n" "a non-negative integer" } { "w" "a sequence of integers" } }
366 { $description "Shifts each element of " { $snippet "u" } " to the right by " { $snippet "n" } " bits." }
367 { $notes "Undefined behavior will result if " { $snippet "n" } " is negative." } ;
368
369 HELP: hlshift
370 { $values { "u" "a SIMD array" } { "n" "a non-negative integer" } { "w" "a SIMD array" } }
371 { $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." } ;
372
373 HELP: hrshift
374 { $values { "u" "a SIMD array" } { "n" "a non-negative integer" } { "w" "a SIMD array" } }
375 { $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." } ;
376
377 HELP: vbroadcast
378 { $values { "u" "a SIMD array" } { "n" "a non-negative integer" } { "v" "a SIMD array" } }
379 { $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" } "." }
380 { $examples
381     { $example
382         "USING: alien.c-types math.vectors math.vectors.simd" "prettyprint ;"
383         "SIMD: int"
384         "int-4{ 69 42 911 13 } 2 vbroadcast ."
385         "int-4{ 911 911 911 911 }"
386     }
387 } ;
388
389 HELP: vshuffle
390 { $values { "u" "a SIMD array" } { "perm" "an array of integers" } { "v" "a SIMD array" } }
391 { $description "Permutes the elements of a SIMD array. Duplicate entries are allowed in the permutation." }
392 { $examples
393     { $example
394         "USING: alien.c-types math.vectors math.vectors.simd" "prettyprint ;"
395         "SIMD: int"
396         "int-4{ 69 42 911 13 } { 1 3 2 3 } vshuffle ."
397         "int-4{ 42 13 911 13 }"
398     }
399 } ;
400
401 HELP: norm-sq
402 { $values { "v" "a sequence of numbers" } { "x" "a non-negative real number" } }
403 { $description "Computes the squared length of a mathematical vector." } ;
404
405 HELP: norm
406 { $values { "v" "a sequence of numbers" } { "x" "a non-negative real number" } }
407 { $description "Computes the length of a mathematical vector." } ;
408
409 HELP: normalize
410 { $values { "u" "a sequence of numbers, not all zero" } { "v" "a sequence of numbers" } }
411 { $description "Outputs a vector with the same direction as " { $snippet "u" } " but length 1." } ;
412
413 HELP: distance
414 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "x" "a non-negative real number" } }
415 { $description "Outputs the Euclidean distance between two vectors." } ;
416
417 HELP: set-axis
418 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "axis" "a sequence of 0/1" } { "w" "a sequence of numbers" } }
419 { $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." }
420 { $examples { $example "USING: math.vectors prettyprint ;" "{ 1 2 3 } { 4 5 6 } { 0 1 0 } set-axis ." "{ 1 5 3 }" } } ;
421
422 HELP: v<
423 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of booleans" } }
424 { $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." }
425 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean results when using SIMD types." } ;
426
427 HELP: v<=
428 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of booleans" } }
429 { $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." }
430 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean results when using SIMD types." } ;
431
432 HELP: v=
433 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of booleans" } }
434 { $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." }
435 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean results when using SIMD types." } ;
436
437 HELP: v>
438 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of booleans" } }
439 { $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." }
440 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean results when using SIMD types." } ;
441
442 HELP: v>=
443 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of booleans" } }
444 { $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." }
445 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean results when using SIMD types." } ;
446
447 HELP: vunordered?
448 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of booleans" } }
449 { $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." }
450 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean results when using SIMD types." } ;
451
452 HELP: vand
453 { $values { "u" "a sequence of booleans" } { "v" "a sequence of booleans" } { "w" "a sequence of booleans" } }
454 { $description "Takes the logical AND of each corresponding element of " { $snippet "u" } " and " { $snippet "v" } "." }
455 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types." } ;
456
457 HELP: vandn
458 { $values { "u" "a sequence of booleans" } { "v" "a sequence of booleans" } { "w" "a sequence of booleans" } }
459 { $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" } "." }
460 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types." } ;
461
462 HELP: vor
463 { $values { "u" "a sequence of booleans" } { "v" "a sequence of booleans" } { "w" "a sequence of booleans" } }
464 { $description "Takes the logical OR of each corresponding element of " { $snippet "u" } " and " { $snippet "v" } "." }
465 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types." } ;
466
467 HELP: vxor
468 { $values { "u" "a sequence of booleans" } { "v" "a sequence of booleans" } { "w" "a sequence of booleans" } }
469 { $description "Takes the logical XOR of each corresponding element of " { $snippet "u" } " and " { $snippet "v" } "." }
470 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types." } ;
471
472 HELP: vnot
473 { $values { "u" "a sequence of booleans" } { "w" "a sequence of booleans" } }
474 { $description "Takes the logical NOT of each element of " { $snippet "u" } "." }
475 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types." } ;
476
477 HELP: v?
478 { $values { "mask" "a sequence of booleans" } { "true" "a sequence of numbers" } { "false" "a sequence of numbers" } { "w" "a sequence of numbers" } }
479 { $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." }
480 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types." } ;
481
482 HELP: vany?
483 { $values { "v" "a sequence of booleans" } { "?" "a boolean" } }
484 { $description "Returns true if any element of " { $snippet "v" } " is true." }
485 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs when using SIMD types." } ;
486
487 HELP: vall?
488 { $values { "v" "a sequence of booleans" } { "?" "a boolean" } }
489 { $description "Returns true if every element of " { $snippet "v" } " is true." }
490 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs when using SIMD types." } ;
491
492 HELP: vnone?
493 { $values { "v" "a sequence of booleans" } { "?" "a boolean" } }
494 { $description "Returns true if every element of " { $snippet "v" } " is false." }
495 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs when using SIMD types." } ;
496
497 { 2map v+ v- v* v/ } related-words
498
499 { 2reduce v. } related-words
500
501 { vs+ vs- vs* } related-words
502
503 { v< v<= v= v> v>= vunordered? vand vor vxor vnot vany? vall? vnone? v? } related-words
504
505 { vbitand vbitandn vbitor vbitxor vbitnot } related-words