Linear
Linear Namespace Reference

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 >
Abs (T x)
 Takes a real number \(x\) and computes \(|x|\). More...
 
template<typename 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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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 >
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, DynamicDiag (Complex< T > a, Complex< T > b, Ts &&... ts)
 
template<typename T , unsigned int Flags = 0>
SquareMatrix< T, DynamicDiag (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>
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>
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>
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>
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>
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, DynamicSubVector (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, DynamicSubVector (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, DynamicSubVector (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
 

Typedef Documentation

◆ Complexd

using Linear::Complexd = typedef Complex<double>

◆ Complexf

using Linear::Complexf = typedef Complex<float>

◆ Complexi

using Linear::Complexi = typedef Complex<int>

◆ Matrix2d

using Linear::Matrix2d = typedef Matrix<double,2,2>

◆ Matrix2f

using Linear::Matrix2f = typedef Matrix<float,2,2>

◆ Matrix2ld

using Linear::Matrix2ld = typedef Matrix<long double,2,2>

◆ Matrix2x2d

using Linear::Matrix2x2d = typedef Matrix<double,2,2>

◆ Matrix2x2f

using Linear::Matrix2x2f = typedef Matrix<float,2,2>

◆ Matrix2x2ld

using Linear::Matrix2x2ld = typedef Matrix<long double,2,2>

◆ Matrix2x3d

using Linear::Matrix2x3d = typedef Matrix<double,2,3>

◆ Matrix2x3f

using Linear::Matrix2x3f = typedef Matrix<float,2,3>

◆ Matrix2x3ld

using Linear::Matrix2x3ld = typedef Matrix<long double,2,3>

◆ Matrix2x4d

using Linear::Matrix2x4d = typedef Matrix<double,2,4>

◆ Matrix2x4f

using Linear::Matrix2x4f = typedef Matrix<float,2,4>

◆ Matrix2x4ld

using Linear::Matrix2x4ld = typedef Matrix<long double,2,4>

◆ Matrix3d

using Linear::Matrix3d = typedef Matrix<double,3,3>

◆ Matrix3f

using Linear::Matrix3f = typedef Matrix<float,3,3>

◆ Matrix3ld

using Linear::Matrix3ld = typedef Matrix<long double,3,3>

◆ Matrix3x2d

using Linear::Matrix3x2d = typedef Matrix<double,3,2>

◆ Matrix3x2f

using Linear::Matrix3x2f = typedef Matrix<float,3,2>

◆ Matrix3x2ld

using Linear::Matrix3x2ld = typedef Matrix<long double,3,2>

◆ Matrix3x3d

using Linear::Matrix3x3d = typedef Matrix<double,3,3>

◆ Matrix3x3f

using Linear::Matrix3x3f = typedef Matrix<float,3,3>

◆ Matrix3x3ld

using Linear::Matrix3x3ld = typedef Matrix<long double,3,3>

◆ Matrix3x4d

using Linear::Matrix3x4d = typedef Matrix<double,3,4>

◆ Matrix3x4f

using Linear::Matrix3x4f = typedef Matrix<float,3,4>

◆ Matrix3x4ld

using Linear::Matrix3x4ld = typedef Matrix<long double,3,4>

◆ Matrix4d

using Linear::Matrix4d = typedef Matrix<double,4,4>

◆ Matrix4f

using Linear::Matrix4f = typedef Matrix<float,4,4>

◆ Matrix4ld

using Linear::Matrix4ld = typedef Matrix<long double,4,4>

◆ Matrix4x2d

using Linear::Matrix4x2d = typedef Matrix<double,4,2>

◆ Matrix4x2f

using Linear::Matrix4x2f = typedef Matrix<float,4,2>

◆ Matrix4x2ld

using Linear::Matrix4x2ld = typedef Matrix<long double,4,2>

◆ Matrix4x3d

using Linear::Matrix4x3d = typedef Matrix<double,4,3>

◆ Matrix4x3f

using Linear::Matrix4x3f = typedef Matrix<float,4,3>

◆ Matrix4x3ld

using Linear::Matrix4x3ld = typedef Matrix<long double,4,3>

◆ Matrix4x4d

using Linear::Matrix4x4d = typedef Matrix<double,4,4>

◆ Matrix4x4f

using Linear::Matrix4x4f = typedef Matrix<float,4,4>

◆ Matrix4x4ld

using Linear::Matrix4x4ld = typedef Matrix<long double,4,4>

◆ MatrixXd

using Linear::MatrixXd = typedef Matrix<double,Dynamic,Dynamic>

◆ MatrixXf

using Linear::MatrixXf = typedef Matrix<float,Dynamic,Dynamic>

◆ MatrixXld

using Linear::MatrixXld = typedef Matrix<long double,Dynamic,Dynamic>

◆ RowVector

template<typename T , size_t N>
using Linear::RowVector = typedef Matrix<T,1,N>

◆ RowVector2d

using Linear::RowVector2d = typedef RowVector<double,2>

◆ RowVector2f

using Linear::RowVector2f = typedef RowVector<float,2>

◆ RowVector2ld

using Linear::RowVector2ld = typedef RowVector<long double,2>

◆ RowVector3d

using Linear::RowVector3d = typedef RowVector<double,3>

◆ RowVector3f

using Linear::RowVector3f = typedef RowVector<float,3>

◆ RowVector3ld

using Linear::RowVector3ld = typedef RowVector<long double,3>

◆ RowVector4d

using Linear::RowVector4d = typedef RowVector<double,4>

◆ RowVector4f

using Linear::RowVector4f = typedef RowVector<float,4>

◆ RowVector4ld

using Linear::RowVector4ld = typedef RowVector<long double,4>

◆ RowVectorXd

using Linear::RowVectorXd = typedef RowVector<double,Dynamic>

◆ RowVectorXf

using Linear::RowVectorXf = typedef RowVector<float,Dynamic>

◆ RowVectorXld

using Linear::RowVectorXld = typedef RowVector<long double,Dynamic>

◆ SquareMatrix

template<typename T , size_t N, unsigned int Flags = 0>
using Linear::SquareMatrix = typedef Matrix<T,N,N,Flags>

◆ Vector

template<typename T , size_t N>
using Linear::Vector = typedef Matrix<T,N,1>

◆ Vector2d

using Linear::Vector2d = typedef Vector<double,2>

◆ Vector2f

using Linear::Vector2f = typedef Vector<float,2>

◆ Vector2ld

using Linear::Vector2ld = typedef Vector<long double,2>

◆ Vector3d

using Linear::Vector3d = typedef Vector<double,3>

◆ Vector3f

using Linear::Vector3f = typedef Vector<float,3>

◆ Vector3ld

using Linear::Vector3ld = typedef Vector<long double,3>

◆ Vector4d

using Linear::Vector4d = typedef Vector<double,4>

◆ Vector4f

using Linear::Vector4f = typedef Vector<float,4>

◆ Vector4ld

using Linear::Vector4ld = typedef Vector<long double,4>

◆ VectorXd

using Linear::VectorXd = typedef Vector<double,Dynamic>

◆ VectorXf

using Linear::VectorXf = typedef Vector<float,Dynamic>

◆ VectorXld

using Linear::VectorXld = typedef Vector<long double,Dynamic>

Enumeration Type Documentation

◆ SVDType

Enumerator
FULL_SVD 
THIN_SVD 

Function Documentation

◆ Abs() [1/3]

template<typename T >
T Linear::Abs ( const Complex< T > &  z)

Takes a complex number \(z=a+bi\) and computes \(|z|=\sqrt{a^2+b^2}\).

Parameters
zComplex number.
Returns
Real number.

◆ Abs() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Abs ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix \(B\) defined by \(b_{ij}=|a_{ij}|\).

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ Abs() [3/3]

template<typename T >
T Linear::Abs ( x)

Takes a real number \(x\) and computes \(|x|\).

Parameters
xReal number.
Returns
Real number.

◆ ACos() [1/3]

template<typename T >
Complex<T> Linear::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)\).

Parameters
zComplex number.
Returns
Complex number.

◆ ACos() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::ACos ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\cos^{-1} a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ ACos() [3/3]

template<typename T >
T Linear::ACos ( x)

Returns the real number \(\cos^{-1}x\).

Parameters
xReal number.
Returns
Real number.

◆ ACosh() [1/3]

template<typename T >
Complex<T> Linear::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)\).

