where

From DavinciWiki
Jump to: navigation, search


Description

Partial replacement for arrays. This is not a function in the normal sense.

Arguments and Return Values

Arguments: A boolean expression involving an array; must be used in conjunction with an array assignment (see below)

Return Value: Returns new array

Usage

The unary operator 'where' provides partial array replacement, based on a boolean expression. The 'where' operator can only be used during array assignment, and only on a named array.

The Syntax is as follows:

array [ where expr1 ] = expr2

Array is a named array.

Expr1 must evaluate to an array with the same organization and dimensions as array, and where expr1 is true, the corresponding element of array is replaced with the value of expr2.

Expr2 must be a single value.


In typical usage, array[where array ?= value1] = value2

"array" is a named array

"?=" is a boolean operator (e.g. >=)

"value" is the test value (a 1x1x1 array)


Example: This example replaces all values in data that are less than zero, with the value 0.

dv> data[ where (data < 0) ] = 0


Examples

dv> x = create(7) - 3
7x1x1 array of int, bsq format [28 bytes]
-3      -2      -1      0       1       2       3
dv> x[where x<0] = 0
7x1x1 array of int, bsq format [28 bytes]
0       0       0       0       1       2       3
dv> image[where stddev(image) > 3] = 0

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left


Recent Core Changes

Modified On: 06-24-2008

Personal tools