dmlfw (Daniyal Machine Learning Framework)
|
Core double precision vector and matrix arithmetic operations. More...
Go to the source code of this file.
Core double precision vector and matrix arithmetic operations.
This module provides fundamental arithmetic operations specialized for double precision vectors and matrices, including multiplication, addition, subtraction, scalar scaling, and advanced matrix multiplication algorithms like Strassen’s method.
Functions validate all input pointers and vector/matrix dimensions. Errors are reported through a centralized error API. After calling functions, check dmlfw_error()
and retrieve error details via dmlfw_get_error_string()
and dmlfw_get_debug_string()
.
Inputs are owned by the caller. Functions allocate new output vectors/matrices if corresponding pointers are NULL
. Any allocated output vectors/matrices are owned by the caller who must free them.
dmlfw_column_vec_double * dmlfw_add_double_column_vector | ( | dmlfw_column_vec_double * | left_vector, |
dmlfw_column_vec_double * | right_vector, | ||
dmlfw_column_vec_double * | new_vector | ||
) |
Adds two column vectors element-wise.
left_vector | [in] First vector (non-NULL). |
right_vector | [in] Second vector (non-NULL). |
new_vector | [in,out] Optional output vector, same size. If NULL, new vector allocated. |
Usage example:
dmlfw_mat_double * dmlfw_add_double_matrix_with_matrix | ( | dmlfw_mat_double * | left_matrix, |
dmlfw_mat_double * | right_matrix, | ||
dmlfw_mat_double * | new_matrix | ||
) |
Adds two matrices element-wise.
left_matrix | [in] First matrix (non-NULL). |
right_matrix | [in] Second matrix (non-NULL). |
new_matrix | [in,out] Optional output matrix, must match input sizes. If NULL, new matrix allocated. |
Usage example:
dmlfw_column_vec_double * dmlfw_element_wise_multiply_double_column_vector | ( | dmlfw_column_vec_double * | left_vector, |
dmlfw_column_vec_double * | right_vector, | ||
dmlfw_column_vec_double * | new_vector | ||
) |
Element-wise multiply two column vectors.
left_vector | [in] First vector (non-NULL). |
right_vector | [in] Second vector (non-NULL). |
new_vector | [in,out] Optional output vector, same size as inputs. If NULL, new vector allocated. |
Usage example:
dmlfw_column_vec_double * dmlfw_multiply_double_matrix_with_column_vector | ( | dmlfw_mat_double * | left_matrix, |
dmlfw_column_vec_double * | right_vector, | ||
dmlfw_column_vec_double * | product_vector | ||
) |
Multiplies a matrix with a column vector, producing a column vector.
left_matrix | [in] Input matrix (non-NULL). |
right_vector | [in] Column vector (non-NULL). |
product_vector | [in,out] Optional output vector with size matching matrix rows. If NULL, a new vector is allocated. |
Usage example:
dmlfw_mat_double * dmlfw_multiply_double_matrix_with_matrix | ( | dmlfw_mat_double * | left_matrix, |
dmlfw_mat_double * | right_matrix, | ||
dmlfw_mat_double * | product_matrix | ||
) |
Multiplies two matrices.
left_matrix | [in] Left matrix (non-NULL). |
right_matrix | [in] Right matrix (non-NULL). |
product_matrix | [in,out] Optional output matrix with appropriate dimensions. If NULL, a new matrix is allocated. |
Usage example:
dmlfw_mat_double * dmlfw_multiply_double_matrix_with_matrix_strassens | ( | dmlfw_mat_double * | left_matrix, |
dmlfw_mat_double * | right_matrix, | ||
dmlfw_mat_double * | new_matrix | ||
) |
Multiplies two square matrices using Strassen's algorithm.
left_matrix | [in] Left square matrix with power-of-two dimensions (non-NULL). |
right_matrix | [in] Right square matrix matching left matrix dimensions (non-NULL). |
new_matrix | [in,out] Optional output matrix, square of same size. If NULL, new matrix allocated. |
Usage example:
dmlfw_column_vec_double * dmlfw_multiply_double_row_vector_with_column_vector | ( | dmlfw_row_vec_double * | left_vector, |
dmlfw_column_vec_double * | right_vector, | ||
dmlfw_column_vec_double * | product_vector | ||
) |
Multiplies a row vector with a column vector, producing a single-value column vector.
left_vector | [in] Left row vector (non-NULL). |
right_vector | [in] Right column vector (non-NULL). |
product_vector | [in,out] Optional pre-allocated output vector, size must be 1. If NULL, a new vector is allocated. |
Usage example:
dmlfw_column_vec_double * dmlfw_multiply_double_scalar_with_column_vector | ( | double | scalar_value, |
dmlfw_column_vec_double * | vector, | ||
dmlfw_column_vec_double * | product_vector | ||
) |
Multiplies a scalar with a column vector.
scalar_value | [in] Scalar to multiply. |
vector | [in] Input vector (non-NULL). |
product_vector | [in,out] Optional output vector matching input size. If NULL, a new vector is allocated. |
Usage example:
dmlfw_column_vec_double * dmlfw_subtract_double_column_vector | ( | dmlfw_column_vec_double * | left_vector, |
dmlfw_column_vec_double * | right_vector, | ||
dmlfw_column_vec_double * | difference_vector | ||
) |
Subtracts two column vectors element-wise.
left_vector | [in] Minuend vector (non-NULL). |
right_vector | [in] Subtrahend vector (non-NULL). |
difference_vector | [in,out] Optional output vector matching input size. If NULL, a new vector is allocated. |
Usage example:
dmlfw_column_vec_double * dmlfw_subtract_double_column_vector_from_scalar | ( | dmlfw_column_vec_double * | vector, |
double | scalar_value, | ||
dmlfw_column_vec_double * | new_vector | ||
) |
Subtracts each element of a column vector from a scalar.
vector | [in] Input vector (non-NULL). |
scalar_value | [in] Scalar to subtract from. |
new_vector | [in,out] Optional output vector same size as input. If NULL, new vector allocated. |
Usage example:
dmlfw_mat_double * dmlfw_subtract_double_matrix_from_matrix | ( | dmlfw_mat_double * | left_matrix, |
dmlfw_mat_double * | right_matrix, | ||
dmlfw_mat_double * | new_matrix | ||
) |
Subtracts second matrix from first element-wise.
left_matrix | [in] Minuend matrix (non-NULL). |
right_matrix | [in] Subtrahend matrix (non-NULL). |
new_matrix | [in,out] Optional output matrix, must match input sizes. If NULL, new matrix allocated. |
Usage example: