Gaussian with Scaled Partial Pivoting

aabc
Last edited on
If you want to do the partial pivoting, you need to SWAP the row (rmax) that has the largest absolute element in that column with the current row (k).

You have (nearly) correctly identified rmax (smax needs to be set to the absolute value of the matrix element, which could be negative). However, I see no evidence of you doing any swapping of rows.

You are also going to run into floating-point round-off problems if you compare a calculated value with 0 to test for singularity (and return the rank).
I just added the swap function. What next should I do?
smax = matrix[i][k];
should be
smax = abs( matrix[i][k] );



What next should I do?

Show us the whole code and an input file so that we can test it.



I repeat: the following is not a good test - it is subject to floating-point round-off error. If you want the matrix rank you need a small tolerance to compare for near-zero.
1
2
		if (!matrix[rmax][k])
			return k; 
Last edited on
thanhquan1704 wrote:
I'm gonna write main function later ....
then what shoud I do next?


That is not how to write code. You should develop it slowly, testing it as you go along.

That means, in this instance, you need to have your main function (and an input routine, and an input file) so that we can test it.
Topic archived. No new replies allowed.