/* Functions for linear algebra and matrix manipulation. */ /* Last edited on 2022-10-20 05:50:05 by stolfi */ #ifndef tf_matrix_H #define tf_matrix_H #include #include #include #include #include #include typedef struct _rmxn_t { int32_t nrows; int32_t ncols; double **c; } *rmxn_t; typedef struct _mat_rm_t { int32_t nrows; int32_t ncols; double *c; } *mat_rm_t; typedef struct _rm_t { int32_t size; double *c; } *rm_t; void tf_copy_vector_rm (rm_t source, rm_t target); mat_rm_t tf_alloc_mat_rm (int32_t nrows, int32_t ncols); void tf_free_mat_rm_structure (mat_rm_t m); rm_t tf_alloc_rm (int32_t size); void tf_free_rm_structure (rm_t v); rmxn_t tf_alloc_rmxn (int32_t nrows, int32_t ncols); void tf_free_rmxn_structure (rmxn_t m); void tf_solve_system_mxn (mat_rm_t M, rm_t a, rm_t b, double wgts[]); void tf_solve_system_mxn_mxp (mat_rm_t M, mat_rm_t U, mat_rm_t B, double wgts[]); /* Solves {M U = B} for {U} in least squares sense. */ void tf_apply_weigths (mat_rm_t m, double wgts[]); mat_rm_t tf_transpose_mat_rm (mat_rm_t m); void tf_print_mat_rm (mat_rm_t m); #endif