44#include <gsl/gsl_matrix.h>
45#include <gsl/gsl_blas.h>
46#include <gsl/gsl_linalg.h>
124 Matrix(
const std::vector<std::vector<double>> &vec);
168 double get(
const int &i,
const int &j)
const;
180 void set(
const int &i,
const int &j,
const double &v);
double dot_row(const Matrix &m1, const Matrix &m2)
This implementation takes two row vectors as arguments and returns their dot product as double.
void subtraction(const Matrix &m1, const Matrix &m2, Matrix &tmp)
Compute the element-wise subtraction of two matrices and store the result in a third matrix.
double dot_col(const Matrix &m1, const Matrix &m2)
This implementation takes two column vectors as arguments and returns their dot product as double.
void addition(const Matrix &m1, const Matrix &m2, Matrix &tmp)
Compute the element-wise addition of two matrices and store the result in a third matrix.
Matrix & operator-=(Matrix &m1, const Matrix &m2)
This implementation takes two gsl_matrix pointers as arguments and subtract the elements of the secon...
Matrix operator/(Matrix matrix, const double &scalar)
This operator takes a double scalar and a matrix as its operands. It returns a new gsl_matrix* that i...
Matrix & operator+=(Matrix &m1, const Matrix &m2)
This implementation takes two gsl_matrix pointers as arguments and adds the elements of the second ma...
void a_cross_b_plus_c_cross_d(const Matrix &a, const Matrix &b, const Matrix &c, const Matrix &d, Matrix &tmp_f, Matrix &tmp_l, Matrix &v_result)
std::ostream & operator<<(std::ostream &stream, const Matrix &matrix)
Bit push all element of a matrix in the format of:
Matrix & operator*=(Matrix &mat, const double &scalar)
This implementation uses the gsl_matrix_scale function to scale each element in the matrix by the sca...
Matrix kron(const Matrix &v1, const Matrix &v2)
the Kronecker product between two column matrices and returns the result in an output matrix....
Matrix & operator/=(Matrix &mat, const double &scalar)
This implementation uses the gsl_matrix_scale function to scale each element in the matrix by 1/the s...
Matrix operator-(const Matrix &m1, const Matrix &m2)
This implementation checks that the matrices have the same dimensions and allocates memory for the re...
void get_unit_vector(Matrix &m)
Get the unit vector in the direction of m which is assumed to be a (3, 1) Matrix and overwrites the r...
void colvec_matrix_multiplication(const Matrix &v1, const Matrix &m1, Matrix &tmp)
Multiply a row vector by a matrix and store the result in a row vector.
Matrix cross_col(const Matrix &m1, const Matrix &m2)
This implementation takes two column vectors as arguments and returns their cross product as a new co...
void multiplication(const Matrix &m1, const Matrix &m2, Matrix &tmp)
Multiply a matrix by a constant and store the result in a second matrix.
Matrix cross_row(const Matrix &m1, const Matrix &m2)
This implementation takes two row vectors as arguments and returns their cross product as a new row v...
void const_division(const Matrix &m1, const double num, Matrix &tmp)
Divide a matrix by a constant and store the result in a second matrix.
Matrix operator+(const Matrix &m1, const Matrix &m2)
This implementation checks that the matrices have the same dimensions and allocates memory for the re...
void cross(const Matrix &m1, const Matrix &m2, Matrix &temp)
Compute the cross product of two 3D vectors represented as 3x1 matrices.
Matrix operator*(const Matrix &matrix, const double &scalar)
This operator takes a double scalar and a matrix as its operands. It returns a new gsl_matrix* that i...
void assign_rowVec_to_colVec(const Matrix &srcRowVec, Matrix &destColVec)
void negative(const Matrix &m1, Matrix &m_neg)
Computes the negative of a given matrix.
void const_multiplication(const Matrix &m1, const double num, Matrix &tmp)
Multiply a matrix by a constant and store the result in a second matrix.
Matrix dot(const Matrix &m1, const Matrix &m2)
Matrix mat_calloc(const int &nrow, const int &ncol)
This function allocates a new Matrix object with the specified number of rows and columns,...
Matrix used in continuum membrane model.
Definition Linear_algebra.hpp:65
double calculate_norm() const
Calculates the Euclidean norm of the member matrix mat.
void get_inverted(Matrix &matInverted)
This function uses cholesky decomposition to solve for the inverse of the input square matrix....
double get(const int &i, const int &j) const
Get element value at i,j.
double calculate_quad() const
Calculates the Euclidean quadrance of the member matrix mat.
void set(const int &i, const int &j, const double &v)
Set element value at i,j to v.
Matrix()
Default constructor.
Matrix & operator=(const Matrix &mat_src)
Assignment operator.
double operator()(const int &i, const int &j) const
Get element value at i,j.
void set_row_from_col(const int &destRow, const Matrix &srcMat, const int &srcCol)
Set the row vector from col vector.
Matrix(const int &nrow, const int &ncol, const bool &setToZero)
Construct a new Matrix object and initialize the members to zeros. The setToZero variable is a place ...
gsl_matrix * mat
Definition Linear_algebra.hpp:67
void free()
Free memory allocation for a Matrix object.
Matrix(const Matrix &mat_src)
Copy constructor for creating a deep copy of a Matrix object.
void set_all(const double &v)
Set all elements to v.
Matrix(const int &nrow, const int &ncol)
Constructor for creating a Matrix with a specified number of rows and columns.
Matrix get_row(const int &irow) const
Get the row vector in the format of Matrix(1, N)
~Matrix()
Destructor for the Matrix class that frees the memory allocated by the mat member.
Matrix get_transposed() const
Get the tranposed matrix.
void transpose()
Transpose the matrix. This overwrites the original matrix.
void set_identity()
Set the matrix to identity matrix.
int ncol() const
get number of columns
Matrix get_col(const int &icol) const
Get the col vector in the format of Matrix(N, 1)
Matrix(const int &nrow)
Constructor for creating a Matrix with a specified number of rows and one column.
Matrix(const std::vector< std::vector< double > > &vec)
Intialize a matrix with a 2d vector.
int nrow() const
get number of rows