C3E: Complex Compute Core Engine v1.0
An engine for handling complex computational tasks
Loading...
Searching...
No Matches
matrix.h File Reference

Matrix operations for the Complex Compute Core Engine (C3E) framework. More...

#include <c3e/commons.h>
Include dependency graph for matrix.h:
This graph shows which files directly or indirectly include this file:

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_matrixc3e_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_matrixc3e_matrix_ones (int rows, int cols)
 Creates a matrix with all elements set to one.
 
c3e_matrixc3e_matrix_ones_like (c3e_matrix *matrix)
 Creates a matrix of ones with the same shape as another matrix.
 
c3e_matrixc3e_matrix_zeros (int rows, int cols)
 Creates a matrix with all elements set to zero.
 
c3e_matrixc3e_matrix_zeros_like (c3e_matrix *matrix)
 Creates a matrix of zeros with the same shape as another matrix.
 
c3e_matrixc3e_matrix_full (int rows, int cols, c3e_number value)
 Creates a matrix with all elements set to a specified value.
 
c3e_matrixc3e_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_matrixc3e_matrix_identity (int side)
 Creates an identity matrix of a given size.
 
c3e_matrixc3e_matrix_random (int rows, int cols, int seed)
 Creates a matrix with random values.
 
c3e_matrixc3e_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_matrixc3e_matrix_copy (c3e_matrix *matrix)
 Creates a copy of a matrix.
 
c3e_matrixc3e_matrix_append (c3e_matrix *matrix, c3e_matrix *subject, int axis)
 Appends one matrix to another along a specified axis.
 
c3e_matrixc3e_matrix_add (c3e_matrix *matrix, c3e_matrix *subject)
 Adds two matrices element-wise.
 
c3e_matrixc3e_matrix_sub (c3e_matrix *matrix, c3e_matrix *subject)
 Subtracts one matrix from another element-wise.
 
c3e_matrixc3e_matrix_mul (c3e_matrix *matrix, c3e_matrix *subject)
 Multiplies two matrices element-wise.
 
c3e_matrixc3e_matrix_div (c3e_matrix *matrix, c3e_matrix *subject)
 Divides one matrix by another element-wise.
 
c3e_matrixc3e_matrix_dot (c3e_matrix *matrix, c3e_matrix *subject)
 Computes the dot product of two matrices.
 
c3e_matrixc3e_matrix_scale (c3e_matrix *matrix, int x)
 Scales the elements of a matrix by a scalar value.
 
c3e_matrixc3e_matrix_transpose (c3e_matrix *matrix)
 Transposes a matrix.
 
c3e_matrixc3e_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_vectorc3e_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_matrixc3e_matrix_normalize (c3e_matrix *matrix)
 Normalizes the elements of a matrix.
 
c3e_matrixc3e_matrix_row_echelon (c3e_matrix *matrix)
 Converts a matrix to its row echelon form.
 
c3e_matrixc3e_matrix_inverse (c3e_matrix *matrix)
 Computes the inverse of a matrix.
 
c3e_matrixc3e_matrix_qr_algo (c3e_matrix *matrix)
 Computes the QR decomposition of a matrix.
 
c3e_matrixc3e_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_matrixc3e_matrix_tril (c3e_matrix *matrix, int diag)
 Extracts the lower triangular part of a matrix.
 
c3e_matrixc3e_matrix_triu (c3e_matrix *matrix, int diag)
 Extracts the upper triangular part of a matrix.
 
c3e_vectorc3e_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_matrixc3e_matrix_min_vals (c3e_matrix *matrix, int dim)
 Finds the minimum values along a specified dimension.
 
c3e_matrixc3e_matrix_max_values (c3e_matrix *matrix, int dim)
 Finds the maximum values along a specified dimension.
 
c3e_matrixc3e_matrix_sum_vals (c3e_matrix *matrix, int dim)
 Computes the sum of elements along a specified dimension.
 
c3e_matrixc3e_matrix_mean_vals (c3e_matrix *matrix, int dim)
 Computes the mean of elements along a specified dimension.
 
c3e_matrixc3e_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_matrixc3e_matrix_from_vec (c3e_vector *vector)
 Converts a vector to a matrix.
 
c3e_matrixc3e_matrix_eigenvec (c3e_matrix *matrix)
 Computes the eigenvectors of a matrix.
 
c3e_vectorc3e_matrix_eigenvalues (c3e_matrix *matrix)
 Computes the eigenvalues of a matrix.
 
c3e_matrixc3e_matrix_vec_mul (c3e_matrix *matrix, c3e_vector *vector)
 Multiplies a matrix by a vector.
 
