From ftm
Revision as of 14:22, 2 July 2010 by Diemo (talk | contribs)
Jump to: navigation, search

This is a method of the fmat class.

Syntax: find <expr: expression> <any: arguments to expression...>

- leave indices where expression is true (use $x, $i and $self)

The find method of fmat replaces an fmat with the (unwrapped) indices of the elements for which the given expression returned non-zero. The expression can use the arguments to the find method following the expression as $1, $2, etc., and the predefined super-local variables $x (the value of the element being tested), $i (its index), and $self (the reference to the fmat itself). Otherwise, only global definitions are visible within the expression. (The latter holds for any expression evaluation.)

Example: ($myfmat find $myexpr 1 20) with myexpr = '(($x >= $1) && ($i < $2))' finds values greater or equal 1 in the first 20 indices and replaces $myfmat with their indices.