44#define MATRIX_ELEM(matrix, row, col) \
45 (matrix)->data[(row) * (matrix)->cols + (col)]
Common data structures and type definitions for the C3E library.
double c3e_number
A type representing a numerical value in C3E. Defaults to double precision.
Definition commons.h:50
c3e_matrix * c3e_matrix_transpose(c3e_matrix *matrix)
Transposes 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_lerp(c3e_matrix *matrix, c3e_matrix *subject, c3e_number weight)
Performs linear interpolation between two matrices.
c3e_matrix * c3e_matrix_solve(c3e_matrix *matrix, c3e_matrix *subject)
Solves the linear system of equations represented by matrix and subject.
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.
bool c3e_matrix_all_close(c3e_matrix *matrix, c3e_matrix *subject)
Checks if all elements in two matrices are close within a tolerance.
c3e_number c3e_matrix_get_at(c3e_matrix *matrix, int row, int col)
Retrieves an element from the matrix at a specific position.
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_random(int rows, int cols, int seed)
Creates a matrix with random values.
c3e_matrix * c3e_matrix_arc_tan(c3e_matrix *matrix)
Computes the inverse tangent (arctan) of each element in the matrix.
c3e_number c3e_matrix_sum(c3e_matrix *matrix)
Sums all elements of a matrix.
c3e_matrix * c3e_matrix_abs(c3e_matrix *matrix)
Computes the absolute value of 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_arc_cosh(c3e_matrix *matrix)
Computes the inverse hyperbolic cosine (arccosh) of each 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_cum_sum(c3e_matrix *matrix)
Computes the cumulative sum of matrix elements along a specified axis.
c3e_matrix * c3e_matrix_cos(c3e_matrix *matrix)
Computes the cosine of each element in the matrix.
c3e_matrix * c3e_matrix_arg_max_vals(c3e_matrix *matrix, int dim)
Finds the indices of the maximum values along a specified dimension.
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_rsqrt(c3e_matrix *matrix)
Computes the reciprocal square root of each element in the matrix.
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_arc_sin(c3e_matrix *matrix)
Computes the inverse sine (arcsine) of each element in the matrix.
c3e_number c3e_matrix_frobenius(c3e_matrix *matrix)
Computes the Frobenius norm of a matrix.
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_eq(c3e_matrix *matrix, c3e_matrix *subject)
Checks for element-wise greater-than-or-equal comparison between two matrices.
int c3e_matrix_non_zero_rows(c3e_matrix *matrix)
Counts the number of non-zero rows in a matrix.
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_vec_mul(c3e_matrix *matrix, c3e_vector *vector)
Multiplies a matrix by a vector.
c3e_matrix * c3e_matrix_tanh(c3e_matrix *matrix)
Computes the hyperbolic tangent (tanh) of each element in the matrix.
c3e_number c3e_matrix_min(c3e_matrix *matrix)
Finds the minimum element in 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.
c3e_number c3e_matrix_mean(c3e_matrix *matrix)
Computes the mean of all elements in 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_arc_sinh(c3e_matrix *matrix)
Computes the inverse hyperbolic sine (arcsinh) of each element in the matrix.
c3e_matrix * c3e_matrix_neg(c3e_matrix *matrix)
Negates each element in the matrix.
c3e_matrix * c3e_matrix_reshape(c3e_matrix *matrix, int rows, int cols)
Reshapes a matrix to the specified dimensions.
c3e_matrix * c3e_matrix_exp(c3e_matrix *matrix)
Computes the exponential of each element in the matrix.
c3e_matrix * c3e_matrix_dot(c3e_matrix *matrix, c3e_matrix *subject)
Computes the dot product of two matrices.
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_log(c3e_matrix *matrix)
Applies the natural logarithm to 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_max_values(c3e_matrix *matrix, int dim)
Finds the maximum values 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_tril(c3e_matrix *matrix, int diag)
Extracts the lower triangular part of a matrix.
c3e_number c3e_matrix_max(c3e_matrix *matrix)
Finds the maximum element in a matrix.
c3e_number c3e_matrix_l1_norm(c3e_matrix *matrix)
Computes the L1 norm of a matrix.
c3e_matrix * c3e_matrix_flatten(c3e_matrix *matrix)
Flattens a matrix into a single-row matrix.
c3e_number c3e_matrix_trace(c3e_matrix *matrix)
Computes the trace of a matrix.
void c3e_matrix_sort(c3e_matrix *matrix)
Sorts the elements of the matrix in ascending order.
c3e_matrix * c3e_matrix_log2(c3e_matrix *matrix)
Applies the base-2 logarithm to each element in the matrix.
c3e_matrix * c3e_matrix_mul(c3e_matrix *matrix, c3e_matrix *subject)
Multiplies two matrices element-wise.
int c3e_matrix_rank(c3e_matrix *matrix)
Determines the rank of a 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_pow(c3e_matrix *matrix, c3e_number exp)
Raises each element in the matrix to a specified power.
c3e_matrix * c3e_matrix_normalize(c3e_matrix *matrix)
Normalizes the elements of a matrix.
c3e_matrix * c3e_matrix_sub(c3e_matrix *matrix, c3e_matrix *subject)
Subtracts one matrix from another element-wise.
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_add(c3e_matrix *matrix, c3e_matrix *subject)
Adds two matrices element-wise.
c3e_matrix * c3e_matrix_inverse(c3e_matrix *matrix)
Computes the inverse of a matrix.
c3e_matrix * c3e_matrix_cosh(c3e_matrix *matrix)
Computes the hyperbolic cosine (cosh) of each element in the matrix.
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.
c3e_matrix * c3e_matrix_sum_vals(c3e_matrix *matrix, int dim)
Computes the sum of elements along a specified dimension.
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_arg_sort(c3e_matrix *matrix)
Returns the indices of the elements in ascending order.
c3e_matrix * c3e_matrix_ones(int rows, int cols)
Creates a matrix with all elements set to one.
c3e_matrix * c3e_matrix_arc_cos(c3e_matrix *matrix)
Computes the inverse cosine (arccos) of each element in the matrix.
c3e_matrix * c3e_matrix_scalar_add(c3e_matrix *matrix, c3e_number x)
Adds a scalar to each element of a matrix.
void c3e_matrix_fill(c3e_matrix *matrix, c3e_number value)
Fills a matrix with a specified value.
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_infinity_norm(c3e_matrix *matrix)
Computes the infinity norm of a matrix.
c3e_matrix * c3e_matrix_greater_than(c3e_matrix *matrix, c3e_matrix *subject)
Checks for element-wise greater-than comparison between two matrices.
void c3e_matrix_set_elements(c3e_matrix *matrix, c3e_number *values)
Sets the elements of a matrix to the given values.
c3e_matrix * c3e_matrix_copy(c3e_matrix *matrix)
Creates a copy of a matrix.
c3e_matrix * c3e_matrix_eigenvec(c3e_matrix *matrix)
Computes the eigenvectors of a matrix.
c3e_matrix * c3e_matrix_arc_tanh(c3e_matrix *matrix)
Computes the inverse hyperbolic tangent (arctanh) of each element in the matrix.
void c3e_matrix_free(c3e_matrix *matrix)
Frees the memory allocated for a matrix.
c3e_number c3e_matrix_log_determ(c3e_matrix *matrix)
Computes the logarithm of the determinant of a matrix.
c3e_matrix * c3e_matrix_equals(c3e_matrix *matrix, c3e_matrix *subject)
Checks for element-wise equality between two matrices.
c3e_number c3e_matrix_product(c3e_matrix *matrix)
Computes the product of all elements in the matrix.
c3e_matrix * c3e_matrix_min_vals(c3e_matrix *matrix, int dim)
Finds the minimum values along a specified dimension.
c3e_matrix * c3e_matrix_tan(c3e_matrix *matrix)
Computes the tangent of each element in the matrix.
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_sqrt(c3e_matrix *matrix)
Computes the square root of each element in the matrix.
c3e_matrix * c3e_matrix_scale(c3e_matrix *matrix, int x)
Scales the elements of a matrix by a scalar value.
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_swap_rows(c3e_matrix *matrix, int row1, int row2)
Swaps two rows in a matrix.
c3e_matrix * c3e_matrix_full(int rows, int cols, c3e_number value)
Creates a matrix with all elements set to a specified value.
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.
c3e_vector * c3e_matrix_eigenvalues(c3e_matrix *matrix)
Computes the eigenvalues of a matrix.
c3e_matrix * c3e_matrix_init(int rows, int cols)
Initializes a matrix with the given number of rows and columns.
c3e_vector * c3e_matrix_diagonal(c3e_matrix *matrix, int k)
Extracts the diagonal elements of a 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_from_vec(c3e_vector *vector)
Converts a vector to a matrix.
c3e_matrix * c3e_matrix_cum_product(c3e_matrix *matrix)
Computes the cumulative product of matrix elements along a specified axis.
void c3e_matrix_col_copy(c3e_matrix *matrix, int col, c3e_matrix *dst, int dst_col)
Copies a column from one matrix to another.
c3e_matrix * c3e_matrix_sinh(c3e_matrix *matrix)
Computes the hyperbolic sine (sinh) of each element in the matrix.
c3e_number c3e_matrix_determinant(c3e_matrix *matrix)
Computes the determinant of a matrix.
c3e_matrix * c3e_matrix_qr_algo(c3e_matrix *matrix)
Computes the QR decomposition of a matrix.
c3e_matrix * c3e_matrix_reciproc(c3e_matrix *matrix)
Computes the reciprocal of each element in the matrix.
c3e_matrix * c3e_matrix_cholesky_decomp(c3e_matrix *matrix)
Performs Cholesky decomposition on a matrix.
c3e_matrix * c3e_matrix_std_vals(c3e_matrix *matrix, int dim)
Computes the standard deviation of elements along a specified dimension.
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_zeros(int rows, int cols)
Creates a matrix with all elements set to zero.
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_sign(c3e_matrix *matrix)
Computes the sign of each element in the matrix.
int c3e_matrix_arg_min(c3e_matrix *matrix)
Finds the index of the minimum element in the matrix.
void c3e_matrix_resize(c3e_matrix *matrix, int rows, int cols)
Resizes the matrix to the specified dimensions.
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_triu(c3e_matrix *matrix, int diag)
Extracts the upper triangular part of a matrix.
c3e_matrix * c3e_matrix_identity(int side)
Creates an identity matrix of a given size.
c3e_matrix * c3e_matrix_row_echelon(c3e_matrix *matrix)
Converts a matrix to its row echelon form.
c3e_matrix * c3e_matrix_ones_like(c3e_matrix *matrix)
Creates a matrix of ones with the same shape as another matrix.
int c3e_matrix_size(c3e_matrix *matrix)
Computes the total number of elements 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_div(c3e_matrix *matrix, c3e_matrix *subject)
Divides one matrix by another element-wise.
c3e_matrix * c3e_matrix_log_gamma(c3e_matrix *matrix)
Computes the logarithm of the Gamma function for each element in the matrix.
c3e_number c3e_matrix_std(c3e_matrix *matrix)
Computes the standard deviation of all elements in a matrix.
Represents a mathematical matrix.
Definition commons.h:74
Represents a mathematical vector.
Definition commons.h:62