HP Forums

Full Version: Gauss-Jordan Elimination Method
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
HP Prime: Gauss-Jordan Elimination Method

Program:
Code:
EXPORT GAUSSJORDAN(mat)
BEGIN
// Guass-Jordan Elimination
// 2015-12-04
// Matrix MUST have
// mat[k,k]≠0

LOCAL l,r,c,j,k,h,v;
PRINT();

l:=SIZE(mat);
r:=l[1]; c:=l[2];
j:=1;

// Main row loop
FOR k FROM 1 TO r DO

// Secondary row loop
FOR h FROM 1 TO r DO

// k = target row
// h = test row
// Pivot operation
IF h≠k THEN
v:=−mat[h,k]/mat[k,k];
mat:=SCALEADD(mat,v,k,h);
PRINT();
PRINT("After Step "+j);
PRINT(mat);
WAIT(0);
j:=j+1;
END;

IF mat[k,k]≠1 THEN
v:=1/mat[k,k];
mat:=SCALE(mat,v,k);
PRINT();
PRINT("After Step "+j);
PRINT(mat);
WAIT(0);
j:=j+1;
END;

END;
END;

PRINT();
PRINT("Result:");
PRINT(mat);

// Final WAIT not needed

RETURN mat;
END;

Blog entry and detail: http://edspi31415.blogspot.com/2015/12/h...ethod.html
Reference URL's