c3e_matrixc3e_matrix_scalar_add (c3e_matrix *matrix, c3e_number x)
 Adds a scalar to each element of a matrix.
 
c3e_matrixc3e_matrix_scalar_sub (c3e_matrix *matrix, c3e_number x)
 Subtracts a scalar from each element of a matrix.
 
c3e_matrixc3e_matrix_scalar_mul (c3e_matrix *matrix, c3e_number x)
 Multiplies each element of a matrix by a scalar.
 
c3e_matrixc3e_matrix_scalar_div (c3e_matrix *matrix, c3e_number x)
 Divides each element of a matrix by a scalar.
 
c3e_matrixc3e_matrix_flatten (c3e_matrix *matrix)
 Flattens a matrix into a single-row matrix.
 
c3e_matrixc3e_matrix_reshape (c3e_matrix *matrix, int rows, int cols)
 Reshapes a matrix to the specified dimensions.
 
c3e_matrixc3e_matrix_clip (c3e_matrix *matrix, c3e_number min, c3e_number max)
 Clips the values of a matrix to be within a specified range.
 
c3e_matrixc3e_matrix_arc_sin (c3e_matrix *matrix)
 Computes the inverse sine (arcsine) of each element in the matrix.
 
c3e_matrixc3e_matrix_arc_sinh (c3e_matrix *matrix)
 Computes the inverse hyperbolic sine (arcsinh) of each element in the matrix.
 
c3e_matrixc3e_matrix_sin (c3e_matrix *matrix)
 Computes the sine of each element in the matrix.
 
c3e_matrixc3e_matrix_sinh (c3e_matrix *matrix)
 Computes the hyperbolic sine (sinh) of each element in the matrix.
 
c3e_matrixc3e_matrix_arc_cos (c3e_matrix *matrix)
 Computes the inverse cosine (arccos) of each element in the matrix.
 
c3e_matrixc3e_matrix_arc_cosh (c3e_matrix *matrix)
 Computes the inverse hyperbolic cosine (arccosh) of each element in the matrix.
 
c3e_matrixc3e_matrix_cos (c3e_matrix *matrix)
 Computes the cosine of each element in the matrix.
 
c3e_matrixc3e_matrix_cosh (c3e_matrix *matrix)
 Computes the hyperbolic cosine (cosh) of each element in the matrix.
 
c3e_matrixc3e_matrix_arc_tan (c3e_matrix *matrix)
 Computes the inverse tangent (arctan) of each element in the matrix.
 
c3e_matrixc3e_matrix_arc_tanh (c3e_matrix *matrix)
 Computes the inverse hyperbolic tangent (arctanh) of each element in the matrix.
 
c3e_matrixc3e_matrix_tan (c3e_matrix *matrix)
 Computes the tangent of each element in the matrix.
 
c3e_matrixc3e_matrix_tanh (c3e_matrix *matrix)
 Computes the hyperbolic tangent (tanh) of each element in the matrix.
 
c3e_matrixc3e_matrix_abs (c3e_matrix *matrix)
 Computes the absolute value of each element in the matrix.
 
c3e_matrixc3e_matrix_a_range (c3e_number start, c3e_number end, c3e_number step)
 Creates a matrix with values within a specified range.
 
c3e_matrixc3e_matrix_cum_sum (c3e_matrix *matrix)
 Computes the cumulative sum of matrix elements along a specified axis.
 
c3e_matrixc3e_matrix_cum_product (c3e_matrix *matrix)
 Computes the cumulative product of matrix elements along a specified axis.
 
c3e_matrixc3e_matrix_log (c3e_matrix *matrix)
 Applies the natural logarithm to each element in the matrix.
 
c3e_matrixc3e_matrix_log10 (c3e_matrix *matrix)
 Applies the base-10 logarithm to each element in the matrix.
 
c3e_matrixc3e_matrix_log2 (c3e_matrix *matrix)
 Applies the base-2 logarithm to each element in the matrix.
 
c3e_matrixc3e_matrix_log1p (c3e_matrix *matrix)
 Applies the natural logarithm of one plus the element to each element in the matrix.
 
c3e_matrixc3e_matrix_reciproc (c3e_matrix *matrix)
 Computes the reciprocal of each element in the matrix.
 
c3e_matrixc3e_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_matrixc3e_matrix_rsqrt (c3e_matrix *matrix)
 Computes the reciprocal square root of each element in the matrix.
 
c3e_matrixc3e_matrix_sqrt (c3e_matrix *matrix)
 Computes the square root of each element in the matrix.
 
c3e_matrixc3e_matrix_lerp (c3e_matrix *matrix, c3e_matrix *subject, c3e_number weight)
 Performs linear interpolation between two matrices.
 
