Talk:Vectors and matrices

From DmWiki

Inverse matrix algorithm not correct

I used the inverse matrix algorithm in a program of mine, and found out it doesn't function correct. The problem is that it is possible that a row that has already been the pivot row can be used again as pivot row. This causes non zero elements in a column that should consist of a 1 and all zeros in matrix a. (the 1 came from the row that was pivot row before). I fixed it by altering the pivot selection loop:

Original:

  for (pivot = 0, i = 1; i < 4; ++i)
 			

My version:

  for (pivot = j, i = j; i < 4; ++i)

In the algorithm rows that get selected get put in row j, so rows 0..j have already been processed. And by starting from j, they are left alone. After reading the Gaussian elimination (http://en.wikipedia.org/wiki/Gaussian_elimination) page on wikipedia, I'm pretty confident I'm right about this.

You are. I just arrived at the same conclusion, except for a detail - i=j+1 :) Changing the page. FeepingCreature 12:49, 7 Aug 2008 (CDT)

Oops - stupid me. Of course, i=j. Putting a min(j+1, 3) call here would be correct, but probably slower. FeepingCreature 12:53, 7 Aug 2008 (CDT)

DevMaster navigation