Zephyr Scientific Library (zscilib)
Typedefs | Functions
Initialisation

Functions used to initialise matrices. More...

Typedefs

typedef int(* zsl_mtx_unary_fn_t) (struct zsl_mtx *m, size_t i, size_t j)
 Function prototype called when applying a set of component-wise unary operations to a matrix via zsl_mtx_unary_func. More...
 
typedef int(* zsl_mtx_binary_fn_t) (struct zsl_mtx *ma, struct zsl_mtx *mb, struct zsl_mtx *mc, size_t i, size_t j)
 Function prototype called when applying a set of component-wise binary operations using a pair of symmetrical matrices via zsl_mtx_binary_func. More...
 
typedef int(* zsl_mtx_init_entry_fn_t) (struct zsl_mtx *m, size_t i, size_t j)
 Function prototype called when populating a matrix via zsl_mtx_init. More...
 

Functions

int zsl_mtx_entry_fn_empty (struct zsl_mtx *m, size_t i, size_t j)
 Assigns a zero-value to all entries in the matrix. More...
 
int zsl_mtx_entry_fn_identity (struct zsl_mtx *m, size_t i, size_t j)
 Sets the value to '1.0' if the entry is on the diagonal (row=col), otherwise '0.0'. More...
 
int zsl_mtx_entry_fn_random (struct zsl_mtx *m, size_t i, size_t j)
 Sets the value to a random number between -1.0 and 1.0. More...
 
int zsl_mtx_init (struct zsl_mtx *m, zsl_mtx_init_entry_fn_t entry_fn)
 Initialises matrix 'm' using the specified entry function to assign values. More...
 
int zsl_mtx_from_arr (struct zsl_mtx *m, zsl_real_t *a)
 Converts an array of values into a matrix. More...
 
int zsl_mtx_copy (struct zsl_mtx *mdest, struct zsl_mtx *msrc)
 Copies the contents of matrix 'msrc' into matrix 'mdest'. More...
 

Detailed Description

Functions used to initialise matrices.

Typedef Documentation

◆ zsl_mtx_binary_fn_t

typedef int(* zsl_mtx_binary_fn_t) (struct zsl_mtx *ma, struct zsl_mtx *mb, struct zsl_mtx *mc, size_t i, size_t j)

Function prototype called when applying a set of component-wise binary operations using a pair of symmetrical matrices via zsl_mtx_binary_func.

Parameters
maPointer to first zsl_mtx to use in the binary operation.
mbPointer to second zsl_mtx to use in the binary operation.
mcPointer to output zsl_mtx used to store results.
iThe row number to write (0-based).
jThe column number to write (0-based).
Returns
0 on success, and non-zero error code on failure

Definition at line 156 of file matrices.h.

◆ zsl_mtx_init_entry_fn_t

typedef int(* zsl_mtx_init_entry_fn_t) (struct zsl_mtx *m, size_t i, size_t j)

Function prototype called when populating a matrix via zsl_mtx_init.

Parameters
mPointer to the zsl_mtx to use.
iThe row number to write (0-based).
jThe column number to write (0-based).
Returns
0 on success, and non-zero error code on failure

Definition at line 168 of file matrices.h.

◆ zsl_mtx_unary_fn_t

typedef int(* zsl_mtx_unary_fn_t) (struct zsl_mtx *m, size_t i, size_t j)

Function prototype called when applying a set of component-wise unary operations to a matrix via zsl_mtx_unary_func.

Parameters
mPointer to the zsl_mtx to use.
iThe row number to write (0-based).
jThe column number to write (0-based).
Returns
0 on success, and non-zero error code on failure

Definition at line 142 of file matrices.h.

Function Documentation

◆ zsl_mtx_copy()

int zsl_mtx_copy ( struct zsl_mtx mdest,
struct zsl_mtx msrc 
)

Copies the contents of matrix 'msrc' into matrix 'mdest'.

Parameters
mdestPointer to the destination matrix data will be copied to.
msrcPointer to the source matrix data will be copied from.
Returns
0 on success, and non-zero error code on failure

Definition at line 81 of file matrices.c.