c3e_matrixc3e_matrix_neg (c3e_matrix *matrix)
 Negates each element in the matrix.
 
c3e_matrixc3e_matrix_sign (c3e_matrix *matrix)
 Computes the sign of each element in the matrix.
 
c3e_matrixc3e_matrix_equals (c3e_matrix *matrix, c3e_matrix *subject)
 Checks for element-wise equality between two matrices.
 
c3e_matrixc3e_matrix_less_than (c3e_matrix *matrix, c3e_matrix *subject)
 Checks for element-wise less-than comparison between two matrices.
 
c3e_matrixc3e_matrix_less_than_eq (c3e_matrix *matrix, c3e_matrix *subject)
 Checks for element-wise less-than-or-equal comparison between two matrices.
 
c3e_matrixc3e_matrix_greater_than (c3e_matrix *matrix, c3e_matrix *subject)
 Checks for element-wise greater-than comparison between two matrices.
 
c3e_matrixc3e_matrix_greater_than_eq (c3e_matrix *matrix, c3e_matrix *subject)
 Checks for element-wise greater-than-or-equal comparison between two matrices.
 
c3e_matrixc3e_matrix_exp (c3e_matrix *matrix)
 Computes the exponential of each element in the matrix.
 
c3e_matrixc3e_matrix_log_cumsum_exp (c3e_matrix *matrix)
 Computes the log-cumulative-sum-exp of each row of the matrix.
 
c3e_matrixc3e_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_matrixc3e_matrix_get (c3e_matrix *matrix, c3e_matrix *subject)
 Extracts a submatrix from the given matrix.
 
c3e_matrixc3e_matrix_repeat (c3e_matrix *matrix, int rrows, int rcols)
 Repeats the matrix rrows times vertically and rcols times horizontally.
 
c3e_matrixc3e_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_matrixc3e_matrix_arg_sort (c3e_matrix *matrix)
 Returns the indices of the elements in ascending order.
 
c3e_matrixc3e_matrix_arg_min_vals (c3e_matrix *matrix, int dim)
 Finds the indices of the minimum values along a specified dimension.
 
c3e_matrixc3e_matrix_arg_max_vals (c3e_matrix *matrix, int dim)
 Finds the indices of the maximum values along a specified dimension.
 

Detailed Description

Author
Nathanne Isip

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.

Macro Definition Documentation

◆ MATRIX_ELEM

#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.

Parameters
matrixPointer to the matrix structure.
rowRow index of the element.
colColumn index of the element.
Returns
Value at the specified row and column in the matrix.

Function Documentation

◆ c3e_matrix_a_range()

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.

Parameters
startThe starting value of the sequence.
endThe end value of the sequence (exclusive).
stepThe increment value.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_abs()

c3e_matrix * c3e_matrix_abs ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix with the absolute values, or NULL on failure.

◆ c3e_matrix_add()

c3e_matrix * c3e_matrix_add ( c3e_matrix matrix,
c3e_matrix subject 
)

Computes the element-wise sum of two matrices of the same dimensions.

Parameters
matrixPointer to the first matrix.
subjectPointer to the second matrix.
Returns
Pointer to the resulting matrix after addition, or NULL on failure.

◆ c3e_matrix_add_row()

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.

Parameters
matrixPointer to the matrix.
row1Index of the row to be modified.
row2Index of the row to be scaled and added.
scalarScalar value to multiply row2 by before adding to row1.

◆ c3e_matrix_all_close()

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.

Parameters
matrixPointer to the first matrix.
subjectPointer to the second matrix to compare with.
Returns
true if all elements are close, false otherwise.

◆ c3e_matrix_append()

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.

Parameters
matrixPointer to the matrix to append to.
subjectPointer to the matrix to append.
axisAxis along which to append the matrices (0 for rows, 1 for columns).
Returns
Pointer to the newly created combined matrix, or NULL on failure.

◆ c3e_matrix_arc_cos()

c3e_matrix * c3e_matrix_arc_cos ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix with the arccos values, or NULL on failure.

◆ c3e_matrix_arc_cosh()

c3e_matrix * c3e_matrix_arc_cosh ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix with the arccosh values, or NULL on failure.

◆ c3e_matrix_arc_sin()

c3e_matrix * c3e_matrix_arc_sin ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix with the arcsine values, or NULL on failure.

◆ c3e_matrix_arc_sinh()

c3e_matrix * c3e_matrix_arc_sinh ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix with the arcsinh values, or NULL on failure.

◆ c3e_matrix_arc_tan()

c3e_matrix * c3e_matrix_arc_tan ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix with the arctan values, or NULL on failure.

