CREATE_MATRIX_FROM_TABLE

This procedure creates a matrix from a row/column/value table.

Usage

The CREATE_MATRIX_FROM_TABLE stored procedure has the following syntax:
CREATE_MATRIX_FROM_TABLE(source_table,mat_name,numRows,numCols)
Parameters
source_table
The name of the input table.
Type: NVARCHAR(ANY)
mat_name
The name of the matrix to be created.
Type: NVARCHAR(ANY)
numRows
The number of matrix rows.
Type: INT4
numCols
The number of matrix columns.
Type: INT4
Returns
BOOLEAN TRUE, if successful.

Details

Note: This procedure silently creates an invalid matrix if fed an invalid input. Unless you are certain your input is valid (no duplicate row, column entries, etc.), follow the instructions bellow for calling nz.._test_dense_valid().
Creates a matrix from a table having the following schema: (row INTEGER, col INTEGER, value DOUBLE PRECISION). The row in-dices should range from 1 to numRows, inclusive and the column indices should range from1 to numCols, inclusive. Any (row, col) pairs outside these ranges are ignored. Each (row, col) pair may appear at most once. Null values are converted to zeros. If the number of values is greater than numRows * numCols, an exception is generated. In case of input data sparse form missing cells will be added and filled with zeros. You can use the procedure nzm.._test_dense_valid(mat_name) to verify that a created matrix has the proper number of values and that the (row, column) index pairs are unique.

Examples

create table mytable (row INT4, col INT4, value DOUBLE); 
insert into mytable values (1, 1, 11);
insert into mytable values (1, 2, 12); 
insert into mytable values (2, 1, 21); 
insert into mytable values (2, 2, 22);
call nzm..create_matrix_from_table('mytable', 'A', 2, 2);
call nzm..print('A');
drop table mytable;
CALL nzm..delete_matrix('A');

 CREATE_MATRIX_FROM_TABLE
--------------------------
 t
(1 row)

             PRINT
-------------------------------
 -- matrix: A --
11, 12
21, 22
(1 row)

 DELETE_MATRIX
---------------
 t
(1 row)