Parameters
zComplex number.
Returns
Complex number.

◆ ACosh() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::ACosh ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\cosh^{-1} a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ ACosh() [3/3]

template<typename T >
T Linear::ACosh ( x)

Returns the real number \(\cosh^{-1} x\).

Parameters
xReal number.
Returns
Real number.

◆ ACot() [1/3]

template<typename T >
Complex<T> Linear::ACot ( const Complex< T > &  z)

Returns the complex number \(\cot^{-1}z=\frac{1}{2i}\log\left(\frac{z+i}{z-i}\right)\).

Parameters
zComplex number.
Returns
Complex number.

◆ ACot() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::ACot ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\cot^{-1} a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ ACot() [3/3]

template<typename T >
T Linear::ACot ( x)

Returns the real number \(\cot^{-1}x=\tan^{-1}(1/x)\).

Parameters
xReal number.
Returns
Real number.

◆ ACoth() [1/3]

template<typename T >
Complex<T> Linear::ACoth ( const Complex< T > &  z)

Returns the complex number \(\coth^{-1} z=\frac{1}{2}\log\left(\frac{z+1}{z-1}\right)\).

Parameters
zComplex number.
Returns
Complex number.

◆ ACoth() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::ACoth ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\coth^{-1} a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ ACoth() [3/3]

template<typename T >
T Linear::ACoth ( x)

Returns the real number \(\coth^{-1} x=\tanh^{-1}(1/x)\).

Parameters
xReal number.
Returns
Real number.

◆ ACsc() [1/3]

template<typename T >
Complex<T> Linear::ACsc ( const Complex< T > &  z)

Returns the complex number \(\csc^{-1}z=\sin^{-1}(1/z)\).

Parameters
zComplex number.
Returns
Complex number.

◆ ACsc() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::ACsc ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\csc^{-1} a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ ACsc() [3/3]

template<typename T >
T Linear::ACsc ( x)

Returns the real number \(\csc^{-1}x=\sin^{-1}(1/x)\).

Parameters
xReal number.
Returns
Real number.

◆ ACsch() [1/3]

template<typename T >
Complex<T> Linear::ACsch ( const Complex< T > &  z)

Returns the complex number \(csch^{-1} z=\sinh^{-1}(1/z)\).

Parameters
zComplex number.
Returns
Complex number.

◆ ACsch() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::ACsch ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=csch^{-1} a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ ACsch() [3/3]

template<typename T >
T Linear::ACsch ( x)

Returns the real number \(csch^{-1} x=\sinh^{-1}(1/x)\).

Parameters
xReal number.
Returns
Real number.

◆ Adjugate()

template<typename T , size_t M, size_t N, unsigned int Flags>
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.

Parameters
AMxN matrix
Returns
NxN matrix

◆ Arg() [1/2]

template<typename T >
T Linear::Arg ( const Complex< T > &  z)

Takes a complex number \(z=a+bi\) and computes \(arg(z)=atan2(b,a)\).

Parameters
zComplex number.
Returns
Real number.

◆ Arg() [2/2]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Arg ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix \(B\) defined by \(b_{ij}=arg(a_{ij})\).

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ ASec() [1/3]

template<typename T >
Complex<T> Linear::ASec ( const Complex< T > &  z)

Returns the complex number \(\sec^{-1}z=\cos^{-1}(1/z)\).

Parameters
zComplex number.
Returns
Complex number.

◆ ASec() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::ASec ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\sec^{-1} a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ ASec() [3/3]

template<typename T >
T Linear::ASec ( x)

Returns the real number \(\sec^{-1}x=\cos^{-1}(1/x)\).

Parameters
xReal number.
Returns
Real number.

◆ ASech() [1/3]

template<typename T >
Complex<T> Linear::ASech ( const Complex< T > &  z)

Returns the complex number \(sech^{-1} z=\cosh^{-1}(1/z)\).

Parameters
zComplex number.
Returns
Complex number.

◆ ASech() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::ASech ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=sech^{-1} a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ ASech() [3/3]

template<typename T >
T Linear::ASech ( x)

Returns the real number \(sech^{-1} x=\cosh^{-1}(1/x)\).

Parameters
xReal number.
Returns
Real number.

◆ ASin() [1/3]

template<typename T >
Complex<T> Linear::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)\).

Parameters
zComplex number.
Returns
Complex number.

◆ ASin() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::ASin ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\sin^{-1} a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ ASin() [3/3]

template<typename T >
T Linear::ASin ( x)

Returns the real number \(\sin^{-1}x\).

Parameters
xReal number.
Returns
Real number.

◆ ASinh() [1/3]

template<typename T >
Complex<T> Linear::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)\).

Parameters
zComplex number.
Returns
Complex number.

◆ ASinh() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::ASinh ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\sinh^{-1} a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ ASinh() [3/3]

template<typename T >
T Linear::ASinh ( x)

Returns the real number \(\sinh^{-1} x\).

Parameters
xReal number.
Returns
Real number.

◆ ATan() [1/3]

template<typename T >
Complex<T> Linear::ATan ( const Complex< T > &  z)

Returns the complex number \(\tan^{-1}z=\frac{1}{2i}\log\left(\frac{i-z}{i+z}\right)\).

Parameters
zComplex number.
Returns
Complex number.

◆ ATan() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::ATan ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\tan^{-1} a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ ATan() [3/3]

template<typename T >
T Linear::ATan ( x)

Returns the real number \(\tan^{-1}x\).

Parameters
xReal number.
Returns
Real number.

◆ ATanh() [1/3]

template<typename T >
Complex<T> Linear::ATanh ( const Complex< T > &  z)

Returns the complex number \(\tanh^{-1} z=\frac{1}{2}\log\left(\frac{1+z}{1-z}\right)\).

Parameters
zComplex number.
Returns
Complex number.

◆ ATanh() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::ATanh ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\tanh^{-1} a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ ATanh() [3/3]

template<typename T >
T Linear::ATanh ( x)

Returns the real number \(\tanh^{-1} x\).

Parameters
xReal number.
Returns
Real number.

◆ Augmented()

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 Linear::Augmented ( const Matrix< T, M1, N1, Flags1 > &  left,
const Matrix< T, M2, N2, Flags2 > &  right 
)