◆ c3e_matrix_arc_tanh()

c3e_matrix * c3e_matrix_arc_tanh ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix with the arctanh values, or NULL on failure.

◆ c3e_matrix_arg_max()

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.

Parameters
matrixPointer to the matrix.
Returns
Index of the maximum element.

◆ c3e_matrix_arg_max_vals()

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).

Parameters
matrixPointer to the matrix.
dimThe dimension along which to find maximum values (0 for rows, 1 for columns).
Returns
Pointer to the resulting matrix of indices, or NULL on failure.

◆ c3e_matrix_arg_min()

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.

Parameters
matrixPointer to the matrix.
Returns
Index of the minimum element.

◆ c3e_matrix_arg_min_vals()

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).

Parameters
matrixPointer to the matrix.
dimThe dimension along which to find minimum values (0 for rows, 1 for columns).
Returns
Pointer to the resulting matrix of indices, or NULL on failure.

◆ c3e_matrix_arg_sort()

c3e_matrix * c3e_matrix_arg_sort ( c3e_matrix matrix)

This function returns a matrix containing the indices of the elements sorted in ascending order.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix of sorted indices, or NULL on failure.

◆ c3e_matrix_cholesky_decomp()

c3e_matrix * c3e_matrix_cholesky_decomp ( c3e_matrix matrix)

Decomposes the matrix into a lower triangular matrix L such that L*L^T = A.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the lower triangular matrix L, or NULL on failure.

◆ c3e_matrix_clip()

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.

Parameters
matrixPointer to the matrix.
minMinimum value to clip to.
maxMaximum value to clip to.
Returns
Pointer to the clipped matrix, or NULL on failure.

◆ c3e_matrix_col_copy()

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.

Parameters
matrixPointer to the source matrix.
colColumn index in the source matrix to copy.
dstPointer to the destination matrix.
dst_colColumn index in the destination matrix where the column is to be copied.

◆ c3e_matrix_col_div()

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.

Parameters
matrixPointer to the matrix.
colColumn index in the matrix.
scalarThe scalar value to divide by.

◆ c3e_matrix_col_sub()

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.

Parameters
matrixPointer to the source matrix.
colColumn index in the source matrix.
dstPointer to the destination matrix.
dcolColumn index in the destination matrix where the result is stored.
scalarThe scalar value to subtract.

◆ c3e_matrix_copy()

c3e_matrix * c3e_matrix_copy ( c3e_matrix matrix)

Allocates memory and copies the contents of the source matrix into a new matrix.

Parameters
matrixPointer to the matrix to copy.
Returns
Pointer to the newly created copy of the matrix, or NULL on failure.

◆ c3e_matrix_cos()

c3e_matrix * c3e_matrix_cos ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix with the cosine values, or NULL on failure.

◆ c3e_matrix_cosh()

c3e_matrix * c3e_matrix_cosh ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix with the cosh values, or NULL on failure.

◆ c3e_matrix_cum_product()

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.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix with cumulative products, or NULL on failure.

◆ c3e_matrix_cum_sum()

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.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix with cumulative sums, or NULL on failure.

◆ c3e_matrix_determinant()

c3e_number c3e_matrix_determinant ( c3e_matrix matrix)

The determinant is a scalar value that is a function of a square matrix.

Parameters
matrixPointer to the matrix.
Returns
The determinant of the matrix.

◆ c3e_matrix_diagonal()

c3e_vector * c3e_matrix_diagonal ( c3e_matrix matrix,
int  k 
)

Returns a vector containing the elements on the specified diagonal.

Parameters
matrixPointer to the matrix.
kDiagonal offset (0 for main diagonal, positive for above, negative for below).
Returns
Pointer to the vector containing the diagonal elements, or NULL on failure.

◆ c3e_matrix_div()

c3e_matrix * c3e_matrix_div ( c3e_matrix matrix,
c3e_matrix subject 
)

Computes the element-wise quotient of two matrices of the same dimensions.

Parameters
matrixPointer to the matrix to divide.
subjectPointer to the matrix to divide by.
Returns
Pointer to the resulting matrix after division, or NULL on failure.

◆ c3e_matrix_dot()

c3e_matrix * c3e_matrix_dot ( c3e_matrix matrix,
c3e_matrix subject 
)

Computes the matrix product (dot product) of two matrices.

Parameters
matrixPointer to the first matrix.
subjectPointer to the second matrix.
Returns
Pointer to the resulting matrix after dot product, or NULL on failure.

◆ c3e_matrix_eigenvalues()

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.

Parameters
matrixPointer to the matrix.
Returns
Pointer to a vector containing the eigenvalues, or NULL on failure.

