Navigation

Operators and Keywords

Function List:

C++ API

: type = matrix_type (A)
: type = matrix_type (A, "nocompute")
: A = matrix_type (A, type)
: A = matrix_type (A, "upper", perm)
: A = matrix_type (A, "lower", perm)
: A = matrix_type (A, "banded", nl, nu)

Identify the matrix type or mark a matrix as a particular type.

This allows more rapid solutions of linear equations involving A to be performed.

Called with a single argument, matrix_type returns the type of the matrix and caches it for future use.

Called with more than one argument, matrix_type allows the type of the matrix to be defined.

If the option "nocompute" is given, the function will not attempt to guess the type if it is still unknown. This is useful for debugging purposes.

The possible matrix types depend on whether the matrix is full or sparse, and can be one of the following

"unknown"

Remove any previously cached matrix type, and mark type as unknown.

"full"

Mark the matrix as full.

"positive definite"

Probable full positive definite matrix.

"diagonal"

Diagonal matrix. (Sparse matrices only)

"permuted diagonal"

Permuted Diagonal matrix. The permutation does not need to be specifically indicated, as the structure of the matrix explicitly gives this. (Sparse matrices only)

"upper"

Upper triangular. If the optional third argument perm is given, the matrix is assumed to be a permuted upper triangular with the permutations defined by the vector perm.

"lower"

Lower triangular. If the optional third argument perm is given, the matrix is assumed to be a permuted lower triangular with the permutations defined by the vector perm.

"banded"
"banded positive definite"

Banded matrix with the band size of nl below the diagonal and nu above it. If nl and nu are 1, then the matrix is tridiagonal and treated with specialized code. In addition the matrix can be marked as probably a positive definite. (Sparse matrices only)

"singular"

The matrix is assumed to be singular and will be treated with a minimum norm solution.

Note that the matrix type will be discovered automatically on the first attempt to solve a linear equation involving A. Therefore matrix_type is only useful to give Octave hints of the matrix type. Incorrectly defining the matrix type will result in incorrect results from solutions of linear equations; it is entirely the responsibility of the user to correctly identify the matrix type.

Also, the test for positive definiteness is a low-cost test for a Hermitian matrix with a real positive diagonal. This does not guarantee that the matrix is positive definite, but only that it is a probable candidate. When such a matrix is factorized, a Cholesky factorization is first attempted, and if that fails the matrix is then treated with an LU factorization. Once the matrix has been factorized, matrix_type will return the correct classification of the matrix.

Package: octave