<< linalg_factorlupivot linalg linalg_gausspivotal >>

linalg >> linalg > linalg_gaussnaive

linalg_gaussnaive

Solves a linear equation by Gauss method and no pivoting.

Calling Sequence

x = linalg_gaussnaive ( A , b )
x = linalg_gaussnaive ( A , b , verbose )

Parameters

A :

a n-by-n matrix of doubles

b :

a n-by-1 matrix of doubles

verbose :

a 1-by-1 matrix of boolean (default verbose = %f), set to true to display intermediate messages

x :

a n-by-1 matrix of doubles

Description

Returns the solution of Ax = b with a Gauss elimination and no pivoting. This algorithm might be inaccurate if A near singular. There is no solution is A is singular. Moreover, it might inaccurate even if A is correctly conditionned. Uses a naive algorithm with all loops expanded (no vectorization).

Examples

A = [
3 17 10
2 4 -2
6 18 -12
];
b = [
67
4
6
];
x = linalg_gaussnaive ( A , b )
xe = [1 2 3]'
// See what happens
x = linalg_gaussnaive ( A , b , %t )

// A failure case : pivoting is necessary
A = [
2 * %eps 1
1     1
];
xe = [1/10 1/3]'
b = A * xe;
x = linalg_gaussnaive ( A , b )

// See the algorithm
edit linalg_gaussnaive

Authors


Report an issue
<< linalg_factorlupivot linalg linalg_gausspivotal >>