◆ c3e_matrix_eigenvec()

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.

Parameters
matrixPointer to the matrix.
Returns
Pointer to a matrix whose columns are the eigenvectors, or NULL on failure.

◆ c3e_matrix_equals()

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.

Parameters
matrixPointer to the first matrix.
subjectPointer to the second matrix.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_exp()

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.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_fill()

void c3e_matrix_fill ( c3e_matrix matrix,
c3e_number  value 
)

Sets all elements of the matrix to the given value.

Parameters
matrixPointer to the matrix.
valueValue to set for all elements in the matrix.

◆ c3e_matrix_find_pivot()

int c3e_matrix_find_pivot ( c3e_matrix matrix,
int  col,
int  row 
)

Identifies the pivot element in the matrix for Gaussian elimination.

Parameters
matrixPointer to the matrix.
colColumn index to search for the pivot.
rowStarting row index for the search.
Returns
The row index of the pivot element, or -1 if no pivot is found.

◆ c3e_matrix_flatten()

c3e_matrix * c3e_matrix_flatten ( c3e_matrix matrix)

Converts the matrix into a one-dimensional representation, stacking rows sequentially.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the flattened matrix, or NULL on failure.

◆ c3e_matrix_free()

void c3e_matrix_free ( c3e_matrix matrix)

Deallocates the memory associated with the matrix structure and its data.

Parameters
matrixPointer to the matrix to be freed.

◆ c3e_matrix_frobenius()

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.

Parameters
matrixPointer to the matrix.
Returns
The Frobenius norm of the matrix.

◆ c3e_matrix_from_vec()

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.

Parameters
vectorPointer to the vector to convert.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_full()

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.

Parameters
rowsNumber of rows in the matrix.
colsNumber of columns in the matrix.
valueThe value to set for all elements in the matrix.
Returns
Pointer to the newly created matrix, or NULL on failure.

◆ c3e_matrix_full_like()

c3e_matrix * c3e_matrix_full_like ( c3e_matrix matrix,
c3e_number  value 
)
Parameters
matrixPointer to the reference matrix.
valueThe value to set for all elements in the new matrix.
Returns
Pointer to the new matrix, or NULL on failure.

◆ c3e_matrix_get()

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.

Parameters
matrixPointer to the source matrix.
subjectPointer to the matrix containing row and column indices.
Returns
Pointer to the resulting submatrix, or NULL on failure.

◆ c3e_matrix_get_at()

c3e_number c3e_matrix_get_at ( c3e_matrix matrix,
int  row,
int  col 
)
Parameters
matrixPointer to the matrix.
rowRow index of the desired element.
colColumn index of the desired element.
Returns
The value at the specified position.

◆ c3e_matrix_get_row()

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.

Parameters
matrixPointer to the c3e_matrix from which to extract the row.
rowThe zero-based index of the row to extract.
Returns
Pointer to a new c3e_vector containing the elements of the specified row, or NULL if the row index is out of bounds.

◆ c3e_matrix_greater_than()

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.

Parameters
matrixPointer to the first matrix.
subjectPointer to the second matrix.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_greater_than_eq()

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.

Parameters
matrixPointer to the first matrix.
subjectPointer to the second matrix.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_identity()

c3e_matrix * c3e_matrix_identity ( int  side)

An identity matrix is a square matrix with ones on the diagonal and zeros elsewhere.

Parameters
sideThe number of rows and columns (must be equal) in the identity matrix.
Returns
Pointer to the newly created identity matrix, or NULL on failure.

◆ c3e_matrix_infinity_norm()

c3e_number c3e_matrix_infinity_norm ( c3e_matrix matrix)

The infinity norm is the maximum absolute row sum of the matrix.

Parameters
matrixPointer to the matrix.
Returns
The infinity norm of the matrix.

◆ c3e_matrix_init()

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.

Parameters
rowsNumber of rows in the matrix.
colsNumber of columns in the matrix.
Returns
Pointer to the initialized matrix, or NULL on failure.

◆ c3e_matrix_inverse()

c3e_matrix * c3e_matrix_inverse ( c3e_matrix matrix)

Calculates the inverse of the matrix if it exists.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the inverted matrix, or NULL if the matrix is singular.

◆ c3e_matrix_l1_norm()

c3e_number c3e_matrix_l1_norm ( c3e_matrix matrix)

The L1 norm is the sum of the absolute values of the matrix elements.

Parameters
matrixPointer to the matrix.
Returns
The L1 norm of the matrix.

◆ c3e_matrix_lerp()

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.

Parameters
matrixPointer to the first matrix.
subjectPointer to the second matrix.
weightThe interpolation weight, ranging from 0 (all from matrix) to 1 (all from subject).
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_less_than()

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.

