fmat class
[FTS Data Classes]


Detailed Description

The fmat class.

Plain two-dimensional floating-point matrix.

float matrices and vectors


Typedefs

typedef struct fmat fmat_t
 The fmat data type.

Functions

float * fmat_lock (fmat_t *fmat)
 Get a thread-safe shared pointer to the raw float data vector of an fmat.
void fmat_unlock (fmat_t *fmat)
 Unlock an fmat after a previous lock.
int fmat_get_m (fmat_t *fmat)
 Get number of rows of an fmat.
int fmat_get_n (fmat_t *fmat)
 Get number of columns of an fmat.
FTS_API fmat_tfmat_create (int m, int n)
 Create an fmat with a given dimensions (number of rows and columns).
FTS_API fts_schema_tfmat_get_schema (fmat_t *self, int dim)
 Get row or column schema of fmat.
FTS_API void fmat_set_schema (fmat_t *self, int dim, fts_schema_t *schema)
 Get row or column schema of fmat.
FTS_API int fmat_reshape_nogrow (fmat_t *self, int m, int n)
 Get pointer to values of redimensioned fmat. (The contained data is not rearranged to fit the new dimensions).
FTS_API int fmat_set_size_nogrow (fmat_t *self, int m, int n)
 Change matrix dimensions (number of rows and columns).
FTS_API int fmat_set_m_nogrow (fmat_t *self, int m)
 Change number of rows of an fmat.
FTS_API int fmat_set_n_nogrow (fmat_t *self, int n)
 Change number of columns of an fmat.
FTS_API int fmat_insert_rows_nogrow (fmat_t *self, int pos, int num)
 Insert (zeroed) columns at given column index to an fmat.
FTS_API int fmat_insert_columns_nogrow (fmat_t *self, int pos, int num)
 Insert (zeroed) rows at given row index to an fmat.
FTS_API int fmat_delete_rows (fmat_t *self, int start_idx, int numrows)
 Delete given number of rows from given index.
FTS_API int fmat_delete_columns (fmat_t *self, int start_idx, int numcols)
 Delete given numner of columns from given index.
float * fmat_get_element (fmat_t *fmat, int i, int j)
 Get the value at given index (row and column) of an fmat.
void fmat_set_element (fmat_t *fmat, int i, int j, float val)
 Set value at given index (row and column) to given value of an fmat.
void fmat_set_onset (fmat_t *fmat, double onset)
 Set fractional onset of an fmat.
double fmat_get_onset (fmat_t *fmat)
 Get fractional onset of an fmat.
void fmat_set_domain (fmat_t *fmat, double domain)
 Set floating-point size (domain) of an fmat.
double fmat_get_domain (fmat_t *fmat)
 Set floating-point size (domain) of an fmat.
FTS_API int fmat_or_fvec_vector (fts_object_t *obj, float **ptr, int *size, int *stride)
 Check class and get dimensions of an fmat or fvec vector.
FTS_API int fmat_or_fvec_vector_lock (fts_object_t *obj, float **ptr, int *size, int *stride)
 Check class and get dimensions of an fmat or fvec vector.
FTS_API int fmat_or_fvec_lock (fts_object_t *obj)
 Check class, and lock an fmat or fvec vector.
FTS_API void fmat_or_fvec_unlock (fts_object_t *obj)
 Unlock object after call to fmat_or_fvec_lock(), fmat_or_fvec_vector_lock(), or fmat_or_fvec_matrix_lock().
FTS_API void fmat_set_const (fmat_t *mat, float c)
 Set all values of an fmat to a constant value.
FTS_API void fmat_set_from_atoms (fmat_t *fmat, int onset, int step, int ac, const fts_atom_t *at)
 Set fmat values from list of atoms starting from given index and unsing given stride.
FTS_API void fmat_copy_locked (fmat_t *orig, fmat_t *copy)
 Copy fmat values (and dimensions) to another with both locked.
FTS_API void fmat_resample_locked (fmat_t *in, fmat_t *out, double factor)
 Copy fmat values to another applying resampling.
FTS_API void fmat_sort_ascending (fmat_t *fmat, int col)
 Sort fmat rows according to the values of a given column in ascending order.
