Navigation

Operators and Keywords

Function List:

C++ API

: x = linsolve (A, b)
: x = linsolve (A, b, opts)
: [x, R] = linsolve (…)

Solve the linear system A*x = b.

With no options, this function is equivalent to the left division operator (x = A \ b) or the matrix-left-divide function (x = mldivide (A, b)).

Octave ordinarily examines the properties of the matrix A and chooses a solver that best matches the matrix. By passing a structure opts to linsolve you can inform Octave directly about the matrix A. In this case Octave will skip the matrix examination and proceed directly to solving the linear system.

Warning: If the matrix A does not have the properties listed in the opts structure then the result will not be accurate AND no warning will be given. When in doubt, let Octave examine the matrix and choose the appropriate solver as this step takes little time and the result is cached so that it is only done once per linear system.

Possible opts fields (set value to true/false):

LT

A is lower triangular

UT

A is upper triangular

UHESS

A is upper Hessenberg (currently makes no difference)

SYM

A is symmetric or complex Hermitian (currently makes no difference)

POSDEF

A is positive definite

RECT

A is general rectangular (currently makes no difference)

TRANSA

Solve A'*x = b by transpose (A) \ b

The optional second output R is the inverse condition number of A (zero if matrix is singular).

See also: mldivide, matrix_type, rcond.

Package: octave