# ge5 - ** ** Purpose: ** Eliminate all elements in column k...

This preview shows pages 1–2. Sign up to view the full content.

/* ** GE0 ** ** Purpose: ** Gauss elimination, find upper triangular matrix ** ** Date: ** 6/8/09 ** ** Version: ** 0 Start program, prepare the extended matrix ** 1 Eliminate one row ** 2 Introduce a loop, over rows ** 3 Introduce a function ** 4 Do multiple columns ** 5 Use function for columns ** ** Author: ** Charles Bos */ #include <oxstd.h> /* ** EliminateRow(const amAB, const j, const k) ** ** Purpose: ** Eliminate element j of column k ** ** Inputs: ** amAB address of iK x iK+1 extended matrix ** j integer, row number ** k integer, pivot/column number ** ** Outputs: ** amAB address of iK x iK+1 extended matrix, with zero ** at element (j,k) ** ** Return value: ** TRUE if pivot not zero */ EliminateRow(const amAB, const j, const k) { decl dF, ir; ir= amAB[0][k][k] == 0; dF= amAB[0][j][k] / amAB[0][k][k]; println ("Multiplicity is ", dF); amAB[0][j][]= amAB[0][j][] - dF * amAB[0][k][]; return !ir; } /* ** EliminateColumn(const amAB, const k)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ** ** Purpose: ** Eliminate all elements in column k below pivot ** ** Inputs: ** amAB address of iK x iK+1 extended matrix ** k integer, pivot/column number ** ** Outputs: ** amAB address of iK x iK+1 extended matrix, with zeros ** at elements (k+1,k), . .., (iK-1,k) ** ** Return value: ** TRUE if ??? */ EliminateColumn(const amAB, const k) { decl j, iK, ir; iK= rows(amAB[0]); for (j= k+1; j &lt; iK; ++j) { // Eliminate element j,k ir= EliminateRow(amAB, j, k); } print (&quot;Extended matrix mAB after elimination step &quot;, k, &quot; is: &quot;, amAB[0]); return ir; } main() { decl mA, vB, mAB, dF, iK, k, j; mA= &lt; 6, -2, 2, 4; 12, -8, 6, 10; 3, -13, 9, 3; -6, 4, 1, -18&gt;; vB= &lt;16; 26; -19; -34&gt;; mAB= mA~vB; print (&quot;Extended matrix mAB is: &quot;, mAB); // Get the number of rows iK= rows(mAB); // Indicate the pivot number for (k= 0; k &lt; iK-1; ++k) EliminateColumn(&amp;mAB, k); }...
View Full Document

## This note was uploaded on 05/28/2010 for the course ECONOMIC FM407 taught by Professor Kimcj during the Spring '04 term at 카이스트, 한국과학기술원.

### Page1 / 2

ge5 - ** ** Purpose: ** Eliminate all elements in column k...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online