473,513 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use Determinant Function

1 New Member
Hi Everybody,
I am doing some project in VB6 where I ahve to calculate the Determinant of the matrix. I have got a function MDETERM but not able to pass on the parameters of the matrix and get the result. Can any body tell me how to get the result of this. I am using a 3x3 matrix.

Code with example is highly appriciated......
Feb 8 '07 #1
1 5608
iburyak
1,017 Recognized Expert Top Contributor
Have a look on the following forum:

http://forums.ni.com/ni/board/message?board.id=170&message.id=57289&requireLogin =False

Hope this helps.

Also I found this code. It is not mine.... :)

[PHP]

'************************************************* ************************************
'
'Matrice Determinant Calculation Code By Adam Ilan 2/11/1999
' adam_ilan@hotmail.com
'************************************************* ************************************

'Test subroutine for the functions
Private Sub Test()
Dim B(1 To 3, 1 To 3) As Double
Dim mB() As Double
Dim m(1 To 1, 1 To 1) As Double
m(1, 1) = 45
Debug.Print GetDeterminant(m)
B(1, 1) = 1.2
B(1, 2) = 2.3
B(1, 3) = 3.2
B(2, 1) = 4.8
B(2, 2) = 5.2
B(2, 3) = 6
B(3, 1) = 7
B(3, 2) = 6
PrintMatrix B
Debug.Print
mB = GetMinorM(B, 2, 2)
PrintMatrix mB
Debug.Print "Determinant of B:" & GetDeterminant(B)
Debug.Print "Determinant of mB:" & GetDeterminant(mB)
End Sub

'************************************************* ************************************
' Purpose: This Function gets a Square matrice of any size, and returns its Determinant
' How: The function is a recursive function, it uses GetMinorM to get the Minor
' Matrice of the first row's limbs and then calls itself to calculate
' the Minor's Determinant
'************************************************* ************************************
Public Function GetDeterminant(Matrix() As Double) As Double
Dim SizeX As Integer, SizeY As Integer
Dim LboundX As Integer, LboundY As Integer
Dim x As Integer, Det As Double
Dim MinorM() As Double
LboundX = LBound(Matrix, 1)
LboundY = LBound(Matrix, 2)
SizeX = UBound(Matrix, 1) - LboundX + 1
SizeY = UBound(Matrix, 2) - LboundY + 1
If SizeX <> SizeY Then
GetDeterminant = 0
Exit Function
End If
If SizeX = 1 Then
GetDeterminant = Matrix(LboundX, LboundY)
Exit Function
End If

For x = LboundX To LboundX + SizeX - 1
MinorM = GetMinorM(Matrix, x, LboundY)
Det = Det + ((-1) ^ (x - LBound(Matrix, LboundY))) * Matrix(x, LboundY) * GetDeterminant(MinorM)
Next x
GetDeterminant = Det





End Function

'************************************************* ************************************
'Purpose: Extracts The (MinorX,MinorY) minor matrice of Matrix()
'************************************************* ************************************
Public Function GetMinorM(Matrix() As Double, MinorX As Integer, MinorY As Integer) As Double()
Dim SizeX As Integer, SizeY As Integer
Dim x As Integer, y As Integer
Dim i As Integer, j As Integer
Dim MinorM() As Double
SizeX = UBound(Matrix, 1) - LBound(Matrix, 1) + 1
SizeY = UBound(Matrix, 2) - LBound(Matrix, 2) + 1
If SizeX <> SizeY Then
Exit Function
End If

ReDim MinorM(LBound(Matrix, 1) To UBound(Matrix, 1) - 1, LBound(Matrix, 2) To UBound(Matrix, 2) - 1)
i = LBound(Matrix, 1)

For x = LBound(Matrix, 1) To UBound(Matrix, 1)
If x <> MinorX Then
j = LBound(Matrix, 2)
For y = LBound(Matrix, 2) To UBound(Matrix, 2)
If y <> MinorY Then
MinorM(i, j) = Matrix(x, y)
j = j + 1
End If
Next y
i = i + 1
End If
Next x

GetMinorM = MinorM


End Function

'Prints a matrice to the debug window
Public Sub PrintMatrix(Matrix() As Double)
Dim x As Integer, y As Integer
For x = LBound(Matrix, 1) To UBound(Matrix, 1)
For y = LBound(Matrix, 2) To UBound(Matrix, 2)
Debug.Print Format(Matrix(x, y), "00.0") & " , ";
Next y
Debug.Print
Next x
End Sub[/PHP]
Feb 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
14909
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
4
8877
by: Tuvas | last post by:
I am trying to find a nice function that quickly determines the determanant in python. Anyone have any recommendations? I've heard about numpy, but I can't get it to work (It doesn't seem to like...
2
10593
by: aruna | last post by:
i want a c program to find the determinant of matrix and inverse of matrix as two separate c programs . please help me
1
3306
by: naren | last post by:
can anyone help with the code for determinant,cofactor and inverse of a matrix in c++ lang? i am not getting the logic.....
14
7096
by: James Stroud | last post by:
Hello All, I'm using numpy to calculate determinants of matrices that look like this (13x13):
2
4022
by: pvsgangadhar | last post by:
I need the program in c-langauge to find the determinant of a matrix for specified no.or rows and columns.
29
13830
by: curiously enough | last post by:
I am having trouble making this recursive C function work for square matrices of size greater than 3 rows and columns. #include<stdio.h> #include<conio.h> #include<math.h> int M; float...
1
4437
by: haderika | last post by:
Hey, I'm having trouble overloading the ~ operator (the determinant of the matrix) in a case of 2x2 matrices. So i have a matrix class, with the constructor, overloading +, += and ~ operators. the...
0
7259
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7380
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7523
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5085
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.