Prev Next


Solution of simultaneous linear equations AX = B by Gaussian elimination with partial pivoting.


double A[n*n], B[n], X[n];
int n, flag;
int IPS[];
int simq();
ercode = simq(A, B, X, n, flag, IPS);


B, X, IPS are vectors of length n.
A is an n x n matrix (i.e. a vector of length n*n), stored row-wise; that is, A(i,j) = A[ij], where ij = i*n + j, which is the transpose of the normal column-wise storage.

The contents of matrix A are destroyed.

Set flag=0 to solve.
Set flag=-1 to do a new back substitution for a different B vector using the same A matrix previously reduced when flag=0.

The routine returns nonzero on error; messages are printed.


Depends on the conditioning (range of eigenvalues) of matrix A.


Computer Solution of Linear Algebraic Systems
by George E. Forsythe and Cleve B. Moler; Prentice-Hall, 1967.