between
The between operator produces a result array from a specified, contiguous region of a source array.
Synopsis
between(array, low_coord1 [,low_coord2…], high_coord1 [,high_coord2…]);
Summary
- The between operator is a filter that masks a rectilinear region of the input array.
- The between operator accepts an input array and a list of coordinates specifying a region within the array. The number of coordinate pairs in the input must equal the number of dimensions in the array. The output is an array of the same shape as input, where all cells outside of the given region are marked empty. The result of the the between operator has the same number of dimensions as the input array, and the output cell's coordinates are the same as they were in the input array.
- Instead of a coordinate value, you can substitute null. SciDB interprets the null syntax as the minimum or maximum coordinate value for that dimension in that location. Â
- The subarray operator is similar, except that subarray additionally shifts the selected region to the array origin. For details, see the subarray operator
Simple between Example
Given a 2-d source array that is 4x4, to select four cells from it, do the following:
To create a 4×4 array called between_array, enter the following:
AFL% CREATE ARRAY between_array <val:double>[i=0:3; j=0:3];
To populate the between_array array with data, enter:
AFL% store(build(between_array,i*4+j),between_array);Â
The output is:{i,j} val {0,0} 0 {0,1} 1 {0,2} 2 {0,3} 3 {1,0} 4 {1,1} 5 {1,2} 6 {1,3} 7 {2,0} 8 {2,1} 9 {2,2} 10 {2,3} 11 {3,0} 12 {3,1} 13 {3,2} 14 {3,3} 15
To select all cells from the last two rows and last two columns from between_array, enter:
AFL% between(between_array,2,2,3,3);Â
The output is:{i,j} val {2,2} 10 {2,3} 11 {3,2} 14 {3,3} 15
Between Example Using Null
Given a 2-d source array that is 4x4, select all cells between the center of the array and the upper boundaries of the array.
To select all cells between the center of the array and the upper boundaries of the array, do the following:
AFL% between(between_array, 2, 2, null ,null );Â
The output is:{i,j} val {2,2} 10 {2,3} 11 {3,2} 14 {3,3} 15
Â
Â