|
-
Mar 10th, 2012, 03:10 PM
#1
Thread Starter
Member
5x5 matrix inverse
Hi friends,
I want to ask a question about finding matrix which is type 5x5 inversion. These my code. This was formed by gauss jordan elimination method.
I get overflow error in this line "Dizi(i, j) = Dizi(i, j) / y".
vb Code:
'the variants were defined and assigned
For i = 1 To 5
Dizi(i, i + 5) = 1
Next
For i = 1 To 4
For j = i + 1 To 5
If Dizi(i, i) = 0 Then
For k = i + 1 To 5
If Dizi(k, i) <> 0 Then
For l = 1 To 10
Dizi(i, l) = Dizi(i, l) + Dizi(k, l)
Next l
End If
Next k
End If
w = Dizi(j, i) / Dizi(i, i)
For l = 1 To 10
Dizi(j, l) = Dizi(j, l) - w * Dizi(i, l)
Next l
Next j
Next i
For i = 5 To 2 Step -1
For j = 4 To 1 Step -1
If Dizi(i, i) = 0 Then
For k = i - 1 To 1 Step -1
If Dizi(k, i) <> 0 Then
For l = 1 To 10
Dizi(i, l) = Dizi(i, l) + Dizi(k, l)
Next l
End If
Next k
End If
w = Dizi(j, i) / Dizi(i, i)
For l = 1 To 10
Dizi(j, l) = Dizi(j, l) - w * Dizi(i, l)
Next l
Next j
Next i
For i = 1 To 5
If Dizi(i, i) <> 1 Then y = Dizi(i, i)
For j = 1 To 10
Dizi(i, j) = Dizi(i, j) / y
Next j
Next i
Could you say where the mistake is?
-
Mar 10th, 2012, 04:05 PM
#2
Re: 5x5 matrix inverse
This might be more suited in the Visual Basic 6 and Earlier forum.
What is the value of Y on that line? 0?
'the variants were defined and assigned
Is Y one of those variants? Can you show this bit? Using doubles might be more appropriate for what you are doing.
-
Mar 10th, 2012, 09:37 PM
#3
Re: 5x5 matrix inverse
Your implementation seems very buggy (I tried it with the identity matrix and it broke immediately after zeroing out the 4th and 9th columns for no apparent reason). Rather than writing your own code and debugging it, you should just google "VB6 matrix inverse". This problem has certainly been solved many times; it's not worth anyone's time to solve it again in this case.
The time you enjoy wasting is not wasted time.
Bertrand Russell
<- Remember to rate posts you find helpful.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|