streaming_algorithms  0.0.5
A collection of streaming data algorithms
Typedefs | Functions
matrix.h File Reference

Matrix data storage. More...

#include <stddef.h>
#include <stdint.h>
Include dependency graph for matrix.h:

Go to the source code of this file.

Typedefs

typedef struct sa_matrix_int sa_matrix_int
 
typedef struct sa_matrix_flt sa_matrix_flt
 

Functions

sa_matrix_intsa_create_matrix_int (int rows, int cols)
 Allocates and initializes the data structure. More...
 
sa_matrix_fltsa_create_matrix_flt (int rows, int cols)
 
void sa_init_matrix_int (sa_matrix_int *m)
 Zeros out the matrix. More...
 
void sa_init_matrix_flt (sa_matrix_flt *m)
 
void sa_init_matrix_row_int (sa_matrix_int *m, int row)
 Zeros out the specified matrix row. More...
 
void sa_init_matrix_row_flt (sa_matrix_flt *m, int row)
 
int sa_add_matrix_int (sa_matrix_int *m, int row, int col, int v)
 Adds the specified value to the matrix. More...
 
float sa_add_matrix_flt (sa_matrix_flt *m, int row, int col, float v)
 
int sa_set_matrix_int (sa_matrix_int *m, int row, int col, int v)
 Sets the time series row to the specified value. More...
 
float sa_set_matrix_flt (sa_matrix_flt *m, int row, int col, float v)
 
int sa_get_matrix_int (sa_matrix_int *m, int row, int cols)
 Gets the value of the time series row. More...
 
float sa_get_matrix_flt (sa_matrix_flt *m, int row, int cols)
 
void sa_destroy_matrix_int (sa_matrix_int *m)
 Free the associated memory. More...
 
void sa_destroy_matrix_flt (sa_matrix_flt *m)
 
char * sa_serialize_matrix_int (sa_matrix_int *m, size_t *len)
 Serialize the internal state to a buffer. More...
 
char * sa_serialize_matrix_flt (sa_matrix_flt *m, size_t *len)
 
int sa_deserialize_matrix_int (sa_matrix_int *m, const char *buf, size_t len)
 Restores the internal state from the serialized output. More...
 
int sa_deserialize_matrix_flt (sa_matrix_flt *m, const char *buf, size_t len)
 

Detailed Description

Matrix data storage.

Definition in file matrix.h.

Typedef Documentation

typedef struct sa_matrix_flt sa_matrix_flt

Definition at line 16 of file matrix.h.

typedef struct sa_matrix_int sa_matrix_int

Definition at line 15 of file matrix.h.

Function Documentation

float sa_add_matrix_flt ( sa_matrix_flt m,
int  row,
int  col,
float  v 
)
int sa_add_matrix_int ( sa_matrix_int m,
int  row,
int  col,
int  v 
)

Adds the specified value to the matrix.

Parameters
mPointer to matrix_int
row
col
vValue to add
Returns
current value
sa_matrix_flt* sa_create_matrix_flt ( int  rows,
int  cols 
)
sa_matrix_int* sa_create_matrix_int ( int  rows,
int  cols 
)

Allocates and initializes the data structure.

Parameters
rows
cols
Returns
Pointer to matrix_int
int sa_deserialize_matrix_flt ( sa_matrix_flt m,
const char *  buf,
size_t  len 
)
int sa_deserialize_matrix_int ( sa_matrix_int m,
const char *  buf,
size_t  len 
)

Restores the internal state from the serialized output.

Parameters
mPointer to matrix_int
bufBuffer containing the output of serialize_matrix_int
lenLength of the buffer
Returns
0 = success 1 = invalid buffer length 2 = invalid rows 3 = invalid cols
void sa_destroy_matrix_flt ( sa_matrix_flt m)
void sa_destroy_matrix_int ( sa_matrix_int m)

Free the associated memory.

Parameters
mPointer to matrix_int
float sa_get_matrix_flt ( sa_matrix_flt m,
int  row,
int  cols 
)
int sa_get_matrix_int ( sa_matrix_int m,
int  row,
int  cols 
)

Gets the value of the time series row.

Parameters
mPointer to matrix_int
row
cols
Returns
current value
void sa_init_matrix_flt ( sa_matrix_flt m)
void sa_init_matrix_int ( sa_matrix_int m)

Zeros out the matrix.

  • matrix_int is set to all zeros
  • matrix_flt is ste to all NAN
Parameters
mPointer to matrix_int
void sa_init_matrix_row_flt ( sa_matrix_flt m,
int  row 
)
void sa_init_matrix_row_int ( sa_matrix_int m,
int  row 
)

Zeros out the specified matrix row.

  • matrix_int is set to all zeros
  • matrix_flt is ste to all NAN
Parameters
mPointer to matrix_int
row
char* sa_serialize_matrix_flt ( sa_matrix_flt m,
size_t *  len 
)
char* sa_serialize_matrix_int ( sa_matrix_int m,
size_t *  len 
)

Serialize the internal state to a buffer.

Parameters
mPointer to matrix_int
lenLength of the returned buffer
Returns
char* Serialized representation MUST be freed by the caller
float sa_set_matrix_flt ( sa_matrix_flt m,
int  row,
int  col,
float  v 
)
int sa_set_matrix_int ( sa_matrix_int m,
int  row,
int  col,
int  v 
)

Sets the time series row to the specified value.

Parameters
mPointer to matrix_int
row
col
vValue to set
Returns
current value