|
Continuum Membrane 719025a62b1e384a6ff80e2f2a223ef4012153dc
|
Matrix used in continuum membrane model. More...
#include <Linear_algebra.hpp>
Public Member Functions | |
| 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 holder to differentiate this function from a malloc or alloc function. | |
| Matrix () | |
| Default constructor. | |
| Matrix (const int &nrow) | |
| Constructor for creating a Matrix with a specified number of rows and one column. | |
| Matrix (const int &nrow, const int &ncol) | |
| Constructor for creating a Matrix with a specified number of rows and columns. | |
| Matrix (const Matrix &mat_src) | |
| Copy constructor for creating a deep copy of a Matrix object. | |
| Matrix (const std::vector< std::vector< double > > &vec) | |
| Intialize a matrix with a 2d vector. | |
| Matrix & | operator= (const Matrix &mat_src) |
| Assignment operator. | |
| ~Matrix () | |
| Destructor for the Matrix class that frees the memory allocated by the mat member. | |
| void | free () |
| Free memory allocation for a Matrix object. | |
| int | nrow () const |
| get number of rows | |
| int | ncol () const |
| get number of columns | |
| double | get (const int &i, const int &j) const |
| Get element value at i,j. | |
| double | operator() (const int &i, const int &j) const |
| Get element value at i,j. | |
| void | set (const int &i, const int &j, const double &v) |
| Set element value at i,j to v. | |
| void | set_all (const double &v) |
| Set all elements to v. | |
| void | transpose () |
| Transpose the matrix. This overwrites the original matrix. | |
| void | set_identity () |
| Set the matrix to identity matrix. | |
| Matrix | get_row (const int &irow) const |
| Get the row vector in the format of Matrix(1, N) | |
| Matrix | get_col (const int &icol) const |
| Get the col vector in the format of Matrix(N, 1) | |
| void | set_row_from_col (const int &destRow, const Matrix &srcMat, const int &srcCol) |
| Set the row vector from col vector. | |
| Matrix | get_transposed () const |
| Get the tranposed matrix. | |
| void | get_inverted (Matrix &matInverted) |
| This function uses cholesky decomposition to solve for the inverse of the input square matrix. https://www.gnu.org/software/gsl/doc/html/linalg.html#c.gsl_linalg_cholesky_decomp1. | |
| double | calculate_norm () const |
| Calculates the Euclidean norm of the member matrix mat. | |
| double | calculate_quad () const |
| Calculates the Euclidean quadrance of the member matrix mat. | |
Public Attributes | |
| gsl_matrix * | mat |
Matrix used in continuum membrane model.
This class represents a N x M matrix. This header is an interface that can be implemented differently to support the use of different linear algebra pacakages. Currently gsl_blas is used for matrix calculation. Note that it is important to double check the destructor ~Matrix() and assign operator (operator=) if you would like to customize an implementation. Be careful of double free and memory leak that might be caused by misuse of pointers.
| Matrix::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 holder to differentiate this function from a malloc or alloc function.
| nrow | |
| ncol | |
| setToZero |
| Matrix::Matrix | ( | ) |
Default constructor.
| Matrix::Matrix | ( | const int & | nrow | ) |
Constructor for creating a Matrix with a specified number of rows and one column.
This constructor creates a new Matrix object with the specified number of rows and one column. The elements of the matrix are uninitialized and may contain garbage values.
| nrow | The number of rows in the matrix |
| Matrix::Matrix | ( | const int & | nrow, |
| const int & | ncol | ||
| ) |
Constructor for creating a Matrix with a specified number of rows and columns.
This constructor creates a new Matrix object with the specified number of rows and columns. The elements of the matrix are uninitialized and may contain garbage values.
| nrow | The number of rows in the matrix |
| ncol | The number of columns in the matrix |
| Matrix::Matrix | ( | const Matrix & | mat_src | ) |
Copy constructor for creating a deep copy of a Matrix object.
This constructor creates a new Matrix object that is a deep copy of the specified Matrix object. All elements of the original matrix are copied to the new matrix, so the two matrices are completely independent.
| mat_src | The Matrix object to be copied |
| Matrix::Matrix | ( | const std::vector< std::vector< double > > & | vec | ) |
Intialize a matrix with a 2d vector.
| Matrix::~Matrix | ( | ) |
Destructor for the Matrix class that frees the memory allocated by the mat member.
A destructor is a special member function of a C++ class that is called automatically when an object of the class goes out of scope or is otherwise destroyed. The purpose of the destructor is to release any resources or memory that the object was holding onto, to ensure that there are no memory leaks or other resource leaks caused by the object's destruction.
| double Matrix::calculate_norm | ( | ) | const |
Calculates the Euclidean norm of the member matrix mat.
| double Matrix::calculate_quad | ( | ) | const |
Calculates the Euclidean quadrance of the member matrix mat.
| void Matrix::free | ( | ) |
Free memory allocation for a Matrix object.
| double Matrix::get | ( | const int & | i, |
| const int & | j | ||
| ) | const |
Get element value at i,j.
| Matrix Matrix::get_col | ( | const int & | icol | ) | const |
| void Matrix::get_inverted | ( | Matrix & | matInverted | ) |
This function uses cholesky decomposition to solve for the inverse of the input square matrix. https://www.gnu.org/software/gsl/doc/html/linalg.html#c.gsl_linalg_cholesky_decomp1.
| matrix |
| Matrix Matrix::get_row | ( | const int & | irow | ) | const |
| int Matrix::ncol | ( | ) | const |
get number of columns
| int Matrix::nrow | ( | ) | const |
get number of rows
| double Matrix::operator() | ( | const int & | i, |
| const int & | j | ||
| ) | const |
Get element value at i,j.
| void Matrix::set | ( | const int & | i, |
| const int & | j, | ||
| const double & | v | ||
| ) |
Set element value at i,j to v.
| void Matrix::set_all | ( | const double & | v | ) |
Set all elements to v.
| void Matrix::set_identity | ( | ) |
Set the matrix to identity matrix.
| void Matrix::set_row_from_col | ( | const int & | destRow, |
| const Matrix & | srcMat, | ||
| const int & | srcCol | ||
| ) |
| void Matrix::transpose | ( | ) |
Transpose the matrix. This overwrites the original matrix.
| gsl_matrix* Matrix::mat |