Creates the M1x(N1+N2) augmented matrix.

\[ \begin{bmatrix} left & \mid & right \end{bmatrix}. \]

If the two matrices have differing numbers of rows, an exception is thrown.

Parameters
leftM1xN1 Matrix
rightM2xN2 Matrix
Returns
M1x(N1+N2) Matrix

◆ Basis() [1/2]

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 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);
Parameters
TType
MNumber of rows
NNumber of columns
FlagsFlags to pass to the matrix (default = row major)
iRow index
jColumn index
Returns
MxN Matrix

◆ Basis() [2/2]

template<typename T , unsigned int Flags = 0>
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);
Parameters
TType
FlagsFlags to pass to the matrix (default = row major)
nrowsNumber of rows
ncolsNumber of columns
iRow index
jColumn index
Returns
nrowsxncols Matrix

◆ Block() [1/3]

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 Linear::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.

\[ \begin{bmatrix} tl & tr \\ bl & br \end{bmatrix}. \]

If \(P\ne M\) or \(Q\ne N\), then an exception is thrown.

Parameters
tlComplex number
trRow vector of length Q
blVector of length P
brMxN Matrix
Returns
(M+1)x(N+1) Matrix

◆ Block() [2/3]

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 Linear::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.

\[ \begin{bmatrix} tl & tr \\ bl & br \end{bmatrix}. \]

If \(P\ne M\) or \(Q\ne N\), then an exception is thrown.

Parameters
tlMxN Matrix
trVector of length P
blRow vector of length Q
brComplex number
Returns
(M+1)x(N+1) Matrix

◆ Block() [3/3]

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 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 
)

Creates the (M1+M3)x(N1+N2) block matrix.

\[ \begin{bmatrix} tl & tr \\ bl & br \end{bmatrix}. \]

If \(M1+M3\ne M2+M4\) or \(N1+N2\ne N3+N4\), then an exception is thrown.

Parameters
tlM1xN1 Matrix
trM2xN2 Matrix
blM3xN3 Matrix
brM4xN4 Matrix
Returns
(M1+M3)x(N1+N2) Matrix

◆ Ceil() [1/2]

template<typename T >
Complex<T> Linear::Ceil ( const Complex< T > &  z)

Returns the complex number \(\lceil a\rceil+\lceil b\rceil i\) where \(z=a+bi\).

Parameters
zComplex number.
Returns
Complex number.

◆ Ceil() [2/2]

template<typename T >
T Linear::Ceil ( x)

Returns the real number \(\lceil x\rceil\).

Parameters
xReal number.
Returns
Real number.

◆ CharPoly()

template<typename T , size_t M, size_t N, unsigned int Flags>
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\).

Parameters
AMxN matrix
Returns
Coefficients of characteristic polynomial

◆ Cofactor()

template<typename T , size_t M, size_t N, unsigned int Flags>
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.

Parameters
AMxN matrix
iRow index
jColumn index
Returns
Complex number

◆ ColumnSpace()

template<typename T , size_t M, size_t N, unsigned int Flags>
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.

Parameters
AMxN matrix
Returns
List of vectors v such that \(colsp(A)=span\{v[0],\dots,v[len(v)-1]\}\)

◆ Companion() [1/2]

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 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}\).

Parameters
FlagsFlags to pass to the matrix (default = row major)
cRow vector of size N
Returns
(N-1)x(N-1) Matrix

◆ Companion() [2/2]

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 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}\).

Parameters
FlagsFlags to pass to the matrix (default = row major)
cVector of size N
Returns
(N-1)x(N-1) Matrix

◆ Conjugate() [1/2]

template<typename T >
Complex<T> Linear::Conjugate ( const Complex< T > &  z)

Takes a complex number \(z=a+bi\) and computes it's conjugate \(\bar{z}=a-bi\).

Parameters
zComplex number.
Returns
Complex number.

◆ Conjugate() [2/2]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Conjugate ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix \(B\) defined by \(b_{ij}=\overline{a_{ij}}\).

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ ConjugateTranspose()

template<typename T , size_t M, size_t N, unsigned int Flags>
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}}\).

Parameters
AMxN matrix
Returns
NxM matrix

◆ Constant() [1/2]

template<typename T , size_t M, size_t N, unsigned int Flags = 0>
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));
Parameters
TType
MNumber of rows
NNumber of columns
FlagsFlags to pass to the matrix (default = row major)
zComplex number
Returns
MxN Matrix

◆ Constant() [2/2]

template<typename T , unsigned int Flags = 0>
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));
Parameters
TType
FlagsFlags to pass to the matrix (default = row major)
nrowsNumber of rows
ncolsNumber of columns
zComplex number
Returns
nrowsxncols Matrix

◆ Cos() [1/3]

template<typename T >
Complex<T> Linear::Cos ( const Complex< T > &  z)

Returns the complex number \(\cos z=\frac{e^{iz}+e^{-iz}}{2}\).

Parameters
zComplex number.
Returns
Complex number.

◆ Cos() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Cos ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\cos a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ Cos() [3/3]

template<typename T >
T Linear::Cos ( x)

Returns the real number \(\cos x\).

Parameters
xReal number.
Returns
Real number.

◆ Cosh() [1/3]

template<typename T >
Complex<T> Linear::Cosh ( const Complex< T > &  z)

Returns the complex number \(\cosh z=\frac{e^z+e^{-z}}{2}\).

Parameters
zComplex number.
Returns
Complex number.

◆ Cosh() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Cosh ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\cosh a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ Cosh() [3/3]

template<typename T >
T Linear::Cosh ( x)

Returns the real number \(\cosh x\).

Parameters
xReal number.
Returns
Real number.

◆ Cot() [1/3]

template<typename T >
Complex<T> Linear::Cot ( const Complex< T > &  z)

Returns the complex number \(\cot z=i\left(\frac{e^{2iz}+1}{e^{2iz}-1}\right)\).

Parameters
zComplex number.
Returns
Complex number.

◆ Cot() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Cot ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\cot a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ Cot() [3/3]

template<typename T >
T Linear::Cot ( x)

Returns the real number \(\cot x=1/\tan x\).

Parameters
xReal number.
Returns
Real number.

◆ Coth() [1/3]

template<typename T >
Complex<T> Linear::Coth ( const Complex< T > &  z)

Returns the complex number \(\coth z=\frac{e^z+e^{-z}}{e^z-e^{-z}}\).

Parameters
zComplex number.
Returns
Complex number.

◆ Coth() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Coth ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\coth a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ Coth() [3/3]

template<typename T >
T Linear::Coth ( x)

Returns the real number \(\coth x = 1/\tanh x\).

Parameters
xReal number.
Returns
Real number.

◆ Cross()

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> 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);
Parameters
aRow/column vector
bRow/column vector
Returns
Column vector if a is a column vector, otherwise row vector.

◆ Csc() [1/3]

template<typename T >
Complex<T> Linear::Csc ( const Complex< T > &  z)

Returns the complex number \(\csc z=\frac{2i}{e^{iz}-e^{-iz}}\).

Parameters
zComplex number.
Returns
Complex number.

◆ Csc() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Csc ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\csc a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ Csc() [3/3]