Parameters
matrixPointer to the first matrix.
subjectPointer to the second matrix.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_less_than_eq()

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.

Parameters
matrixPointer to the first matrix.
subjectPointer to the second matrix.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_log()

c3e_matrix * c3e_matrix_log ( c3e_matrix matrix)

This function computes the natural logarithm (base e) of each element in the matrix.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_log10()

c3e_matrix * c3e_matrix_log10 ( c3e_matrix matrix)

This function computes the logarithm base 10 of each element in the matrix.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_log1p()

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.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_log2()

c3e_matrix * c3e_matrix_log2 ( c3e_matrix matrix)

This function computes the logarithm base 2 of each element in the matrix.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_log_cumsum_exp()

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.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_log_determ()

c3e_number c3e_matrix_log_determ ( c3e_matrix matrix)

Computes the natural logarithm of the absolute value of the determinant of a matrix.

Parameters
matrixPointer to the matrix.
Returns
The logarithm of the determinant.

◆ c3e_matrix_log_gamma()

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.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_max()

c3e_number c3e_matrix_max ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
The maximum element in the matrix.

◆ c3e_matrix_max_values()

c3e_matrix * c3e_matrix_max_values ( c3e_matrix matrix,
int  dim 
)
Parameters
matrixPointer to the matrix.
dimDimension along which to find maximum values (0 for rows, 1 for columns).
Returns
Pointer to a matrix or vector containing the maximum values, or NULL on failure.

◆ c3e_matrix_mean()

c3e_number c3e_matrix_mean ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
The mean of the matrix elements.

◆ c3e_matrix_mean_vals()

c3e_matrix * c3e_matrix_mean_vals ( c3e_matrix matrix,
int  dim 
)
Parameters
matrixPointer to the matrix.
dimDimension along which to compute the mean (0 for rows, 1 for columns).
Returns
Pointer to a matrix or vector containing the mean of elements, or NULL on failure.

◆ c3e_matrix_min()

c3e_number c3e_matrix_min ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
The minimum element in the matrix.

◆ c3e_matrix_min_vals()

c3e_matrix * c3e_matrix_min_vals ( c3e_matrix matrix,
int  dim 
)
Parameters
matrixPointer to the matrix.
dimDimension along which to find minimum values (0 for rows, 1 for columns).
Returns
Pointer to a matrix or vector containing the minimum values, or NULL on failure.

◆ c3e_matrix_mul()

c3e_matrix * c3e_matrix_mul ( c3e_matrix matrix,
c3e_matrix subject 
)

Computes the element-wise product of two matrices of the same dimensions.

Parameters
matrixPointer to the first matrix.
subjectPointer to the second matrix.
Returns
Pointer to the resulting matrix after multiplication, or NULL on failure.

◆ c3e_matrix_multiply_row()

void c3e_matrix_multiply_row ( c3e_matrix matrix,
int  row1,
c3e_number  scalar 
)

Scales the elements of a specified row by a scalar value.

Parameters
matrixPointer to the matrix.
row1Index of the row to be multiplied.
scalarThe scalar value to multiply with.

◆ c3e_matrix_neg()

c3e_matrix * c3e_matrix_neg ( c3e_matrix matrix)

This function computes the negative of each element in the matrix.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_non_zero_rows()

int c3e_matrix_non_zero_rows ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
The number of non-zero rows.

◆ c3e_matrix_normalize()

c3e_matrix * c3e_matrix_normalize ( c3e_matrix matrix)

Adjusts the matrix elements such that they lie within a certain range, typically [0, 1].

Parameters
matrixPointer to the matrix to be normalized.
Returns
Pointer to the normalized matrix, or NULL on failure.

◆ c3e_matrix_ones()

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.

Parameters
rowsNumber of rows in the matrix.
colsNumber of columns in the matrix.
Returns
Pointer to the newly created matrix, or NULL on failure.

◆ c3e_matrix_ones_like()

c3e_matrix * c3e_matrix_ones_like ( c3e_matrix matrix)
Parameters
matrixPointer to the reference matrix.
Returns
Pointer to the new matrix, or NULL on failure.

◆ c3e_matrix_pow()

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.

Parameters
matrixPointer to the matrix.
expThe exponent to raise each element to.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_product()

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.

Parameters
matrixPointer to the matrix.
Returns
The product of all matrix elements.

◆ c3e_matrix_qr_algo()

c3e_matrix * c3e_matrix_qr_algo ( c3e_matrix matrix)

Decomposes the matrix into an orthogonal matrix Q and an upper triangular matrix R.