Referenced by zsl_mtx_balance(), zsl_mtx_gauss_elim(), zsl_mtx_gauss_reduc(), zsl_mtx_inv(), zsl_mtx_mult(), zsl_mtx_norm_elem(), zsl_mtx_qrd(), zsl_mtx_qrd_iter(), and zsl_mtx_reduce_iter().

◆ zsl_mtx_entry_fn_empty()

int zsl_mtx_entry_fn_empty ( struct zsl_mtx m,
size_t  i,
size_t  j 
)

Assigns a zero-value to all entries in the matrix.

Parameters
mPointer to the zsl_mtx to use.
iThe row number to write (0-based).
jThe column number to write (0-based).
Returns
0 on success, and non-zero error code on failure

Definition at line 31 of file matrices.c.

Referenced by zsl_mtx_cholesky(), and zsl_mtx_init().

◆ zsl_mtx_entry_fn_identity()

int zsl_mtx_entry_fn_identity ( struct zsl_mtx m,
size_t  i,
size_t  j 
)

Sets the value to '1.0' if the entry is on the diagonal (row=col), otherwise '0.0'.

Parameters
mPointer to the zsl_mtx to use.
iThe row number to write (0-based).
jThe column number to write (0-based).
Returns
0 on success, and non-zero error code on failure

Definition at line 37 of file matrices.c.

Referenced by zsl_mtx_augm_diag(), zsl_mtx_eigenvectors(), zsl_mtx_householder(), zsl_mtx_inv(), zsl_mtx_inv_3x3(), zsl_mtx_qrd(), and zsl_sta_weighted_mult_linear_reg().

◆ zsl_mtx_entry_fn_random()

int zsl_mtx_entry_fn_random ( struct zsl_mtx m,
size_t  i,
size_t  j 
)

Sets the value to a random number between -1.0 and 1.0.

Parameters
mPointer to the zsl_mtx to use.
iThe row number to write (0-based).
jThe column number to write (0-based).
Returns
0 on success, and non-zero error code on failure

Definition at line 43 of file matrices.c.

◆ zsl_mtx_from_arr()

int zsl_mtx_from_arr ( struct zsl_mtx m,
zsl_real_t a 
)

Converts an array of values into a matrix.

The number of elements in array 'a' must match the number of elements in matrix 'm' (m.sz_rows * m.sz_cols). As such, 'm' should be a previously initialised matrix with appropriate values assigned to m.sz_rows and m.sz_cols. Assumes array values are in row-major order.

Parameters
mThe matrix that the contents of array 'a' should be assigned to. The m.sz_rows and m.sz_cols dimensions must match the number of elements in 'a', meaning that the matrix should be initialised before being passed in to this function.
aPointer to the array containing the values to assign to 'm' in row-major order (left-to-right, top-to-bottom). The array will be read m.sz_rows * m.sz_cols elements deep.
Returns
0 on success, and non-zero error code on failure

Definition at line 73 of file matrices.c.

Referenced by zsl_mtx_householder(), zsl_mtx_reduce(), zsl_mtx_svd(), zsl_sta_mult_linear_reg(), and zsl_sta_weighted_mult_linear_reg().

◆ zsl_mtx_init()

int zsl_mtx_init ( struct zsl_mtx m,
zsl_mtx_init_entry_fn_t  entry_fn 
)

Initialises matrix 'm' using the specified entry function to assign values.

Parameters
mPointer to the zsl_mtx to use.
entry_fnThe zsl_mtx_init_entry_fn_t instance to call. If this is set to NULL 'zsl_mtx_entry_fn_empty' will be called.
Returns
0 on success, and non-zero error code on failure

Definition at line 50 of file matrices.c.

Referenced by zsl_mtx_augm_diag(), zsl_mtx_cholesky(), zsl_mtx_deter(), zsl_mtx_eigenvectors(), zsl_mtx_householder(), zsl_mtx_inv(), zsl_mtx_inv_3x3(), zsl_mtx_qrd(), zsl_mtx_svd(), zsl_mtx_vec_wedge(), zsl_sta_mult_linear_reg(), and zsl_sta_weighted_mult_linear_reg().