# 11.9. Linear Algebra

AuxilliaryUnitMatrix
`AuxilliaryUnitMatrix (n)`

Get the auxilliary unit matrix of size `n`. This is a square matrix matrix with that is all zero except the superdiagonal being all ones. It is the Jordan block matrix of one zero eigenvalue.

BilinearForm
`BilinearForm (v,A,w)`

Evaluate (v,w) with respect to the bilinear form given by the matrix A.

BilinearFormFunction
`BilinearFormFunction (A)`

Return a function that evaluates two vectors with respect to the bilinear form given by A.

CharacteristicPolynomial
`CharacteristicPolynomial (M)`

Aliases: `CharPoly`

Get the characteristic polynomial as a vector.

CharacteristicPolynomialFunction
`CharacteristicPolynomialFunction (M)`

Get the characteristic polynomial as a function.

ColumnSpace
`ColumnSpace (M)`

Get a basis matrix for the columnspace of a matrix.

CommutationMatrix
`CommutationMatrix (m, n)`

Return the commutation matrix K(m,n) which is the unique m*n by m*n matrix such that K(m,n) * MakeVector(A) = MakeVector(A.') for all m by n matrices A.

CompanionMatrix
`CompanionMatrix (p)`

Companion matrix of a polynomial (as vector).

ConjugateTranspose
`ConjugateTranspose (M)`

Conjugate transpose of a matrix (adjoint). This is the same as the ' operator.

Convolution
`Convolution (a,b)`

Aliases: `convol`

Calculate convolution of two horizontal vectors.

ConvolutionVector
`ConvolutionVector (a,b)`

Calculate convolution of two horizontal vectors.

CrossProduct
`CrossProduct (v,w)`

CrossProduct of two vectors in R3.

DeterminantalDivisorsInteger
`DeterminantalDivisorsInteger (M)`

Get the determinantal divisors of an integer matrix (not its characteristic).

DirectSum
`DirectSum (M,N...)`

Direct sum of matrices.

DirectSumMatrixVector
`DirectSumMatrixVector (v)`

Direct sum of a vector of matrices.

Eigenvalues
`Eigenvalues (M)`

Aliases: `eig`

Get the eigenvalues of a square matrix. Currently only works for matrices of size up to 4 by 4, or for triangular matrices (for which the eigenvalues are on the diagonal).

GramSchmidt
`GramSchmidt (v,B...)`

Apply the Gram-Schmidt process (to the columns) with respect to inner product given by `B`. If `B` is not given then the standard hermitian product is used. `B` can either be a sesquilinear function of two arguments or it can be a matrix giving a sesquilinear form. The vectors will be made orthonormal with respect to `B`.

HankelMatrix
`HankelMatrix (c,r)`

Hankel matrix.

HilbertMatrix
`HilbertMatrix (n)`

Hilbert matrix of order `n`.

Image
`Image (T)`

Get the image (columnspace) of a linear transform.

InfNorm
`InfNorm (v)`

Get the Inf Norm of a vector, sometimes called the sup norm or the max norm.

InvariantFactorsInteger
`InvariantFactorsInteger (M)`

Get the invariant factors of a square integer matrix (not its characteristic).

InverseHilbertMatrix
`InverseHilbertMatrix (n)`

Inverse Hilbert matrix of order `n`.

IsHermitian
`IsHermitian (M)`

Is a matrix hermitian. That is, is it equal to its conjugate transpose.

IsInSubspace
`IsInSubspace (v,W)`

Test if a vector is in a subspace.

IsInvertible
`IsInvertible (n)`

Is a matrix (or number) invertible (Integer matrix is invertible iff it's invertible over the integers).

IsInvertibleField
`IsInvertibleField (n)`

Is a matrix (or number) invertible over a field.

IsNormal
`IsNormal (M)`

Is `M` a normal matrix. That is, does M*M' == M'*M.

IsPositiveDefinite
`IsPositiveDefinite (M)`

Is `M` a hermitian positive definite matrix. That is if HermitianProduct(M*v,v) is always strictly positive for any vector `v`. `M` must be square and hermitian to be positive definite. The check that is performed is that every principal submatrix has a nonnegative determinant. (See HermitianProduct)

Note that some authors (for example Mathworld) do not require that `M` be hermitian, and then the condition is on the real part of the inner product, but we do not take this view. If you wish to perform this check, just check the hermitian part of the matrix `M` as follows: IsPositiveDefinite(M+M').

IsPositiveSemidefinite
`IsPositiveSemidefinite (M)`

Is `M` a hermitian positive semidefinite matrix. That is if HermitianProduct(M*v,v) is always nonnegative for any vector `v`. `M` must be square and hermitian to be positive semidefinite. The check that is performed is that every principal submatrix has a nonnegative determinant. (See HermitianProduct)

Note that some authors do not require that `M` be hermitian, and then the condition is on the real part of the inner product, but we do not take this view. If you wish to perform this check, just check the hermitian part of the matrix `M` as follows: IsPositiveSemidefinite(M+M').

IsSkewHermitian
`IsSkewHermitian (M)`

Is a matrix skew-hermitian. That is, is the conjugate transpose equal to negative of the matrix.

IsUnitary
`IsUnitary (M)`

Is a matrix unitary? That is, does M'*M and M*M' equal the identity.

JordanBlock
`JordanBlock (n,lambda)`

Aliases: `J`

Get the Jordan block corresponding to the eigenvalue `lambda` with multiplicity `n`.

Kernel
`Kernel (T)`

Get the kernel (nullspace) of a linear transform.

(See NullSpace)

LUDecomposition
`LUDecomposition (A, L, U)`

Get the LU decomposition of `A` and store the result in the `L` and `U` which should be references. It returns true if successful. For example suppose that A is a square matrix, then after running:

```genius> LUDecomposition(A,&L,&U)
```
You will have the lower matrix stored in a variable called `L` and the upper matrix in a variable called `U`.

This is the LU decomposition of a matrix aka Crout and/or Cholesky reduction. (ISBN 0-201-11577-8 pp.99-103) The upper triangular matrix features a diagonal of values 1 (one). This is not Doolittle's Method which features the 1's diagonal on the lower matrix.

Not all matrices have LU decompositions, for example [0,1;1,0] does not and this function returns false in this case and sets `L` and `U` to null.

Minor
`Minor (M,i,j)`

Get the `i`-`j` minor of a matrix.

NonPivotColumns
`NonPivotColumns (M)`

Return the columns that are not the pivot columns of a matrix.

Norm
`Norm (v,p...)`

Aliases: `norm`

Get the p Norm (or 2 Norm if no p is supplied) of a vector.

NullSpace
`NullSpace (T)`

Get the nullspace of a matrix. That is the kernel of the linear mapping that the matrix represents. This is returned as a matrix whose column space is the nullspace of `T`.

Nullity
`Nullity (M)`

Aliases: `nullity`

Get the nullity of a matrix.

OrthogonalComplement
`OrthogonalComplement (M)`

Get the orthogonal complement of the columnspace.

PivotColumns
`PivotColumns (M)`

Return pivot columns of a matrix, that is columns which have a leading 1 in row reduced form. Also returns the row where they occur.

Projection
`Projection (v,W,B...)`

Projection of vector `v` onto subspace `W` with respect to inner product given by `B`. If `B` is not given then the standard hermitian product is used. `B` can either be a sesquilinear function of two arguments or it can be a matrix giving a sesquilinear form.

QRDecomposition
`QRDecomposition (A, Q)`

Get the QR decomposition of a square matrix `A`, returns the upper triangular matrix `R` and sets `Q` to the orthogonal (unitary) matrix. `Q` should be a reference or null if you don't want any return. For example:

```genius> R = QRDecomposition(A,&Q)
```
You will have the upper triangular matrix stored in a variable called `R` and the orthogonal (unitary) matrix stored in `Q`.

RayleighQuotient
`RayleighQuotient (A,x)`

Return the Rayleigh quotient (also called the Rayleigh-Ritz quotient or ratio) of a matrix and a vector.

RayleighQuotientIteration
`RayleighQuotientIteration (A,x,epsilon,maxiter,vecref)`

Find eigenvalues of `A` using the Rayleigh quotient iteration method. `x` is a guess at a eigenvector and could be random. It should have nonzero imaginary part if it will have any chance at finding complex eigenvalues. The code will run at most `maxiter` iterations and return null if we cannot get within an error of `epsilon`. `vecref` should either be null or a reference to a variable where the eigenvector should be stored.

Rank
`Rank (M)`

Aliases: `rank`

Get the rank of a matrix.

RosserMatrix
`RosserMatrix ()`

Rosser matrix, a classic symmetric eigenvalue test problem.

Rotation2D
`Rotation2D (angle)`

Aliases: `RotationMatrix`

Rotation around origin in R2.

Rotation3DX
`Rotation3DX (angle)`

Rotation around origin in R3 about the x-axis.

Rotation3DY
`Rotation3DY (angle)`

Rotation around origin in R3 about the y-axis.

Rotation3DZ
`Rotation3DZ (angle)`

Rotation around origin in R3 about the z-axis.

RowSpace
`RowSpace (M)`

Get a basis matrix for the rowspace of a matrix.

SesquilinearForm
`SesquilinearForm (v,A,w)`

Evaluate (v,w) with respect to the sesquilinear form given by the matrix A.

SesquilinearFormFunction
`SesquilinearFormFunction (A)`

Return a function that evaluates two vectors with respect to the sesquilinear form given by A.

SmithNormalFormField
`SmithNormalFormField (A)`

Smith Normal Form for fields (will end up with 1's on the diagonal).

SmithNormalFormInteger
`SmithNormalFormInteger (M)`

Smith Normal Form for square integer matrices (not its characteristic).

SolveLinearSystem
`SolveLinearSystem (M,V,args...)`

Solve linear system Mx=V, return solution V if there is a unique solution, null otherwise. Extra two reference parameters can optionally be used to get the reduced M and V.

ToeplitzMatrix
`ToeplitzMatrix (c, r...)`

Return the Toeplitz matrix constructed given the first column c and (optionally) the first row r. If only the column c is given then it is conjugated and the nonconjugated version is used for the first row to give a Hermitian matrix (if the first element is real of course).

Trace
`Trace (m)`

Aliases: `trace`

Calculate the trace of a matrix.

Transpose
`Transpose (M)`

Transpose of a matrix. This is the same as the .' operator.

VandermondeMatrix
`VandermondeMatrix (v)`

Aliases: `vander`

Return the Vandermonde matrix.

VectorAngle
`VectorAngle (v,w,B...)`

The angle of two vectors with respect to inner product given by `B`. If `B` is not given then the standard hermitian product is used. `B` can either be a sesquilinear function of two arguments or it can be a matrix giving a sesquilinear form.

VectorSpaceDirectSum
`VectorSpaceDirectSum (M,N)`

The direct sum of the vector spaces M and N.

VectorSubspaceIntersection
`VectorSubspaceIntersection (M,N)`

Intersection of the subspaces given by M and N.

VectorSubspaceSum
`VectorSubspaceSum (M,N)`

The sum of the vector spaces M and N, that is {w | w=m+n, m in M, n in N}.

`adj (m)`

Aliases: `Adjugate`

cref
`cref (M)`

Aliases: `CREF` `ColumnReducedEchelonForm`

Compute the Column Reduced Echelon Form.

det
`det (M)`

Aliases: `Determinant`

Get the determinant of a matrix.

ref
`ref (M)`

Aliases: `REF` `RowEchelonForm`

Get the row echelon form of a matrix.

`rref (M)`
Aliases: `RREF` `ReducedRowEchelonForm`