Parameters
matrixPointer to the matrix.
Returns
Pointer to a matrix containing Q and R, or NULL on failure.

◆ c3e_matrix_random()

c3e_matrix * c3e_matrix_random ( int  rows,
int  cols,
int  seed 
)

Initializes a matrix with random values. The randomness is controlled by a seed.

Parameters
rowsNumber of rows in the matrix.
colsNumber of columns in the matrix.
seedSeed for the random number generator.
Returns
Pointer to the newly created matrix, or NULL on failure.

◆ c3e_matrix_random_bound()

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.

Parameters
rowsNumber of rows in the matrix.
colsNumber of columns in the matrix.
seedSeed for the random number generator.
minMinimum value for the random numbers.
maxMaximum value for the random numbers.
Returns
Pointer to the newly created matrix, or NULL on failure.

◆ c3e_matrix_rank()

int c3e_matrix_rank ( c3e_matrix matrix)

The rank is the maximum number of linearly independent rows or columns in the matrix.

Parameters
matrixPointer to the matrix.
Returns
The rank of the matrix.

◆ c3e_matrix_reciproc()

c3e_matrix * c3e_matrix_reciproc ( c3e_matrix matrix)

This function calculates the reciprocal (1/x) of each element in the matrix.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_repeat()

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.

Parameters
matrixPointer to the matrix to be repeated.
rrowsNumber of repetitions along rows.
rcolsNumber of repetitions along columns.
Returns
Pointer to the resulting repeated matrix, or NULL on failure.

◆ c3e_matrix_reshape()

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.

Parameters
matrixPointer to the matrix.
rowsNumber of rows for the new shape.
colsNumber of columns for the new shape.
Returns
Pointer to the reshaped matrix, or NULL on failure.

◆ c3e_matrix_resize()

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.

Parameters
matrixPointer to the matrix to be resized.
rowsNew number of rows.
colsNew number of columns.

◆ c3e_matrix_resize_as()

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.

Parameters
matrixPointer to the matrix to be resized.
subjectPointer to the matrix whose dimensions are used.

◆ c3e_matrix_row_echelon()

c3e_matrix * c3e_matrix_row_echelon ( c3e_matrix matrix)

Transforms the matrix to row echelon form using Gaussian elimination.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the matrix in row echelon form, or NULL on failure.

◆ c3e_matrix_rsqrt()

c3e_matrix * c3e_matrix_rsqrt ( c3e_matrix matrix)

This function calculates the reciprocal of the square root of each element in the matrix.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_scalar_add()

c3e_matrix * c3e_matrix_scalar_add ( c3e_matrix matrix,
c3e_number  x 
)
Parameters
matrixPointer to the matrix.
xThe scalar value to add.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_scalar_div()

c3e_matrix * c3e_matrix_scalar_div ( c3e_matrix matrix,
c3e_number  x 
)
Parameters
matrixPointer to the matrix.
xThe scalar value to divide by.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_scalar_mul()

c3e_matrix * c3e_matrix_scalar_mul ( c3e_matrix matrix,
c3e_number  x 
)
Parameters
matrixPointer to the matrix.
xThe scalar value to multiply with.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_scalar_sub()

c3e_matrix * c3e_matrix_scalar_sub ( c3e_matrix matrix,
c3e_number  x 
)
Parameters
matrixPointer to the matrix.
xThe scalar value to subtract.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_scale()

c3e_matrix * c3e_matrix_scale ( c3e_matrix matrix,
int  x 
)

Multiplies each element of the matrix by the given scalar value.

Parameters
matrixPointer to the matrix to be scaled.
xThe scalar value to multiply with.
Returns
Pointer to the scaled matrix, or NULL on failure.

◆ c3e_matrix_set_elements()

void c3e_matrix_set_elements ( c3e_matrix matrix,
c3e_number values 
)

Populates the matrix with values provided in an array.

Parameters
matrixPointer to the matrix.
valuesArray of values to set in the matrix.

◆ c3e_matrix_sign()

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.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_sin()

c3e_matrix * c3e_matrix_sin ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix with the sine values, or NULL on failure.

◆ c3e_matrix_sinh()

c3e_matrix * c3e_matrix_sinh ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix with the sinh values, or NULL on failure.

◆ c3e_matrix_size()

int c3e_matrix_size ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
The total number of elements in the matrix.

◆ c3e_matrix_slice()

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.

Parameters
matrixPointer to the original matrix.
frowsStarting row index (inclusive).
trowsEnding row index (exclusive).
fcolsStarting column index (inclusive).
tcolsEnding column index (exclusive).
Returns
Pointer to the sliced matrix, or NULL on failure.

◆ c3e_matrix_solve()

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.