template<typename T >
T Linear::Csc ( x)

Returns the real number \(\csc x=1/\sin x\).

Parameters
xReal number.
Returns
Real number.

◆ Csch() [1/3]

template<typename T >
Complex<T> Linear::Csch ( const Complex< T > &  z)

Returns the complex number \(csch z=\frac{2}{e^z-e^{-z}}\).

Parameters
zComplex number.
Returns
Complex number.

◆ Csch() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Csch ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=csch a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ Csch() [3/3]

template<typename T >
T Linear::Csch ( x)

Returns the real number \(csch x = 1/\sinh x\).

Parameters
xReal number.
Returns
Real number.

◆ Determinant()

template<typename T , size_t M, size_t N, unsigned int Flags>
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.

Parameters
AMxN matrix
Returns
Complex number

◆ Diag() [1/9]

template<typename T , typename... Ts>
Matrix<T,Dynamic,Dynamic> Linear::Diag ( Complex< T >  a,
Complex< T >  b,
Ts &&...  ts 
)

◆ Diag() [2/9]

template<typename T , unsigned int Flags = 0>
Matrix<T,2,2,Flags> Linear::Diag ( Complex< T >  z,
Complex< T >  w 
)

Computes the 2x2 diagonal matrix.

\[ \begin{bmatrix} z & 0 \\ 0 & w \end{bmatrix}. \]

Parameters
FlagsFlags to pass to the matrix (default = row major)
zComplex number
wComplex number
Returns
2x2 Matrix

◆ Diag() [3/9]

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> Linear::Diag ( const Matrix< T, M, N, Flags > &  A,
Complex< T >  z 
)

Computes the (M+1)x(N+1) block diagonal matrix.

\[ \begin{bmatrix} A & 0 \\ 0 & z \end{bmatrix}. \]

Parameters
AMxN Matrix
zComplex number
Returns
(M+1)x(N+1) Matrix

◆ Diag() [4/9]

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> Linear::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.

\[ \begin{bmatrix} A & 0 \\ 0 & B \end{bmatrix}. \]

Parameters
AM1xN1 Matrix
BM2xN2 Matrix
Returns
(M1+M2)x(N1+N2) Matrix

◆ Diag() [5/9]

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> Linear::Diag ( const Matrix< T, M1, N1, Flags1 > &  a,
const Matrix< T, M2, N2, Flags2 > &  b,
Ts &&...  ts 
)

◆ Diag() [6/9]

template<typename T , size_t N, unsigned int Flags = 0>
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}. \]

Parameters
FlagsFlags to pass to the matrix (default = row major)
vRow vector of size N
Returns
NxN Matrix

◆ Diag() [7/9]

template<typename T , unsigned int Flags = 0>
SquareMatrix<T,Dynamic> Linear::Diag ( std::vector< Complex< T >>  v)

Dynamically computes the NxN diagonal matrix.

\[ diag(v[0],\dots,v[N-1])=\begin{bmatrix} v[0] & & \\ & \ddots & \\ & & v[N-1] \end{bmatrix}. \]

Parameters
FlagsFlags to pass to the matrix (default = row major)
vList of N Complex numbers
Returns
NxN Matrix

◆ Diag() [8/9]

template<typename T , unsigned int Flags>
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}. \]

Parameters
FlagsFlags to pass to the matrix (default = row major)
AsList of N matrices
Returns
PxQ Matrix

◆ Diag() [9/9]

template<typename T , size_t N, unsigned int Flags = 0>
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}. \]

Parameters
FlagsFlags to pass to the matrix (default = row major)
vVector of size N
Returns
NxN Matrix

◆ Dot()

template<typename T , size_t M, size_t N, unsigned int Flags, size_t P, size_t Q, unsigned int Flags2>
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);
Parameters
aRow/column vector
bRow/column vector
Returns
Complex number

◆ Eigen()

template<typename T , size_t M, size_t N, unsigned int Flags>
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.

Parameters
AMxN matrix
Returns
List of Eigenpairs

◆ Eigenvalues()

template<typename T , size_t M, size_t N, unsigned int Flags>
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.

Parameters
AMxN matrix
Returns
Column vector of eigenvalues.

◆ EntrywiseDivision()

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> Linear::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}\).

If \(M\ne P\) or \(N\ne Q\) an exception is thrown.

Parameters
AMxN Matrix
BPxQ Matrix
Returns
MxN Matrix

◆ EntrywiseNorm()

template<typename T , size_t M, size_t N, unsigned int Flags>
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}\).

Parameters
AMxN Matrix
pReal number (default = 2)
Returns
Real number

◆ EntrywiseProduct()

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> Linear::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}\).

If \(M\ne P\) or \(N\ne Q\) an exception is thrown.

Parameters
AMxN Matrix
BPxQ Matrix
Returns
MxN Matrix

◆ Exp() [1/3]

template<typename T >
Complex<T> Linear::Exp ( const Complex< T > &  z)

Takes a complex number \(z\) and computes \(e^z\).

This is done using Euler's formula. Thus \(e^z=e^{a+bi}=e^ae^{bi}=e^a(\cos b+i\sin b)\).

Parameters
zComplex number.
Returns
Complex number.

◆ Exp() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
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.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ Exp() [3/3]

template<typename T >
T Linear::Exp ( x)

Takes a real number \(x\) and computes \(e^x\).

Parameters
xReal number.
Returns
Real number.

◆ Floor() [1/2]

template<typename T >
Complex<T> Linear::Floor ( const Complex< T > &  z)

Returns the complex number \(\lfloor a\rfloor+\lfloor b\rfloor i\) where \(z=a+bi\).

Parameters
zComplex number.
Returns
Complex number.

◆ Floor() [2/2]

template<typename T >
T Linear::Floor ( x)

Returns the real number \(\lfloor x\rfloor\).

Parameters
xReal number.
Returns
Real number.

◆ FrobeniusNorm()

template<typename T , size_t M, size_t N, unsigned int Flags>
T Linear::FrobeniusNorm ( const Matrix< T, M, N, Flags > &  A)

Computes the Frobenius norm.

This is identical to EntrywiseNorm(A,2).

Parameters
AMxN Matrix
Returns
Real number

◆ GramSchmidt() [1/4]

template<typename T , size_t N>
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);
Parameters
vList of row vectors
Returns
List of row vectors

◆ GramSchmidt() [2/4]

template<typename T >
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);
Parameters
vList of vectors all of length 1
Returns
List of vectors all of length 1

◆ GramSchmidt() [3/4]

template<typename T , size_t N>
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);
Parameters
vList of column vectors
Returns
List of column vectors

◆ GramSchmidt() [4/4]

template<typename T , size_t M, size_t N, unsigned int Flags>
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);
Parameters
AMxN Matrix
Returns
MxN matrix

◆ Householder() [1/2]

template<typename T , size_t N, unsigned int Flags = 0>
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.

Parameters
FlagsFlags to pass to the matrix (default = row major)
xColumn vector of length N
kNumber of elements to zero out
Returns
NxN Matrix

◆ Householder() [2/2]

template<typename T , size_t N, unsigned int Flags = 0>
SquareMatrix<T,N,Flags> Linear::Householder ( Vector< T, N >  v)

Creates an NxN Householder transformation \(H\) defined by \(H = I - 2vv^*.\).

