Array Predicates: Difference between revisions

From NARS2000
Jump to navigationJump to search
(New page: This clever idea of Bob Bernecky's [http://www.snakeisland.com/predicat.pdf] provides a performance improvement for certain expressions by marking certain arrays with special properties. ...)
 
No edit summary
Line 1: Line 1:
This clever idea of Bob Bernecky's [http://www.snakeisland.com/predicat.pdf] provides a performance improvement for certain expressions by marking certain arrays with special properties.  For example, a permutation vector [http://mathworld.wolfram.com/Permutation.html] has the property that it is invariant under various APL primitives such as rotate/reversal (<apll></apll>) and grade up/down (<apll>⍋ ⍒</apll>).
This clever idea of Bob Bernecky's [http://www.snakeisland.com/predicat.pdf] provides a performance improvement for certain expressions by marking certain arrays with special properties.  For example, a permutation vector [http://mathworld.wolfram.com/Permutation.html] has the property that it is invariant under various APL primitives such as rotate/reversal (<apll>L⌽R</apll> and <apll>⌽R</apll>) and grade up/down (<apll>⍋R</apll> and <apll>⍒R</apll>).


Bernecky has defined several array predicate properties, one of which has been implemented in NARS so far:  permutation vectors.
Bernecky has defined several array predicate properties, one of which has been implemented in NARS so far.


In this case, monadic iota (<apll>{iota}</apll>) produces a permutation vector, as does deal (<apll>?</apll>) when the left and right arguments are the same, and are marked internally as such.  Further use of such arrays maintain that property when operated on by rotate/reversal and grade up/down.  Moreover, the grade primitive uses a much faster (linear) algorithm than it would normally use.
== Permutation Vectors ==
 
In this case, index generator (<apll>⍳R</apll>) produces a Permutation Vector, as does deal (L<apll>?</apll>R) when the left and right arguments are the same &mdash; the results of these primitives are marked internally as Permutation Vectors.  Further use of such arrays maintains that property when operated on by rotate/reversal and grade up/down.  Moreover, both the grade and index of (<apll>L⍳R</apll>) primitives use a much faster (linear) algorithm than they would normally use.

Revision as of 23:59, 17 August 2008

This clever idea of Bob Bernecky's [1] provides a performance improvement for certain expressions by marking certain arrays with special properties. For example, a permutation vector [2] has the property that it is invariant under various APL primitives such as rotate/reversal (L⌽R and ⌽R) and grade up/down (⍋R and ⍒R).

Bernecky has defined several array predicate properties, one of which has been implemented in NARS so far.

Permutation Vectors

In this case, index generator (⍳R) produces a Permutation Vector, as does deal (L?R) when the left and right arguments are the same — the results of these primitives are marked internally as Permutation Vectors. Further use of such arrays maintains that property when operated on by rotate/reversal and grade up/down. Moreover, both the grade and index of (L⍳R) primitives use a much faster (linear) algorithm than they would normally use.