LOC - locate non-zero elements
This procedure locates the vector of positions of non-zero elements.
Usage
- LOC(matrixIn,matrixOut)
- Parameters
- matrixIn
- The name of the input matrix.
- matrixOut
- The name of the output matrix.
Details
The procedure returns a row vector of indices positioning the non-zero elements of the input matrix. Index values are in row-major order, and the indices must be in the range from 1 to the number of elements in the first argument. If all elements are zero, the result is a NULL, as a matrix with zero rows and zero columns cannot be created, and an error occurs. The statement loc('AA','CC'); for a one row matrix AA={25,0,71,18} returns a row vector {1,3,4}. The output matrix must not exist prior to the operation.
Examples
CALL nzm..SHAPE('0,1,2,3,4,5,6,7,8,0,0,0,0,3,4,5',4,4,'A');
CALL nzm..LOC('A','B');
CALL nzm..PRINT('B');
CALL nzm..DELETE_MATRIX('A');
CALL nzm..DELETE_MATRIX('B');
SHAPE
-------
t
(1 row)
LOC
-----
t
(1 row)
PRINT
----------------------------------------------------
-- matrix: B --
2, 3, 4, 5, 6, 7, 8, 9, 14, 15, 16
(1 row)
DELETE_MATRIX
---------------
t
(1 row)
DELETE_MATRIX
---------------
t
(1 row)