Classes | |
class | Complex |
Class for complex numbers. More... | |
struct | LUP |
Struct for LUP decomposition. More... | |
struct | QR |
Struct for QR decomposition. More... | |
struct | Cholesky |
Struct for Cholesky decomposition. More... | |
struct | Eigendecomposition |
Struct for Eigendecomposition. More... | |
struct | SVD |
Struct for SVD decomposition. More... | |
struct | Hessenberg |
Struct for Hessenberg decomposition. More... | |
struct | Schur |
Struct for Schur decomposition. More... | |
struct | Eigenpair |
Struct for eigenpairs. More... | |
class | Matrix |
Class for matrices. More... | |
Typedefs | |
using | Complexi = Complex< int > |
using | Complexf = Complex< float > |
using | Complexd = Complex< double > |
template<typename T , size_t N, unsigned int Flags = 0> | |
using | SquareMatrix = Matrix< T, N, N, Flags > |
using | Matrix2f = Matrix< float, 2, 2 > |
using | Matrix2x2f = Matrix< float, 2, 2 > |
using | Matrix2x3f = Matrix< float, 2, 3 > |
using | Matrix2x4f = Matrix< float, 2, 4 > |
using | Matrix3f = Matrix< float, 3, 3 > |
using | Matrix3x2f = Matrix< float, 3, 2 > |
using | Matrix3x3f = Matrix< float, 3, 3 > |
using | Matrix3x4f = Matrix< float, 3, 4 > |
using | Matrix4f = Matrix< float, 4, 4 > |
using | Matrix4x2f = Matrix< float, 4, 2 > |
using | Matrix4x3f = Matrix< float, 4, 3 > |
using | Matrix4x4f = Matrix< float, 4, 4 > |
using | MatrixXf = Matrix< float, Dynamic, Dynamic > |
using | Matrix2d = Matrix< double, 2, 2 > |
using | Matrix2x2d = Matrix< double, 2, 2 > |
using | Matrix2x3d = Matrix< double, 2, 3 > |
using | Matrix2x4d = Matrix< double, 2, 4 > |
using | Matrix3d = Matrix< double, 3, 3 > |
using | Matrix3x2d = Matrix< double, 3, 2 > |
using | Matrix3x3d = Matrix< double, 3, 3 > |
using | Matrix3x4d = Matrix< double, 3, 4 > |
using | Matrix4d = Matrix< double, 4, 4 > |
using | Matrix4x2d = Matrix< double, 4, 2 > |
using | Matrix4x3d = Matrix< double, 4, 3 > |
using | Matrix4x4d = Matrix< double, 4, 4 > |
using | MatrixXd = Matrix< double, Dynamic, Dynamic > |
using | Matrix2ld = Matrix< long double, 2, 2 > |
using | Matrix2x2ld = Matrix< long double, 2, 2 > |
using | Matrix2x3ld = Matrix< long double, 2, 3 > |
using | Matrix2x4ld = Matrix< long double, 2, 4 > |
using | Matrix3ld = Matrix< long double, 3, 3 > |
using | Matrix3x2ld = Matrix< long double, 3, 2 > |
using | Matrix3x3ld = Matrix< long double, 3, 3 > |
using | Matrix3x4ld = Matrix< long double, 3, 4 > |
using | Matrix4ld = Matrix< long double, 4, 4 > |
using | Matrix4x2ld = Matrix< long double, 4, 2 > |
using | Matrix4x3ld = Matrix< long double, 4, 3 > |
using | Matrix4x4ld = Matrix< long double, 4, 4 > |
using | MatrixXld = Matrix< long double, Dynamic, Dynamic > |
template<typename T , size_t N> | |
using | Vector = Matrix< T, N, 1 > |
using | Vector2f = Vector< float, 2 > |
using | Vector3f = Vector< float, 3 > |
using | Vector4f = Vector< float, 4 > |
using | VectorXf = Vector< float, Dynamic > |
using | Vector2d = Vector< double, 2 > |
using | Vector3d = Vector< double, 3 > |
using | Vector4d = Vector< double, 4 > |
using | VectorXd = Vector< double, Dynamic > |
using | Vector2ld = Vector< long double, 2 > |
using | Vector3ld = Vector< long double, 3 > |
using | Vector4ld = Vector< long double, 4 > |
using | VectorXld = Vector< long double, Dynamic > |
template<typename T , size_t N> | |
using | RowVector = Matrix< T, 1, N > |
using | RowVector2f = RowVector< float, 2 > |
using | RowVector3f = RowVector< float, 3 > |
using | RowVector4f = RowVector< float, 4 > |
using | RowVectorXf = RowVector< float, Dynamic > |
using | RowVector2d = RowVector< double, 2 > |
using | RowVector3d = RowVector< double, 3 > |
using | RowVector4d = RowVector< double, 4 > |
using | RowVectorXd = RowVector< double, Dynamic > |
using | RowVector2ld = RowVector< long double, 2 > |
using | RowVector3ld = RowVector< long double, 3 > |
using | RowVector4ld = RowVector< long double, 4 > |
using | RowVectorXld = RowVector< long double, Dynamic > |
Enumerations | |
enum | SVDType { FULL_SVD , THIN_SVD } |
Functions | |
template<size_t P, size_t Q, typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, P, Q, Flags > | SubMatrix (Matrix< T, M, N, Flags > A, size_t i=0, size_t j=0) |
Returns the PxQ submatrix located at (i,j) If i+P>M or j+Q > N, an exception is raised. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, Dynamic, Dynamic, Flags > | SubMatrix (Matrix< T, M, N, Flags > A, size_t nrows, size_t ncols, size_t i=0, size_t j=0) |
Returns the nrowsxncols submatrix located at (i,j) If i+nrows>M or j+ncols > N, an exception is raised. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T,(M==Dynamic?Dynamic:M-1), N, Flags > | RemoveRow (Matrix< T, M, N, Flags > A, size_t i) |
Returns the (M-1)xN submatrix formed by removing the ith row. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M,(N==Dynamic?Dynamic:N-1), Flags > | RemoveColumn (Matrix< T, M, N, Flags > A, size_t i) |
Returns the Mx(N-1) submatrix formed by removing the ith column. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T,(M==Dynamic?Dynamic:M-1),(N==Dynamic?Dynamic:N-1), Flags > | RemoveRowAndColumn (Matrix< T, M, N, Flags > A, size_t i, size_t j) |
Returns the (M-1)x(N-1) submatrix formed by removing the ith row and jth column. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, N, M, Flags > | Transpose (const Matrix< T, M, N, Flags > &A) |
Returns the NxM matrix \(B=A^\top\) defined by \(b_{ij}=a_{ji}\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, N, M, Flags > | ConjugateTranspose (Matrix< T, M, N, Flags > A) |
Returns the NxM matrix \(B=A^*\) defined by \(b_{ij}=\overline{a_{ji}}\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | RREF (Matrix< T, M, N, Flags > A) |
Computes A's reduced row echelon form. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Complex< T > | Trace (const Matrix< T, M, N, Flags > &A) |
Computes the trace of a square matrix \(\sum_{i=0}^{N-1}a_{ii}\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Complex< T > | Determinant (const Matrix< T, M, N, Flags > &A) |
Computes the determinant of a square matrix defined by \(\sum_{i=0}^{N-1}(-1)^ia_{0i}\det(A_{0i})\) where \(A_{0i}\) is the (N-1)x(N-1) matrix obtained by deleting the 0th row and ith column. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Complex< T > | Minor (const Matrix< T, M, N, Flags > &A, size_t i, size_t j) |
Computes the (i,j)-minor of a square matrix defined by \(\det(A_{ij})\) where \(A_{ij}\) is the (N-1)x(N-1) matrix obtained by deleting the ith row and jth column. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Complex< T > | Cofactor (const Matrix< T, M, N, Flags > &A, size_t i, size_t j) |
Computes the (i,j)-cofactor of a square matrix defined by \((-1)^{i+j}\det(A_{ij})\) where \(A_{ij}\) is the (N-1)x(N-1) matrix obtained by deleting the ith row and jth column. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Adjugate (const Matrix< T, M, N, Flags > &A) |
Computes the NxN adjugate B of a square matrix A defined by \(b_{ij}=c_{ji}\) where \(c_{ij}\) represents the (i,j)-cofactor of A. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Inverse (const Matrix< T, M, N, Flags > &A) |
Computes the NxN inverse \(A^{-1}=\frac{1}{\det A}Adj\) of a square matrix A where Adj is the adjugate of A. More... | |
template<typename T > | |
bool | IsReal (const Complex< T > &z) |
Checks if a complex number \(z=a+bi\) is real. More... | |
template<typename T > | |
T | Abs (T x) |
Takes a real number \(x\) and computes \(|x|\). More... | |
template<typename T > | |
T | Abs (const Complex< T > &z) |
Takes a complex number \(z=a+bi\) and computes \(|z|=\sqrt{a^2+b^2}\). More... | |
template<typename T > | |
T | Sign (T x) |
Takes a real number \(x\) and computes \(sgn(x)\). More... | |
template<typename T > | |
Complex< T > | Sign (const Complex< T > &z) |
Takes a complex number \(z\) and computes \(sgn(z)\). More... | |
template<typename T > | |
T | Arg (const Complex< T > &z) |
Takes a complex number \(z=a+bi\) and computes \(arg(z)=atan2(b,a)\). More... | |
template<typename T > | |
Complex< T > | Conjugate (const Complex< T > &z) |
Takes a complex number \(z=a+bi\) and computes it's conjugate \(\bar{z}=a-bi\). More... | |
template<typename T > | |
Complex< T > | Sqrt (T x) |
Computes the square root of a real number \(x\). More... | |
template<typename T > | |
Complex< T > | Sqrt (const Complex< T > &z) |
Takes a complex number \(z=a+bi\) and computes it's principal square root \(\sqrt{z}=\gamma+\delta i\), where \(\gamma=\sqrt{\frac{a+|z|}{2}}\) and \(\delta=(sgn b)\sqrt{\frac{-a+|z|}{2}}\). More... | |
template<typename T > | |
T | Exp (T x) |
Takes a real number \(x\) and computes \(e^x\). More... | |
template<typename T > | |
Complex< T > | Exp (const Complex< T > &z) |
Takes a complex number \(z\) and computes \(e^z\). More... | |
template<typename T > | |
T | Log (T x) |
Computes the natural log of a real number. More... | |
template<typename T > | |
Complex< T > | Log (const Complex< T > &z) |
Computes the principal natural log of a complex number \(z\). More... | |
template<typename T > | |
T | Log (T x, T base) |
Computes the \(\log_{base}x\). More... | |
template<typename T > | |
Complex< T > | Log (const Complex< T > &z, const Complex< T > &base) |
Computes the \(\log_{base}z\). More... | |
template<typename T > | |
Complex< T > | Log (const Complex< T > &z, T base) |
Computes the \(\log_{base}z\). More... | |
template<typename T > | |
Complex< T > | Log (T x, const Complex< T > &base) |
Computes the \(\log_{base}x\). More... | |
template<typename T > | |
T | Pow (T x, T y) |
Computes the real number \(x^y\). More... | |
template<typename T > | |
Complex< T > | Pow (const Complex< T > &z, const Complex< T > &w) |
Computes the complex number \(z^w\). More... | |
template<typename T > | |
T | Mod (T x, T y) |
Computes the floating-point modulus \(x\bmod y\). More... | |
template<typename T > | |
Complex< T > | Mod (const Complex< T > &z, T y) |
Returns the complex number \((a\bmod y)+(b\bmod y)i\) where \(z=a+bi\). More... | |
template<typename T > | |
Complex< T > | Mod (const Complex< T > &z, const Complex< T > &w) |
Returns the complex number \((a\bmod c)+(b\bmod d)i\) where \(z=a+bi\) and \(w=b+di\). More... | |
template<typename T > | |
T | Sin (T x) |
Returns the real number \(\sin x\). More... | |
template<typename T > | |
Complex< T > | Sin (const Complex< T > &z) |
Returns the complex number \(\sin z=\frac{e^{iz}-e^{-iz}}{2i}\). More... | |
template<typename T > | |
T | Cos (T x) |
Returns the real number \(\cos x\). More... | |
template<typename T > | |
Complex< T > | Cos (const Complex< T > &z) |
Returns the complex number \(\cos z=\frac{e^{iz}+e^{-iz}}{2}\). More... | |
template<typename T > | |
T | Tan (T x) |
Returns the real number \(\tan x\). More... | |
template<typename T > | |
Complex< T > | Tan (const Complex< T > &z) |
Returns the complex number \(\tan z=\frac{1}{i}\left(\frac{e^{2iz}-1}{e^{2iz}+1}\right)\). More... | |
template<typename T > | |
T | Csc (T x) |
Returns the real number \(\csc x=1/\sin x\). More... | |
template<typename T > | |
Complex< T > | Csc (const Complex< T > &z) |
Returns the complex number \(\csc z=\frac{2i}{e^{iz}-e^{-iz}}\). More... | |
template<typename T > | |
T | Sec (T x) |
Returns the real number \(\sec x=1/\cos x\). More... | |
template<typename T > | |
Complex< T > | Sec (const Complex< T > &z) |
Returns the complex number \(\sec z=\frac{2}{e^{iz}+e^{-iz}}\). More... | |
template<typename T > | |
T | Cot (T x) |
Returns the real number \(\cot x=1/\tan x\). More... | |
template<typename T > | |
Complex< T > | Cot (const Complex< T > &z) |
Returns the complex number \(\cot z=i\left(\frac{e^{2iz}+1}{e^{2iz}-1}\right)\). More... | |
template<typename T > | |
T | ASin (T x) |
Returns the real number \(\sin^{-1}x\). More... | |
template<typename T > | |
Complex< T > | ASin (const Complex< T > &z) |
Returns the complex number \(\sin^{-1}z=\frac{1}{i}\log\left(iz+|1-z^2|^{1/2}e^{\frac{i}{2}arg(1-z^2)}\right)\). More... | |
template<typename T > | |
T | ACos (T x) |
Returns the real number \(\cos^{-1}x\). More... | |
template<typename T > | |
Complex< T > | ACos (const Complex< T > &z) |
Returns the complex number \(\cos^{-1}z=\frac{1}{i}\log\left(z+i|1-z^2|^{1/2}e^{\frac{i}{2}arg(1-z^2)}\right)\). More... | |
template<typename T > | |
T | ATan (T x) |
Returns the real number \(\tan^{-1}x\). More... | |
template<typename T > | |
Complex< T > | ATan (const Complex< T > &z) |
Returns the complex number \(\tan^{-1}z=\frac{1}{2i}\log\left(\frac{i-z}{i+z}\right)\). More... | |
template<typename T > | |
T | ACsc (T x) |
Returns the real number \(\csc^{-1}x=\sin^{-1}(1/x)\). More... | |
template<typename T > | |
Complex< T > | ACsc (const Complex< T > &z) |
Returns the complex number \(\csc^{-1}z=\sin^{-1}(1/z)\). More... | |
template<typename T > | |
T | ASec (T x) |
Returns the real number \(\sec^{-1}x=\cos^{-1}(1/x)\). More... | |
template<typename T > | |
Complex< T > | ASec (const Complex< T > &z) |
Returns the complex number \(\sec^{-1}z=\cos^{-1}(1/z)\). More... | |
template<typename T > | |
T | ACot (T x) |
Returns the real number \(\cot^{-1}x=\tan^{-1}(1/x)\). More... | |
template<typename T > | |
Complex< T > | ACot (const Complex< T > &z) |
Returns the complex number \(\cot^{-1}z=\frac{1}{2i}\log\left(\frac{z+i}{z-i}\right)\). More... | |
template<typename T > | |
T | Sinh (T x) |
Returns the real number \(\sinh x\). More... | |
template<typename T > | |
Complex< T > | Sinh (const Complex< T > &z) |
Returns the complex number \(\sinh z=\frac{e^z-e^{-z}}{2}\). More... | |
template<typename T > | |
T | Cosh (T x) |
Returns the real number \(\cosh x\). More... | |
template<typename T > | |
Complex< T > | Cosh (const Complex< T > &z) |
Returns the complex number \(\cosh z=\frac{e^z+e^{-z}}{2}\). More... | |
template<typename T > | |
T | Tanh (T x) |
Returns the real number \(\tanh x\). More... | |
template<typename T > | |
Complex< T > | Tanh (const Complex< T > &z) |
Returns the complex number \(\tanh z=\frac{e^z-e^{-z}}{e^z+e^{-z}}\). More... | |
template<typename T > | |
T | Csch (T x) |
Returns the real number \(csch x = 1/\sinh x\). More... | |
template<typename T > | |
Complex< T > | Csch (const Complex< T > &z) |
Returns the complex number \(csch z=\frac{2}{e^z-e^{-z}}\). More... | |
template<typename T > | |
T | Sech (T x) |
Returns the real number \(sech x = 1/\cosh x\). More... | |
template<typename T > | |
Complex< T > | Sech (const Complex< T > &z) |
Returns the complex number \(sech z=\frac{2}{e^z+e^{-z}}\). More... | |
template<typename T > | |
T | Coth (T x) |
Returns the real number \(\coth x = 1/\tanh x\). More... | |
template<typename T > | |
Complex< T > | Coth (const Complex< T > &z) |
Returns the complex number \(\coth z=\frac{e^z+e^{-z}}{e^z-e^{-z}}\). More... | |
template<typename T > | |
T | ASinh (T x) |
Returns the real number \(\sinh^{-1} x\). More... | |
template<typename T > | |
Complex< T > | ASinh (const Complex< T > &z) |
Returns the complex number \(\sinh^{-1} z=\log\left(z+|1+z^2|^{1/2}e^{\frac{i}{2}arg(1+z^2)}\right)\). More... | |
template<typename T > | |
T | ACosh (T x) |
Returns the real number \(\cosh^{-1} x\). More... | |
template<typename T > | |
Complex< T > | ACosh (const Complex< T > &z) |
Returns the complex number \(\cosh^{-1} z=\log\left(z+|z^2-1|^{1/2}e^{\frac{i}{2}arg(z^2-1)}\right)\). More... | |
template<typename T > | |
T | ATanh (T x) |
Returns the real number \(\tanh^{-1} x\). More... | |
template<typename T > | |
Complex< T > | ATanh (const Complex< T > &z) |
Returns the complex number \(\tanh^{-1} z=\frac{1}{2}\log\left(\frac{1+z}{1-z}\right)\). More... | |
template<typename T > | |
T | ACsch (T x) |
Returns the real number \(csch^{-1} x=\sinh^{-1}(1/x)\). More... | |
template<typename T > | |
Complex< T > | ACsch (const Complex< T > &z) |
Returns the complex number \(csch^{-1} z=\sinh^{-1}(1/z)\). More... | |
template<typename T > | |
T | ASech (T x) |
Returns the real number \(sech^{-1} x=\cosh^{-1}(1/x)\). More... | |
template<typename T > | |
Complex< T > | ASech (const Complex< T > &z) |
Returns the complex number \(sech^{-1} z=\cosh^{-1}(1/z)\). More... | |
template<typename T > | |
T | ACoth (T x) |
Returns the real number \(\coth^{-1} x=\tanh^{-1}(1/x)\). More... | |
template<typename T > | |
Complex< T > | ACoth (const Complex< T > &z) |
Returns the complex number \(\coth^{-1} z=\frac{1}{2}\log\left(\frac{z+1}{z-1}\right)\). More... | |
template<typename T > | |
T | Ceil (T x) |
Returns the real number \(\lceil x\rceil\). More... | |
template<typename T > | |
Complex< T > | Ceil (const Complex< T > &z) |
Returns the complex number \(\lceil a\rceil+\lceil b\rceil i\) where \(z=a+bi\). More... | |
template<typename T > | |
T | Floor (T x) |
Returns the real number \(\lfloor x\rfloor\). More... | |
template<typename T > | |
Complex< T > | Floor (const Complex< T > &z) |
Returns the complex number \(\lfloor a\rfloor+\lfloor b\rfloor i\) where \(z=a+bi\). More... | |
template<typename T > | |
T | Round (T x) |
Rounds \(x\) to the nearest integer. More... | |
template<typename T > | |
Complex< T > | Round (const Complex< T > &z) |
Rounds the real and imaginary parts of \(z\) to the nearest integer. More... | |
template<typename T , size_t N, unsigned int Flags = 0> | |
SquareMatrix< T, N, Flags > | Identity () |
Creates the NxN Identity matrix. More... | |
template<typename T , unsigned int Flags = 0> | |
SquareMatrix< T, Dynamic, Flags > | Identity (size_t n) |
Dynamically creates the nxn Identity matrix. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags = 0> | |
Matrix< T, M, N, Flags > | Zero () |
Creates the MxN all zeros matrix. More... | |
template<typename T , unsigned int Flags = 0> | |
Matrix< T, Dynamic, Dynamic, Flags > | Zero (size_t nrows, size_t ncols) |
Dynamically creates the nrowsxncols all zeros matrix. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags = 0> | |
Matrix< T, M, N, Flags > | One () |
Creates the MxN all ones matrix. More... | |
template<typename T , unsigned int Flags = 0> | |
Matrix< T, Dynamic, Dynamic, Flags > | One (size_t nrows, size_t ncols) |
Dynamically creates the nrowsxncols all ones matrix. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags = 0> | |
Matrix< T, M, N, Flags > | Constant (Complex< T > z) |
Creates an MxN matrix with every entry set to z. More... | |
template<typename T , unsigned int Flags = 0> | |
Matrix< T, Dynamic, Dynamic, Flags > | Constant (size_t nrows, size_t ncols, Complex< T > z) |
Dynamically creates an nrowsxncols matrix with every entry set to v. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags = 0> | |
std::enable_if<(M >0 &&N >0), Matrix< T, M, N, Flags > >::type | Basis (size_t i, size_t j) |
Creates an MxN basis matrix \(A\) where all entries are set to 0 except \(a_{ij}=1\). More... | |
template<typename T , unsigned int Flags = 0> | |
Matrix< T, Dynamic, Dynamic, Flags > | Basis (size_t nrows, size_t ncols, size_t i, size_t j) |
Dynamically creates an nrowsxncols basis matrix \(A\) where all entries are set to 0 except \(a_{ij}=1\). More... | |
void | SeedRandom (unsigned int seed) |
Seeds the random number generator used in Random. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags = 0> | |
Matrix< T, M, N, Flags > | Random (Complex< T > min=Complex< T >(0.0), Complex< T > max=Complex< T >(1.0)) |
Creates an MxN random matrix \(A\) where all entries are randomly determined between min and max. More... | |
template<typename T , unsigned int Flags = 0> | |
Matrix< T, Dynamic, Dynamic, Flags > | Random (size_t nrows, size_t ncols, Complex< T > min=Complex< T >(0.0), Complex< T > max=Complex< T >(1.0)) |
Dynamically creates an nrowsxncols random matrix \(A\) where all entries are randomly determined between min and max. More... | |
template<typename T , size_t N, unsigned int Flags = 0> | |
SquareMatrix< T, N, Flags > | Householder (Vector< T, N > v) |
Creates an NxN Householder transformation \(H\) defined by \(H = I - 2vv^*.\). More... | |
template<typename T , size_t N, unsigned int Flags = 0> | |
SquareMatrix< T, N, Flags > | Householder (const Vector< T, N > &x, size_t k) |
Creates an NxN Householder transformation \(H\) such that \(Hx\) eliminates the last k elements. More... | |
template<typename T , size_t M1, size_t N1, unsigned int Flags1, size_t M2, size_t N2, unsigned int Flags2> | |
std::enable_if<(M1==M2||M1==Dynamic||M2==Dynamic), Matrix< T, M1,(N1==Dynamic||N2==Dynamic?Dynamic:N1+N2), Flags1 > >::type | Augmented (const Matrix< T, M1, N1, Flags1 > &left, const Matrix< T, M2, N2, Flags2 > &right) |
Creates the M1x(N1+N2) augmented matrix. More... | |
template<typename T , size_t M1, size_t N1, unsigned int Flags1, size_t M2, size_t N2, unsigned int Flags2> | |
std::enable_if<(N1==N2||N1==Dynamic||N2==Dynamic), Matrix< T,(M1==Dynamic||M2==Dynamic?Dynamic:M1+M2), N1, Flags1 > >::type | RowAugmented (const Matrix< T, M1, N1, Flags1 > &top, const Matrix< T, M2, N2, Flags2 > &bottom) |
Creates the (M1+M2)xN1 row augmented matrix. More... | |
template<typename T , size_t M1, size_t N1, unsigned int Flags1, size_t M2, size_t N2, unsigned int Flags2, size_t M3, size_t N3, unsigned int Flags3, size_t M4, size_t N4, unsigned int Flags4> | |
std::enable_if<((M1+M3==M2+M4||M1==Dynamic||M2==Dynamic||M3==Dynamic||M4==Dynamic)&&(N1+N2==N3+N4||N1==Dynamic||N2==Dynamic||N3==Dynamic||N4==Dynamic)), Matrix< T,(M1==Dynamic||M2==Dynamic||M3==Dynamic||M4==Dynamic?Dynamic:M1+M3),(N1==Dynamic||N2==Dynamic||N3==Dynamic||N4==Dynamic?Dynamic:N1+N2), Flags1 > >::type | Block (const Matrix< T, M1, N1, Flags1 > &tl, const Matrix< T, M2, N2, Flags2 > &tr, const Matrix< T, M3, N3, Flags3 > &bl, const Matrix< T, M4, N4, Flags4 > &br) |
Creates the (M1+M3)x(N1+N2) block matrix. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags, size_t P, size_t Q> | |
std::enable_if<((M==P||M==Dynamic||P==Dynamic)&&(N==Q||N==Dynamic||Q==Dynamic)), Matrix< T,(M==Dynamic?Dynamic:M+1),(N==Dynamic?Dynamic:N+1), Flags > >::type | Block (const Matrix< T, M, N, Flags > &tl, const Vector< T, P > &tr, const RowVector< T, Q > &bl, Complex< T > br) |
Creates the (M+1)x(N+1) block matrix. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags, size_t P, size_t Q> | |
std::enable_if<((M==P||M==Dynamic||P==Dynamic)&&(N==Q||N==Dynamic||Q==Dynamic)), Matrix< T,(M==Dynamic?Dynamic:M+1),(N==Dynamic?Dynamic:N+1), Flags > >::type | Block (Complex< T > tl, const RowVector< T, Q > &tr, const Vector< T, P > &bl, const Matrix< T, M, N, Flags > &br) |
Creates the (M+1)x(N+1) block matrix. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags1, size_t P, size_t Q, unsigned int Flags2> | |
Matrix< T, M *P, Q *N, Flags1 > | Kronecker (const Matrix< T, M, N, Flags1 > &A, const Matrix< T, P, Q, Flags2 > &B) |
Computes the (MP)x(NQ) block matrix. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags1, size_t P, size_t Q, unsigned int Flags2> | |
SquareMatrix< T, N *Q, Flags1 > | KroneckerSum (const Matrix< T, M, N, Flags1 > &A, const Matrix< T, P, Q, Flags2 > &B) |
Computes the (NQ)x(NQ) Kronecker sum defined by. More... | |
template<typename T , size_t M1, size_t N1, unsigned int Flags1, size_t M2, size_t N2, unsigned int Flags2> | |
Matrix< T,(M1==Dynamic||M2==Dynamic?Dynamic:M1+M2),(N1==Dynamic||N2==Dynamic?Dynamic:N1+N2), Flags1 > | Diag (const Matrix< T, M1, N1, Flags1 > &A, const Matrix< T, M2, N2, Flags2 > &B) |
Computes the (M1+M2)x(N1+N2) block diagonal matrix. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T,(M==Dynamic?Dynamic:M+1),(N==Dynamic?Dynamic:N+1), Flags > | Diag (const Matrix< T, M, N, Flags > &A, Complex< T > z) |
Computes the (M+1)x(N+1) block diagonal matrix. More... | |
template<typename T , unsigned int Flags = 0> | |
Matrix< T, 2, 2, Flags > | Diag (Complex< T > z, Complex< T > w) |
Computes the 2x2 diagonal matrix. More... | |
template<typename T , size_t M1, size_t N1, unsigned int Flags1, size_t M2, size_t N2, unsigned int Flags2, typename... Ts> | |
Matrix< T, Dynamic, Dynamic, Flags1 > | Diag (const Matrix< T, M1, N1, Flags1 > &a, const Matrix< T, M2, N2, Flags2 > &b, Ts &&... ts) |
template<typename T , typename... Ts> | |
Matrix< T, Dynamic, Dynamic > | Diag (Complex< T > a, Complex< T > b, Ts &&... ts) |
template<typename T , unsigned int Flags = 0> | |
SquareMatrix< T, Dynamic > | Diag (std::vector< Complex< T >> v) |
Dynamically computes the NxN diagonal matrix. More... | |
template<typename T , unsigned int Flags> | |
Matrix< T, Dynamic, Dynamic, Flags > | Diag (std::vector< Matrix< T, Dynamic, Dynamic, Flags >> As) |
Computes the PxQ diagonal matrix, where \(P=\sum_{i=0}^{N-1}NumRows(As[i])\) and \(Q=\sum_{i=0}^{N-1}NumColumns(As[i])\),. More... | |
template<typename T , size_t N, unsigned int Flags = 0> | |
SquareMatrix< T, N > | Diag (Vector< T, N > v) |
Computes the NxN diagonal matrix. More... | |
template<typename T , size_t N, unsigned int Flags = 0> | |
SquareMatrix< T, N > | Diag (RowVector< T, N > v) |
Computes the NxN diagonal matrix. More... | |
template<typename T , size_t N, unsigned int Flags = 0> | |
std::enable_if<(N >1||N==Dynamic), SquareMatrix< T,(N==Dynamic?Dynamic:N-1), Flags > >::type | Companion (const Vector< T, N > &c) |
Computes the (N-1)x(N-1) companion matrix. More... | |
template<typename T , size_t N, unsigned int Flags = 0> | |
std::enable_if<(N >1||N==Dynamic), SquareMatrix< T,(N==Dynamic?Dynamic:N-1), Flags > >::type | Companion (const RowVector< T, N > &c) |
Computes the (N-1)x(N-1) companion matrix. More... | |
template<typename T , size_t N, unsigned int Flags = 0> | |
SquareMatrix< T,(N==Dynamic?Dynamic:N+1), Flags > | Translation (const Vector< T, N > &t) |
Computes the (N+1)x(N+1) translation matrix T such that. More... | |
template<typename T , size_t N, unsigned int Flags = 0> | |
SquareMatrix< T, N, Flags > | Scaling (const Vector< T, N > &s) |
Computes the NxN scaling matrix S such that. More... | |
template<typename T , size_t N = 4, unsigned int Flags = 0> | |
std::enable_if<(N==3||N==4), SquareMatrix< T, N, Flags > >::type | RotationX (T theta) |
Computes the 4x4 rotatation matrix. More... | |
template<typename T , size_t N = 4, unsigned int Flags = 0> | |
std::enable_if<(N==3||N==4), SquareMatrix< T, N, Flags > >::type | RotationY (T theta) |
Computes the 4x4 rotatation matrix. More... | |
template<typename T , size_t N, unsigned int Flags = 0> | |
std::enable_if<(N==3||N==4), SquareMatrix< T, N, Flags > >::type | RotationZ (T theta) |
Computes the 4x4 rotatation matrix. More... | |
template<size_t P, typename T , size_t N = 4, unsigned int Flags = 0> | |
std::enable_if<((N==3||N==4)&&(P==3||P==Dynamic)), SquareMatrix< T, N, Flags > >::type | Rotation (T theta, Vector< T, P > axis) |
Computes the 4x4 rotatation matrix about an axis. More... | |
template<size_t P, typename T , size_t N = 4, unsigned int Flags = 0> | |
std::enable_if<((N==3||N==4)&&(P==4||P==Dynamic)), SquareMatrix< T, N, Flags > >::type | Rotation (Vector< T, P > q) |
Computes the 4x4 rotatation matrix given a quaternion q. More... | |
template<typename T , unsigned int Flags = 0> | |
SquareMatrix< T, 4, Flags > | Orthographic (T left, T right, T bottom, T top, T near, T far) |
Computes the 4x4 orthographic projection matrix. More... | |
template<typename T , unsigned int Flags = 0> | |
SquareMatrix< T, 4, Flags > | Perspective (T fov, T aspect, T near, T far) |
Computes the 4x4 perspective projection matrix. More... | |
template<typename T , size_t N1, size_t N2, size_t N3, size_t N4, unsigned int Flags = 0> | |
std::enable_if<((N1==3||N1==Dynamic)||(N2==3||N2==Dynamic)||(N3==3||N3==Dynamic)||(N4==3||N4==Dynamic)), SquareMatrix< T, 4, Flags > >::type | LookAt (Vector< T, N1 > right, Vector< T, N2 > up, Vector< T, N3 > dir, Vector< T, N4 > eye) |
Computes the 4x4 look at matrix. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags, size_t P> | |
std::enable_if<(P==N||P==Dynamic||N==Dynamic), Eigenpair< T, P > >::type | PowerIteration (const Matrix< T, M, N, Flags > &A, Vector< T, P > b0, unsigned int max_iterations) |
Performs power iteration on A. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags, size_t P> | |
std::enable_if<(P==N||P==Dynamic||N==Dynamic), Vector< T, P > >::type | InverseIteration (const Matrix< T, M, N, Flags > &A, Vector< T, P > b0, Complex< T > mu, unsigned int max_iterations) |
Performs inverse iteration on A with guess mu. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Vector< T, N > | WielandtDeflationAlgorithm (const Matrix< T, M, N, Flags > &A, unsigned int max_iterations=100) |
Performs a combination of deflation and power iteration to get every eigenpair of A Since power iteration returns the largest eigenvalue, if we want to compute the eigenvalues we need to use deflation. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Vector< T, N > | Eigenvalues (const Matrix< T, M, N, Flags > &A) |
Calculates all eigenvalues of A. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
std::vector< Eigenpair< T, N > > | Eigen (const Matrix< T, M, N, Flags > &A) |
Calculates all eigenpairs of A. More... | |
template<typename T , size_t N> | |
void | VietaFormulaHelper (size_t data[], size_t start, size_t end, size_t index, size_t k, Complex< T > &sum, const Vector< T, N > &roots) |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Vector< T,(N==Dynamic?Dynamic:N+1)> | CharPoly (const Matrix< T, M, N, Flags > &A) |
Computes the characteristic polynomial. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags, size_t P, size_t Q, unsigned int Flags2> | |
Matrix< T, M, N, Flags > | EntrywiseProduct (const Matrix< T, M, N, Flags > &A, const Matrix< T, P, Q, Flags2 > &B) |
Computes the matrix \(C\) defined by \(c_{ij}=a_{ij}b_{ij}\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags, size_t P, size_t Q, unsigned int Flags2> | |
Matrix< T, M, N, Flags > | EntrywiseDivision (const Matrix< T, M, N, Flags > &A, const Matrix< T, P, Q, Flags2 > &B) |
Computes the matrix \(C\) defined by \(c_{ij}=a_{ij}/b_{ij}\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
T | Norm (const Matrix< T, M, N, Flags > &A, size_t p=2) |
If \(A\) is a vector, it computes the entrywise vector p-norm \(\left(\sum_{i=0}^{N-1}|a_i|^p\right)^{1/p}\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
T | EntrywiseNorm (const Matrix< T, M, N, Flags > &A, size_t p=2) |
Computes the entrywise p-norm \(\left(\sum_{j=0}^{N-1}\sum_{i=0}^{M-1}|a_{ij}|^p\right)^{1/p}\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
T | FrobeniusNorm (const Matrix< T, M, N, Flags > &A) |
Computes the Frobenius norm. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
T | MaxNorm (const Matrix< T, M, N, Flags > &A) |
Computes the max norm \(\max_{ij}|a_{ij}|\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
T | InfinityNorm (const Matrix< T, M, N, Flags > &A) |
Computes the infinity norm \(\max_{i=0,...M-1}\sum_{j=0}^{N-1}|a_{ij}|\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
bool | IsReal (const Matrix< T, M, N, Flags > &A) |
Determines if a matrix is real or complex. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Abs (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix \(B\) defined by \(b_{ij}=|a_{ij}|\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Sign (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix \(B\) defined by \(b_{ij}=sgn(a_{ij})\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Arg (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix \(B\) defined by \(b_{ij}=arg(a_{ij})\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Conjugate (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix \(B\) defined by \(b_{ij}=\overline{a_{ij}}\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Sqrt (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix \(B\) defined by \(b_{ij}=\sqrt{a_{ij}}\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Exp (Matrix< T, M, N, Flags > A) |
If \(A\) is not square, it computes the MxN Matrix \(B\) defined by \(b_{ij}=e^{a_{ij}}\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Log (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix \(B\) defined by \(b_{ij}=\log a_{ij}\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Log (Matrix< T, M, N, Flags > A, T base) |
Computes the MxN Matrix \(B\) defined by \(b_{ij}=\log_{base} a_{ij}\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Log (Matrix< T, M, N, Flags > A, Complex< T > base) |
Computes the MxN Matrix \(B\) defined by \(b_{ij}=\log_{base} a_{ij}\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Pow (Matrix< T, M, N, Flags > A, Complex< T > power) |
If \(A\) is not square, it computes the MxN Matrix \(B\) defined by \(b_{ij}=a_{ij}^{power}\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags, typename U > | |
Matrix< T, M, N, Flags > | Pow (const Matrix< T, M, N, Flags > &A, U power) |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Mod (Matrix< T, M, N, Flags > A, Complex< T > z) |
Computes the MxN Matrix \(B\) defined by \(b_{ij}=a_{ij}\bmod z\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags, typename U > | |
Matrix< T, M, N, Flags > | Mod (Matrix< T, M, N, Flags > A, U y) |
Computes the MxN Matrix \(B\) defined by \(b_{ij}=a_{ij}\bmod y\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Sin (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\sin a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Cos (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\cos a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Tan (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\tan a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Csc (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\csc a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Sec (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\sec a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Cot (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\cot a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | ASin (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\sin^{-1} a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | ACos (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\cos^{-1} a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | ATan (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\tan^{-1} a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | ACsc (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\csc^{-1} a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | ASec (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\sec^{-1} a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | ACot (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\cot^{-1} a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Sinh (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\sinh a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Cosh (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\cosh a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Tanh (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\tanh a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Csch (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=csch a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Sech (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=sech a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Coth (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\coth a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | ASinh (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\sinh^{-1} a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | ACosh (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\cosh^{-1} a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | ATanh (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\tanh^{-1} a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | ACsch (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=csch^{-1} a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | ASech (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=sech^{-1} a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | ACoth (Matrix< T, M, N, Flags > A) |
Computes the MxN Matrix$B$ defined by $b_{ij}=\coth^{-1} a_{ij}$. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
std::vector< Vector< T, N > > | NullSpace (const Matrix< T, M, N, Flags > &A) |
Computes a basis for the null space of A. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
unsigned int | Nullity (const Matrix< T, M, N, Flags > &A) |
Computes the dimension of the A's null space. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
std::vector< Vector< T, N > > | ColumnSpace (const Matrix< T, M, N, Flags > &A) |
Computes a basis for the column space of A. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
unsigned int | Rank (const Matrix< T, M, N, Flags > &A) |
Computes the dimension of the A's column space. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags, size_t P> | |
std::enable_if<(M==P||P==Dynamic||M==Dynamic), Vector< T, N > >::type | Solve (const Matrix< T, M, N, Flags > &A, const Vector< T, P > &b) |
Solves the matrix equation Ax=b for x. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags, size_t P> | |
std::enable_if<(M==P||P==Dynamic||M==Dynamic), RowVector< T, M > >::type | Solve (const Matrix< T, M, N, Flags > &A, const RowVector< T, P > &b) |
Solves the matrix equation xA=b for x. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
bool | IsVector (const Matrix< T, M, N, Flags > &A) |
Checks if a matrix is a row or column vector. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
bool | IsSquare (Matrix< T, M, N, Flags > A) |
Checks if the matrix is squre. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
bool | IsUpperTriangular (const Matrix< T, M, N, Flags > &A) |
Checks if A is upper triangular form. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
bool | IsLowerTriangular (const Matrix< T, M, N, Flags > &A) |
Checks if A is lower triangular form. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
bool | IsTriangular (const Matrix< T, M, N, Flags > &A) |
Checks if A is lower triangular form or upper triangular form. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
bool | IsDiagonal (const Matrix< T, M, N, Flags > &A) |
Checks if A is a diagonal matrix. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
bool | IsIdentity (const Matrix< T, M, N, Flags > &A) |
Checks if A is the identity matrix. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
bool | IsCompanion (const Matrix< T, M, N, Flags > &A) |
Checks if A is a companion matrix. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
bool | IsSymmetric (const Matrix< T, M, N, Flags > &A) |
Checks if a matrix is symmetric. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
bool | IsHermitian (const Matrix< T, M, N, Flags > &A) |
Checks if a matrix is Hermitian. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
bool | IsUpperHessenberg (const Matrix< T, M, N, Flags > &A) |
Checks if a matrix is upper Hessenberg. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
bool | IsLowerHessenberg (const Matrix< T, M, N, Flags > &A) |
Checks if a matrix is lower Hessenberg. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
bool | IsHessenberg (const Matrix< T, M, N, Flags > &a) |
Checks if a matrix is Hessenberg. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
bool | IsTridiagonal (const Matrix< T, M, N, Flags > &a) |
Checks if a matrix is Tridiagonal. More... | |
template<size_t P, typename T , size_t N> | |
Vector< T, P > | SubVector (const Vector< T, N > &v, size_t off=0) |
Constructs a subvector of a column vector. More... | |
template<typename T , size_t N> | |
Vector< T, Dynamic > | SubVector (const Vector< T, N > &v, size_t size, size_t off=0) |
Constructs a subvector of a column vector. More... | |
template<size_t P, typename T , size_t N> | |
RowVector< T, P > | SubVector (const RowVector< T, N > &v, size_t off=0) |
Constructs a subvector of a row vector. More... | |
template<typename T , size_t N> | |
RowVector< T, Dynamic > | SubVector (const RowVector< T, N > &v, size_t size, size_t off=0) |
Constructs a subvector of a row vector. More... | |
template<size_t P, typename T > | |
Vector< T, P > | SubVector (const Vector< T, 1 > &v, size_t off=0) |
Handles subvector in the size 1 case. More... | |
template<typename T > | |
Vector< T, Dynamic > | SubVector (const Vector< T, 1 > &v, size_t size, size_t off=0) |
Handles subvector in the size 1 case. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags, size_t P, size_t Q, unsigned int Flags2> | |
Complex< T > | Dot (const Matrix< T, M, N, Flags > &a, const Matrix< T, P, Q, Flags2 > &b) |
Computes the dot product of two vectors a and b both of size N, \(\sum{i=0}^{N-1}\overline{a_i}b_i\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | Normalize (Matrix< T, M, N, Flags > v) |
Normalize a vector, \(v=\frac{v}{\|v\|}\). More... | |
template<typename T , size_t M, size_t N, unsigned int Flags, size_t P, size_t Q, unsigned int Flags2> | |
Matrix< T, M, N, Flags > | Cross (const Matrix< T, M, N, Flags > &a, const Matrix< T, P, Q, Flags2 > &b) |
Computes the cross product of two vectors a and b both of length 3. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags, size_t P, size_t Q, unsigned int Flags2> | |
Matrix< T, P, Q, Flags2 > | Proj (const Matrix< T, M, N, Flags > &v, const Matrix< T, P, Q, Flags2 > &onto) |
Computes the vector projection \(\proj_{onto}v = \frac{Dot(onto,v)}{Dot(onto,onto)}onto\). More... | |
template<typename T , size_t N> | |
std::vector< Vector< T, N > > | GramSchmidt (const std::vector< Vector< T, N >> &v) |
Performs Gram-Schmidt on a list of column vectors. More... | |
template<typename T , size_t N> | |
std::vector< RowVector< T, N > > | GramSchmidt (const std::vector< RowVector< T, N >> &v) |
Performs Gram-Schmidt on a list of row vectors. More... | |
template<typename T , size_t M, size_t N, unsigned int Flags> | |
Matrix< T, M, N, Flags > | GramSchmidt (Matrix< T, M, N, Flags > A) |
Performs Gram-Schmidt on the columns of A. More... | |
template<typename T > | |
std::vector< Vector< T, 1 > > | GramSchmidt (const std::vector< Vector< T, 1 >> &v) |
Performs Gram-Schmidt on a list of length 1 vectors. More... | |
Variables | |
std::mt19937 | random_number_generator |
double | Tol = 0.00001 |
const unsigned int | Dynamic = 0 |
const unsigned int | RowMajor = 0x0000 |
const unsigned int | ColumnMajor = 0x0001 |
using Linear::Complexd = typedef Complex<double> |
using Linear::Complexf = typedef Complex<float> |
using Linear::Complexi = typedef Complex<int> |
using Linear::Matrix2d = typedef Matrix<double,2,2> |
using Linear::Matrix2f = typedef Matrix<float,2,2> |
using Linear::Matrix2ld = typedef Matrix<long double,2,2> |
using Linear::Matrix2x2d = typedef Matrix<double,2,2> |
using Linear::Matrix2x2f = typedef Matrix<float,2,2> |
using Linear::Matrix2x2ld = typedef Matrix<long double,2,2> |
using Linear::Matrix2x3d = typedef Matrix<double,2,3> |
using Linear::Matrix2x3f = typedef Matrix<float,2,3> |
using Linear::Matrix2x3ld = typedef Matrix<long double,2,3> |
using Linear::Matrix2x4d = typedef Matrix<double,2,4> |
using Linear::Matrix2x4f = typedef Matrix<float,2,4> |
using Linear::Matrix2x4ld = typedef Matrix<long double,2,4> |
using Linear::Matrix3d = typedef Matrix<double,3,3> |
using Linear::Matrix3f = typedef Matrix<float,3,3> |
using Linear::Matrix3ld = typedef Matrix<long double,3,3> |
using Linear::Matrix3x2d = typedef Matrix<double,3,2> |
using Linear::Matrix3x2f = typedef Matrix<float,3,2> |
using Linear::Matrix3x2ld = typedef Matrix<long double,3,2> |
using Linear::Matrix3x3d = typedef Matrix<double,3,3> |
using Linear::Matrix3x3f = typedef Matrix<float,3,3> |
using Linear::Matrix3x3ld = typedef Matrix<long double,3,3> |
using Linear::Matrix3x4d = typedef Matrix<double,3,4> |
using Linear::Matrix3x4f = typedef Matrix<float,3,4> |
using Linear::Matrix3x4ld = typedef Matrix<long double,3,4> |
using Linear::Matrix4d = typedef Matrix<double,4,4> |
using Linear::Matrix4f = typedef Matrix<float,4,4> |
using Linear::Matrix4ld = typedef Matrix<long double,4,4> |
using Linear::Matrix4x2d = typedef Matrix<double,4,2> |
using Linear::Matrix4x2f = typedef Matrix<float,4,2> |
using Linear::Matrix4x2ld = typedef Matrix<long double,4,2> |
using Linear::Matrix4x3d = typedef Matrix<double,4,3> |
using Linear::Matrix4x3f = typedef Matrix<float,4,3> |
using Linear::Matrix4x3ld = typedef Matrix<long double,4,3> |
using Linear::Matrix4x4d = typedef Matrix<double,4,4> |
using Linear::Matrix4x4f = typedef Matrix<float,4,4> |
using Linear::Matrix4x4ld = typedef Matrix<long double,4,4> |
using Linear::MatrixXd = typedef Matrix<double,Dynamic,Dynamic> |
using Linear::MatrixXf = typedef Matrix<float,Dynamic,Dynamic> |
using Linear::MatrixXld = typedef Matrix<long double,Dynamic,Dynamic> |
using Linear::RowVector = typedef Matrix<T,1,N> |
using Linear::RowVector2d = typedef RowVector<double,2> |
using Linear::RowVector2f = typedef RowVector<float,2> |
using Linear::RowVector2ld = typedef RowVector<long double,2> |
using Linear::RowVector3d = typedef RowVector<double,3> |
using Linear::RowVector3f = typedef RowVector<float,3> |
using Linear::RowVector3ld = typedef RowVector<long double,3> |
using Linear::RowVector4d = typedef RowVector<double,4> |
using Linear::RowVector4f = typedef RowVector<float,4> |
using Linear::RowVector4ld = typedef RowVector<long double,4> |
using Linear::RowVectorXd = typedef RowVector<double,Dynamic> |
using Linear::RowVectorXf = typedef RowVector<float,Dynamic> |
using Linear::RowVectorXld = typedef RowVector<long double,Dynamic> |
using Linear::SquareMatrix = typedef Matrix<T,N,N,Flags> |
using Linear::Vector = typedef Matrix<T,N,1> |
using Linear::Vector2d = typedef Vector<double,2> |
using Linear::Vector2f = typedef Vector<float,2> |
using Linear::Vector2ld = typedef Vector<long double,2> |
using Linear::Vector3d = typedef Vector<double,3> |
using Linear::Vector3f = typedef Vector<float,3> |
using Linear::Vector3ld = typedef Vector<long double,3> |
using Linear::Vector4d = typedef Vector<double,4> |
using Linear::Vector4f = typedef Vector<float,4> |
using Linear::Vector4ld = typedef Vector<long double,4> |
using Linear::VectorXd = typedef Vector<double,Dynamic> |
using Linear::VectorXf = typedef Vector<float,Dynamic> |
using Linear::VectorXld = typedef Vector<long double,Dynamic> |
enum Linear::SVDType |
T Linear::Abs | ( | const Complex< T > & | z | ) |
Takes a complex number \(z=a+bi\) and computes \(|z|=\sqrt{a^2+b^2}\).
z | Complex number. |
T Linear::Abs | ( | T | x | ) |
Takes a real number \(x\) and computes \(|x|\).
x | Real number. |
T Linear::ACos | ( | T | x | ) |
Returns the real number \(\cos^{-1}x\).
x | Real number. |
T Linear::ACosh | ( | T | x | ) |
Returns the real number \(\cosh^{-1} x\).
x | Real number. |
T Linear::ACot | ( | T | x | ) |
Returns the real number \(\cot^{-1}x=\tan^{-1}(1/x)\).
x | Real number. |
T Linear::ACoth | ( | T | x | ) |
Returns the real number \(\coth^{-1} x=\tanh^{-1}(1/x)\).
x | Real number. |
T Linear::ACsc | ( | T | x | ) |
Returns the real number \(\csc^{-1}x=\sin^{-1}(1/x)\).
x | Real number. |
T Linear::ACsch | ( | T | x | ) |
Returns the real number \(csch^{-1} x=\sinh^{-1}(1/x)\).
x | Real number. |
Matrix<T,M,N,Flags> Linear::Adjugate | ( | const Matrix< T, M, N, Flags > & | A | ) |
Computes the NxN adjugate B of a square matrix A defined by \(b_{ij}=c_{ji}\) where \(c_{ij}\) represents the (i,j)-cofactor of A.
If A is not square, an exception is thrown.
A | MxN matrix |
T Linear::Arg | ( | const Complex< T > & | z | ) |
Takes a complex number \(z=a+bi\) and computes \(arg(z)=atan2(b,a)\).
z | Complex number. |
T Linear::ASec | ( | T | x | ) |
Returns the real number \(\sec^{-1}x=\cos^{-1}(1/x)\).
x | Real number. |
T Linear::ASech | ( | T | x | ) |
Returns the real number \(sech^{-1} x=\cosh^{-1}(1/x)\).
x | Real number. |
T Linear::ASin | ( | T | x | ) |
Returns the real number \(\sin^{-1}x\).
x | Real number. |
T Linear::ASinh | ( | T | x | ) |
Returns the real number \(\sinh^{-1} x\).
x | Real number. |
T Linear::ATan | ( | T | x | ) |
Returns the real number \(\tan^{-1}x\).
x | Real number. |
T Linear::ATanh | ( | T | x | ) |
Returns the real number \(\tanh^{-1} x\).
x | Real number. |
std::enable_if<(M1==M2||M1==Dynamic||M2==Dynamic), Matrix<T,M1,(N1==Dynamic||N2==Dynamic?Dynamic:N1+N2),Flags1> >::type Linear::Augmented | ( | const Matrix< T, M1, N1, Flags1 > & | left, |
const Matrix< T, M2, N2, Flags2 > & | right | ||
) |
std::enable_if<(M>0&&N>0), Matrix<T,M,N,Flags> >::type Linear::Basis | ( | size_t | i, |
size_t | j | ||
) |
Creates an MxN basis matrix \(A\) where all entries are set to 0 except \(a_{ij}=1\).
If i or j are out of bounds, an exception is thrown.
Example: A is the 2x2 matrix {{0,1}, {0,0}}
Matrix2d A = Basis<double, 2, 2>(0, 1);
T | Type |
M | Number of rows |
N | Number of columns |
Flags | Flags to pass to the matrix (default = row major) |
i | Row index |
j | Column index |
Matrix<T,Dynamic,Dynamic,Flags> Linear::Basis | ( | size_t | nrows, |
size_t | ncols, | ||
size_t | i, | ||
size_t | j | ||
) |
Dynamically creates an nrowsxncols basis matrix \(A\) where all entries are set to 0 except \(a_{ij}=1\).
If i or j are out of bounds, an exception is thrown.
Example: A is the 2x2 matrix {{0,1}, {0,0}}
MatrixXd A = Basis<double>(2, 2, 0, 1);
T | Type |
Flags | Flags to pass to the matrix (default = row major) |
nrows | Number of rows |
ncols | Number of columns |
i | Row index |
j | Column index |
std::enable_if<((M==P||M==Dynamic||P==Dynamic)&&(N==Q||N==Dynamic||Q==Dynamic)), Matrix<T,(M==Dynamic?Dynamic:M+1),(N==Dynamic?Dynamic:N+1),Flags> >::type Linear::Block | ( | Complex< T > | tl, |
const RowVector< T, Q > & | tr, | ||
const Vector< T, P > & | bl, | ||
const Matrix< T, M, N, Flags > & | br | ||
) |
std::enable_if<((M==P||M==Dynamic||P==Dynamic)&&(N==Q||N==Dynamic||Q==Dynamic)), Matrix<T,(M==Dynamic?Dynamic:M+1),(N==Dynamic?Dynamic:N+1),Flags> >::type Linear::Block | ( | const Matrix< T, M, N, Flags > & | tl, |
const Vector< T, P > & | tr, | ||
const RowVector< T, Q > & | bl, | ||
Complex< T > | br | ||
) |
std::enable_if<((M1+M3==M2+M4||M1==Dynamic||M2==Dynamic||M3==Dynamic||M4==Dynamic)&&(N1+N2==N3+N4||N1==Dynamic||N2==Dynamic||N3==Dynamic||N4==Dynamic)), Matrix<T,(M1==Dynamic||M2==Dynamic||M3==Dynamic||M4==Dynamic?Dynamic:M1+M3),(N1==Dynamic||N2==Dynamic||N3==Dynamic||N4==Dynamic?Dynamic:N1+N2),Flags1> >::type Linear::Block | ( | const Matrix< T, M1, N1, Flags1 > & | tl, |
const Matrix< T, M2, N2, Flags2 > & | tr, | ||
const Matrix< T, M3, N3, Flags3 > & | bl, | ||
const Matrix< T, M4, N4, Flags4 > & | br | ||
) |
T Linear::Ceil | ( | T | x | ) |
Returns the real number \(\lceil x\rceil\).
x | Real number. |
Vector<T,(N==Dynamic?Dynamic:N+1)> Linear::CharPoly | ( | const Matrix< T, M, N, Flags > & | A | ) |
Computes the characteristic polynomial.
This returns the coefficients as a vector c of length N+1 such that \(\det(A-tI)=c_0+c_1t+\dots+c_{N-1}t^{N-1}+c_Nt^N\).
A | MxN matrix |
Complex<T> Linear::Cofactor | ( | const Matrix< T, M, N, Flags > & | A, |
size_t | i, | ||
size_t | j | ||
) |
Computes the (i,j)-cofactor of a square matrix defined by \((-1)^{i+j}\det(A_{ij})\) where \(A_{ij}\) is the (N-1)x(N-1) matrix obtained by deleting the ith row and jth column.
If A is not square, an exception is thrown. Likewise if i or j is out-of-bounds an exception is thrown.
A | MxN matrix |
i | Row index |
j | Column index |
std::vector<Vector<T,N> > Linear::ColumnSpace | ( | const Matrix< T, M, N, Flags > & | A | ) |
Computes a basis for the column space of A.
The column space of a matrix is the set of vectors v such that Ax=v for some vector x.
A | MxN matrix |
std::enable_if<(N>1||N==Dynamic), SquareMatrix<T,(N==Dynamic?Dynamic:N-1),Flags> >::type Linear::Companion | ( | const RowVector< T, N > & | c | ) |
Computes the (N-1)x(N-1) companion matrix.
\[ C = \begin{bmatrix} 0 & 0 & \dots & 0 & -c_0/c_{N-1} \\ 1 & 0 & \dots & 0 & -c_1/c_{N-1} \\ 0 & 1 & \dots & 0 & -c_2/c_{N-1} \\ \vdots & \vdots & \ddots & \vdots & \vdots \\ 0 & 0 & \dots & 1 & -c_{N-2}/c_{N-1} \end{bmatrix} \]
such that \(\det(C-tI)=c_0/c_{N-1}+c_1/c_{N-1}t+\dots+c_{N-2}/c_{N-1}t^{N-2}+t^{N-1}\).
Flags | Flags to pass to the matrix (default = row major) |
c | Row vector of size N |
std::enable_if<(N>1||N==Dynamic), SquareMatrix<T,(N==Dynamic?Dynamic:N-1),Flags> >::type Linear::Companion | ( | const Vector< T, N > & | c | ) |
Computes the (N-1)x(N-1) companion matrix.
\[ C = \begin{bmatrix} 0 & 0 & \dots & 0 & -c_0/c_{N-1} \\ 1 & 0 & \dots & 0 & -c_1/c_{N-1} \\ 0 & 1 & \dots & 0 & -c_2/c_{N-1} \\ \vdots & \vdots & \ddots & \vdots & \vdots \\ 0 & 0 & \dots & 1 & -c_{N-2}/c_{N-1} \end{bmatrix} \]
such that \(\det(C-tI)=c_0/c_{N-1}+c_1/c_{N-1}t+\dots+c_{N-2}/c_{N-1}t^{N-2}+t^{N-1}\).
Flags | Flags to pass to the matrix (default = row major) |
c | Vector of size N |
Matrix<T,N,M,Flags> Linear::ConjugateTranspose | ( | Matrix< T, M, N, Flags > | A | ) |
Returns the NxM matrix \(B=A^*\) defined by \(b_{ij}=\overline{a_{ji}}\).
A | MxN matrix |
Matrix<T,M,N,Flags> Linear::Constant | ( | Complex< T > | z | ) |
Creates an MxN matrix with every entry set to z.
Example: A is the 2x3 matrix {{1+1i,1+1i,1+1i}, {1+1i,1+1i,1+1i}}
Matrix<double,2,3> A = Constant<double, 2, 3>(Complexd(1,1));
T | Type |
M | Number of rows |
N | Number of columns |
Flags | Flags to pass to the matrix (default = row major) |
z | Complex number |
Matrix<T,Dynamic,Dynamic,Flags> Linear::Constant | ( | size_t | nrows, |
size_t | ncols, | ||
Complex< T > | z | ||
) |
Dynamically creates an nrowsxncols matrix with every entry set to v.
Example: A is the 2x3 matrix {{1+1i,1+1i,1+1i}, {1+1i,1+1i,1+1i}}
MatrixXd A = Constant<double>(2, 3, Complexd(1,1));
T | Type |
Flags | Flags to pass to the matrix (default = row major) |
nrows | Number of rows |
ncols | Number of columns |
z | Complex number |
T Linear::Cos | ( | T | x | ) |
Returns the real number \(\cos x\).
x | Real number. |
T Linear::Cosh | ( | T | x | ) |
Returns the real number \(\cosh x\).
x | Real number. |
T Linear::Cot | ( | T | x | ) |
Returns the real number \(\cot x=1/\tan x\).
x | Real number. |
T Linear::Coth | ( | T | x | ) |
Returns the real number \(\coth x = 1/\tanh x\).
x | Real number. |
Matrix<T,M,N,Flags> Linear::Cross | ( | const Matrix< T, M, N, Flags > & | a, |
const Matrix< T, P, Q, Flags2 > & | b | ||
) |
Computes the cross product of two vectors a and b both of length 3.
The cross product is defined by
\[a\times b = (a_0i+a_1j+a_2k)\times (b_0i+b_1j+b_2k)=(a_1b_2-a_2b_1)i + (a_2b_0-a_0b_2)j + (a_0b_1-a_1b_0)k.\]
If either a or b is not a vector, or they aren't length 3, an exception is thrown.
Example: c is the column vector {-3,6,-3}
Vector3d a = {1, 2, 3}; Vector3d b = {4, 5, 6}; Vector3d c = Cross(a,b);
a | Row/column vector |
b | Row/column vector |
T Linear::Csc | ( | T | x | ) |
Returns the real number \(\csc x=1/\sin x\).
x | Real number. |
T Linear::Csch | ( | T | x | ) |
Returns the real number \(csch x = 1/\sinh x\).
x | Real number. |
Complex<T> Linear::Determinant | ( | const Matrix< T, M, N, Flags > & | A | ) |
Computes the determinant of a square matrix defined by \(\sum_{i=0}^{N-1}(-1)^ia_{0i}\det(A_{0i})\) where \(A_{0i}\) is the (N-1)x(N-1) matrix obtained by deleting the 0th row and ith column.
If A is not square, an exception is thrown.
A | MxN matrix |
Matrix<T,Dynamic,Dynamic> Linear::Diag | ( | Complex< T > | a, |
Complex< T > | b, | ||
Ts &&... | ts | ||
) |
Matrix<T,(M1==Dynamic||M2==Dynamic?Dynamic:M1+M2),(N1==Dynamic||N2==Dynamic?Dynamic:N1+N2),Flags1> Linear::Diag | ( | const Matrix< T, M1, N1, Flags1 > & | A, |
const Matrix< T, M2, N2, Flags2 > & | B | ||
) |
Matrix<T,Dynamic,Dynamic,Flags1> Linear::Diag | ( | const Matrix< T, M1, N1, Flags1 > & | a, |
const Matrix< T, M2, N2, Flags2 > & | b, | ||
Ts &&... | ts | ||
) |
SquareMatrix<T,N> Linear::Diag | ( | RowVector< T, N > | v | ) |
Computes the NxN diagonal matrix.
\[ diag(v_0,\dots,v_{N-1})=\begin{bmatrix} v_0 & & \\ & \ddots & \\ & & v_{N-1} \end{bmatrix}. \]
Flags | Flags to pass to the matrix (default = row major) |
v | Row vector of size N |
SquareMatrix<T,Dynamic> Linear::Diag | ( | std::vector< Complex< T >> | v | ) |
Matrix<T,Dynamic,Dynamic,Flags> Linear::Diag | ( | std::vector< Matrix< T, Dynamic, Dynamic, Flags >> | As | ) |
Computes the PxQ diagonal matrix, where \(P=\sum_{i=0}^{N-1}NumRows(As[i])\) and \(Q=\sum_{i=0}^{N-1}NumColumns(As[i])\),.
\[ diag(As[0],\dots,As[N-1])=\begin{bmatrix} As[0] & & \\ & \ddots & \\ & & As[N-1] \end{bmatrix}. \]
Flags | Flags to pass to the matrix (default = row major) |
As | List of N matrices |
SquareMatrix<T,N> Linear::Diag | ( | Vector< T, N > | v | ) |
Computes the NxN diagonal matrix.
\[ diag(v_0,\dots,v_{N-1}) = \begin{bmatrix} v_0 & & \\ & \ddots & \\ & & v_{N-1} \end{bmatrix}. \]
Flags | Flags to pass to the matrix (default = row major) |
v | Vector of size N |
Complex<T> Linear::Dot | ( | const Matrix< T, M, N, Flags > & | a, |
const Matrix< T, P, Q, Flags2 > & | b | ||
) |
Computes the dot product of two vectors a and b both of size N, \(\sum{i=0}^{N-1}\overline{a_i}b_i\).
If either a or b is not a vector, or they have differing sizes, an exception is thrown.
Example: z=1*3+2*4=11
Vector2d a = {1, 2}; Vector2d b = {3, 4}; Complexd z = Dot(a,b);
a | Row/column vector |
b | Row/column vector |
std::vector<Eigenpair<T,N> > Linear::Eigen | ( | const Matrix< T, M, N, Flags > & | A | ) |
Calculates all eigenpairs of A.
This function handles various cases. First, if the matrix is either upper or lower triangular, then the eigenvalues are simply across the diagonal. Allowing us to pull them directly out of the matrix and use either the Nullspace or InverseIteration to calculate their corresponding eigenvectors. Second, if the matrix is 2x2, then a easy direct formula exists to calculate the eigenvalues. Namely \((tr(A)\pm\sqrt{tr(A)^2-4det(A)})/2\). Third, if neither of the first two cases handles the matrix, we attempt to calculate the Schur decomposition of A. If that fails, we resort to calling WielandtDeflationAlgorithm.
A | MxN matrix |
Vector<T,N> Linear::Eigenvalues | ( | const Matrix< T, M, N, Flags > & | A | ) |
Calculates all eigenvalues of A.
This function handles various cases. First, if the matrix is either upper or lower triangular, then the eigenvalues are simply across the diagonal. Allowing us to pull them directly out of the matrix and use either the Nullspace or InverseIteration to calculate their corresponding eigenvectors. Second, if the matrix is 2x2, then a easy direct formula exists to calculate the eigenvalues. Namely \((tr(A)\pm\sqrt{tr(A)^2-4det(A)})/2\). Third, if neither of the first two cases handles the matrix, we attempt to calculate the Schur decomposition of A. If that fails, we resort to calling WielandtDeflationAlgorithm.
A | MxN matrix |
T Linear::EntrywiseNorm | ( | const Matrix< T, M, N, Flags > & | A, |
size_t | p = 2 |
||
) |
Computes the entrywise p-norm \(\left(\sum_{j=0}^{N-1}\sum_{i=0}^{M-1}|a_{ij}|^p\right)^{1/p}\).
A | MxN Matrix |
p | Real number (default = 2) |
Matrix<T,M,N,Flags> Linear::Exp | ( | Matrix< T, M, N, Flags > | A | ) |
If \(A\) is not square, it computes the MxN Matrix \(B\) defined by \(b_{ij}=e^{a_{ij}}\).
Otherwise it computes the matrix exponential \(e^A=\sum_{k=0}^\infty\frac{1}{k!}A^k\). If \(A=VDV^{-1}\) with \(D=diag(d_1,\dots,d_N)\) a diagonal matrix, then \(e^{A}=Ve^{D}V^{-1}\) and \(e^D=diag(e^{d_1},\dots,e^{d_N})\). If no such decomposition can be found, it simply estimates the series upto the first 10 terms.
A | MxN Matrix |
T Linear::Exp | ( | T | x | ) |
Takes a real number \(x\) and computes \(e^x\).
x | Real number. |
T Linear::Floor | ( | T | x | ) |
Returns the real number \(\lfloor x\rfloor\).
x | Real number. |
T Linear::FrobeniusNorm | ( | const Matrix< T, M, N, Flags > & | A | ) |
Computes the Frobenius norm.
This is identical to EntrywiseNorm(A,2).
A | MxN Matrix |
std::vector<RowVector<T,N> > Linear::GramSchmidt | ( | const std::vector< RowVector< T, N >> & | v | ) |
Performs Gram-Schmidt on a list of row vectors.
If all vectors don't have the same length, an exception is thrown.
Example: vectors is the list of row vectors {0.477,0.894} and {0.894,-0.477}
RowVector2d v1 = { 1, 2 }; RowVector2d v2 = { 3, 4 }; std::vector<RowVector2d> vectors = { v1, v2 }; vectors = GramSchmidt(vectors);
v | List of row vectors |
std::vector<Vector<T,1> > Linear::GramSchmidt | ( | const std::vector< Vector< T, 1 >> & | v | ) |
Performs Gram-Schmidt on a list of length 1 vectors.
Example: vectors is the list of length 1 vectors {1} and {1}
Vector<double, 1> v1 = { 1 }; Vector<double, 1> v2 = { 2 }; std::vector<Vector<double,1>> vectors = { v1, v2 }; vectors = GramSchmidt(vectors);
v | List of vectors all of length 1 |
std::vector<Vector<T,N> > Linear::GramSchmidt | ( | const std::vector< Vector< T, N >> & | v | ) |
Performs Gram-Schmidt on a list of column vectors.
If all vectors don't have the same length, an exception is thrown.
Example: vectors is the list of column vectors {0.477,0.894} and {0.894,-0.477}
Vector2d v1 = { 1, 2 }; Vector2d v2 = { 3, 4 }; std::vector<Vector2d> vectors = { v1, v2 }; vectors = GramSchmidt(vectors);
v | List of column vectors |
Matrix<T,M,N,Flags> Linear::GramSchmidt | ( | Matrix< T, M, N, Flags > | A | ) |
Performs Gram-Schmidt on the columns of A.
Example: B is the 2x2 matrix {{0.477,0.894}, {0.894,-0.477}}
Matrix2d A = { {1, 3}, {2, 4} }; Matrix2d B = GramSchmidt(A);
A | MxN Matrix |
SquareMatrix<T,N,Flags> Linear::Householder | ( | const Vector< T, N > & | x, |
size_t | k | ||
) |
Creates an NxN Householder transformation \(H\) such that \(Hx\) eliminates the last k elements.
Flags | Flags to pass to the matrix (default = row major) |
x | Column vector of length N |
k | Number of elements to zero out |
SquareMatrix<T,N,Flags> Linear::Householder | ( | Vector< T, N > | v | ) |
Creates an NxN Householder transformation \(H\) defined by \(H = I - 2vv^*.\).
Flags | Flags to pass to the matrix (default = row major) |
v | Column vector of length N |
SquareMatrix<T,N,Flags> Linear::Identity | ( | ) |
Creates the NxN Identity matrix.
Example: I is the 3x3 matrix {{1,0,0}, {0,1,0}, {0,0,1}}
Matrix3d I = Identity<double, 3>();
T | Type |
N | Size of matrix. |
Flags | Flags to pass to the matrix (default = row major) |
SquareMatrix<T,Dynamic,Flags> Linear::Identity | ( | size_t | n | ) |
Dynamically creates the nxn Identity matrix.
Example: I is the 3x3 matrix {{1,0,0}, {0,1,0}, {0,0,1}}
MatrixXd I = Identity<double>(3);
T | Type |
Flags | Flags to pass to the matrix (default = row major) |
n | Size of matrix |
T Linear::InfinityNorm | ( | const Matrix< T, M, N, Flags > & | A | ) |
Computes the infinity norm \(\max_{i=0,...M-1}\sum_{j=0}^{N-1}|a_{ij}|\).
A | MxN Matrix |
Matrix<T,M,N,Flags> Linear::Inverse | ( | const Matrix< T, M, N, Flags > & | A | ) |
Computes the NxN inverse \(A^{-1}=\frac{1}{\det A}Adj\) of a square matrix A where Adj is the adjugate of A.
If A is not square or if A is singular, an exception is thrown.
A | MxN matrix |
std::enable_if<(P==N||P==Dynamic||N==Dynamic), Vector<T,P> >::type Linear::InverseIteration | ( | const Matrix< T, M, N, Flags > & | A, |
Vector< T, P > | b0, | ||
Complex< T > | mu, | ||
unsigned int | max_iterations | ||
) |
Performs inverse iteration on A with guess mu.
Inverse iteration, defined by the sequence \(b_{k+1}=\frac{(A-\mu I)^{-1}b_k}{\|(A-\mu I)^{-1}b_k\|}\) is a simple algorithm that computes the eigenvalue of A closest to mu along with it's corresponding eigenvector. Convergence rate depends on how close mu is.
More information: https://en.wikipedia.org/wiki/Inverse_iteration
A | MxN matrix |
b0 | Initial vector of length P to start the sequence |
mu | Original guess at an eigenvalue |
max_iterations | Maximum number of iterations to perform |
bool Linear::IsCompanion | ( | const Matrix< T, M, N, Flags > & | A | ) |
Checks if A is a companion matrix.
A | MxN matrix |
bool Linear::IsDiagonal | ( | const Matrix< T, M, N, Flags > & | A | ) |
Checks if A is a diagonal matrix.
A | MxN matrix |
bool Linear::IsHermitian | ( | const Matrix< T, M, N, Flags > & | A | ) |
Checks if a matrix is Hermitian.
A | MxN matrix |
bool Linear::IsHessenberg | ( | const Matrix< T, M, N, Flags > & | a | ) |
Checks if a matrix is Hessenberg.
A | MxN matrix |
bool Linear::IsIdentity | ( | const Matrix< T, M, N, Flags > & | A | ) |
Checks if A is the identity matrix.
A | MxN matrix |
bool Linear::IsLowerHessenberg | ( | const Matrix< T, M, N, Flags > & | A | ) |
Checks if a matrix is lower Hessenberg.
A | MxN matrix |
bool Linear::IsLowerTriangular | ( | const Matrix< T, M, N, Flags > & | A | ) |
Checks if A is lower triangular form.
A | MxN matrix |
bool Linear::IsReal | ( | const Complex< T > & | z | ) |
Checks if a complex number \(z=a+bi\) is real.
z | Complex number. |
bool Linear::IsReal | ( | const Matrix< T, M, N, Flags > & | A | ) |
Determines if a matrix is real or complex.
A | MxN Matrix |
bool Linear::IsSquare | ( | Matrix< T, M, N, Flags > | A | ) |
Checks if the matrix is squre.
A | MxN matrix |
bool Linear::IsSymmetric | ( | const Matrix< T, M, N, Flags > & | A | ) |
Checks if a matrix is symmetric.
A | MxN matrix |
bool Linear::IsTriangular | ( | const Matrix< T, M, N, Flags > & | A | ) |
Checks if A is lower triangular form or upper triangular form.
A | MxN matrix |
bool Linear::IsTridiagonal | ( | const Matrix< T, M, N, Flags > & | a | ) |
Checks if a matrix is Tridiagonal.
A | MxN matrix |
bool Linear::IsUpperHessenberg | ( | const Matrix< T, M, N, Flags > & | A | ) |
Checks if a matrix is upper Hessenberg.
A | MxN matrix |
bool Linear::IsUpperTriangular | ( | const Matrix< T, M, N, Flags > & | A | ) |
Checks if A is upper triangular form.
A | MxN matrix |
bool Linear::IsVector | ( | const Matrix< T, M, N, Flags > & | A | ) |
Checks if a matrix is a row or column vector.
A | MxN matrix |
SquareMatrix<T,N*Q,Flags1> Linear::KroneckerSum | ( | const Matrix< T, M, N, Flags1 > & | A, |
const Matrix< T, P, Q, Flags2 > & | B | ||
) |
Computes the principal natural log of a complex number \(z\).
If we use Euler's formula and rewrite \(z=re^{\varphi i}\), then \(\log z=\log r+\varphi i\). Generally this would be considered a multivalued function as \(\log z=\{\log r+(\varphi+2\pi k)i\mid k\in\mathbb{Z}\}\). But we just take the principal natural log, i.e., set \(k=0\).
(Read more: https://en.wikipedia.org/wiki/Complex_number#Complex_logarithm)
z | Complex number |
T Linear::Log | ( | T | x | ) |
Computes the natural log of a real number.
x | Real number. |
T Linear::Log | ( | T | x, |
T | base | ||
) |
Computes the \(\log_{base}x\).
This is done via change-of-base formula, \(\log_{base}x=\log x/\log base\).
x | Real number. |
base | Real number. |
std::enable_if<((N1==3||N1==Dynamic)||(N2==3||N2==Dynamic)||(N3==3||N3==Dynamic)||(N4==3||N4==Dynamic)), SquareMatrix<T,4,Flags> >::type Linear::LookAt | ( | Vector< T, N1 > | right, |
Vector< T, N2 > | up, | ||
Vector< T, N3 > | dir, | ||
Vector< T, N4 > | eye | ||
) |
Computes the 4x4 look at matrix.
Flags | Flags to pass to the matrix (default = row major) |
right | Right direction |
up | Up direction |
dir | Forward direction |
eye | Camera position |
T Linear::MaxNorm | ( | const Matrix< T, M, N, Flags > & | A | ) |
Complex<T> Linear::Minor | ( | const Matrix< T, M, N, Flags > & | A, |
size_t | i, | ||
size_t | j | ||
) |
Computes the (i,j)-minor of a square matrix defined by \(\det(A_{ij})\) where \(A_{ij}\) is the (N-1)x(N-1) matrix obtained by deleting the ith row and jth column.
If A is not square, an exception is thrown. Likewise if i or j is out-of-bounds an exception is thrown.
A | MxN matrix |
i | Row index |
j | Column index |
T Linear::Mod | ( | T | x, |
T | y | ||
) |
Computes the floating-point modulus \(x\bmod y\).
x | Real number. |
y | Real number. |
T Linear::Norm | ( | const Matrix< T, M, N, Flags > & | A, |
size_t | p = 2 |
||
) |
If \(A\) is a vector, it computes the entrywise vector p-norm \(\left(\sum_{i=0}^{N-1}|a_i|^p\right)^{1/p}\).
Otherwise it computes the matrix norm \(\|A\|_p\). If p=1, it returns \(\max_{j=0,\dots,N-1}\sum_{i=0}^{M-1}|a_{ij}|\). If p=2, it returns the largest singular value of \(A\). Otherwise an error is returned.
A | MxN Matrix |
p | Real number (default = 2) |
Matrix<T,M,N,Flags> Linear::Normalize | ( | Matrix< T, M, N, Flags > | v | ) |
Normalize a vector, \(v=\frac{v}{\|v\|}\).
Example: w is the column vector {1/5, 2/5}
Vector2d v = {1, 2}; Vector2d w = Normalize(v);
v | Row/column vector |
unsigned int Linear::Nullity | ( | const Matrix< T, M, N, Flags > & | A | ) |
Computes the dimension of the A's null space.
A | MxN matrix |
std::vector<Vector<T,N> > Linear::NullSpace | ( | const Matrix< T, M, N, Flags > & | A | ) |
Computes a basis for the null space of A.
The null space of a matrix is the set of vectors v such that Av=0.
A | MxN matrix |
Matrix<T,M,N,Flags> Linear::One | ( | ) |
Creates the MxN all ones matrix.
Example: A is the 2x3 matrix {{1,1,1}, {1,1,1}}
Matrix<double,2,3> A = One<double, 2, 3>();
T | Type |
M | Number of rows |
N | Number of columns |
Flags | Flags to pass to the matrix (default = row major) |
Matrix<T,Dynamic,Dynamic,Flags> Linear::One | ( | size_t | nrows, |
size_t | ncols | ||
) |
Dynamically creates the nrowsxncols all ones matrix.
Example: A is the 2x3 matrix {{1,1,1}, {1,1,1}}
MatrixXd A = One<double>(2, 3);
T | Type |
Flags | Flags to pass to the matrix (default = row major) |
nrows | Number of rows |
ncols | Number of columns |
SquareMatrix<T,4,Flags> Linear::Orthographic | ( | T | left, |
T | right, | ||
T | bottom, | ||
T | top, | ||
T | near, | ||
T | far | ||
) |
Computes the 4x4 orthographic projection matrix.
See https://en.wikipedia.org/wiki/Orthographic_projection for more information.
Flags | Flags to pass to the matrix (default = row major) |
SquareMatrix<T,4,Flags> Linear::Perspective | ( | T | fov, |
T | aspect, | ||
T | near, | ||
T | far | ||
) |
Computes the 4x4 perspective projection matrix.
Flags | Flags to pass to the matrix (default = row major) |
fov | Field of view in radians |
aspect | Aspect ratio |
near | Distance to near plane |
far | Distance to far plane |
Matrix<T,M,N,Flags> Linear::Pow | ( | const Matrix< T, M, N, Flags > & | A, |
U | power | ||
) |
Matrix<T,M,N,Flags> Linear::Pow | ( | Matrix< T, M, N, Flags > | A, |
Complex< T > | power | ||
) |
If \(A\) is not square, it computes the MxN Matrix \(B\) defined by \(b_{ij}=a_{ij}^{power}\).
Otherwise it attempts to computes the matrix power \(A^{power}\). If \(A=VDV^{-1}\) with \(D=diag(d_1,\dots,d_N)\) a diagonal matrix, then \(A^{power}=VD^{power}V^{-1}\) and \(D^{power}=diag(d_1^{power},\dots,d_N^{power})\). If no such decomposition can be found and power is an integer, it multiplies A by itself |power|-times then taking the inverse if power<0. Otherwise it gives up and throws an exception.
A | MxN Matrix |
T Linear::Pow | ( | T | x, |
T | y | ||
) |
Computes the real number \(x^y\).
Note this will not safeguard expressions such as \((-1)^{1/2}\).
x | Real number. |
y | Real number. |
std::enable_if<(P==N||P==Dynamic||N==Dynamic), Eigenpair<T,P> >::type Linear::PowerIteration | ( | const Matrix< T, M, N, Flags > & | A, |
Vector< T, P > | b0, | ||
unsigned int | max_iterations | ||
) |
Performs power iteration on A.
Power iteration, defined by the sequence \(b_{k+1}=\frac{Ab_k}{\|Ab_k\|}\) is a simple algorithm that computes the greatest (in magnitude) eigenvalue of A along with it's corresponding eigenvector. Convergence is often slow.
More information: https://en.wikipedia.org/wiki/Power_iteration
A | MxN matrix |
b0 | Initial vector of length P to start the sequence. |
max_iterations | Maximum number of iterations to perform |
Matrix<T,P,Q,Flags2> Linear::Proj | ( | const Matrix< T, M, N, Flags > & | v, |
const Matrix< T, P, Q, Flags2 > & | onto | ||
) |
Computes the vector projection \(\proj_{onto}v = \frac{Dot(onto,v)}{Dot(onto,onto)}onto\).
If onto is the zero vector, by definition this function will return the zero vector. If either v or onto is not a vector, or they have different lengths, an exception is thrown.
Example: w is the column vector {2,0}
Vector2d v = {2, 2}; Vector2d onto = {1, 0}; Vector2d w = Proj(v,onto);
v | Row/column vector |
onto | Row/column vector |
Matrix<T,M,N,Flags> Linear::Random | ( | Complex< T > | min = Complex<T>(0.0) , |
Complex< T > | max = Complex<T>(1.0) |
||
) |
Creates an MxN random matrix \(A\) where all entries are randomly determined between min and max.
If \(min=a+bi\) and \(max=c+di\), then each entry of \(A\) will be of the form \(x+iy\) where \(a\le x\le c\) and \(b\le y\le d\).
T | Type |
M | Number of rows |
N | Number of columns |
Flags | Flags to pass to the matrix (default = row major) |
min | Complex number (default = 0) |
max | Complex number (default = 1+0i) |
Matrix<T,Dynamic,Dynamic,Flags> Linear::Random | ( | size_t | nrows, |
size_t | ncols, | ||
Complex< T > | min = Complex<T>(0.0) , |
||
Complex< T > | max = Complex<T>(1.0) |
||
) |
Dynamically creates an nrowsxncols random matrix \(A\) where all entries are randomly determined between min and max.
If \(min=a+bi\) and \(max=c+di\), then each entry of \(A\) will be of the form \(x+iy\) where \(a\le x\le c\) and \(b\le y\le d\).
T | Type |
Flags | Flags to pass to the matrix (default = row major) |
nrows | Number of rows |
ncols | Number of columns |
min | Complex number (default = 0) |
max | Complex number (default = 1+0i) |
unsigned int Linear::Rank | ( | const Matrix< T, M, N, Flags > & | A | ) |
Computes the dimension of the A's column space.
A | MxN matrix |
Matrix<T,M,(N==Dynamic?Dynamic:N-1),Flags> Linear::RemoveColumn | ( | Matrix< T, M, N, Flags > | A, |
size_t | i | ||
) |
Returns the Mx(N-1) submatrix formed by removing the ith column.
A | MxN matrix |
i | Column to remove |
Matrix<T,(M==Dynamic?Dynamic:M-1),N,Flags> Linear::RemoveRow | ( | Matrix< T, M, N, Flags > | A, |
size_t | i | ||
) |
Returns the (M-1)xN submatrix formed by removing the ith row.
A | MxN matrix |
i | Row to remove |
Matrix<T,(M==Dynamic?Dynamic:M-1),(N==Dynamic?Dynamic:N-1),Flags> Linear::RemoveRowAndColumn | ( | Matrix< T, M, N, Flags > | A, |
size_t | i, | ||
size_t | j | ||
) |
Returns the (M-1)x(N-1) submatrix formed by removing the ith row and jth column.
A | MxN matrix |
i | Row to remove |
j | Column to remove |
std::enable_if<((N==3||N==4)&&(P==3||P==Dynamic)), SquareMatrix<T,N,Flags> >::type Linear::Rotation | ( | T | theta, |
Vector< T, P > | axis | ||
) |
Computes the 4x4 rotatation matrix about an axis.
If N=3, it removes the last row and column.
N | Size of matrix (either 3 or 4, default = 4) |
Flags | Flags to pass to the matrix (default = row major) |
theta | Angle to use in radians |
axis | Vector of length 3 representing the axis of rotation |
std::enable_if<((N==3||N==4)&&(P==4||P==Dynamic)), SquareMatrix<T,N,Flags> >::type Linear::Rotation | ( | Vector< T, P > | q | ) |
Computes the 4x4 rotatation matrix given a quaternion q.
If N=3, it removes the last row and column.
N | Size of matrix (either 3 or 4, default = 4) |
Flags | Flags to pass to the matrix (default = row major) |
q | Vector of length 4 representing quaternion q[0]+q[1]i+q[2]j+q[3]k |
std::enable_if<(N==3||N==4), SquareMatrix<T,N,Flags> >::type Linear::RotationX | ( | T | theta | ) |
Computes the 4x4 rotatation matrix.
\[ \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & \cos\theta & -\sin\theta & 0 \\ 0 & \sin\theta & \cos\theta & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix}. \]
If N=3, it removes the last row and column.
N | Size of matrix (either 3 or 4, default = 4) |
Flags | Flags to pass to the matrix (default = row major) |
theta | Angle to use in radians |
std::enable_if<(N==3||N==4), SquareMatrix<T,N,Flags> >::type Linear::RotationY | ( | T | theta | ) |
Computes the 4x4 rotatation matrix.
\[ \begin{bmatrix} \cos\theta & 0 & \sin\theta & 0 \\ 0 & 1 & 0 & 0 \\ -\sin\theta & 0 & \cos\theta & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix}. \]
If N=3, it removes the last row and column.
N | Size of matrix (either 3 or 4, default = 4) |
Flags | Flags to pass to the matrix (default = row major) |
theta | Angle to use in radians |
std::enable_if<(N==3||N==4), SquareMatrix<T,N,Flags> >::type Linear::RotationZ | ( | T | theta | ) |
Computes the 4x4 rotatation matrix.
\[ \begin{bmatrix} \cos\theta & -\sin\theta & 0 & 0 \\ \sin\theta & \cos\theta & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix}. \]
If N=3, it removes the last row and column.
N | Size of matrix (either 3 or 4, default = 4) |
Flags | Flags to pass to the matrix (default = row major) |
theta | Angle to use in radians |
T Linear::Round | ( | T | x | ) |
Rounds \(x\) to the nearest integer.
x | Real number. |
std::enable_if<(N1==N2||N1==Dynamic||N2==Dynamic), Matrix<T,(M1==Dynamic||M2==Dynamic?Dynamic:M1+M2),N1,Flags1> >::type Linear::RowAugmented | ( | const Matrix< T, M1, N1, Flags1 > & | top, |
const Matrix< T, M2, N2, Flags2 > & | bottom | ||
) |
Matrix<T,M,N,Flags> Linear::RREF | ( | Matrix< T, M, N, Flags > | A | ) |
Computes A's reduced row echelon form.
A | MxN matrix |
SquareMatrix<T,N,Flags> Linear::Scaling | ( | const Vector< T, N > & | s | ) |
Computes the NxN scaling matrix S such that.
\[ Sx = \begin{bmatrix} s_0 & \dots & \\ & \ddots & \\ & & s_{N-1} \end{bmatrix} \begin{bmatrix} x_0\\ \vdots \\ x_{N-1}\end{bmatrix} = \begin{bmatrix} s_0x_0\\ \vdots \\ s_{N-1}x_{N-1} \end{bmatrix}. \]
Flags | Flags to pass to the matrix (default = row major) |
s | Vector of length N |
T Linear::Sec | ( | T | x | ) |
Returns the real number \(\sec x=1/\cos x\).
x | Real number. |
T Linear::Sech | ( | T | x | ) |
Returns the real number \(sech x = 1/\cosh x\).
x | Real number. |
void Linear::SeedRandom | ( | unsigned int | seed | ) |
Seeds the random number generator used in Random.
seed | Seed to feed random_number_generator |
T Linear::Sign | ( | T | x | ) |
Takes a real number \(x\) and computes \(sgn(x)\).
If \(x>0\) it returns \(1\). If \(x=0\) it returns \(0\). Otherwise it returns \(-1\).
x | Real number. |
T Linear::Sin | ( | T | x | ) |
Returns the real number \(\sin x\).
x | Real number. |
T Linear::Sinh | ( | T | x | ) |
Returns the real number \(\sinh x\).
x | Real number. |
std::enable_if<(M==P||P==Dynamic||M==Dynamic), RowVector<T,M> >::type Linear::Solve | ( | const Matrix< T, M, N, Flags > & | A, |
const RowVector< T, P > & | b | ||
) |
Solves the matrix equation xA=b for x.
This just recycles the old solver for Ax=b since \((xA)^\top=A^\top x^\top=b^\top\). If N != P, an exception is thrown. If there is no solution, an exception is thrown.
A | MxN matrix |
b | Row vector of length P |
std::enable_if<(M==P||P==Dynamic||M==Dynamic), Vector<T,N> >::type Linear::Solve | ( | const Matrix< T, M, N, Flags > & | A, |
const Vector< T, P > & | b | ||
) |
Solves the matrix equation Ax=b for x.
This functions breaks into various cases.
If M != P, an exception is thrown. If there is no solution, an exception is thrown.
A | MxN matrix |
b | Vector of length P |
Complex<T> Linear::Sqrt | ( | T | x | ) |
Computes the square root of a real number \(x\).
If \(x<0\) it returns the complex number \(\sqrt{|x|}i\).
x | Real number. |
Matrix<T,P,Q,Flags> Linear::SubMatrix | ( | Matrix< T, M, N, Flags > | A, |
size_t | i = 0 , |
||
size_t | j = 0 |
||
) |
Returns the PxQ submatrix located at (i,j) If i+P>M or j+Q > N, an exception is raised.
Example: B is the matrix {{2,3},{5,6}}
Matrix3d A = { {1,2,3}, {4,5,6}, {7,8,9} }; Matrix2d B = SubMatrix<2,2>(A, 0, 1);
A | MxN matrix |
i | Row offset (default = 0) |
j | Column offset (default = 0) |
Matrix<T,Dynamic,Dynamic,Flags> Linear::SubMatrix | ( | Matrix< T, M, N, Flags > | A, |
size_t | nrows, | ||
size_t | ncols, | ||
size_t | i = 0 , |
||
size_t | j = 0 |
||
) |
Returns the nrowsxncols submatrix located at (i,j) If i+nrows>M or j+ncols > N, an exception is raised.
Example: B is the matrix {{2,3},{5,6}}
Matrix3d A = { {1,2,3}, {4,5,6}, {7,8,9} }; MatrixXd B = SubMatrix(A, 2, 2, 0, 1);
A | MxN matrix |
nrows | Number of rows in submatrix |
ncols | Number of columns in submatrix |
i | Row offset (default = 0) |
j | Column offset (default = 0) |
RowVector<T,P> Linear::SubVector | ( | const RowVector< T, N > & | v, |
size_t | off = 0 |
||
) |
Constructs a subvector of a row vector.
If P<1 or off+P>N, an exception is thrown.
Example: w is row vector {2,3}
RowVector4d v = { 1, 2, 3, 4 }; RowVector2d w = SubVector<2>(v, 1);
P | Length for subvector |
v | Row vector of size N |
off | Offset to start the subvector (default = 0) |
RowVector<T,Dynamic> Linear::SubVector | ( | const RowVector< T, N > & | v, |
size_t | size, | ||
size_t | off = 0 |
||
) |
Constructs a subvector of a row vector.
If size<1 or off+size>N, an exception is thrown.
Example: w is dynamic row vector {2,3}
RowVector4d v = { 1, 2, 3, 4 }; RowVectorXd w = SubVector<2>(v, 2, 1);
v | Row vector of size N |
size | Length for subvector |
off | Offset to start the subvector (default = 0) |
Vector<T,P> Linear::SubVector | ( | const Vector< T, 1 > & | v, |
size_t | off = 0 |
||
) |
Handles subvector in the size 1 case.
If P is not one or off is not zero, an exception is raised.
Example: w is vector {1}
Vector<double,1> v = { 1 }; Vector<double,1> w = SubVector<1>(v);
P | Length for subvector |
v | Vector of length 1 |
off | Offset to start the subvector (default = 0) |
Vector<T,Dynamic> Linear::SubVector | ( | const Vector< T, 1 > & | v, |
size_t | size, | ||
size_t | off = 0 |
||
) |
Handles subvector in the size 1 case.
If size is not one or off is not zero, an exception is raised.
Example: w is dynamic vector {1}
Vector<double,1> v = { 1 }; VectorXd w = SubVector(v, 1);
v | Row vector of size 1 |
size | Size for subvector |
off | Offset to start the subvector (default = 0) |
Vector<T,P> Linear::SubVector | ( | const Vector< T, N > & | v, |
size_t | off = 0 |
||
) |
Constructs a subvector of a column vector.
If P<1 or off+P>N, an exception is thrown.
Example: w is column vector {2,3}
Vector4d v = { 1, 2, 3, 4 }; Vector2d w = SubVector<2>(v, 1);
P | Length for subvector |
v | Column vector of size N |
off | Offset to start the subvector (default = 0) |
Vector<T,Dynamic> Linear::SubVector | ( | const Vector< T, N > & | v, |
size_t | size, | ||
size_t | off = 0 |
||
) |
Constructs a subvector of a column vector.
If size<1 or off+size>N, an exception is thrown.
Example: w is dynamic column vector {2,3}
Vector4d v = { 1, 2, 3, 4 }; VectorXd w = SubVector(v, 2, 1);
v | Column vector of size N |
size | Length for subvector |
off | Offset to start the subvector (default 0) |
T Linear::Tan | ( | T | x | ) |
Returns the real number \(\tan x\).
x | Real number. |
T Linear::Tanh | ( | T | x | ) |
Returns the real number \(\tanh x\).
x | Real number. |
Complex<T> Linear::Trace | ( | const Matrix< T, M, N, Flags > & | A | ) |
Computes the trace of a square matrix \(\sum_{i=0}^{N-1}a_{ii}\).
If A is not square, an exception is thrown.
A | MxN matrix |
SquareMatrix<T,(N==Dynamic?Dynamic:N+1),Flags> Linear::Translation | ( | const Vector< T, N > & | t | ) |
Computes the (N+1)x(N+1) translation matrix T such that.
\[ Tx = \begin{bmatrix} 1 & 0 & \dots & 0 & t_0 \\ 0 & 1 & & 0 & t_1 \\ \vdots & & \ddots & \vdots & \vdots \\ 0 & 0 & \dots & 1 & t_{N-1} \\ 0 & 0 & \dots & 0 & 1 \end{bmatrix} \begin{bmatrix} x_0\\ x_1 \\ \vdots \\ x_{N-1} \\ 1\end{bmatrix} = \begin{bmatrix} x_0+t_0\\ x_1+t_1\\ \vdots \\ x_{N-1}+t_{N-1} \\ 1 \end{bmatrix}. \]
Flags | Flags to pass to the matrix (default = row major) |
t | Vector of length N |
Matrix<T,N,M,Flags> Linear::Transpose | ( | const Matrix< T, M, N, Flags > & | A | ) |
Returns the NxM matrix \(B=A^\top\) defined by \(b_{ij}=a_{ji}\).
A | MxN matrix |
void Linear::VietaFormulaHelper | ( | size_t | data[], |
size_t | start, | ||
size_t | end, | ||
size_t | index, | ||
size_t | k, | ||
Complex< T > & | sum, | ||
const Vector< T, N > & | roots | ||
) |
Vector<T,N> Linear::WielandtDeflationAlgorithm | ( | const Matrix< T, M, N, Flags > & | A, |
unsigned int | max_iterations = 100 |
||
) |
Performs a combination of deflation and power iteration to get every eigenpair of A Since power iteration returns the largest eigenvalue, if we want to compute the eigenvalues we need to use deflation.
The general idea is that once an eigenvalue is calculated, we reduce A to a slightly smaller matrix which has the same eigenvalues except removing the one we just calculated. Repeating this process eventually computes all eigenvalues.
A | MxN matrix |
max_iterations | Maximum number of iterations to perform for each call of PowerIteration |
Matrix<T,M,N,Flags> Linear::Zero | ( | ) |
Creates the MxN all zeros matrix.
Example: A is the 2x3 matrix {{0,0,0}, {0,0,0}}
Matrix<double,2,3> A = Zero<double, 2, 3>();
T | Type |
M | Number of rows |
N | Number of columns |
Flags | Flags to pass to the matrix (default = row major) |
Matrix<T,Dynamic,Dynamic,Flags> Linear::Zero | ( | size_t | nrows, |
size_t | ncols | ||
) |
Dynamically creates the nrowsxncols all zeros matrix.
Example: A is the 2x3 matrix {{0,0,0}, {0,0,0}}
MatrixXd A = Zero<double>(2, 3);
T | Type |
Flags | Flags to pass to the matrix (default = row major) |
nrows | Number of rows |
ncols | Number of columns |
const unsigned int Linear::ColumnMajor = 0x0001 |
const unsigned int Linear::Dynamic = 0 |
std::mt19937 Linear::random_number_generator |
const unsigned int Linear::RowMajor = 0x0000 |
double Linear::Tol = 0.00001 |