#include <vector>
#include <iostream>
#include <cmath>
Go to the source code of this file.
Functions | |
std::vector< double > | VectorDifference (std::vector< double > A, std::vector< double > B) |
Vector difference between two vectors. More... | |
std::vector< double > | VectorScalarProduct (std::vector< double > A, double b) |
Vector scalar prodcut of vector and scalar. More... | |
std::vector< double > | VectorSum (std::vector< double > A, std::vector< double > B) |
Vector sum between two vectors. More... | |
std::vector< double > | MatrixVectorProduct (std::vector< std::vector< double > > M, std::vector< double > A) |
double | VectorVectorProduct (std::vector< double > A, std::vector< double > B) |
Dot product of vectors. More... | |
std::vector< double > | GetMatrixColumn (std::vector< std::vector< double >> M, int column) |
Function to get a column from a matrix. More... | |
std::vector< double > | GetMatrixRow (std::vector< std::vector< double >> M, int row) |
Function to get a row from a matrix. More... | |
std::vector< std::vector< double > > | TransposeMatrix (std::vector< std::vector< double > > M) |
std::vector< double > | MatrixTrace (std::vector< std::vector< double >> M) |
Function to the trace of a square \(n \times n\) matrix \(M\). More... | |
std::vector< std::vector< double > > | InvertMatrixElements (std::vector< std::vector< double >> M) |
Function to take the inverse of the individual matrix elements. More... | |
std::vector< std::vector< double > > | VectorToDiagonal (std::vector< double > A) |
Function which takes a std::vector of double to make a diagonal matrix of it, such that \( A_{i} = M_{ii} \). More... | |
std::vector< std::vector< double > > | MatrixMatrixProduct (std::vector< std::vector< double >> M, std::vector< std::vector< double >> N) |
Function incorporating the standard matrix-matrix product, producing a new matrix. Matrix M should have as many columns as N has rows, otherwise an exception is thrown. More... | |
std::vector< std::vector< double > > | MatrixMatrixSum (std::vector< std::vector< double >> M, std::vector< std::vector< double >> N) |
A function to calculate the sum of the entries of two matrices. More... | |
std::vector< std::vector< double > > | operator+ (std::vector< std::vector< double >> M, std::vector< std::vector< double >> N) |
Operator form of MatrixMatrixSum(), using std library forwarding. More... | |
std::vector< std::vector< double > > | operator* (std::vector< std::vector< double >> M, std::vector< std::vector< double >> N) |
Operator form of MatrixMatrixProduct(), using std library forwarding. More... | |
double | operator* (std::vector< double > A, std::vector< double > B) |
Operator form of VectorVectorProduct(), using std library forwarding. More... | |
std::vector< double > | operator* (std::vector< std::vector< double >> M, std::vector< double > A) |
Operator form of MatrixVectorProduct(), using std library forwarding. More... | |
std::vector< double > | operator+ (std::vector< double > A, std::vector< double > B) |
Operator form of VectorSum(), using std library forwarding. More... | |
std::vector< double > | operator- (std::vector< double > A, std::vector< double > B) |
Operator form of VectorDifference(), using std library forwarding. More... | |
std::vector< double > | operator* (double b, std::vector< double > A) |
Operator form of VectorScalarProduct(), using std library forwarding. More... | |
std::vector< double > | operator* (std::vector< double > A, double b) |
Operator form of VectorScalarProduct(), using std library forwarding. More... | |
std::vector< std::vector< double > > | CholeskyDecompose (std::vector< std::vector< double >> A) |
Cholesky-decomposition of a positive definite Hermitian \( n \times n\) matrix \( M \). More... | |
std::vector< double > | SolveLowerTriangular (std::vector< std::vector< double >> L, std::vector< double > x) |
Solve linear equation \( L y = x\) where \( L \) is a lower triangular \( n \times n\) matrix and \( x \) and \( y \) are \( n\) dimensional vectors. Uses forward and backward substitution to iteratively solve the system. More... | |
std::vector< std::vector< double > > | InvertLowerTriangular (std::vector< std::vector< double >> L) |
Invert a lower triangular \( n \times n\) matrix by use of solving the system \( L L^{-1} = I\) per column of \( I \) using SolveLowerTriangular(), the identity matrix. More... | |
std::vector< double > | operator/ (std::vector< double > A, double b) |
Operator form of vector by scalar division. Uses VectorScalarProduct() with std library forwarding. More... | |
std::vector< double > | NormalizeVector (std::vector< double > A) |
Normalizes a vector to unit length. More... | |
std::vector<std::vector<double> > CholeskyDecompose | ( | std::vector< std::vector< double >> | A | ) |
Cholesky-decomposition of a positive definite Hermitian \( n \times n\) matrix \( M \).
A | A positive definite Hermitian \( n \times n\) matrix. |
Definition at line 275 of file linearalgebra.cpp.
std::vector<double> GetMatrixColumn | ( | std::vector< std::vector< double >> | M, |
int | column | ||
) |
Function to get a column from a matrix.
M | Any \( n \times m \) matrix \(M\). |
row | Integer indicating the column. Numbering starts at 0. |
Definition at line 93 of file linearalgebra.cpp.
std::vector<double> GetMatrixRow | ( | std::vector< std::vector< double >> | M, |
int | row | ||
) |
Function to get a row from a matrix.
M | Any \( n \times m \) matrix \(M\). |
row | Integer indicating the row. Numbering starts at 0. |
Definition at line 110 of file linearalgebra.cpp.
std::vector<std::vector<double> > InvertLowerTriangular | ( | std::vector< std::vector< double >> | L | ) |
Invert a lower triangular \( n \times n\) matrix by use of solving the system \( L L^{-1} = I\) per column of \( I \) using SolveLowerTriangular(), the identity matrix.
L | Any lower triangular \( n \times n\) matrix. |
Definition at line 325 of file linearalgebra.cpp.
std::vector<std::vector<double> > InvertMatrixElements | ( | std::vector< std::vector< double >> | M | ) |
Function to take the inverse of the individual matrix elements.
M | Any \( n \times m \) matrix \(M\). |
Definition at line 158 of file linearalgebra.cpp.
std::vector<std::vector<double> > MatrixMatrixProduct | ( | std::vector< std::vector< double >> | M, |
std::vector< std::vector< double >> | N | ||
) |
Function incorporating the standard matrix-matrix product, producing a new matrix. Matrix M should have as many columns as N has rows, otherwise an exception is thrown.
M | Any \( n \times m \) matrix \(M\). |
N | Any \( m \times p \) matrix \(N\). |
Definition at line 184 of file linearalgebra.cpp.
std::vector<std::vector<double> > MatrixMatrixSum | ( | std::vector< std::vector< double >> | M, |
std::vector< std::vector< double >> | N | ||
) |
A function to calculate the sum of the entries of two matrices.
M | Any \( n \times m \) matrix \(M\). |
N | Any \( n \times m \) matrix \(N\). |
Definition at line 213 of file linearalgebra.cpp.
std::vector<double> MatrixTrace | ( | std::vector< std::vector< double >> | M | ) |
Function to the trace of a square \(n \times n\) matrix \(M\).
M | Any square matrix. |
Definition at line 144 of file linearalgebra.cpp.
std::vector<double> MatrixVectorProduct | ( | std::vector< std::vector< double > > | M, |
std::vector< double > | A | ||
) |
Definition at line 54 of file linearalgebra.cpp.
std::vector<double> NormalizeVector | ( | std::vector< double > | A | ) |
Normalizes a vector to unit length.
A | Any vector \( A \). |
Definition at line 345 of file linearalgebra.cpp.
std::vector<std::vector<double> > operator* | ( | std::vector< std::vector< double >> | M, |
std::vector< std::vector< double >> | N | ||
) |
Operator form of MatrixMatrixProduct(), using std library forwarding.
Definition at line 245 of file linearalgebra.cpp.
double operator* | ( | std::vector< double > | A, |
std::vector< double > | B | ||
) |
Operator form of VectorVectorProduct(), using std library forwarding.
Definition at line 250 of file linearalgebra.cpp.
std::vector<double> operator* | ( | std::vector< std::vector< double >> | M, |
std::vector< double > | A | ||
) |
Operator form of MatrixVectorProduct(), using std library forwarding.
Definition at line 254 of file linearalgebra.cpp.
std::vector<double> operator* | ( | double | b, |
std::vector< double > | A | ||
) |
Operator form of VectorScalarProduct(), using std library forwarding.
Definition at line 267 of file linearalgebra.cpp.
std::vector<double> operator* | ( | std::vector< double > | A, |
double | b | ||
) |
Operator form of VectorScalarProduct(), using std library forwarding.
Definition at line 271 of file linearalgebra.cpp.
std::vector<std::vector<double> > operator+ | ( | std::vector< std::vector< double >> | M, |
std::vector< std::vector< double >> | N | ||
) |
Operator form of MatrixMatrixSum(), using std library forwarding.
Definition at line 240 of file linearalgebra.cpp.
std::vector<double> operator+ | ( | std::vector< double > | A, |
std::vector< double > | B | ||
) |
Operator form of VectorSum(), using std library forwarding.
Definition at line 259 of file linearalgebra.cpp.
std::vector<double> operator- | ( | std::vector< double > | A, |
std::vector< double > | B | ||
) |
Operator form of VectorDifference(), using std library forwarding.
Definition at line 263 of file linearalgebra.cpp.
std::vector<double> operator/ | ( | std::vector< double > | A, |
double | b | ||
) |
Operator form of vector by scalar division. Uses VectorScalarProduct() with std library forwarding.
Definition at line 341 of file linearalgebra.cpp.
std::vector<double> SolveLowerTriangular | ( | std::vector< std::vector< double >> | L, |
std::vector< double > | x | ||
) |
Solve linear equation \( L y = x\) where \( L \) is a lower triangular \( n \times n\) matrix and \( x \) and \( y \) are \( n\) dimensional vectors. Uses forward and backward substitution to iteratively solve the system.
L | Any lower triangular \( n \times n\) matrix. |
x | Any \( n\) dimensional vector. |
Definition at line 303 of file linearalgebra.cpp.
std::vector<std::vector<double> > TransposeMatrix | ( | std::vector< std::vector< double > > | M | ) |
Definition at line 127 of file linearalgebra.cpp.
std::vector<double> VectorDifference | ( | std::vector< double > | A, |
std::vector< double > | B | ||
) |
Vector difference between two vectors.
A | Vector \( A \) of dimension \( n\). |
B | Vector \( B \) of dimension \( n\). |
Definition at line 11 of file linearalgebra.cpp.
std::vector<double> VectorScalarProduct | ( | std::vector< double > | A, |
double | b | ||
) |
Vector scalar prodcut of vector and scalar.
A | Any vector \( A \). |
B | Scalar \( b \). |
Definition at line 29 of file linearalgebra.cpp.
std::vector<double> VectorSum | ( | std::vector< double > | A, |
std::vector< double > | B | ||
) |
Vector sum between two vectors.
A | Vector \( A \) of dimension \( n\). |
B | Vector \( B \) of dimension \( n\). |
Definition at line 36 of file linearalgebra.cpp.
std::vector<std::vector<double> > VectorToDiagonal | ( | std::vector< double > | A | ) |
Function which takes a std::vector of double to make a diagonal matrix of it, such that \( A_{i} = M_{ii} \).
A | Any Any \( n \) dimensional vector. |
Definition at line 169 of file linearalgebra.cpp.
double VectorVectorProduct | ( | std::vector< double > | A, |
std::vector< double > | B | ||
) |
Dot product of vectors.
A | Vector \( A \) of dimension \( n\). |
B | Vector \( B \) of dimension \( n\). |
Definition at line 78 of file linearalgebra.cpp.