Mask: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
(Created page with "{| class=vertical-navbox style="float:right; font-size:500%; margin:0 1ex;" |<math>/a,u,b/</math> |} In Iverson notation, '''Mask''' (<math>/a,u,b/</math>) is a three-argument operation which merges two arguments according to a Boolean array, all with matching shape. The relationship between Mask and Mesh is similar to that between Compress and Expand. The Case function can also be seen as a generalization of Mask. A related function also name...")
 
mNo edit summary
 
Line 16: Line 16:
For numeric arrays, Mask <math>/A,U,B/</math> can be defined algebraically as <syntaxhighlight lang=apl inline>(A×1-U)+B×U</syntaxhighlight> or <syntaxhighlight lang=apl inline>A+U×B-A</syntaxhighlight>, that is, a special case of [[wikipedia:linear interpolation|linear interpolation]]. Similarly, possible implementations for [[Boolean]] arrays include <syntaxhighlight lang=apl inline>(A∧~U)∨B∧U</syntaxhighlight> and <syntaxhighlight lang=apl inline>A≠U∧B≠A</syntaxhighlight>.
For numeric arrays, Mask <math>/A,U,B/</math> can be defined algebraically as <syntaxhighlight lang=apl inline>(A×1-U)+B×U</syntaxhighlight> or <syntaxhighlight lang=apl inline>A+U×B-A</syntaxhighlight>, that is, a special case of [[wikipedia:linear interpolation|linear interpolation]]. Similarly, possible implementations for [[Boolean]] arrays include <syntaxhighlight lang=apl inline>(A∧~U)∨B∧U</syntaxhighlight> and <syntaxhighlight lang=apl inline>A≠U∧B≠A</syntaxhighlight>.


The operation performed by Mask is often supported by dedicated instructions in [[wikipedia:SIMD|SIMD]] programming, often called "blend" instructions.
The operation performed by Mask may be supported by dedicated instructions in [[wikipedia:SIMD|SIMD]] programming, often called "blend" instructions.


=== Documentation ===
== Documentation ==


* [http://wiki.nars2000.org/index.php/Compose#Mask NARS2000]
* [http://wiki.nars2000.org/index.php/Compose#Mask NARS2000]
== References ==
<references />


[[Category:APL primitives]][[Category:Iverson notation]]
[[Category:APL primitives]][[Category:Iverson notation]]

Navigation menu