<< Linear System of Equations Linear System of Equations lsqod >>

sci_gsl >> sci_gsl > Linear System of Equations > linsys

linsys

Solution of linear system of equations Ax=b using LU decomposition, QR decomposition and Householder solver.

Syntax

y = linsys(A,b,c)

Parameters

y:

output Array containing the solution of linear system of equations.

b:

Array of real or integer constant term presents in the equations on RHS.

A:

Array containing the real or integer coefficients of unknowns in the equations. The number of elements in A must be equal to the square of elements in array b. e.g. if number of elements in b is n then number of elements in A must be equal to n^2.

c = 1:

Solve system of linear equations using LU decompositon method. This function factorize the matrix A into the LU decomposition PA=LU. On output the diagonal and upper triangular (or trapezoidal) part of the input matrix A contain the matrix U . The lower triangular (or trapezoidal) part of the input matrix (excluding the diagonal) contains L. The diagonal elements of L are unity, and are not stored.

c = 2:

Solve system of linear equations using QR decompositon method. This function factorizes the A into the QR decomposition A = QR. On output the diagonal and upper triangular part of the input matrix contain the matrix R. The columns of the lower triangular part of the matrix A contain the Householder vectors which encode the orthogonal matrix Q.

c >=3:

Solve system of linear equations using Householder transformations. The matrix A is destroyed by the Householder transformations.

Description

This function is used to solve linear system of equations Ax=b using LU decomposition, QR decomposition and Householder solver.

Examples

// Solve the linear system of equations 2p+q+r=-1, 3p+2q+r=-12, p+4q+5r=-5 using LU decomposition method
A=[2 1 1 3 2 1 1 4 5]
b=[-1 -12 -5]
c=1
y = linsys(A,b,c)
disp(y)

Authors


Report an issue
<< Linear System of Equations Linear System of Equations lsqod >>