Parameters
FlagsFlags to pass to the matrix (default = row major)
vColumn vector of length N
Returns
NxN Matrix

◆ Identity() [1/2]

template<typename T , size_t N, unsigned int Flags = 0>
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>();
Parameters
TType
NSize of matrix.
FlagsFlags to pass to the matrix (default = row major)
Returns
NxN Matrix

◆ Identity() [2/2]

template<typename T , unsigned int Flags = 0>
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);
Parameters
TType
FlagsFlags to pass to the matrix (default = row major)
nSize of matrix
Returns
nxn Matrix

◆ InfinityNorm()

template<typename T , size_t M, size_t N, unsigned int Flags>
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}|\).

Parameters
AMxN Matrix
Returns
Real number

◆ Inverse()

template<typename T , size_t M, size_t N, unsigned int Flags>
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.

Parameters
AMxN matrix
Returns
NxN matrix

◆ InverseIteration()

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 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

Parameters
AMxN matrix
b0Initial vector of length P to start the sequence
muOriginal guess at an eigenvalue
max_iterationsMaximum number of iterations to perform
Returns
Vector v such that \(Av\approx\lambda v\) where \(\lambda\) is the eigenvalue of A closest to mu

◆ IsCompanion()

template<typename T , size_t M, size_t N, unsigned int Flags>
bool Linear::IsCompanion ( const Matrix< T, M, N, Flags > &  A)

Checks if A is a companion matrix.

Parameters
AMxN matrix
Returns
True if A is a companion matrix

◆ IsDiagonal()

template<typename T , size_t M, size_t N, unsigned int Flags>
bool Linear::IsDiagonal ( const Matrix< T, M, N, Flags > &  A)

Checks if A is a diagonal matrix.

Parameters
AMxN matrix
Returns
True if A is diagonal

◆ IsHermitian()

template<typename T , size_t M, size_t N, unsigned int Flags>
bool Linear::IsHermitian ( const Matrix< T, M, N, Flags > &  A)

Checks if a matrix is Hermitian.

Parameters
AMxN matrix
Returns
True if A is square and \(a_{ij}=\overline{a_{ji}}\) for all i and j.

◆ IsHessenberg()

template<typename T , size_t M, size_t N, unsigned int Flags>
bool Linear::IsHessenberg ( const Matrix< T, M, N, Flags > &  a)

Checks if a matrix is Hessenberg.

Parameters
AMxN matrix
Returns
True if A is either lower or upper Hessenberg

◆ IsIdentity()

template<typename T , size_t M, size_t N, unsigned int Flags>
bool Linear::IsIdentity ( const Matrix< T, M, N, Flags > &  A)

Checks if A is the identity matrix.

Parameters
AMxN matrix
Returns
True if A is the identity

◆ IsLowerHessenberg()

template<typename T , size_t M, size_t N, unsigned int Flags>
bool Linear::IsLowerHessenberg ( const Matrix< T, M, N, Flags > &  A)

Checks if a matrix is lower Hessenberg.

Parameters
AMxN matrix
Returns
True if A is square and \(a_{ij}=0\) for all i,j such that \(j>i+1\)

◆ IsLowerTriangular()

template<typename T , size_t M, size_t N, unsigned int Flags>
bool Linear::IsLowerTriangular ( const Matrix< T, M, N, Flags > &  A)

Checks if A is lower triangular form.

Parameters
AMxN matrix
Returns
True if A is lower triangular form

◆ IsReal() [1/2]

template<typename T >
bool Linear::IsReal ( const Complex< T > &  z)

Checks if a complex number \(z=a+bi\) is real.

Parameters
zComplex number.
Returns
Returns true if \(b=0\).

◆ IsReal() [2/2]

template<typename T , size_t M, size_t N, unsigned int Flags>
bool Linear::IsReal ( const Matrix< T, M, N, Flags > &  A)

Determines if a matrix is real or complex.

Parameters
AMxN Matrix
Returns
Returns true if every entry of A is real.

◆ IsSquare()

template<typename T , size_t M, size_t N, unsigned int Flags>
bool Linear::IsSquare ( Matrix< T, M, N, Flags >  A)

Checks if the matrix is squre.

Parameters
AMxN matrix
Returns
True if M=N.

◆ IsSymmetric()

template<typename T , size_t M, size_t N, unsigned int Flags>
bool Linear::IsSymmetric ( const Matrix< T, M, N, Flags > &  A)

Checks if a matrix is symmetric.

Parameters
AMxN matrix
Returns
True if A is square and \(a_{ij}=a_{ji}\) for all i and j.

◆ IsTriangular()

template<typename T , size_t M, size_t N, unsigned int Flags>
bool Linear::IsTriangular ( const Matrix< T, M, N, Flags > &  A)

Checks if A is lower triangular form or upper triangular form.

Parameters
AMxN matrix
Returns
True if A is upper triangular form or lower triangular form

◆ IsTridiagonal()

template<typename T , size_t M, size_t N, unsigned int Flags>
bool Linear::IsTridiagonal ( const Matrix< T, M, N, Flags > &  a)

Checks if a matrix is Tridiagonal.

Parameters
AMxN matrix
Returns
True if A is both lower and upper Hessenberg

◆ IsUpperHessenberg()

template<typename T , size_t M, size_t N, unsigned int Flags>
bool Linear::IsUpperHessenberg ( const Matrix< T, M, N, Flags > &  A)

Checks if a matrix is upper Hessenberg.

Parameters
AMxN matrix
Returns
True if A is square and \(a_{ij}=0\) for all i,j such that \(i>j+1\)

◆ IsUpperTriangular()

template<typename T , size_t M, size_t N, unsigned int Flags>
bool Linear::IsUpperTriangular ( const Matrix< T, M, N, Flags > &  A)

Checks if A is upper triangular form.

Parameters
AMxN matrix
Returns
True if A is upper triangular form

◆ IsVector()

template<typename T , size_t M, size_t N, unsigned int Flags>
bool Linear::IsVector ( const Matrix< T, M, N, Flags > &  A)

Checks if a matrix is a row or column vector.

Parameters
AMxN matrix
Returns
True if M=1 or N=1

◆ Kronecker()

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> Linear::Kronecker ( const Matrix< T, M, N, Flags1 > &  A,
const Matrix< T, P, Q, Flags2 > &  B 
)

Computes the (MP)x(NQ) block matrix.

\[ A\otimes B = \begin{bmatrix} a_{0,0}B & \dots & a_{0,N-1}B \\ \vdots & \ddots & \vdots \\ a_{M-1,0}B & \dots & a_{M-1,N-1}B \end{bmatrix}. \]

Parameters
AMxN Matrix
BPxQ Matrix
Returns
(MP)x(NQ) Matrix

◆ KroneckerSum()

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> Linear::KroneckerSum ( const Matrix< T, M, N, Flags1 > &  A,
const Matrix< T, P, Q, Flags2 > &  B 
)

Computes the (NQ)x(NQ) Kronecker sum defined by.

\[ A \oplus B = A\otimes I_Q + I_N\otimes B \]

where \(I_N\) represents the NxN identity matrix.

Parameters
ANxN Matrix
BQxQ Matrix
Returns
(NQ)x(NQ) Matrix

◆ Log() [1/9]

