Sparse matrix object (similar to MacKay, Davey, Lafferty convention)
Public Functions
smatrixi | smatrixi_create( |
smatrixi | smatrixi_create_array( |
int | smatrixi_destroy( |
int | smatrixi_print( |
int | smatrixi_print_expanded( |
int | smatrixi_size( |
int | smatrixi_clear( |
int | smatrixi_reset( |
int | smatrixi_isset( |
int | smatrixi_insert( |
int | smatrixi_delete( |
int | smatrixi_set( |
short int | smatrixi_get( |
int | smatrixi_eye( |
int | smatrixi_mul( |
int | smatrixi_vmul( |
Interfaces
smatrixi smatrixi_create(
Create \(M \times N\) sparse matrix, initialized with zeros
- _m : number of rows in matrix
- _n : number of columns in matrix
smatrixi smatrixi_create_array(
Create \(M \times N\) sparse matrix, initialized on array
- _x : input matrix, shape: (_m, _n)
- _m : number of rows in input matrix
- _n : number of columns in input matrix
int smatrixi_destroy(
Destroy object, freeing all internal memory
int smatrixi_print(
Print sparse matrix in compact form to stdout
int smatrixi_print_expanded(
Print sparse matrix in expanded form to stdout
int smatrixi_size(
Get size of sparse matrix (number of rows and columns)
- _q : sparse matrix object
- _m : number of rows in matrix
- _n : number of columns in matrix
int smatrixi_clear(
Zero all elements and retain allocated memory
int smatrixi_reset(
Zero all elements and clear memory
int smatrixi_isset(
Determine if value has been set (allocated memory)
- _q : sparse matrix object
- _m : row index of value to query
- _n : column index of value to query
int smatrixi_insert(
Insert an element at index, allocating memory as necessary
- _q : sparse matrix object
- _m : row index of value to insert
- _n : column index of value to insert
- _v : value to insert
int smatrixi_delete(
Delete an element at index, freeing memory
- _q : sparse matrix object
- _m : row index of value to delete
- _n : column index of value to delete
int smatrixi_set(
Set the value in matrix at specified row and column, allocating memory if needed
- _q : sparse matrix object
- _m : row index of value to set
- _n : column index of value to set
- _v : value to set in matrix
short int smatrixi_get(
Get the value from matrix at specified row and column
- _q : sparse matrix object
- _m : row index of value to get
- _n : column index of value to get
int smatrixi_eye(
Initialize to identity matrix; set all diagonal elements to 1, all others to 0. This is done with both square and non-square matrices.
int smatrixi_mul(
Multiply two sparse matrices, \( \vec{Z} = \vec{X} \vec{Y} \)
- _x : sparse matrix object (input)
- _y : sparse matrix object (input)
- _z : sparse matrix object (output)
int smatrixi_vmul(
Multiply sparse matrix by vector
- _q : sparse matrix
- _x : input vector, shape: (_n, 1)
- _y : output vector, shape: (_m, 1)