18 #define MAT(m, x, y) (m->data[(x * m->col) + y]) 19 #define VEC(v, x) (v->data[x]) 35 inline friend std::ostream& operator<< (std::ostream &out,
const _vector &
vector) {
36 for(
size_t i = 0; i < vector.
size; i ++) {
37 out << (vector.
data)[i];
56 inline friend std::ostream& operator<< (std::ostream &out,
const _matrix &
matrix) {
57 for(
size_t i = 0; i < matrix.
row; i ++) {
58 for(
size_t j = 0; j < matrix.
col; j ++) {
59 out << (matrix.
data)[(i * matrix.
col) + j];
131 double dot_product(
const double* left,
const double* right,
int length);
266 void eigen(
int N,
double a[],
int it_max,
double v[],
double d[],
int* it_num,
int* rot_num);
292 double frobenius_norm(
int n,
int k,
double a[],
double x[],
double lambda[]);
represents a matrix between matrix and vector they are able to be casted into one another ...
Definition: linalg.h:49
double data[]
the elements of the vector
Definition: linalg.h:34
void vec_print(const vector *vec)
prints the vector this function will not modify the vector and print to stdout
double dot_product(const double *left, const double *right, int length)
Performs dot product on two double* this function will malloc for the user a double arrays must be of...
vector * vecscalar_divide(const vector *vec, const double scalar)
Performs scalar division of a vector this function will malloc for the user a vector*.
matrix * matmat_multiply(const matrix *left, const matrix *right)
Performs standard matrix multiplication this function will malloc for the user a matrix*.
matrix * matrix_create(size_t row, size_t col)
Creates a matrix this function will malloc the exact space for the required dimensions.
struct _matrix matrix
represents a matrix between matrix and vector they are able to be casted into one another ...
size_t row
the number of rows in the matrix
Definition: linalg.h:51
matrix * covmat(matrix *mat)
computes the variance covariance matrix
struct _vector vector
represents a vector padding is to make sure that matrix and vector both have the same byte size and a...
matrix * vec_to_mat(vector *vec, int orientation)
Converts vector into matrix this function will "cast" the vector into a matrix by using the fact that...
void vec_append(vector **vec_a, vector *vec_b)
Appends vector b to vector a this function will realloc for the user vector a and free vector b...
void eigen(int N, double a[], int it_max, double v[], double d[], int *it_num, int *rot_num)
Performs Jacobi eigenvalue iteration this function will required the user to pass in non-null it_num ...
matrix * mat_transpose(const matrix *mat)
Performs matrix transpose this function will malloc for the user a matrix*.
void matrix_reshape(matrix *mat, size_t row, size_t col)
Reshapes the matrix this function will reshape the matrix in constant time.
vector * mat_to_vec(matrix *mat)
Converts matrix into vector this function will "cast" the matrix into a vector by using the fact that...
vector * vecscalar_multiply(const vector *vec, const double scalar)
Performs scalar multiplication of a vector this function will malloc for the user a vector*...
void diag_vector(int n, double a[], double v[])
gets the diagonal entries
matrix * matmat_subtraction(const matrix *left, const matrix *right)
Performs standard matrix subtration this function will malloc for the user a matrix*.
vector * vector_create(size_t size)
Creates a vector this function will malloc the exact space for the required dimensions.
void mat_identity(int n, double a[])
modifies a matrix to be the identity matrix of size n
size_t col
the number of columns in the matrix
Definition: linalg.h:53
matrix * matscalar_multiply(const matrix *mat, const double scalar)
Performs scalar multiplication of a matrix this function will malloc for the user a matrix*...
matrix * matscalar_divide(const matrix *mat, const double scalar)
Performs scalar division of a matrix this function will malloc for the user a matrix*.
vector * matvec_multiply(const matrix *mat, const vector *vec)
Performs matrix vector multiplication this function will malloc for the user a vector* if the matrix ...
size_t padding
unused value but important as padding
Definition: linalg.h:32
void mat_print(const matrix *mat)
prints the matrix this function will not modify the matrix and print to stdout
vector * vecmat_multiply(const vector *vec, const matrix *mat)
Performs vector matrix multiplication this function will malloc for the user a vector* if the vector ...
matrix * matmat_addition(const matrix *left, const matrix *right)
Performs standard matrix addition this function will malloc for the user a matrix*.
double frobenius_norm(int n, int k, double a[], double x[], double lambda[])
computes the Frobenius norm in a right eigensystem
double data[]
row wise expansion of the elements in the matrix
Definition: linalg.h:55
size_t size
the number of elements in the vector
Definition: linalg.h:30
represents a vector padding is to make sure that matrix and vector both have the same byte size and a...
Definition: linalg.h:28