template<typename T >
Complex<T> Linear::Log ( const Complex< T > &  z)

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)

Parameters
zComplex number
Returns
Complex number.

◆ Log() [2/9]

template<typename T >
Complex<T> Linear::Log ( const Complex< T > &  z,
const Complex< T > &  base 
)

Computes the \(\log_{base}z\).

This is done via change-of-base formula, \(\log_{base}z=\log z/\log base\).

Parameters
zComplex number.
baseComplex number.
Returns
Complex number.

◆ Log() [3/9]

template<typename T >
Complex<T> Linear::Log ( const Complex< T > &  z,
base 
)

Computes the \(\log_{base}z\).

This is done via change-of-base formula, \(\log_{base}z=\log z/\log base\).

Parameters
zComplex number.
baseReal number.
Returns
Complex number.

◆ Log() [4/9]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Log ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix \(B\) defined by \(b_{ij}=\log a_{ij}\).

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ Log() [5/9]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Log ( Matrix< T, M, N, Flags >  A,
Complex< T >  base 
)

Computes the MxN Matrix \(B\) defined by \(b_{ij}=\log_{base} a_{ij}\).

Parameters
AMxN Matrix
baseComplex number
Returns
MxN Matrix

◆ Log() [6/9]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Log ( Matrix< T, M, N, Flags >  A,
base 
)

Computes the MxN Matrix \(B\) defined by \(b_{ij}=\log_{base} a_{ij}\).

Parameters
AMxN Matrix
baseReal number
Returns
MxN Matrix

◆ Log() [7/9]

template<typename T >
T Linear::Log ( x)

Computes the natural log of a real number.

Parameters
xReal number.
Returns
Real number.

◆ Log() [8/9]

template<typename T >
Complex<T> Linear::Log ( x,
const Complex< T > &  base 
)

Computes the \(\log_{base}x\).

This is done via change-of-base formula, \(\log_{base}x=\log x/\log base\).

Parameters
xReal number.
baseComplex number.
Returns
Complex number.

◆ Log() [9/9]

template<typename T >
T Linear::Log ( x,
base 
)

Computes the \(\log_{base}x\).

This is done via change-of-base formula, \(\log_{base}x=\log x/\log base\).

Parameters
xReal number.
baseReal number.
Returns
Real number.

◆ LookAt()

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 Linear::LookAt ( Vector< T, N1 >  right,
Vector< T, N2 >  up,
Vector< T, N3 >  dir,
Vector< T, N4 >  eye 
)

Computes the 4x4 look at matrix.

Parameters
FlagsFlags to pass to the matrix (default = row major)
rightRight direction
upUp direction
dirForward direction
eyeCamera position
Returns
4x4 Matrix

◆ MaxNorm()

template<typename T , size_t M, size_t N, unsigned int Flags>
T Linear::MaxNorm ( const Matrix< T, M, N, Flags > &  A)

Computes the max norm \(\max_{ij}|a_{ij}|\).

Parameters
AMxN Matrix
Returns
Real number

◆ Minor()

template<typename T , size_t M, size_t N, unsigned int Flags>
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.

Parameters
AMxN matrix
iRow index
jColumn index
Returns
Complex number

◆ Mod() [1/5]

template<typename T >
Complex<T> Linear::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\).

Parameters
zComplex number.
wComplex number.
Returns
Complex number.

◆ Mod() [2/5]

template<typename T >
Complex<T> Linear::Mod ( const Complex< T > &  z,
y 
)

Returns the complex number \((a\bmod y)+(b\bmod y)i\) where \(z=a+bi\).

Parameters
zComplex number.
yReal number.
Returns
Complex number.

◆ Mod() [3/5]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Mod ( Matrix< T, M, N, Flags >  A,
Complex< T >  z 
)

Computes the MxN Matrix \(B\) defined by \(b_{ij}=a_{ij}\bmod z\).

Parameters
AMxN Matrix
zComplex number
Returns
MxN Matrix

◆ Mod() [4/5]

template<typename T , size_t M, size_t N, unsigned int Flags, typename U >
Matrix<T,M,N,Flags> Linear::Mod ( Matrix< T, M, N, Flags >  A,
y 
)

Computes the MxN Matrix \(B\) defined by \(b_{ij}=a_{ij}\bmod y\).

Parameters
AMxN Matrix
yReal number
Returns
MxN Matrix

◆ Mod() [5/5]

template<typename T >
T Linear::Mod ( x,
y 
)

Computes the floating-point modulus \(x\bmod y\).

Parameters
xReal number.
yReal number.
Returns
Real number.

◆ Norm()

template<typename T , size_t M, size_t N, unsigned int Flags>
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.

Parameters
AMxN Matrix
pReal number (default = 2)
Returns
Real number

◆ Normalize()

template<typename T , size_t M, size_t N, unsigned int Flags>
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);
Parameters
vRow/column vector
Returns
Column vector if v is a column vector, otherwise row vector.

◆ Nullity()

template<typename T , size_t M, size_t N, unsigned int Flags>
unsigned int Linear::Nullity ( const Matrix< T, M, N, Flags > &  A)

Computes the dimension of the A's null space.

Parameters
AMxN matrix
Returns
dim(Null(A))

◆ NullSpace()

template<typename T , size_t M, size_t N, unsigned int Flags>
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.

Parameters
AMxN matrix
Returns
List of vectors v such that \(Null(A)=span\{v[0],\dots,v[len(v)-1]\}\)

◆ One() [1/2]

template<typename T , size_t M, size_t N, unsigned int Flags = 0>
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>();
Parameters
TType
MNumber of rows
NNumber of columns
FlagsFlags to pass to the matrix (default = row major)
Returns
MxN Matrix

◆ One() [2/2]

template<typename T , unsigned int Flags = 0>
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);
Parameters
TType
FlagsFlags to pass to the matrix (default = row major)
nrowsNumber of rows
ncolsNumber of columns
Returns
nrowsxncols Matrix

◆ Orthographic()

template<typename T , unsigned int Flags = 0>
SquareMatrix<T,4,Flags> Linear::Orthographic ( left,
right,
bottom,
top,
near,
far 
)

Computes the 4x4 orthographic projection matrix.

See https://en.wikipedia.org/wiki/Orthographic_projection for more information.

Parameters
FlagsFlags to pass to the matrix (default = row major)
Returns
4x4 Matrix

◆ Perspective()

template<typename T , unsigned int Flags = 0>
SquareMatrix<T,4,Flags> Linear::Perspective ( fov,
aspect,
near,
far 
)

Computes the 4x4 perspective projection matrix.

Parameters
FlagsFlags to pass to the matrix (default = row major)
fovField of view in radians
aspectAspect ratio
nearDistance to near plane
farDistance to far plane
Returns
4x4 Matrix

◆ Pow() [1/4]

template<typename T >
Complex<T> Linear::Pow ( const Complex< T > &  z,
const Complex< T > &  w 
)

Computes the complex number \(z^w\).

This is done using the exponential, \(z^w:=e^{w\log z}\). Again this is a multivalued function but we take the principal value.

Parameters
zComplex number.
wComplex number.
Returns
Complex number.

◆ Pow() [2/4]

template<typename T , size_t M, size_t N, unsigned int Flags, typename U >
Matrix<T,M,N,Flags> Linear::Pow ( const Matrix< T, M, N, Flags > &  A,
power 
)

