This project has moved and is read-only. For the latest updates, please go here.

Having trouble w/ determinant in matrix feature

Nov 14, 2011 at 1:41 AM
Edited Nov 14, 2011 at 1:56 AM

Hello,

I'm having trouble with the following code.  Finding the determinant of sqMat using the method below returns a -12, however, I believe the result should be 3 (or maybe -3).  I struggle with math.  Any help is greatly appreciated. 

 

 

       Dim sqMat As New SquareMatrix(3)
        Dim vec1, vec2 As New ColumnVector(3)
        Dim lu As SquareLUDecomposition
        Dim smallestValue, det As Double
 
        sqMat(0, 0) = 3
        sqMat(0, 1) = 0
        sqMat(0, 2) = 0
        sqMat(1, 0) = 8
        sqMat(1, 1) = 0
        sqMat(1, 2) = 2
        sqMat(2, 0) = 0
        sqMat(2, 1) = 2
        sqMat(2, 2) = 1
 
        vec1(0) = 1
        vec1(1) = 0
        vec1(2) = 2
 
        lu = sqMat.LUDecomposition()
        vec2 = lu.Solve(vec1)
        det = lu.Determinant
Nov 15, 2011 at 2:01 AM

Never mind.  I see now it is calculating it correctly.  I'm setting the equations up incorrectly.