rtable_scanblock - scan a block of elements in an rtable
rtable_scanblock(A, ranges, operation)
rtable_scanblock(A, ranges, noindex, operation1, data1, stopresult=val1, passindex, operation2, ... )
operation_passindex(value, index, data)
empty list or list of ranges
name of a builtin operation or a proc
(optional) stop scanning when the operation proc returns this
(optional) do not pass the index to the operation proc
(optional) pass the index to the operation proc
value at the current element in A
index of the current element entry in A
val1, or value of the previous result
calling sequence for the operation parameter when passindex is given
calling sequence for the operation parameter when noindex is given
The rtable_scanblock(A) command applies one or more operations to the values in the specified ranges of an Array, Matrix, or Vector.
If ranges is an empty list all elements of A will be scanned. Otherwise, the given list of ranges must be fully specified with integer lower and upper bounds, and fall within the index-space of A. Note that for an integer n, the range n..n can be written as simply n.
The following built-in operations are recognized.
compute the average value
true if there exists a non-zero value
true if there exists a zero value
find the maximum defined value
find the maximum value or undefined if present
find the minimum defined value
find the minimum value or undefined if present
find the max and min of only the numeric entries
count the number of non-zero entries
compute the average of the non-zero entries
find the maximum excluding zero
find the minimum excluding zero
compute the sum of all the elements
Most of these built-in operations work only on numeric data. A value of FAIL is returned if the operation cannot be completed.
The operation parameter can be a procedure that accepts either the calling sequence given by operation_passindex or by operation_noindex listed in the Parameter Sequence section. If the option noindex is specified in the calling sequence, then every operation following is assumed to have the form of the operation_noindex calling-sequence. In other words, the elements index is not passed to those operation procedures. This may be more efficient as creation of the index expression sequence can sometimes be avoided. When passindex is specified, then the subsequent operation parameters are called with the index of the element in addition to the element's value.
The data parameter to the operation callbacks is initially the valN value passed to rtable_scanblock. After the first callback, data becomes the result of the last callback. This is useful for building a result that depends on previous scanned elements.
It is often desirable to stop scanning once certain information is known about an element. For example, upon detection of the first non-numeric type you may want to interrupt the scan. This can be done using the stopresult parameter. If the operation procedure returns the value given by stopresult, then the block scan is terminated and that result is returned. Only the operation paired with its stopresult is terminated. If other operations specified in the rtable_scanblock calling-sequence are not finished, they will continue.
The rtable_scanblock command is thread-safe as of Maple 15.
For more information on thread safety, see index/threadsafe.
Compute the average, maximum, and minimum values in a Matrix.
A:= 100 x 100 MatrixData Type: float8Storage: rectangularOrder: Fortran_order
Check if a Vector has a value bigger than 0.
gzero := proc(val,res)
if val > 0 then
gzero:=procval,resif0<valthenreturntrueelsereturnfalseend ifend proc
Find the maximum element and its index in the first column of a Matrix. Note [[1,1],A[1,1]] is used as the initial max value.
Find the maximum and minimum elements and their corresponding indices in the last row of a Matrix.
Array, for, Matrix, rtable, rtable_dims, seq, Vector
Download Help Document