dmlfw (Daniyal Machine Learning Framework)
|
Core string matrix types and utilities. More...
#include <dmlfw_types.h>
Go to the source code of this file.
typedef struct __dmlfw_mat_string | dmlfw_mat_string |
Opaque structure representing a string matrix. | |
void | dmlfw_mat_string_copy (dmlfw_mat_string *target, dmlfw_mat_string *source, index_t target_row_index, index_t target_column_index, index_t source_from_row_index, index_t source_from_column_index, index_t source_to_row_index, index_t source_to_column_index) |
Copies a submatrix region from source to target matrix. | |
dmlfw_mat_string * | dmlfw_mat_string_create_new (dimension_t rows, dimension_t columns) |
Creates a new string matrix with specified rows and columns. | |
dmlfw_mat_string * | dmlfw_mat_string_delete_columns (dmlfw_mat_string *matrix, index_t *indexes, dimension_t indexes_size, dmlfw_mat_string *new_matrix) |
Deletes specified columns from the matrix. | |
void | dmlfw_mat_string_destroy (dmlfw_mat_string *matrix) |
Destroys a string matrix and frees all allocated memory. | |
dmlfw_mat_string * | dmlfw_mat_string_from_csv (const char *csv_file_name, dmlfw_mat_string *matrix, dmlfw_row_vec_string **header) |
Loads a matrix and header from a CSV file. | |
void | dmlfw_mat_string_get (dmlfw_mat_string *matrix, index_t row, index_t column, char **string) |
Retrieves the string at specified row and column. | |
void | dmlfw_mat_string_get_dimensions (dmlfw_mat_string *matrix, dimension_t *rows, dimension_t *columns) |
Retrieves dimensions of the string matrix. | |
void | dmlfw_mat_string_set (dmlfw_mat_string *matrix, index_t row, index_t column, char *string) |
Sets the string at specified row and column. | |
dmlfw_mat_string * | dmlfw_mat_string_shuffle (dmlfw_mat_string *matrix, uint8_t how_many_times_to_shuffle, dmlfw_mat_string *shuffled_matrix) |
Shuffles rows of the string matrix. | |
void | dmlfw_mat_string_to_csv (dmlfw_mat_string *matrix, const char *csv_file_name, dmlfw_row_vec_string *header) |
Saves a string matrix and header to a CSV file. | |
dmlfw_mat_string * | dmlfw_mat_string_transpose (dmlfw_mat_string *matrix, dmlfw_mat_string *transposed_matrix) |
Transposes a string matrix. | |
Core string matrix types and utilities.
This header defines opaque matrix structures specialized for string data. It provides APIs for creation, destruction, element access and mutation, CSV import/export, matrix transpose, shuffle, copy, and column deletion.
All functions report errors via the centralized error API. Use dmlfw_error()
to check for errors after calls. dmlfw_get_error_string()
and dmlfw_get_debug_string()
provide error information.
Functions returning new matrix pointers transfer ownership to the caller, who is responsible for freeing with dmlfw_mat_string_destroy()
.
All indices are zero-based.
typedef struct __dmlfw_mat_string dmlfw_mat_string |
Opaque structure representing a string matrix.
The internal representation is hidden. Use the provided API functions to create, manipulate, and destroy instances.
void dmlfw_mat_string_copy | ( | dmlfw_mat_string * | target, |
dmlfw_mat_string * | source, | ||
index_t | target_row_index, | ||
index_t | target_column_index, | ||
index_t | source_from_row_index, | ||
index_t | source_from_column_index, | ||
index_t | source_to_row_index, | ||
index_t | source_to_column_index | ||
) |
Copies a submatrix region from source to target matrix.
target | [in,out] Destination matrix (non-NULL). |
source | [in] Source matrix (non-NULL). |
target_row_index | [in] Start row index in target. |
target_column_index | [in] Start column index in target. |
source_from_row_index | [in] Starting row index in source. |
source_from_column_index | [in] Starting column index in source. |
source_to_row_index | [in] Ending row index in source. |
source_to_column_index | [in] Ending column index in source. |
Usage example:
dmlfw_mat_string * dmlfw_mat_string_create_new | ( | dimension_t | rows, |
dimension_t | columns | ||
) |
Creates a new string matrix with specified rows and columns.
rows | [in] Number of rows (must be > 0). |
columns | [in] Number of columns (must be > 0). |
dmlfw_mat_string_destroy()
.Usage example:
dmlfw_mat_string * dmlfw_mat_string_delete_columns | ( | dmlfw_mat_string * | matrix, |
index_t * | indexes, | ||
dimension_t | indexes_size, | ||
dmlfw_mat_string * | new_matrix | ||
) |
Deletes specified columns from the matrix.
matrix | [in] Source matrix (non-NULL). |
indexes | [in] Array of zero-based column indexes to delete. |
indexes_size | [in] Number of indexes to delete. |
new_matrix | [in,out] Optional matrix container for result, or NULL. |
Usage example:
void dmlfw_mat_string_destroy | ( | dmlfw_mat_string * | matrix | ) |
Destroys a string matrix and frees all allocated memory.
matrix | [in] Pointer to matrix, or NULL (no-op). |
Usage example:
dmlfw_mat_string * dmlfw_mat_string_from_csv | ( | const char * | csv_file_name, |
dmlfw_mat_string * | matrix, | ||
dmlfw_row_vec_string ** | header | ||
) |
Loads a matrix and header from a CSV file.
csv_file_name | [in] CSV file path (non-NULL). |
matrix | [in,out] Optional matrix to reuse or NULL. |
header | [out] Pointer to receive the newly allocated header row vector. |
Usage example:
void dmlfw_mat_string_get | ( | dmlfw_mat_string * | matrix, |
index_t | row, | ||
index_t | column, | ||
char ** | string | ||
) |
Retrieves the string at specified row and column.
matrix | [in] Matrix (non-NULL). |
row | [in] Zero-based row index. |
column | [in] Zero-based column index. |
string | [out] Allocation pointer to receive string copy (must not be NULL). |
Usage example:
void dmlfw_mat_string_get_dimensions | ( | dmlfw_mat_string * | matrix, |
dimension_t * | rows, | ||
dimension_t * | columns | ||
) |
Retrieves dimensions of the string matrix.
matrix | [in] Matrix (non-NULL). |
rows | [out] Pointer to receive row count (non-NULL). |
columns | [out] Pointer to receive column count (non-NULL). |
Usage example:
void dmlfw_mat_string_set | ( | dmlfw_mat_string * | matrix, |
index_t | row, | ||
index_t | column, | ||
char * | string | ||
) |
Sets the string at specified row and column.
matrix | [in,out] Matrix (non-NULL). |
row | [in] Zero-based row index. |
column | [in] Zero-based column index. |
string | [in] String value to copy into matrix (non-NULL). |
Usage example:
dmlfw_mat_string * dmlfw_mat_string_shuffle | ( | dmlfw_mat_string * | matrix, |
uint8_t | how_many_times_to_shuffle, | ||
dmlfw_mat_string * | shuffled_matrix | ||
) |
Shuffles rows of the string matrix.
matrix | [in] Matrix to shuffle (non-NULL). |
how_many_times_to_shuffle | [in] Number of shuffle iterations. |
shuffled_matrix | [in,out] Optional matrix container for result, or NULL. |
Usage example:
void dmlfw_mat_string_to_csv | ( | dmlfw_mat_string * | matrix, |
const char * | csv_file_name, | ||
dmlfw_row_vec_string * | header | ||
) |
Saves a string matrix and header to a CSV file.
matrix | [in] Matrix to save (non-NULL). |
csv_file_name | [in] Output CSV file path (non-NULL). |
header | [in] Header row vector (non-NULL). |
Usage example:
dmlfw_mat_string * dmlfw_mat_string_transpose | ( | dmlfw_mat_string * | matrix, |
dmlfw_mat_string * | transposed_matrix | ||
) |
Transposes a string matrix.
matrix | [in] Matrix to transpose (non-NULL). |
transposed_matrix | [in,out] Optional matrix container to receive transpose, or NULL. |
Usage example: