|
-
Jan 31st, 2007, 12:44 PM
#1
Thread Starter
Addicted Member
[RESOLVED] help me understand 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, 12:45 PM
#2
Re: help me understand how to use this module plz
 Originally Posted by lplover2k
i get "type mismatch"
On what line?
-
Jan 31st, 2007, 12:54 PM
#3
Re: help me understand how to use this module plz
And don't bother with the "Call" part. The function name will be returned as a Boolean variable, so for your return, put something like this:
VB Code:
MsgBox SymmetricEVD(mat, 2, 1, True, Result, eigenvect)
-
Jan 31st, 2007, 12:55 PM
#4
Re: help me understand how to use this module plz
 Originally Posted by lplover2k
but i get "type mismatch"
well mat and result aren't declared as double, they're declared as variants, it should be:
VB Code:
Dim mat(0 To 1, 0 To 1) As Double, Result(0 To 1, 0 To 1) As Double, eigenvect(0 To 1, 0 To 1) As Double
-
Jan 31st, 2007, 01:10 PM
#5
Thread Starter
Addicted Member
Re: help me understand how to use this module plz
-
Jan 31st, 2007, 01:56 PM
#6
Re: help me understand how to use this module plz
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
|