|
-
Jan 31st, 2007, 07:25 AM
#1
Thread Starter
Addicted Member
[2005] help understanding how to use this module plz
i want to find the eigenvectors and eigenvalues for a matrix... can someone help me use this module from
VB Code:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This code is generated by the AlgoPascal translator
'
'This code is distributed under the ALGLIB license
' (see [url]http://www.alglib.net/copyrules.php[/url] for details)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This routines must be defined by the programmer
' Function TridiagonalEVD(ByRef D() As Double, _
' ByRef E_() As Double, _
' ByVal N As Long, _
' ByVal ZNeeded As Long, _
' ByRef Z() As Double) As Boolean
' Sub ToTridiagonal(ByRef A() As Double, _
' ByVal N As Long, _
' ByVal IsUpper As Boolean, _
' ByRef Tau() As Double, _
' ByRef D() As Double, _
' ByRef E() As Double)
' Sub UnpackQFromTridiagonal(ByRef A() As Double, _
' ByRef N As Long, _
' ByRef IsUpper As Boolean, _
' ByRef Tau() As Double, _
' ByRef Q() As Double)
'Routines
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Finding the eigenvalues and eigenvectors of a symmetric matrix
'
'The algorithm finds eigen pairs of a symmetric matrix by reducing it to
'tridiagonal form and using the QL/QR algorithm.
'
'Input parameters:
' A - symmetric matrix which is given by its upper or lower
' triangular part.
' Array whose indexes range within [1..N, 1..N].
' N - size of matrix A.
' IsUpper - storage format.
' ZNeeded - flag controlling whether the eigenvectors are needed or not.
' If ZNeeded is equal to:
' * 0, the eigenvectors are not returned;
' * 1, the eigenvectors are returned.
'
'Output parameters:
' D - eigenvalues in ascending order.
' Array whose index ranges within [1..N].
' Z - if ZNeeded is equal to:
' * 0, Z hasn’t changed;
' * 1, Z contains the eigenvectors.
' Array whose indexes range within [1..N, 1..N].
' The eigenvectors are stored in the matrix columns.
'
'Result:
' True, if the algorithm has converged.
' False, if the algorithm hasn't converged (uncommon case).
'
' -- ALGLIB --
' Copyright 2005 by Bochkanov Sergey
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function SymmetricEVD(ByRef A_() As Double, _
ByVal N As Long, _
ByVal ZNeeded As Long, _
ByVal IsUpper As Boolean, _
ByRef D() As Double, _
ByRef Z() As Double) As Boolean
Dim Result As Boolean
Dim A() As Double
Dim Tau() As Double
Dim E() As Double
A = A_
Call ToTridiagonal(A, N, IsUpper, Tau, D, E)
If ZNeeded = 1# Then
Call UnpackQFromTridiagonal(A, N, IsUpper, Tau, Z)
End If
Result = TridiagonalEVD(D, E, N, ZNeeded, Z)
SymmetricEVD = Result
End Function
i got this module from http://www.alglib.net/eigen/symmetric/symmevd.php .. i have add the ap lib module and this module...
i used that code to test the function SymmetricEVD
VB Code:
Private Sub Command1_Click()
Dim mat(0 To 1, 0 To 1), Result(0 To 1, 0 To 1), eigenvect(0 To 1, 0 To 1) As Double
mat(0, 0) = 1
mat(0, 1) = 2
mat(1, 0) = 3
mat(1, 1) = 4
Call SymmetricEVD(mat, 2, 1, True, Result, eigenvect)
End Sub
but i get "type mismatch"
-
Jan 31st, 2007, 07:39 AM
#2
Re: [2005] help understanding how to use this module plz
It would, you have a multi-dimension array being passed to a function that only takes an array
ie:
SymmetricEVD(ByRef A_() As Double Needs a Dim mat (0 to 1) not a mat(0 to 1, 0 to 1). What makes you think you had to do that?
-
Jan 31st, 2007, 07:47 AM
#3
Thread Starter
Addicted Member
Re: [2005] help understanding how to use this module plz
in the module description
"symmetric matrix which is given by its upper or lower
' triangular part.
' Array whose indexes range within [1..N, 1..N]."
how can i store a matrix in a 1d array??
-
Jan 31st, 2007, 07:52 AM
#4
Re: [2005] help understanding how to use this module plz
The function should read like this if that was the case, but I have no idea what the functions you are calling within that are declared as:
Public Function SymmetricEVD(ByRef A_(,) As Double, _
ByVal N As Long, _
ByVal ZNeeded As Long, _
ByVal IsUpper As Boolean, _
ByRef D(,) As Double, _
ByRef Z(,) As Double) As Boolean
-
Jan 31st, 2007, 07:56 AM
#5
Re: [2005] help understanding how to use this module plz
I've just read the site (Im feeling helpful ) the code you are using is from VB6, which you do not have to declare as a specifc array size. You can use either (0 to 1) or (0 to 1, 0 to 1).
-
Jan 31st, 2007, 08:23 AM
#6
Thread Starter
Addicted Member
Re: [2005] help understanding how to use this module plz
oh i posted in the wrong forum.. but anyway how can i use this in vb 2005??
-
Jan 31st, 2007, 08:28 AM
#7
Re: [2005] help understanding how to use this module plz
It depends what you have, I assume you have a .dll from this place that contains UnpackQFromTridiagonal and TridiagonalEVD methods?
-
Jan 31st, 2007, 08:46 AM
#8
Thread Starter
Addicted Member
Re: [2005] help understanding how to use this module plz
no it's not a .dll but a .bas for the other functions
-
Jan 31st, 2007, 08:59 AM
#9
Re: [2005] help understanding how to use this module plz
Well, you will have to convert them as well into a module, and update it to take the new array, probly in the method declaration again.
-
Jan 31st, 2007, 09:01 AM
#10
Thread Starter
Addicted Member
Re: [2005] help understanding how to use this module plz
anyway what am i doing wrong in my code..cuz i am getting "type mismatch"
-
Jan 31st, 2007, 11:07 AM
#11
Re: [2005] help understanding how to use this module plz
I have already said what would be going wrong, and suggested what to do.
You need to convert the bas file into .net. You will most likely have to change the .bas file to use this array, as VB6 allows you to pass arrays about without being specific of their size. This will mean changing the declaration of the functions to use multi-dimension arrays.
I have included an example of what the new function header would look like, but you havent shown anything of the .bas file so I can't advise on how to change it.
-
Jan 31st, 2007, 12:42 PM
#12
Thread Starter
Addicted Member
Re: [2005] help understanding how to use this module plz
oh ok will post this on vb6 forum thanks
-
Jan 31st, 2007, 01:53 PM
#13
Re: [2005] help understanding how to use this module plz
Im lost, I thought you are coding this in .net 2005 ?
-
Jan 31st, 2007, 01:58 PM
#14
Re: [2005] help understanding how to use this module plz
It all becomes clear...
It is VB6 your using this in, which works differently. But you did ask how to get this working in 2005. Sorry for wasting your time.
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
|