◆ Pow() [3/4]

template<typename T , size_t M, size_t N, unsigned int Flags>
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.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ Pow() [4/4]

template<typename T >
T Linear::Pow ( x,
y 
)

Computes the real number \(x^y\).

Note this will not safeguard expressions such as \((-1)^{1/2}\).

Parameters
xReal number.
yReal number.
Returns
Real number.

◆ PowerIteration()

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 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

Parameters
AMxN matrix
b0Initial vector of length P to start the sequence.
max_iterationsMaximum number of iterations to perform
Returns
Pair \((\lambda,v)\) such that \(Av\approx \lambda v\)

◆ Proj()

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> 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);
Parameters
vRow/column vector
ontoRow/column vector
Returns
Column vector if onto is a column vector, otherwise row vector.

◆ Random() [1/2]

template<typename T , size_t M, size_t N, unsigned int Flags = 0>
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\).

Parameters
TType
MNumber of rows
NNumber of columns
FlagsFlags to pass to the matrix (default = row major)
minComplex number (default = 0)
maxComplex number (default = 1+0i)
Returns
MxN Matrix

◆ Random() [2/2]

template<typename T , unsigned int Flags = 0>
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\).

Parameters
TType
FlagsFlags to pass to the matrix (default = row major)
nrowsNumber of rows
ncolsNumber of columns
minComplex number (default = 0)
maxComplex number (default = 1+0i)
Returns
nrowsxncols Matrix

◆ Rank()

template<typename T , size_t M, size_t N, unsigned int Flags>
unsigned int Linear::Rank ( const Matrix< T, M, N, Flags > &  A)

Computes the dimension of the A's column space.

Parameters
AMxN matrix
Returns
dim(colsp(A))

◆ RemoveColumn()

template<typename T , size_t M, size_t N, unsigned int Flags>
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.

Parameters
AMxN matrix
iColumn to remove
Returns
Mx(N-1) submatrix of A

◆ RemoveRow()

template<typename T , size_t M, size_t N, unsigned int Flags>
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.

Parameters
AMxN matrix
iRow to remove
Returns
(M-1)xN submatrix of A

◆ RemoveRowAndColumn()

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> 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.

Parameters
AMxN matrix
iRow to remove
jColumn to remove
Returns
(M-1)x(N-1) submatrix of A

◆ Rotation() [1/2]

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 Linear::Rotation ( theta,
Vector< T, P >  axis 
)

Computes the 4x4 rotatation matrix about an axis.

If N=3, it removes the last row and column.

Parameters
NSize of matrix (either 3 or 4, default = 4)
FlagsFlags to pass to the matrix (default = row major)
thetaAngle to use in radians
axisVector of length 3 representing the axis of rotation
Returns
NxN Matrix

◆ Rotation() [2/2]

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 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.

Parameters
NSize of matrix (either 3 or 4, default = 4)
FlagsFlags to pass to the matrix (default = row major)
qVector of length 4 representing quaternion q[0]+q[1]i+q[2]j+q[3]k
Returns
NxN Matrix

◆ RotationX()

template<typename T , size_t N = 4, unsigned int Flags = 0>
std::enable_if<(N==3||N==4), SquareMatrix<T,N,Flags> >::type Linear::RotationX ( 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.

Parameters
NSize of matrix (either 3 or 4, default = 4)
FlagsFlags to pass to the matrix (default = row major)
thetaAngle to use in radians
Returns
NxN Matrix

◆ RotationY()

template<typename T , size_t N = 4, unsigned int Flags = 0>
std::enable_if<(N==3||N==4), SquareMatrix<T,N,Flags> >::type Linear::RotationY ( 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.

Parameters
NSize of matrix (either 3 or 4, default = 4)
FlagsFlags to pass to the matrix (default = row major)
thetaAngle to use in radians
Returns
NxN Matrix

◆ RotationZ()

template<typename T , size_t N, unsigned int Flags = 0>
std::enable_if<(N==3||N==4), SquareMatrix<T,N,Flags> >::type Linear::RotationZ ( 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.

Parameters
NSize of matrix (either 3 or 4, default = 4)
FlagsFlags to pass to the matrix (default = row major)
thetaAngle to use in radians
Returns
NxN Matrix

◆ Round() [1/2]

template<typename T >
Complex<T> Linear::Round ( const Complex< T > &  z)

Rounds the real and imaginary parts of \(z\) to the nearest integer.

Parameters
zComplex number.
Returns
Complex number.

◆ Round() [2/2]

template<typename T >
T Linear::Round ( x)

Rounds \(x\) to the nearest integer.

Parameters
xReal number.
Returns
Real number.

◆ RowAugmented()

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 Linear::RowAugmented ( const Matrix< T, M1, N1, Flags1 > &  top,
const Matrix< T, M2, N2, Flags2 > &  bottom 
)

Creates the (M1+M2)xN1 row augmented matrix.

\[ \begin{bmatrix} top \\ \hline bottom \end{bmatrix}. \]

If the two matrices have differing numbers of columns, an exception is thrown.

Parameters
topM1xN1 Matrix
bottomM2xN2 Matrix
Returns
(M1+M2)xN1 Matrix

◆ RREF()

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::RREF ( Matrix< T, M, N, Flags >  A)

Computes A's reduced row echelon form.

Parameters
AMxN matrix
Returns
MxN matrix

◆ Scaling()

template<typename T , size_t N, unsigned int Flags = 0>
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}. \]

Parameters
FlagsFlags to pass to the matrix (default = row major)
sVector of length N
Returns
NxN Matrix

◆ Sec() [1/3]

template<typename T >
Complex<T> Linear::Sec ( const Complex< T > &  z)

Returns the complex number \(\sec z=\frac{2}{e^{iz}+e^{-iz}}\).

Parameters
zComplex number.
Returns
Complex number.

◆ Sec() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Sec ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\sec a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ Sec() [3/3]

template<typename T >
T Linear::Sec ( x)

Returns the real number \(\sec x=1/\cos x\).

Parameters
xReal number.
Returns
Real number.

◆ Sech() [1/3]

template<typename T >
Complex<T> Linear::Sech ( const Complex< T > &  z)

Returns the complex number \(sech z=\frac{2}{e^z+e^{-z}}\).

Parameters
zComplex number.
Returns
Complex number.

◆ Sech() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Sech ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=sech a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ Sech() [3/3]

template<typename T >
T Linear::Sech ( x)

Returns the real number \(sech x = 1/\cosh x\).

Parameters
xReal number.
Returns
Real number.

◆ SeedRandom()

void Linear::SeedRandom ( unsigned int  seed)

Seeds the random number generator used in Random.

Parameters
seedSeed to feed random_number_generator

◆ Sign() [1/3]

template<typename T >
Complex<T> Linear::Sign ( const Complex< T > &  z)

Takes a complex number \(z\) and computes \(sgn(z)\).

If \(z\) is real and if \(z>0\) it returns \(1\). If \(z\) is real and \(z=0\) it returns \(0\). Otherwise if \(z\) is real it returns \(-1\). If \(z\) is not real, it returns \(\frac{z}{|z|}\).

Parameters
zComplex number.
Returns
Complex number.

◆ Sign() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Sign ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix \(B\) defined by \(b_{ij}=sgn(a_{ij})\).

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ Sign() [3/3]

template<typename T >
T Linear::Sign ( 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\).

Parameters
xReal number.
Returns
-1, 0 or 1.

◆ Sin() [1/3]

template<typename T >
Complex<T> Linear::Sin ( const Complex< T > &  z)

Returns the complex number \(\sin z=\frac{e^{iz}-e^{-iz}}{2i}\).

Parameters
zComplex number.
Returns
Complex number.

◆ Sin() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Sin ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\sin a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ Sin() [3/3]

template<typename T >
T Linear::Sin ( x)

Returns the real number \(\sin x\).

Parameters
xReal number.
Returns
Real number.

◆ Sinh() [1/3]

template<typename T >
Complex<T> Linear::Sinh ( const Complex< T > &  z)

Returns the complex number \(\sinh z=\frac{e^z-e^{-z}}{2}\).

Parameters
zComplex number.
Returns
Complex number.

◆ Sinh() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Sinh ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\sinh a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ Sinh() [3/3]

template<typename T >
T Linear::Sinh ( x)

Returns the real number \(\sinh x\).

Parameters
xReal number.
Returns
Real number.

◆ Solve() [1/2]

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 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.

Parameters
AMxN matrix
bRow vector of length P
Returns
Row vector of length M

◆ Solve() [2/2]

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 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.

  1. If A is square we have 2 special cases. a. If A is invertible, then \(x=A^{-1}b\). b. If A is upper triangular or lower triangular, then we can use forward/backward subsitution to solve.
  2. If those two cases don't hold, we employ Guassian elimination.

If M != P, an exception is thrown. If there is no solution, an exception is thrown.

Parameters
AMxN matrix
bVector of length P
Returns
Vector of length N

◆ Sqrt() [1/3]

template<typename T >
Complex<T> Linear::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}}\).

