Sparse matrix object (similar to MacKay, Davey, Lafferty convention)
Public Functions
smatrixb | smatrixb_create( |
smatrixb | smatrixb_create_array( |
int | smatrixb_destroy( |
int | smatrixb_print( |
int | smatrixb_print_expanded( |
int | smatrixb_size( |
int | smatrixb_clear( |
int | smatrixb_reset( |
int | smatrixb_isset( |
int | smatrixb_insert( |
int | smatrixb_delete( |
int | smatrixb_set( |
unsigned char | smatrixb_get( |
int | smatrixb_eye( |
int | smatrixb_mul( |
int | smatrixb_vmul( |
Interfaces
smatrixb smatrixb_create(
Create \(M \times N\) sparse matrix, initialized with zeros
- _m : number of rows in matrix
- _n : number of columns in matrix
smatrixb smatrixb_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 smatrixb_destroy(
Destroy object, freeing all internal memory
int smatrixb_print(
Print sparse matrix in compact form to stdout
int smatrixb_print_expanded(
Print sparse matrix in expanded form to stdout
int smatrixb_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 smatrixb_clear(
Zero all elements and retain allocated memory
int smatrixb_reset(
Zero all elements and clear memory
int smatrixb_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 smatrixb_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 smatrixb_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 smatrixb_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
unsigned char smatrixb_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 smatrixb_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 smatrixb_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 smatrixb_vmul(
Multiply sparse matrix by vector
- _q : sparse matrix
- _x : input vector, shape: (_n, 1)
- _y : output vector, shape: (_m, 1)