![]() |
C3E: Complex Compute Core Engine v1.0
An engine for handling complex computational tasks
|
Matrix operations for the Complex Compute Core Engine (C3E) framework. More...
#include <c3e/commons.h>

Go to the source code of this file.
Macros | |
| #define | MATRIX_ELEM(matrix, row, col) (matrix)->data[(row) * (matrix)->cols + (col)] |
| Macro to access a matrix element. | |
Functions | |
| c3e_matrix * | c3e_matrix_init (int rows, int cols) |
| Initializes a matrix with the given number of rows and columns. | |
| void | c3e_matrix_free (c3e_matrix *matrix) |
| Frees the memory allocated for a matrix. | |
| void | c3e_matrix_set_elements (c3e_matrix *matrix, c3e_number *values) |
| Sets the elements of a matrix to the given values. | |
| void | c3e_matrix_fill (c3e_matrix *matrix, c3e_number value) |
| Fills a matrix with a specified value. | |
| c3e_number | c3e_matrix_get_at (c3e_matrix *matrix, int row, int col) |
| Retrieves an element from the matrix at a specific position. | |
| int | c3e_matrix_size (c3e_matrix *matrix) |
| Computes the total number of elements in a matrix. | |
| c3e_matrix * | c3e_matrix_ones (int rows, int cols) |
| Creates a matrix with all elements set to one. | |
| c3e_matrix * | c3e_matrix_ones_like (c3e_matrix *matrix) |
| Creates a matrix of ones with the same shape as another matrix. | |
| c3e_matrix * | c3e_matrix_zeros (int rows, int cols) |
| Creates a matrix with all elements set to zero. | |
| c3e_matrix * | c3e_matrix_zeros_like (c3e_matrix *matrix) |
| Creates a matrix of zeros with the same shape as another matrix. | |
| c3e_matrix * | c3e_matrix_full (int rows, int cols, c3e_number value) |
| Creates a matrix with all elements set to a specified value. | |
| c3e_matrix * | c3e_matrix_full_like (c3e_matrix *matrix, c3e_number value) |
| Creates a matrix with the same shape as another matrix and fills it with a specified value. | |
| c3e_matrix * | c3e_matrix_identity (int side) |
| Creates an identity matrix of a given size. | |
| c3e_matrix * | c3e_matrix_random (int rows, int cols, int seed) |
| Creates a matrix with random values. | |
| c3e_matrix * | c3e_matrix_random_bound (int rows, int cols, int seed, c3e_number min, c3e_number max) |
| Creates a matrix with random values within a specified range. | |
| c3e_matrix * | c3e_matrix_copy (c3e_matrix *matrix) |
| Creates a copy of a matrix. | |
| c3e_matrix * | c3e_matrix_append (c3e_matrix *matrix, c3e_matrix *subject, int axis) |
| Appends one matrix to another along a specified axis. | |
| c3e_matrix * | c3e_matrix_add (c3e_matrix *matrix, c3e_matrix *subject) |
| Adds two matrices element-wise. | |
| c3e_matrix * | c3e_matrix_sub (c3e_matrix *matrix, c3e_matrix *subject) |
| Subtracts one matrix from another element-wise. | |
| c3e_matrix * | c3e_matrix_mul (c3e_matrix *matrix, c3e_matrix *subject) |
| Multiplies two matrices element-wise. | |
| c3e_matrix * | c3e_matrix_div (c3e_matrix *matrix, c3e_matrix *subject) |
| Divides one matrix by another element-wise. | |
| c3e_matrix * | c3e_matrix_dot (c3e_matrix *matrix, c3e_matrix *subject) |
| Computes the dot product of two matrices. | |
| c3e_matrix * | c3e_matrix_scale (c3e_matrix *matrix, int x) |
| Scales the elements of a matrix by a scalar value. | |
| c3e_matrix * | c3e_matrix_transpose (c3e_matrix *matrix) |
| Transposes a matrix. | |
| c3e_matrix * | c3e_matrix_slice (c3e_matrix *matrix, int frows, int trows, int fcols, int tcols) |
| Slices a sub-matrix from a matrix. | |
| void | c3e_matrix_col_copy (c3e_matrix *matrix, int col, c3e_matrix *dst, int dst_col) |
| Copies a column from one matrix to another. | |
| void | c3e_matrix_col_sub (c3e_matrix *matrix, int col, c3e_matrix *dst, int dcol, c3e_number scalar) |
| Subtracts a scalar value from a column of a matrix. | |
| void | c3e_matrix_col_div (c3e_matrix *matrix, int col, c3e_number scalar) |
| Divides a column of a matrix by a scalar value. | |
| c3e_number | c3e_matrix_trace (c3e_matrix *matrix) |
| Computes the trace of a matrix. | |
| c3e_number | c3e_matrix_determinant (c3e_matrix *matrix) |
| Computes the determinant of a matrix. | |
| c3e_number | c3e_matrix_log_determ (c3e_matrix *matrix) |
| Computes the logarithm of the determinant of a matrix. | |
| c3e_number | c3e_matrix_frobenius (c3e_matrix *matrix) |
| Computes the Frobenius norm of a matrix. | |
| c3e_number | c3e_matrix_l1_norm (c3e_matrix *matrix) |
| Computes the L1 norm of a matrix. | |
| c3e_number | c3e_matrix_infinity_norm (c3e_matrix *matrix) |
| Computes the infinity norm of a matrix. | |
| c3e_vector * | c3e_matrix_get_row (c3e_matrix *matrix, int row) |
| Extracts a row from the given matrix and returns it as a c3e_vector. | |
| void | c3e_matrix_add_row (c3e_matrix *matrix, int row1, int row2, c3e_number scalar) |
| Adds a scaled row to another row in a matrix. | |
| void | c3e_matrix_swap_rows (c3e_matrix *matrix, int row1, int row2) |
| Swaps two rows in a matrix. | |
| void | c3e_matrix_multiply_row (c3e_matrix *matrix, int row1, c3e_number scalar) |
| Multiplies a row in a matrix by a scalar value. | |
| c3e_matrix * | c3e_matrix_normalize (c3e_matrix *matrix) |
| Normalizes the elements of a matrix. | |
| c3e_matrix * | c3e_matrix_row_echelon (c3e_matrix *matrix) |
| Converts a matrix to its row echelon form. | |
| c3e_matrix * | c3e_matrix_inverse (c3e_matrix *matrix) |
| Computes the inverse of a matrix. | |
| c3e_matrix * | c3e_matrix_qr_algo (c3e_matrix *matrix) |
| Computes the QR decomposition of a matrix. | |
| c3e_matrix * | c3e_matrix_cholesky_decomp (c3e_matrix *matrix) |
| Performs Cholesky decomposition on a matrix. | |
| int | c3e_matrix_rank (c3e_matrix *matrix) |
| Determines the rank of a matrix. | |
| int | c3e_matrix_non_zero_rows (c3e_matrix *matrix) |
| Counts the number of non-zero rows in a matrix. | |
| int | c3e_matrix_find_pivot (c3e_matrix *matrix, int col, int row) |
| Finds the pivot element in a specified column starting from a given row. | |
| c3e_matrix * | c3e_matrix_tril (c3e_matrix *matrix, int diag) |
| Extracts the lower triangular part of a matrix. | |
| c3e_matrix * | c3e_matrix_triu (c3e_matrix *matrix, int diag) |
| Extracts the upper triangular part of a matrix. | |
| c3e_vector * | c3e_matrix_diagonal (c3e_matrix *matrix, int k) |
| Extracts the diagonal elements of a matrix. | |
| c3e_number | c3e_matrix_sum (c3e_matrix *matrix) |
| Sums all elements of a matrix. | |
| c3e_number | c3e_matrix_max (c3e_matrix *matrix) |
| Finds the maximum element in a matrix. | |
| c3e_number | c3e_matrix_min (c3e_matrix *matrix) |
| Finds the minimum element in a matrix. | |
| c3e_number | c3e_matrix_mean (c3e_matrix *matrix) |
| Computes the mean of all elements in a matrix. | |
| c3e_number | c3e_matrix_std (c3e_matrix *matrix) |
| Computes the standard deviation of all elements in a matrix. | |
| c3e_matrix * | c3e_matrix_min_vals (c3e_matrix *matrix, int dim) |
| Finds the minimum values along a specified dimension. | |
| c3e_matrix * | c3e_matrix_max_values (c3e_matrix *matrix, int dim) |
| Finds the maximum values along a specified dimension. | |
| c3e_matrix * | c3e_matrix_sum_vals (c3e_matrix *matrix, int dim) |
| Computes the sum of elements along a specified dimension. | |
| c3e_matrix * | c3e_matrix_mean_vals (c3e_matrix *matrix, int dim) |
| Computes the mean of elements along a specified dimension. | |
| c3e_matrix * | c3e_matrix_std_vals (c3e_matrix *matrix, int dim) |
| Computes the standard deviation of elements along a specified dimension. | |
| bool | c3e_matrix_all_close (c3e_matrix *matrix, c3e_matrix *subject) |
| Checks if all elements in two matrices are close within a tolerance. | |
| c3e_matrix * | c3e_matrix_from_vec (c3e_vector *vector) |
| Converts a vector to a matrix. | |
| c3e_matrix * | c3e_matrix_eigenvec (c3e_matrix *matrix) |
| Computes the eigenvectors of a matrix. | |
| c3e_vector * | c3e_matrix_eigenvalues (c3e_matrix *matrix) |
| Computes the eigenvalues of a matrix. | |
| c3e_matrix * | c3e_matrix_vec_mul (c3e_matrix *matrix, c3e_vector *vector) |
| Multiplies a matrix by a vector. | |
| c3e_matrix * | c3e_matrix_scalar_add (c3e_matrix *matrix, c3e_number x) |
| Adds a scalar to each element of a matrix. | |
| c3e_matrix * | c3e_matrix_scalar_sub (c3e_matrix *matrix, c3e_number x) |
| Subtracts a scalar from each element of a matrix. | |
| c3e_matrix * | c3e_matrix_scalar_mul (c3e_matrix *matrix, c3e_number x) |
| Multiplies each element of a matrix by a scalar. | |
| c3e_matrix * | c3e_matrix_scalar_div (c3e_matrix *matrix, c3e_number x) |
| Divides each element of a matrix by a scalar. | |
| c3e_matrix * | c3e_matrix_flatten (c3e_matrix *matrix) |
| Flattens a matrix into a single-row matrix. | |
| c3e_matrix * | c3e_matrix_reshape (c3e_matrix *matrix, int rows, int cols) |
| Reshapes a matrix to the specified dimensions. | |
| c3e_matrix * | c3e_matrix_clip (c3e_matrix *matrix, c3e_number min, c3e_number max) |
| Clips the values of a matrix to be within a specified range. | |
| c3e_matrix * | c3e_matrix_arc_sin (c3e_matrix *matrix) |
| Computes the inverse sine (arcsine) of each element in the matrix. | |
| c3e_matrix * | c3e_matrix_arc_sinh (c3e_matrix *matrix) |
| Computes the inverse hyperbolic sine (arcsinh) of each element in the matrix. | |
| c3e_matrix * | c3e_matrix_sin (c3e_matrix *matrix) |
| Computes the sine of each element in the matrix. | |
| c3e_matrix * | c3e_matrix_sinh (c3e_matrix *matrix) |
| Computes the hyperbolic sine (sinh) of each element in the matrix. | |
| c3e_matrix * | c3e_matrix_arc_cos (c3e_matrix *matrix) |
| Computes the inverse cosine (arccos) of each element in the matrix. | |
| c3e_matrix * | c3e_matrix_arc_cosh (c3e_matrix *matrix) |
| Computes the inverse hyperbolic cosine (arccosh) of each element in the matrix. | |
| c3e_matrix * | c3e_matrix_cos (c3e_matrix *matrix) |
| Computes the cosine of each element in the matrix. | |
| c3e_matrix * | c3e_matrix_cosh (c3e_matrix *matrix) |
| Computes the hyperbolic cosine (cosh) of each element in the matrix. | |
| c3e_matrix * | c3e_matrix_arc_tan (c3e_matrix *matrix) |
| Computes the inverse tangent (arctan) of each element in the matrix. | |
| c3e_matrix * | c3e_matrix_arc_tanh (c3e_matrix *matrix) |
| Computes the inverse hyperbolic tangent (arctanh) of each element in the matrix. | |
| c3e_matrix * | c3e_matrix_tan (c3e_matrix *matrix) |
| Computes the tangent of each element in the matrix. | |
| c3e_matrix * | c3e_matrix_tanh (c3e_matrix *matrix) |
| Computes the hyperbolic tangent (tanh) of each element in the matrix. | |
| c3e_matrix * | c3e_matrix_abs (c3e_matrix *matrix) |
| Computes the absolute value of each element in the matrix. | |
| c3e_matrix * | c3e_matrix_a_range (c3e_number start, c3e_number end, c3e_number step) |
| Creates a matrix with values within a specified range. | |
| c3e_matrix * | c3e_matrix_cum_sum (c3e_matrix *matrix) |
| Computes the cumulative sum of matrix elements along a specified axis. | |
| c3e_matrix * | c3e_matrix_cum_product (c3e_matrix *matrix) |
| Computes the cumulative product of matrix elements along a specified axis. | |
| c3e_matrix * | c3e_matrix_log (c3e_matrix *matrix) |
| Applies the natural logarithm to each element in the matrix. | |
| c3e_matrix * | c3e_matrix_log10 (c3e_matrix *matrix) |
| Applies the base-10 logarithm to each element in the matrix. | |
| c3e_matrix * | c3e_matrix_log2 (c3e_matrix *matrix) |
| Applies the base-2 logarithm to each element in the matrix. | |
| c3e_matrix * | c3e_matrix_log1p (c3e_matrix *matrix) |
| Applies the natural logarithm of one plus the element to each element in the matrix. | |
| c3e_matrix * | c3e_matrix_reciproc (c3e_matrix *matrix) |
| Computes the reciprocal of each element in the matrix. | |
| c3e_matrix * | c3e_matrix_pow (c3e_matrix *matrix, c3e_number exp) |
| Raises each element in the matrix to a specified power. | |
| c3e_number | c3e_matrix_product (c3e_matrix *matrix) |
| Computes the product of all elements in the matrix. | |
| c3e_matrix * | c3e_matrix_rsqrt (c3e_matrix *matrix) |
| Computes the reciprocal square root of each element in the matrix. | |
| c3e_matrix * | c3e_matrix_sqrt (c3e_matrix *matrix) |
| Computes the square root of each element in the matrix. | |
| c3e_matrix * | c3e_matrix_lerp (c3e_matrix *matrix, c3e_matrix *subject, c3e_number weight) |
| Performs linear interpolation between two matrices. | |
| c3e_matrix * | c3e_matrix_neg (c3e_matrix *matrix) |
| Negates each element in the matrix. | |
| c3e_matrix * | c3e_matrix_sign (c3e_matrix *matrix) |
| Computes the sign of each element in the matrix. | |
| c3e_matrix * | c3e_matrix_equals (c3e_matrix *matrix, c3e_matrix *subject) |
| Checks for element-wise equality between two matrices. | |
| c3e_matrix * | c3e_matrix_less_than (c3e_matrix *matrix, c3e_matrix *subject) |
| Checks for element-wise less-than comparison between two matrices. | |
| c3e_matrix * | c3e_matrix_less_than_eq (c3e_matrix *matrix, c3e_matrix *subject) |
| Checks for element-wise less-than-or-equal comparison between two matrices. | |
| c3e_matrix * | c3e_matrix_greater_than (c3e_matrix *matrix, c3e_matrix *subject) |
| Checks for element-wise greater-than comparison between two matrices. | |
| c3e_matrix * | c3e_matrix_greater_than_eq (c3e_matrix *matrix, c3e_matrix *subject) |
| Checks for element-wise greater-than-or-equal comparison between two matrices. | |
| c3e_matrix * | c3e_matrix_exp (c3e_matrix *matrix) |
| Computes the exponential of each element in the matrix. | |
| c3e_matrix * | c3e_matrix_log_cumsum_exp (c3e_matrix *matrix) |
| Computes the log-cumulative-sum-exp of each row of the matrix. | |
| c3e_matrix * | c3e_matrix_log_gamma (c3e_matrix *matrix) |
| Computes the logarithm of the Gamma function for each element in the matrix. | |
| void | c3e_matrix_sort (c3e_matrix *matrix) |
| Sorts the elements of the matrix in ascending order. | |
| void | c3e_matrix_resize (c3e_matrix *matrix, int rows, int cols) |
| Resizes the matrix to the specified dimensions. | |
| void | c3e_matrix_resize_as (c3e_matrix *matrix, c3e_matrix *subject) |
| Resizes the matrix to match the dimensions of another matrix. | |
| c3e_matrix * | c3e_matrix_get (c3e_matrix *matrix, c3e_matrix *subject) |
| Extracts a submatrix from the given matrix. | |
| c3e_matrix * | c3e_matrix_repeat (c3e_matrix *matrix, int rrows, int rcols) |
Repeats the matrix rrows times vertically and rcols times horizontally. | |
| c3e_matrix * | c3e_matrix_solve (c3e_matrix *matrix, c3e_matrix *subject) |
Solves the linear system of equations represented by matrix and subject. | |
| int | c3e_matrix_arg_min (c3e_matrix *matrix) |
| Finds the index of the minimum element in the matrix. | |
| int | c3e_matrix_arg_max (c3e_matrix *matrix) |
| Finds the index of the maximum element in the matrix. | |
| c3e_matrix * | c3e_matrix_arg_sort (c3e_matrix *matrix) |
| Returns the indices of the elements in ascending order. | |
| c3e_matrix * | c3e_matrix_arg_min_vals (c3e_matrix *matrix, int dim) |
| Finds the indices of the minimum values along a specified dimension. | |
| c3e_matrix * | c3e_matrix_arg_max_vals (c3e_matrix *matrix, int dim) |
| Finds the indices of the maximum values along a specified dimension. | |
This file contains the definitions and functions for working with matrices in the C3E framework. It includes functions for matrix initialization, manipulation, and various matrix operations.
| #define MATRIX_ELEM | ( | matrix, | |
| row, | |||
| col | |||
| ) | (matrix)->data[(row) * (matrix)->cols + (col)] |
This macro provides a convenient way to access an element in a matrix given its row and column indices.
| matrix | Pointer to the matrix structure. |
| row | Row index of the element. |
| col | Column index of the element. |
| c3e_matrix * c3e_matrix_a_range | ( | c3e_number | start, |
| c3e_number | end, | ||
| c3e_number | step | ||
| ) |
Generates a matrix with elements starting from start, incrementing by step, up to but not including end.
| start | The starting value of the sequence. |
| end | The end value of the sequence (exclusive). |
| step | The increment value. |
| c3e_matrix * c3e_matrix_abs | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_add | ( | c3e_matrix * | matrix, |
| c3e_matrix * | subject | ||
| ) |
Computes the element-wise sum of two matrices of the same dimensions.
| matrix | Pointer to the first matrix. |
| subject | Pointer to the second matrix. |
| void c3e_matrix_add_row | ( | c3e_matrix * | matrix, |
| int | row1, | ||
| int | row2, | ||
| c3e_number | scalar | ||
| ) |
Adds a scalar multiple of one row to another row within the matrix.
| matrix | Pointer to the matrix. |
| row1 | Index of the row to be modified. |
| row2 | Index of the row to be scaled and added. |
| scalar | Scalar value to multiply row2 by before adding to row1. |
| bool c3e_matrix_all_close | ( | c3e_matrix * | matrix, |
| c3e_matrix * | subject | ||
| ) |
Compares each element in the given matrices to see if they are close in value within a certain tolerance, indicating similarity between the matrices.
| matrix | Pointer to the first matrix. |
| subject | Pointer to the second matrix to compare with. |
true if all elements are close, false otherwise. | c3e_matrix * c3e_matrix_append | ( | c3e_matrix * | matrix, |
| c3e_matrix * | subject, | ||
| int | axis | ||
| ) |
Combines two matrices by appending the second matrix to the first along the specified axis. Axis 0 appends rows, and axis 1 appends columns.
| matrix | Pointer to the matrix to append to. |
| subject | Pointer to the matrix to append. |
| axis | Axis along which to append the matrices (0 for rows, 1 for columns). |
| c3e_matrix * c3e_matrix_arc_cos | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_arc_cosh | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_arc_sin | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_arc_sinh | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_arc_tan | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_arc_tanh | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| int c3e_matrix_arg_max | ( | c3e_matrix * | matrix | ) |
This function returns the index of the largest element in the matrix. The index is computed as a single integer where the row and column indices can be derived.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_arg_max_vals | ( | c3e_matrix * | matrix, |
| int | dim | ||
| ) |
This function returns a matrix where each element represents the index of the maximum value along the specified dimension (0 for rows, 1 for columns).
| matrix | Pointer to the matrix. |
| dim | The dimension along which to find maximum values (0 for rows, 1 for columns). |
| int c3e_matrix_arg_min | ( | c3e_matrix * | matrix | ) |
This function returns the index of the smallest element in the matrix. The index is computed as a single integer where the row and column indices can be derived.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_arg_min_vals | ( | c3e_matrix * | matrix, |
| int | dim | ||
| ) |
This function returns a matrix where each element represents the index of the minimum value along the specified dimension (0 for rows, 1 for columns).
| matrix | Pointer to the matrix. |
| dim | The dimension along which to find minimum values (0 for rows, 1 for columns). |
| c3e_matrix * c3e_matrix_arg_sort | ( | c3e_matrix * | matrix | ) |
This function returns a matrix containing the indices of the elements sorted in ascending order.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_cholesky_decomp | ( | c3e_matrix * | matrix | ) |
Decomposes the matrix into a lower triangular matrix L such that L*L^T = A.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_clip | ( | c3e_matrix * | matrix, |
| c3e_number | min, | ||
| c3e_number | max | ||
| ) |
Limits the values in the matrix such that they do not exceed the specified minimum and maximum bounds.
| matrix | Pointer to the matrix. |
| min | Minimum value to clip to. |
| max | Maximum value to clip to. |
| void c3e_matrix_col_copy | ( | c3e_matrix * | matrix, |
| int | col, | ||
| c3e_matrix * | dst, | ||
| int | dst_col | ||
| ) |
Copies the elements from a specified column in the source matrix to a specified column in the destination matrix.
| matrix | Pointer to the source matrix. |
| col | Column index in the source matrix to copy. |
| dst | Pointer to the destination matrix. |
| dst_col | Column index in the destination matrix where the column is to be copied. |
| void c3e_matrix_col_div | ( | c3e_matrix * | matrix, |
| int | col, | ||
| c3e_number | scalar | ||
| ) |
Divides each element in the specified column of the matrix by the given scalar value.
| matrix | Pointer to the matrix. |
| col | Column index in the matrix. |
| scalar | The scalar value to divide by. |
| void c3e_matrix_col_sub | ( | c3e_matrix * | matrix, |
| int | col, | ||
| c3e_matrix * | dst, | ||
| int | dcol, | ||
| c3e_number | scalar | ||
| ) |
Subtracts a scalar value from each element in the specified column of the matrix and stores the result in another matrix.
| matrix | Pointer to the source matrix. |
| col | Column index in the source matrix. |
| dst | Pointer to the destination matrix. |
| dcol | Column index in the destination matrix where the result is stored. |
| scalar | The scalar value to subtract. |
| c3e_matrix * c3e_matrix_copy | ( | c3e_matrix * | matrix | ) |
Allocates memory and copies the contents of the source matrix into a new matrix.
| matrix | Pointer to the matrix to copy. |
| c3e_matrix * c3e_matrix_cos | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_cosh | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_cum_product | ( | c3e_matrix * | matrix | ) |
This function calculates the cumulative product of the elements in the matrix along the specified axis, either row-wise or column-wise.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_cum_sum | ( | c3e_matrix * | matrix | ) |
This function calculates the cumulative sum of the elements in the matrix along the specified axis, either row-wise or column-wise.
| matrix | Pointer to the matrix. |
| c3e_number c3e_matrix_determinant | ( | c3e_matrix * | matrix | ) |
The determinant is a scalar value that is a function of a square matrix.
| matrix | Pointer to the matrix. |
| c3e_vector * c3e_matrix_diagonal | ( | c3e_matrix * | matrix, |
| int | k | ||
| ) |
Returns a vector containing the elements on the specified diagonal.
| matrix | Pointer to the matrix. |
| k | Diagonal offset (0 for main diagonal, positive for above, negative for below). |
| c3e_matrix * c3e_matrix_div | ( | c3e_matrix * | matrix, |
| c3e_matrix * | subject | ||
| ) |
Computes the element-wise quotient of two matrices of the same dimensions.
| matrix | Pointer to the matrix to divide. |
| subject | Pointer to the matrix to divide by. |
| c3e_matrix * c3e_matrix_dot | ( | c3e_matrix * | matrix, |
| c3e_matrix * | subject | ||
| ) |
Computes the matrix product (dot product) of two matrices.
| matrix | Pointer to the first matrix. |
| subject | Pointer to the second matrix. |
| c3e_vector * c3e_matrix_eigenvalues | ( | c3e_matrix * | matrix | ) |
Calculates the eigenvalues of a square matrix, which are scalars representing the factor by which the eigenvectors are scaled during transformation.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_eigenvec | ( | c3e_matrix * | matrix | ) |
Calculates the eigenvectors of a square matrix, which are vectors that describe the directions along which the matrix acts by stretching.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_equals | ( | c3e_matrix * | matrix, |
| c3e_matrix * | subject | ||
| ) |
This function returns a matrix where each element is 1 if the corresponding elements of matrix and subject are equal, and 0 otherwise.
| matrix | Pointer to the first matrix. |
| subject | Pointer to the second matrix. |
| c3e_matrix * c3e_matrix_exp | ( | c3e_matrix * | matrix | ) |
This function calculates the exponential of each element, i.e., e raised to the power of the element.
| matrix | Pointer to the matrix. |
| void c3e_matrix_fill | ( | c3e_matrix * | matrix, |
| c3e_number | value | ||
| ) |
Sets all elements of the matrix to the given value.
| matrix | Pointer to the matrix. |
| value | Value to set for all elements in the matrix. |
| int c3e_matrix_find_pivot | ( | c3e_matrix * | matrix, |
| int | col, | ||
| int | row | ||
| ) |
Identifies the pivot element in the matrix for Gaussian elimination.
| matrix | Pointer to the matrix. |
| col | Column index to search for the pivot. |
| row | Starting row index for the search. |
| c3e_matrix * c3e_matrix_flatten | ( | c3e_matrix * | matrix | ) |
Converts the matrix into a one-dimensional representation, stacking rows sequentially.
| matrix | Pointer to the matrix. |
| void c3e_matrix_free | ( | c3e_matrix * | matrix | ) |
Deallocates the memory associated with the matrix structure and its data.
| matrix | Pointer to the matrix to be freed. |
| c3e_number c3e_matrix_frobenius | ( | c3e_matrix * | matrix | ) |
The Frobenius norm is the square root of the sum of the absolute squares of the matrix elements.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_from_vec | ( | c3e_vector * | vector | ) |
Transforms a vector into a single-column matrix, with each element of the vector becoming a row in the resulting matrix.
| vector | Pointer to the vector to convert. |
| c3e_matrix * c3e_matrix_full | ( | int | rows, |
| int | cols, | ||
| c3e_number | value | ||
| ) |
Initializes a matrix with the specified number of rows and columns, and sets all elements to the provided value.
| rows | Number of rows in the matrix. |
| cols | Number of columns in the matrix. |
| value | The value to set for all elements in the matrix. |
| c3e_matrix * c3e_matrix_full_like | ( | c3e_matrix * | matrix, |
| c3e_number | value | ||
| ) |
| matrix | Pointer to the reference matrix. |
| value | The value to set for all elements in the new matrix. |
| c3e_matrix * c3e_matrix_get | ( | c3e_matrix * | matrix, |
| c3e_matrix * | subject | ||
| ) |
This function extracts elements from the matrix based on the indices provided in subject. The subject matrix contains the row and column indices for the elements to be extracted.
| matrix | Pointer to the source matrix. |
| subject | Pointer to the matrix containing row and column indices. |
| c3e_number c3e_matrix_get_at | ( | c3e_matrix * | matrix, |
| int | row, | ||
| int | col | ||
| ) |
| matrix | Pointer to the matrix. |
| row | Row index of the desired element. |
| col | Column index of the desired element. |
| c3e_vector * c3e_matrix_get_row | ( | c3e_matrix * | matrix, |
| int | row | ||
| ) |
This function creates a new vector that contains the elements of the specified row from the given matrix. The row index is zero-based, so the first row is index 0.
| matrix | Pointer to the c3e_matrix from which to extract the row. |
| row | The zero-based index of the row to extract. |
| c3e_matrix * c3e_matrix_greater_than | ( | c3e_matrix * | matrix, |
| c3e_matrix * | subject | ||
| ) |
This function returns a matrix where each element is 1 if the corresponding element of matrix is greater than that of subject, and 0 otherwise.
| matrix | Pointer to the first matrix. |
| subject | Pointer to the second matrix. |
| c3e_matrix * c3e_matrix_greater_than_eq | ( | c3e_matrix * | matrix, |
| c3e_matrix * | subject | ||
| ) |
This function returns a matrix where each element is 1 if the corresponding element of matrix is greater than or equal to that of subject, and 0 otherwise.
| matrix | Pointer to the first matrix. |
| subject | Pointer to the second matrix. |
| c3e_matrix * c3e_matrix_identity | ( | int | side | ) |
An identity matrix is a square matrix with ones on the diagonal and zeros elsewhere.
| side | The number of rows and columns (must be equal) in the identity matrix. |
| c3e_number c3e_matrix_infinity_norm | ( | c3e_matrix * | matrix | ) |
The infinity norm is the maximum absolute row sum of the matrix.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_init | ( | int | rows, |
| int | cols | ||
| ) |
Allocates memory and initializes a matrix structure with the specified dimensions. The matrix data is not initialized.
| rows | Number of rows in the matrix. |
| cols | Number of columns in the matrix. |
| c3e_matrix * c3e_matrix_inverse | ( | c3e_matrix * | matrix | ) |
Calculates the inverse of the matrix if it exists.
| matrix | Pointer to the matrix. |
| c3e_number c3e_matrix_l1_norm | ( | c3e_matrix * | matrix | ) |
The L1 norm is the sum of the absolute values of the matrix elements.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_lerp | ( | c3e_matrix * | matrix, |
| c3e_matrix * | subject, | ||
| c3e_number | weight | ||
| ) |
This function computes a weighted sum of two matrices, matrix and subject, based on the specified weight.
| matrix | Pointer to the first matrix. |
| subject | Pointer to the second matrix. |
| weight | The interpolation weight, ranging from 0 (all from matrix) to 1 (all from subject). |
| c3e_matrix * c3e_matrix_less_than | ( | c3e_matrix * | matrix, |
| c3e_matrix * | subject | ||
| ) |
This function returns a matrix where each element is 1 if the corresponding element of matrix is less than that of subject, and 0 otherwise.
| matrix | Pointer to the first matrix. |
| subject | Pointer to the second matrix. |
| c3e_matrix * c3e_matrix_less_than_eq | ( | c3e_matrix * | matrix, |
| c3e_matrix * | subject | ||
| ) |
This function returns a matrix where each element is 1 if the corresponding element of matrix is less than or equal to that of subject, and 0 otherwise.
| matrix | Pointer to the first matrix. |
| subject | Pointer to the second matrix. |
| c3e_matrix * c3e_matrix_log | ( | c3e_matrix * | matrix | ) |
This function computes the natural logarithm (base e) of each element in the matrix.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_log10 | ( | c3e_matrix * | matrix | ) |
This function computes the logarithm base 10 of each element in the matrix.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_log1p | ( | c3e_matrix * | matrix | ) |
This function computes log(1 + x) for each element x in the matrix, which is useful for computing logarithms of values near zero.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_log2 | ( | c3e_matrix * | matrix | ) |
This function computes the logarithm base 2 of each element in the matrix.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_log_cumsum_exp | ( | c3e_matrix * | matrix | ) |
This function calculates the log of the cumulative sum of the exponentials of the elements in each row.
| matrix | Pointer to the matrix. |
| c3e_number c3e_matrix_log_determ | ( | c3e_matrix * | matrix | ) |
Computes the natural logarithm of the absolute value of the determinant of a matrix.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_log_gamma | ( | c3e_matrix * | matrix | ) |
This function calculates the log of the Gamma function, which generalizes the factorial function, for each element in the matrix.
| matrix | Pointer to the matrix. |
| c3e_number c3e_matrix_max | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_max_values | ( | c3e_matrix * | matrix, |
| int | dim | ||
| ) |
| matrix | Pointer to the matrix. |
| dim | Dimension along which to find maximum values (0 for rows, 1 for columns). |
| c3e_number c3e_matrix_mean | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_mean_vals | ( | c3e_matrix * | matrix, |
| int | dim | ||
| ) |
| matrix | Pointer to the matrix. |
| dim | Dimension along which to compute the mean (0 for rows, 1 for columns). |
| c3e_number c3e_matrix_min | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_min_vals | ( | c3e_matrix * | matrix, |
| int | dim | ||
| ) |
| matrix | Pointer to the matrix. |
| dim | Dimension along which to find minimum values (0 for rows, 1 for columns). |
| c3e_matrix * c3e_matrix_mul | ( | c3e_matrix * | matrix, |
| c3e_matrix * | subject | ||
| ) |
Computes the element-wise product of two matrices of the same dimensions.
| matrix | Pointer to the first matrix. |
| subject | Pointer to the second matrix. |
| void c3e_matrix_multiply_row | ( | c3e_matrix * | matrix, |
| int | row1, | ||
| c3e_number | scalar | ||
| ) |
Scales the elements of a specified row by a scalar value.
| matrix | Pointer to the matrix. |
| row1 | Index of the row to be multiplied. |
| scalar | The scalar value to multiply with. |
| c3e_matrix * c3e_matrix_neg | ( | c3e_matrix * | matrix | ) |
This function computes the negative of each element in the matrix.
| matrix | Pointer to the matrix. |
| int c3e_matrix_non_zero_rows | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_normalize | ( | c3e_matrix * | matrix | ) |
Adjusts the matrix elements such that they lie within a certain range, typically [0, 1].
| matrix | Pointer to the matrix to be normalized. |
| c3e_matrix * c3e_matrix_ones | ( | int | rows, |
| int | cols | ||
| ) |
Initializes a matrix with the specified number of rows and columns, and sets all elements to one.
| rows | Number of rows in the matrix. |
| cols | Number of columns in the matrix. |
| c3e_matrix * c3e_matrix_ones_like | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the reference matrix. |
| c3e_matrix * c3e_matrix_pow | ( | c3e_matrix * | matrix, |
| c3e_number | exp | ||
| ) |
This function computes the result of raising each element in the matrix to the power of exp.
| matrix | Pointer to the matrix. |
| exp | The exponent to raise each element to. |
| c3e_number c3e_matrix_product | ( | c3e_matrix * | matrix | ) |
This function calculates the product of all elements in the matrix, which can be useful for various mathematical and statistical applications.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_qr_algo | ( | c3e_matrix * | matrix | ) |
Decomposes the matrix into an orthogonal matrix Q and an upper triangular matrix R.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_random | ( | int | rows, |
| int | cols, | ||
| int | seed | ||
| ) |
Initializes a matrix with random values. The randomness is controlled by a seed.
| rows | Number of rows in the matrix. |
| cols | Number of columns in the matrix. |
| seed | Seed for the random number generator. |
| c3e_matrix * c3e_matrix_random_bound | ( | int | rows, |
| int | cols, | ||
| int | seed, | ||
| c3e_number | min, | ||
| c3e_number | max | ||
| ) |
Initializes a matrix with random values within the given bounds [min, max]. The randomness is controlled by a seed.
| rows | Number of rows in the matrix. |
| cols | Number of columns in the matrix. |
| seed | Seed for the random number generator. |
| min | Minimum value for the random numbers. |
| max | Maximum value for the random numbers. |
| int c3e_matrix_rank | ( | c3e_matrix * | matrix | ) |
The rank is the maximum number of linearly independent rows or columns in the matrix.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_reciproc | ( | c3e_matrix * | matrix | ) |
This function calculates the reciprocal (1/x) of each element in the matrix.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_repeat | ( | c3e_matrix * | matrix, |
| int | rrows, | ||
| int | rcols | ||
| ) |
This function creates a new matrix where the original matrix is tiled rrows times along the rows and rcols times along the columns.
| matrix | Pointer to the matrix to be repeated. |
| rrows | Number of repetitions along rows. |
| rcols | Number of repetitions along columns. |
| c3e_matrix * c3e_matrix_reshape | ( | c3e_matrix * | matrix, |
| int | rows, | ||
| int | cols | ||
| ) |
Changes the dimensions of the matrix to the given number of rows and columns.
| matrix | Pointer to the matrix. |
| rows | Number of rows for the new shape. |
| cols | Number of columns for the new shape. |
| void c3e_matrix_resize | ( | c3e_matrix * | matrix, |
| int | rows, | ||
| int | cols | ||
| ) |
This function changes the dimensions of the matrix to rows by cols. If the new size is smaller, the matrix elements will be truncated. If larger, the additional elements will be uninitialized.
| matrix | Pointer to the matrix to be resized. |
| rows | New number of rows. |
| cols | New number of columns. |
| void c3e_matrix_resize_as | ( | c3e_matrix * | matrix, |
| c3e_matrix * | subject | ||
| ) |
This function resizes the matrix to have the same number of rows and columns as the subject matrix. The matrix's content is not affected by this operation.
| matrix | Pointer to the matrix to be resized. |
| subject | Pointer to the matrix whose dimensions are used. |
| c3e_matrix * c3e_matrix_row_echelon | ( | c3e_matrix * | matrix | ) |
Transforms the matrix to row echelon form using Gaussian elimination.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_rsqrt | ( | c3e_matrix * | matrix | ) |
This function calculates the reciprocal of the square root of each element in the matrix.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_scalar_add | ( | c3e_matrix * | matrix, |
| c3e_number | x | ||
| ) |
| matrix | Pointer to the matrix. |
| x | The scalar value to add. |
| c3e_matrix * c3e_matrix_scalar_div | ( | c3e_matrix * | matrix, |
| c3e_number | x | ||
| ) |
| matrix | Pointer to the matrix. |
| x | The scalar value to divide by. |
| c3e_matrix * c3e_matrix_scalar_mul | ( | c3e_matrix * | matrix, |
| c3e_number | x | ||
| ) |
| matrix | Pointer to the matrix. |
| x | The scalar value to multiply with. |
| c3e_matrix * c3e_matrix_scalar_sub | ( | c3e_matrix * | matrix, |
| c3e_number | x | ||
| ) |
| matrix | Pointer to the matrix. |
| x | The scalar value to subtract. |
| c3e_matrix * c3e_matrix_scale | ( | c3e_matrix * | matrix, |
| int | x | ||
| ) |
Multiplies each element of the matrix by the given scalar value.
| matrix | Pointer to the matrix to be scaled. |
| x | The scalar value to multiply with. |
| void c3e_matrix_set_elements | ( | c3e_matrix * | matrix, |
| c3e_number * | values | ||
| ) |
Populates the matrix with values provided in an array.
| matrix | Pointer to the matrix. |
| values | Array of values to set in the matrix. |
| c3e_matrix * c3e_matrix_sign | ( | c3e_matrix * | matrix | ) |
This function calculates the sign of each element, returning 1 for positive, -1 for negative, and 0 for zero values.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_sin | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_sinh | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| int c3e_matrix_size | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_slice | ( | c3e_matrix * | matrix, |
| int | frows, | ||
| int | trows, | ||
| int | fcols, | ||
| int | tcols | ||
| ) |
Extracts a sub-matrix from the original matrix, defined by the range of rows and columns specified.
| matrix | Pointer to the original matrix. |
| frows | Starting row index (inclusive). |
| trows | Ending row index (exclusive). |
| fcols | Starting column index (inclusive). |
| tcols | Ending column index (exclusive). |
| c3e_matrix * c3e_matrix_solve | ( | c3e_matrix * | matrix, |
| c3e_matrix * | subject | ||
| ) |
This function solves the matrix equation matrix * x = subject for x. It assumes that matrix is a square matrix and subject is a column vector.
| matrix | Pointer to the coefficient matrix. |
| subject | Pointer to the right-hand side matrix or vector. |
| void c3e_matrix_sort | ( | c3e_matrix * | matrix | ) |
This function sorts all elements in the matrix in ascending order, modifying the matrix in place. The sorting is performed in a row-major order.
| matrix | Pointer to the matrix to be sorted. |
| c3e_matrix * c3e_matrix_sqrt | ( | c3e_matrix * | matrix | ) |
This function calculates the square root of each element in the matrix.
| matrix | Pointer to the matrix. |
| c3e_number c3e_matrix_std | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_std_vals | ( | c3e_matrix * | matrix, |
| int | dim | ||
| ) |
| matrix | Pointer to the matrix. |
| dim | Dimension along which to compute the standard deviation (0 for rows, 1 for columns). |
| c3e_matrix * c3e_matrix_sub | ( | c3e_matrix * | matrix, |
| c3e_matrix * | subject | ||
| ) |
Computes the element-wise difference of two matrices of the same dimensions.
| matrix | Pointer to the matrix to subtract from. |
| subject | Pointer to the matrix to subtract. |
| c3e_number c3e_matrix_sum | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_sum_vals | ( | c3e_matrix * | matrix, |
| int | dim | ||
| ) |
| matrix | Pointer to the matrix. |
| dim | Dimension along which to sum elements (0 for rows, 1 for columns). |
| void c3e_matrix_swap_rows | ( | c3e_matrix * | matrix, |
| int | row1, | ||
| int | row2 | ||
| ) |
Interchanges the contents of two rows in the matrix.
| matrix | Pointer to the matrix. |
| row1 | Index of the first row. |
| row2 | Index of the second row. |
| c3e_matrix * c3e_matrix_tan | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_tanh | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the matrix. |
| c3e_number c3e_matrix_trace | ( | c3e_matrix * | matrix | ) |
The trace is the sum of the diagonal elements of a square matrix.
| matrix | Pointer to the matrix. |
| c3e_matrix * c3e_matrix_transpose | ( | c3e_matrix * | matrix | ) |
Swaps the rows and columns of the matrix, effectively rotating it by 90 degrees.
| matrix | Pointer to the matrix to transpose. |
| c3e_matrix * c3e_matrix_tril | ( | c3e_matrix * | matrix, |
| int | diag | ||
| ) |
The lower triangular part includes the diagonal and the elements below it.
| matrix | Pointer to the matrix. |
| diag | Diagonal offset (0 for main diagonal, positive for above, negative for below). |
| c3e_matrix * c3e_matrix_triu | ( | c3e_matrix * | matrix, |
| int | diag | ||
| ) |
The upper triangular part includes the diagonal and the elements above it.
| matrix | Pointer to the matrix. |
| diag | Diagonal offset (0 for main diagonal, positive for above, negative for below). |
| c3e_matrix * c3e_matrix_vec_mul | ( | c3e_matrix * | matrix, |
| c3e_vector * | vector | ||
| ) |
Performs matrix-vector multiplication, resulting in a new vector.
| matrix | Pointer to the matrix. |
| vector | Pointer to the vector to multiply. |
| c3e_matrix * c3e_matrix_zeros | ( | int | rows, |
| int | cols | ||
| ) |
Initializes a matrix with the specified number of rows and columns, and sets all elements to zero.
| rows | Number of rows in the matrix. |
| cols | Number of columns in the matrix. |
| c3e_matrix * c3e_matrix_zeros_like | ( | c3e_matrix * | matrix | ) |
| matrix | Pointer to the reference matrix. |