Angka  0.0.1
A C library focusing on data manipulation and visualization
matrix.h
Go to the documentation of this file.
1 
7 #ifndef __MATRIX_H
8 #define __MATRIX_H
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
19 typedef char * p_matrixString_t;
20 
27 typedef struct s_matrix {
29  double *p_r_nums;
31  int r_shape[2];
33  int size;
34 } AgxMatrix;
35 
42 AgxMatrix *agx_matrix_new(int row, int column);
43 
47 void agx_matrix_delete(AgxMatrix **mat);
48 
54 
59 AgxMatrix *agx_matrix_new_constant(int row, int column, double val);
60 
65 AgxMatrix *agx_matrix_new_random(int row, int column, double min, double max);
66 
74 AgxMatrix *agx_matrix_new_from_array(double *ndarray_in, int dim1, int dim2);
75 
81 void agx_matrix_to_array(AgxMatrix *mat, double **ndarray_out, int *dim1, int *dim2);
82 
86 int agx_matrix_row_col_to_index(AgxMatrix *mat, int row, int col);
87 
92 int agx_matrix_set_item(AgxMatrix *mat, int row, int col, double val);
93 
98 int agx_matrix_get_item(AgxMatrix *mat, int row, int col, double *output);
99 
105 p_matrixString_t agx_matrix_to_string(AgxMatrix *mat, int islong);
106 
111 int agx_matrix_print(AgxMatrix *mat, int islong);
112 
118 
124 
129 int agx_matrix_add_by_value(AgxMatrix *mat, double val);
130 
135 int agx_matrix_substract_by_value(AgxMatrix *mat, double val);
136 
141 int agx_matrix_multiply_by_value(AgxMatrix *mat, double val);
142 
147 int agx_matrix_divide_by_value(AgxMatrix *mat, double val);
148 
154 
160 int agx_matrix_copy_elements(AgxMatrix *src, AgxMatrix *target);
161 
167 int agx_matrix_copy_shape(AgxMatrix *src, AgxMatrix *target);
168 
174 
180 
187 
193 
198 AgxMatrix *agx_matrix_new_zero(int row, int col);
199 
205 
211 
217 
223 
228 AgxMatrix *agx_matrix_new_extract_row_col(AgxMatrix *mat, int row1, int row2, int col1, int col2);
229 
233 double agx_matrix_min(AgxMatrix *mat);
234 
238 double agx_matrix_max(AgxMatrix *mat);
239 
240 #ifdef __cplusplus
241 }
242 #endif
243 
244 #endif
AgxMatrix * agx_matrix_new_from_vector(AgxVector *vec)
create a new matrix based on the vector
int agx_matrix_copy_shape(AgxMatrix *src, AgxMatrix *target)
copy shape the vector to the target vector
int agx_matrix_print_full(AgxMatrix *mat)
print a matrix in a full form (islong = 1)
AgxMatrix * agx_matrix_new_extract_column(AgxMatrix *mat, int col)
create a new matrix based on a certain column values
int agx_matrix_row_col_to_index(AgxMatrix *mat, int row, int col)
change row and col values to index of array matrix
struct s_matrix AgxMatrix
creating matrix data type in this library
char * p_matrixString_t
matrix string typedef
Definition: matrix.h:19
int agx_matrix_copy_elements(AgxMatrix *src, AgxMatrix *target)
copy all elements of the vector to the target vector
AgxMatrix * agx_matrix_new_extract_row(AgxMatrix *mat, int row)
create a new matrix based on a certain row values
AgxMatrix * agx_matrix_new_from_array(double *ndarray_in, int dim1, int dim2)
create a new matrix from C array
AgxMatrix * agx_matrix_new_identity(int size)
create a new identity matrix (m x m)
AgxMatrix * agx_matrix_new_zero(int row, int col)
create a new zero matrix
int size
size of the matrix
Definition: matrix.h:33
p_matrixString_t agx_matrix_to_string(AgxMatrix *mat, int islong)
change a matrix to matrix string
AgxMatrix * agx_matrix_new_copy(AgxMatrix *mat)
copy the matrix
int agx_matrix_multiply_by_value(AgxMatrix *mat, double val)
multiplying all elements of matrix by a value
void agx_matrix_to_array(AgxMatrix *mat, double **ndarray_out, int *dim1, int *dim2)
passing the array reference to ndarray_out
int agx_matrix_get_item(AgxMatrix *mat, int row, int col, double *output)
get the value from matrix based on row and column
int agx_matrix_print_partial(AgxMatrix *mat)
print a matrix in a partial form (islong = 0)
double agx_matrix_max(AgxMatrix *mat)
look for a maximum value of the matrix
double agx_matrix_min(AgxMatrix *mat)
look for a minimum value of the matrix
double * p_r_nums
array of the matrix
Definition: matrix.h:29
AgxMatrix * agx_matrix_new_multiplication(AgxMatrix *mat1, AgxMatrix *mat2)
matrix multiplication and stored in the new matrix
int agx_matrix_substract_by_value(AgxMatrix *mat, double val)
substracting all elements of matrix by a value
creating vector data type in this library
Definition: vector.h:27
int agx_matrix_transpose(AgxMatrix *mat)
transpose the matrix
AgxMatrix * agx_matrix_new_extract_row_col(AgxMatrix *mat, int row1, int row2, int col1, int col2)
create a new matrix based on a certain row and column range
AgxMatrix * agx_matrix_new_duplicate_size(AgxMatrix *mat)
create a new matrix based on the row of col values on another matrix
AgxMatrix * agx_matrix_new(int row, int column)
create an empty matrix with a certain row and column
creating matrix data type in this library
Definition: matrix.h:27
int r_shape[2]
shape of the matrix (m x n)
Definition: matrix.h:31
AgxMatrix * agx_matrix_new_random(int row, int column, double min, double max)
create a new matrix with some random values
void agx_matrix_delete(AgxMatrix **mat)
delete matrix
AgxVector * agx_vector_new_from_matrix(AgxMatrix *mat)
create a new vector from the matrix
int agx_matrix_change_elements_by_value(AgxMatrix *mat, double val)
change all elements of matrix by a value
int agx_matrix_set_item(AgxMatrix *mat, int row, int col, double val)
set a value in a corresponding row and column
int agx_matrix_add_by_value(AgxMatrix *mat, double val)
adding all elements of matrix by a value
int agx_matrix_divide_by_value(AgxMatrix *mat, double val)
dividing all elements of matrix by a value
AgxMatrix * agx_matrix_new_constant(int row, int column, double val)
create a new matrix with a constant value
int agx_matrix_print(AgxMatrix *mat, int islong)
print a matrix in the console with islong parameter