Parameters
zComplex number.
Returns
Complex number.

◆ Sqrt() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Sqrt ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix \(B\) defined by \(b_{ij}=\sqrt{a_{ij}}\).

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ Sqrt() [3/3]

template<typename T >
Complex<T> Linear::Sqrt ( x)

Computes the square root of a real number \(x\).

If \(x<0\) it returns the complex number \(\sqrt{|x|}i\).

Parameters
xReal number.
Returns
Complex number.

◆ SubMatrix() [1/2]

template<size_t P, size_t Q, typename T , size_t M, size_t N, unsigned int Flags>
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);
Parameters
AMxN matrix
iRow offset (default = 0)
jColumn offset (default = 0)
Returns
PxQ submatrix of A

◆ SubMatrix() [2/2]

template<typename T , size_t M, size_t N, unsigned int Flags>
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);
Parameters
AMxN matrix
nrowsNumber of rows in submatrix
ncolsNumber of columns in submatrix
iRow offset (default = 0)
jColumn offset (default = 0)
Returns
nrowsxncols submatrix of A

◆ SubVector() [1/6]

template<size_t P, typename T , size_t N>
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);
Parameters
PLength for subvector
vRow vector of size N
offOffset to start the subvector (default = 0)
Returns
Row vector of size P

◆ SubVector() [2/6]

template<typename T , size_t N>
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);
Parameters
vRow vector of size N
sizeLength for subvector
offOffset to start the subvector (default = 0)
Returns
Row vector of size size

◆ SubVector() [3/6]

template<size_t P, typename T >
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);
Parameters
PLength for subvector
vVector of length 1
offOffset to start the subvector (default = 0)
Returns
v

◆ SubVector() [4/6]

template<typename T >
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);
Parameters
vRow vector of size 1
sizeSize for subvector
offOffset to start the subvector (default = 0)
Returns
v

◆ SubVector() [5/6]

template<size_t P, typename T , size_t N>
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);
Parameters
PLength for subvector
vColumn vector of size N
offOffset to start the subvector (default = 0)
Returns
Column vector of size P

◆ SubVector() [6/6]

template<typename T , size_t N>
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);
Parameters
vColumn vector of size N
sizeLength for subvector
offOffset to start the subvector (default 0)
Returns
Column vector of size size

◆ Tan() [1/3]

template<typename T >
Complex<T> Linear::Tan ( const Complex< T > &  z)

Returns the complex number \(\tan z=\frac{1}{i}\left(\frac{e^{2iz}-1}{e^{2iz}+1}\right)\).

Parameters
zComplex number.
Returns
Complex number.

◆ Tan() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Tan ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\tan a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ Tan() [3/3]

template<typename T >
T Linear::Tan ( x)

Returns the real number \(\tan x\).

Parameters
xReal number.
Returns
Real number.

◆ Tanh() [1/3]

template<typename T >
Complex<T> Linear::Tanh ( const Complex< T > &  z)

Returns the complex number \(\tanh z=\frac{e^z-e^{-z}}{e^z+e^{-z}}\).

Parameters
zComplex number.
Returns
Complex number.

◆ Tanh() [2/3]

template<typename T , size_t M, size_t N, unsigned int Flags>
Matrix<T,M,N,Flags> Linear::Tanh ( Matrix< T, M, N, Flags >  A)

Computes the MxN Matrix $B $ defined by $b_{ij}=\tanh a_{ij} $.

Parameters
AMxN Matrix
Returns
MxN Matrix

◆ Tanh() [3/3]

template<typename T >
T Linear::Tanh ( x)

Returns the real number \(\tanh x\).

Parameters
xReal number.
Returns
Real number.

◆ Trace()

template<typename T , size_t M, size_t N, unsigned int Flags>
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.

Parameters
AMxN matrix
Returns
Complex number

◆ Translation()

template<typename T , size_t N, unsigned int Flags = 0>
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}. \]

Parameters
FlagsFlags to pass to the matrix (default = row major)
tVector of length N
Returns
(N+1)x(N+1) Matrix

◆ Transpose()

template<typename T , size_t M, size_t N, unsigned int Flags>
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}\).

Parameters
AMxN matrix
Returns
NxM matrix

◆ VietaFormulaHelper()

template<typename T , size_t N>
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 
)

◆ WielandtDeflationAlgorithm()

template<typename T , size_t M, size_t N, unsigned int Flags>
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.

Parameters
AMxN matrix
max_iterationsMaximum number of iterations to perform for each call of PowerIteration
Returns
Column vector of eigenvalues.

◆ Zero() [1/2]

template<typename T , size_t M, size_t N, unsigned int Flags = 0>
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>();
Parameters
TType
MNumber of rows
NNumber of columns
FlagsFlags to pass to the matrix (default = row major)
Returns
MxN Matrix

◆ Zero() [2/2]

template<typename T , unsigned int Flags = 0>
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);
Parameters
TType
FlagsFlags to pass to the matrix (default = row major)
nrowsNumber of rows
ncolsNumber of columns
Returns
nrowsxncols Matrix

Variable Documentation

◆ ColumnMajor

const unsigned int Linear::ColumnMajor = 0x0001

◆ Dynamic

const unsigned int Linear::Dynamic = 0

◆ random_number_generator

std::mt19937 Linear::random_number_generator

◆ RowMajor

const unsigned int Linear::RowMajor = 0x0000

◆ Tol

double Linear::Tol = 0.00001