''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'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