FTS_API void fmat_sort_descending (fmat_t *fmat, int col)
 Sort fmat rows according to the values of a given column in descending order.

Variables

FTS_API fts_class_tfmat_class
 The fmat class identifier (pointer to class instance).
FTS_API fmat_tfmat_null
 Empty fmat constant.


Function Documentation

FTS_API void fmat_copy_locked ( fmat_t orig,
fmat_t copy 
)

Copy fmat values (and dimensions) to another with both locked.

Parameters:
orig the original fmat
copy the copy fmat
Returns:
max absolute value in range

FTS_API fmat_t* fmat_create ( int  m,
int  n 
)

Create an fmat with a given dimensions (number of rows and columns).

Parameters:
m number of rows
n number of columns
Returns:
created fmat

FTS_API int fmat_delete_columns ( fmat_t self,
int  start_idx,
int  numcols 
)

Delete given numner of columns from given index.

Parameters:
self the fmat
start_idx start index
numcols number of columns to delete
Returns:
actual number of columns deleted

FTS_API int fmat_delete_rows ( fmat_t self,
int  start_idx,
int  numrows 
)

Delete given number of rows from given index.

Parameters:
self the fmat
start_idx start index
numrows number of rows to delete
Returns:
actual number of rows deleted

double fmat_get_domain ( fmat_t fmat  ) 

Set floating-point size (domain) of an fmat.

Parameters:
fmat the fmat
Returns:
floating-point size (domain)

float* fmat_get_element ( fmat_t fmat,
int  i,
int  j 
)

Get the value at given index (row and column) of an fmat.

Parameters:
fmat the fmat
i the row
j the column
Returns:
element at row i and coulmn j

int fmat_get_m ( fmat_t fmat  ) 

Get number of rows of an fmat.

Parameters:
fmat the fmat
Returns:
number of rows

int fmat_get_n ( fmat_t fmat  ) 

Get number of columns of an fmat.

Parameters:
fmat the fmat
Returns:
number of columns

double fmat_get_onset ( fmat_t fmat  ) 

Get fractional onset of an fmat.

