CREATE_TABLE_FROM_MATRIX - export only non-empty cells

This procedure creates a user-visible table from a matrix and allows it to export only non-empty cells, that is, cells with non-zero values.

Usage

The CREATE_TABLE_FROM_MATRIX stored procedure has the following syntax:
CREATE_TABLE_FROM_MATRIX(mat_name,destination_table,sparse_only)
Parameters
mat_name
The name of the matrix to be copied.
Type: NVARCHAR(ANY)
destination_table
The name of the table to be generated.
Type: NVARCHAR(ANY)
sparse_only
If TRUE, only non-zero values are exported.
Type: BOOLEAN
Returns
BOOLEAN TRUE, if successful.

Details

Creates a table, owned by the caller, having the following schema: (row INTEGER, col INTEGER, value DOUBLE PRECISION). The created table contains the matrix data in a row/column/value representation. This hides the implementation details of NZMatrix and provides data to the user via a table representation. This procedure can export only nonempty cells, that is, cells with a non-zero value.

Examples

call nzm..shape('0,1,2,0,0,0,0,0,33',3,3,'A'); 
call nzm..create_table_from_matrix('A', 
 'my_rcv_dense',false);
call nzm..create_table_from_matrix('A',
 'my_rcv_sparse',true);
select * from my_rcv_dense order by row,col; 
select * from my_rcv_sparse order by row,col; 
drop table my_rcv_dense; 
drop table my_rcv_sparse;
call nzm..delete_matrix('A' );

 SHAPE
-------
 t
(1 row)

 CREATE_TABLE_FROM_MATRIX
--------------------------
 t
(1 row)

 CREATE_TABLE_FROM_MATRIX
--------------------------
 t
(1 row)
 ROW | COL | VALUE
-----+-----+-------
   1 |   1 |     0
   1 |   2 |     1
   1 |   3 |     2
   2 |   1 |     0
   2 |   2 |     0
   2 |   3 |     0
   3 |   1 |     0
   3 |   2 |     0
   3 |   3 |    33
(9 rows)

 ROW | COL | VALUE
-----+-----+-------
   1 |   2 |     1
   1 |   3 |     2
   3 |   3 |    33
(3 rows)

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