gecko3
Electrical
- Dec 1, 2005
- 3
Hello, I am trying to build a loop that makes a matrix diagnolly dominant (I'm not sure if thats the right term... I mean where the values on the diagnol are from greatest to least... like this
like if I was given this:
2 3 7 8
9 2 3 4
5 9 0 6
3 8 4 3
I would get this:
9 2 3 4
3 8 4 3
2 3 7 8
5 9 0 6
with 9,8,7,6 making this diagnolly dominant.
I was wondering if anyone has any ideas on the simplest way to go about this...
I'm having a hard time thinking on how to approach this, I'm thinking
1) compare the entire first column
2) take the line with the largest first column value and switch
it with first line
3) lock the first line then compare colum 2 in the following 3 lines
put largest value for column 2 line as second line
4) lock the 2nd line check the third column last two lines
if the 3rd line has the larger value switch those as well....
at this point I'm thinking my algorithm is running into trouble...
any suggestions would be greatly appreciated.
Thank You
like if I was given this:
2 3 7 8
9 2 3 4
5 9 0 6
3 8 4 3
I would get this:
9 2 3 4
3 8 4 3
2 3 7 8
5 9 0 6
with 9,8,7,6 making this diagnolly dominant.
I was wondering if anyone has any ideas on the simplest way to go about this...
I'm having a hard time thinking on how to approach this, I'm thinking
1) compare the entire first column
2) take the line with the largest first column value and switch
it with first line
3) lock the first line then compare colum 2 in the following 3 lines
put largest value for column 2 line as second line
4) lock the 2nd line check the third column last two lines
if the 3rd line has the larger value switch those as well....
at this point I'm thinking my algorithm is running into trouble...
any suggestions would be greatly appreciated.
Thank You