Parameters
matrixPointer to the coefficient matrix.
subjectPointer to the right-hand side matrix or vector.
Returns
Pointer to the solution matrix or vector, or NULL on failure.

◆ c3e_matrix_sort()

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.

Parameters
matrixPointer to the matrix to be sorted.

◆ c3e_matrix_sqrt()

c3e_matrix * c3e_matrix_sqrt ( c3e_matrix matrix)

This function calculates the square root of each element in the matrix.

Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix, or NULL on failure.

◆ c3e_matrix_std()

c3e_number c3e_matrix_std ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
The standard deviation of the matrix elements.

◆ c3e_matrix_std_vals()

c3e_matrix * c3e_matrix_std_vals ( c3e_matrix matrix,
int  dim 
)
Parameters
matrixPointer to the matrix.
dimDimension along which to compute the standard deviation (0 for rows, 1 for columns).
Returns
Pointer to a matrix or vector containing the standard deviation, or NULL on failure.

◆ c3e_matrix_sub()

c3e_matrix * c3e_matrix_sub ( c3e_matrix matrix,
c3e_matrix subject 
)

Computes the element-wise difference of two matrices of the same dimensions.

Parameters
matrixPointer to the matrix to subtract from.
subjectPointer to the matrix to subtract.
Returns
Pointer to the resulting matrix after subtraction, or NULL on failure.

◆ c3e_matrix_sum()

c3e_number c3e_matrix_sum ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
The sum of all elements in the matrix.

◆ c3e_matrix_sum_vals()

c3e_matrix * c3e_matrix_sum_vals ( c3e_matrix matrix,
int  dim 
)
Parameters
matrixPointer to the matrix.
dimDimension along which to sum elements (0 for rows, 1 for columns).
Returns
Pointer to a matrix or vector containing the sum of elements, or NULL on failure.

◆ c3e_matrix_swap_rows()

void c3e_matrix_swap_rows ( c3e_matrix matrix,
int  row1,
int  row2 
)

Interchanges the contents of two rows in the matrix.

Parameters
matrixPointer to the matrix.
row1Index of the first row.
row2Index of the second row.

◆ c3e_matrix_tan()

c3e_matrix * c3e_matrix_tan ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix with the tangent values, or NULL on failure.

◆ c3e_matrix_tanh()

c3e_matrix * c3e_matrix_tanh ( c3e_matrix matrix)
Parameters
matrixPointer to the matrix.
Returns
Pointer to the resulting matrix with the tanh values, or NULL on failure.

◆ c3e_matrix_trace()

c3e_number c3e_matrix_trace ( c3e_matrix matrix)

The trace is the sum of the diagonal elements of a square matrix.

Parameters
matrixPointer to the matrix.
Returns
The trace of the matrix.

◆ c3e_matrix_transpose()

c3e_matrix * c3e_matrix_transpose ( c3e_matrix matrix)

Swaps the rows and columns of the matrix, effectively rotating it by 90 degrees.

Parameters
matrixPointer to the matrix to transpose.
Returns
Pointer to the transposed matrix, or NULL on failure.

◆ c3e_matrix_tril()

c3e_matrix * c3e_matrix_tril ( c3e_matrix matrix,
int  diag 
)

The lower triangular part includes the diagonal and the elements below it.

Parameters
matrixPointer to the matrix.
diagDiagonal offset (0 for main diagonal, positive for above, negative for below).
Returns
Pointer to the lower triangular matrix, or NULL on failure.

◆ c3e_matrix_triu()

c3e_matrix * c3e_matrix_triu ( c3e_matrix matrix,
int  diag 
)

The upper triangular part includes the diagonal and the elements above it.

Parameters
matrixPointer to the matrix.
diagDiagonal offset (0 for main diagonal, positive for above, negative for below).
Returns
Pointer to the upper triangular matrix, or NULL on failure.

◆ c3e_matrix_vec_mul()

c3e_matrix * c3e_matrix_vec_mul ( c3e_matrix matrix,
c3e_vector vector 
)

Performs matrix-vector multiplication, resulting in a new vector.

Parameters
matrixPointer to the matrix.
vectorPointer to the vector to multiply.
Returns
Pointer to the resulting vector, or NULL on failure.

◆ c3e_matrix_zeros()

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.

Parameters
rowsNumber of rows in the matrix.
colsNumber of columns in the matrix.
Returns
Pointer to the newly created matrix, or NULL on failure.

◆ c3e_matrix_zeros_like()

c3e_matrix * c3e_matrix_zeros_like ( c3e_matrix matrix)
Parameters
matrixPointer to the reference matrix.
Returns
Pointer to the new matrix, or NULL on failure.