Parameters:
fmat the fmat
Returns:
fractional onset [0 ... 1[

FTS_API fts_schema_t* fmat_get_schema ( fmat_t self,
int  dim 
)

Get row or column schema of fmat.

Parameters:
dim get row schema if dim == 1, column schema if dim == 2
Returns:
pointer to schema

FTS_API int fmat_insert_columns_nogrow ( fmat_t self,
int  pos,
int  num 
)

Insert (zeroed) rows at given row index to an fmat.

Parameters:
self the fmat
pos index where insert new rows
num number of rows to insert
Returns:
actual number of columns inserted

FTS_API int fmat_insert_rows_nogrow ( fmat_t self,
int  pos,
int  num 
)

Insert (zeroed) columns at given column index to an fmat.

Parameters:
self the fmat
pos index where insert new cols
num number of columns to insert
Returns:
actual number of rows inserted

float* fmat_lock ( fmat_t fmat  ) 

Get a thread-safe shared pointer to the raw float data vector of an fmat.

This function puts a shared lock (read lock) on the fmat. The fmat has to be unlocked by a call to fmat_unlock().

Parameters:
fmat the fmat
Returns:
pointer to raw float data vector

FTS_API int fmat_or_fvec_lock ( fts_object_t obj  ) 

Check class, and lock an fmat or fvec vector.

This function puts a shared lock (read lock) on the object (fmat ro fvec). The object has be unlocked by a call to fmat_or_fvec_unlock().

Parameters:
obj the object
Returns:
1 for fvec, 2 for fmat, 0 for objects of any other class.

FTS_API void fmat_or_fvec_unlock ( fts_object_t obj  ) 

Unlock object after call to fmat_or_fvec_lock(), fmat_or_fvec_vector_lock(), or fmat_or_fvec_matrix_lock().

Parameters:
obj the object

FTS_API int fmat_or_fvec_vector ( fts_object_t obj,
float **  ptr,
int *  size,
int *  stride 
)

Check class and get dimensions of an fmat or fvec vector.

The functions returns 1 for fvec, 2 for fmat or 0 for any other object.

 float *ptr
 int size;
 int stride;
 
 if(fmat_or_fvec_vector(obj, &ptr, &size, &stride) != 0)
 {
 int i;
 
 for(i=0, j=0; i<size; i++, j+=stride)
 {
 out[i] = ptr[j];
 }
 }

Parameters:
obj the object
ptr return pointer to raw floating point values.
size return size
stride return size
Returns:
1 for fvec, 2 for fmat, 0 for objects of any other class.

FTS_API int fmat_or_fvec_vector_lock ( fts_object_t obj,
float **  ptr,
int *  size,
int *  stride 
)

Check class and get dimensions of an fmat or fvec vector.

This function puts a shared lock (read lock) on the object (fmat ro fvec). The object has be unlocked by a call to fmat_or_fvec_unlock().

Parameters:
obj the object
ptr return pointer to raw floating point values.
size return size
stride return size
Returns:
1 for fvec, 2 for fmat, 0 for objects of any other class.

FTS_API void fmat_resample_locked ( fmat_t in,
fmat_t out,
double  factor 
)

Copy fmat values to another applying resampling.

Parameters:
in the input fmat
out the output fmat
factor resampling factor (downsampling factor > 1)

FTS_API int fmat_reshape_nogrow ( fmat_t self,
int  m,
int  n 
)

Get pointer to values of redimensioned fmat. (The contained data is not rearranged to fit the new dimensions).

Parameters:
self the fmat
m number of rows
n number of columns
Returns:
actual number of rows obtained

FTS_API void fmat_set_const ( fmat_t mat,
float  c 
)

Set all values of an fmat to a constant value.

Parameters:
mat the object (fmat or fvec)
c the const value

void fmat_set_domain ( fmat_t fmat,
double  domain 
)

Set floating-point size (domain) of an fmat.

Parameters:
fmat the fmat
domain floating-point size (domain)

void fmat_set_element ( fmat_t fmat,
int  i,
int  j,
float  val 
)

Set value at given index (row and column) to given value of an fmat.

Parameters:
fmat the fmat
i the row
j the column
val new value
Returns:
new element

FTS_API void fmat_set_from_atoms ( fmat_t fmat,
int  onset,
int  step,
int  ac,
const fts_atom_t *  at 
)

Set fmat values from list of atoms starting from given index and unsing given stride.

Parameters:
fmat the fmat
onset starting index
step stride
ac number of values
at values

FTS_API int fmat_set_m_nogrow ( fmat_t self,
int  m 
)

Change number of rows of an fmat.

Parameters:
self the fmat
m new number of rows
Returns:
actual number of rows obtained

FTS_API int fmat_set_n_nogrow ( fmat_t self,
int  n 
)

Change number of columns of an fmat.

Parameters:
self the fmat
n new number of columns
Returns:
actual number of columns obtained

void fmat_set_onset ( fmat_t fmat,
double  onset 
)

Set fractional onset of an fmat.

Parameters:
fmat the fmat
onset fractional onset [0 ... 1[

FTS_API void fmat_set_schema ( fmat_t self,
int  dim,
fts_schema_t schema 
)

Get row or column schema of fmat.

Parameters:
schema pointer to schema
dim set row schema if dim == 1, column schema if dim == 2

FTS_API int fmat_set_size_nogrow ( fmat_t self,
int  m,
int  n 
)

Change matrix dimensions (number of rows and columns).

This function re-arranges the matrix values corresponing to the new dimensions. Additional rows and/or colums will be zeroed.

Parameters:
self the fmat
m number of rows
n number of columns
Returns:
actual number of rows obtained
If you want to resize the memory block without moving data, use fmat_reshape.

FTS_API void fmat_sort_ascending ( fmat_t fmat,
int  col 
)

Sort fmat rows according to the values of a given column in ascending order.

Parameters:
fmat the fmat
col reference column

FTS_API void fmat_sort_descending ( fmat_t fmat,
int  col 
)

Sort fmat rows according to the values of a given column in descending order.

Parameters:
fmat the fmat
col reference column

void fmat_unlock ( fmat_t fmat  ) 

Unlock an fmat after a previous lock.

This function has to be calles after a call to fmat_lock().

Parameters:
fmat the fmat


Generated on Wed Aug 24 18:28:43 2011 for FTM API by  doxygen 1.5.6