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