Octave Programming Tutorial/Linear algebra
Functions
d = det(A)computes the determinant of the matrix A.lambda = eig(A)returns the eigenvalues ofAin the vectorlambda, and[V, lambda] = eig(A)also returns the eigenvectors inVbutlambdais now a matrix whose diagonals contain the eigenvalues. This relationship holds true (within round off errors)A = V*lambda*inv(V).inv(A)computes the inverse of non-singular matrix A. Note that calculating the inverse is often 'not' necessary. See the next two operators as examples. Note that in theoryA*inv(A)should return the identity matrix, but in practice, there may be some round off errors so the result may not be exact.A / Bcomputes X such that . This is called right division and is done without forming the inverse of B.A \ Bcomputes X such that . This is called left division and is done without forming the inverse of A.norm(A, p)computes the p-norm of the matrix (or vector) A. The second argument is optional with default value .rank(A)computes the (numerical) rank of a matrix.trace(A)computes the trace (sum of the diagonal elements) of A.expm(A)computes the matrix exponential of a square matrix. This is defined as
logm(A)computes the matrix logarithm of a square matrix.sqrtm(A)computes the matrix square root of a square matrix.
Below are some more linear algebra functions. Use help to find out more about them.
balance(eigenvalue balancing),cond(condition number),dmult(computes diag(x) * A efficiently),dot(dot product),givens(Givens rotation),kron(Kronecker product),null(orthonormal basis of the null space),orth(orthonormal basis of the range space),pinv(pseudoinverse),syl(solves the Sylvester equation).
Factorizations
R = chol(A)computes the Cholesky factorization of the symmetric positive definite matrix A, i.e. the upper triangular matrix R such that .[L, U] = lu(A)computes the LU decomposition of A, i.e. L is lower triangular, U upper triangular and .[Q, R] = qr(A)computes the QR decomposition of A, i.e. Q is orthogonal, R is upper triangular and .
Below are some more available factorizations. Use help to find out more about them.
qz(generalized eigenvalue problem: QZ decomposition),qzhess(Hessenberg-triangular decomposition),schur(Schur decomposition),svd(singular value decomposition),housh(Householder reflections),krylov(Orthogonal basis of block Krylov subspace).
Return to the Octave Programming Tutorial index