Visible to Intel only — GUID: GUID-97CA756B-3A40-4464-BD25-6E81328F5B1E
ZHEEV Example Program in Fortran
* Copyright (C) 2009-2015 Intel Corporation. All Rights Reserved.
* The information and material ("Material") provided below is owned by Intel
* Corporation or its suppliers or licensors, and title to such Material remains
* with Intel Corporation or its suppliers or licensors. The Material contains
* proprietary information of Intel or its suppliers and licensors. The Material
* is protected by worldwide copyright laws and treaty provisions. No part of
* the Material may be copied, reproduced, published, uploaded, posted,
* transmitted, or distributed in any way without Intel's prior express written
* permission. No license under any patent, copyright or other intellectual
* property rights in the Material is granted to or conferred upon you, either
* expressly, by implication, inducement, estoppel or otherwise. Any license
* under such intellectual property rights must be express and approved by Intel
* in writing.
* =============================================================================
*
* ZHEEV Example.
* ==============
*
* Program computes all eigenvalues and eigenvectors of a complex Hermitian
* matrix A:
*
* ( 9.14, 0.00) ( -4.37, -9.22) ( -1.98, -1.72) ( -8.96, -9.50)
* ( -4.37, 9.22) ( -3.35, 0.00) ( 2.25, -9.51) ( 2.57, 2.40)
* ( -1.98, 1.72) ( 2.25, 9.51) ( -4.82, 0.00) ( -3.24, 2.04)
* ( -8.96, 9.50) ( 2.57, -2.40) ( -3.24, -2.04) ( 8.44, 0.00)
*
* Description.
* ============
*
* The routine computes all eigenvalues and, optionally, eigenvectors of an
* n-by-n complex Hermitian matrix A. The eigenvector v(j) of A satisfies
*
* A*v(j) = lambda(j)*v(j)
*
* where lambda(j) is its eigenvalue. The computed eigenvectors are
* orthonormal.
*
* Example Program Results.
* ========================
*
* ZHEEV Example Program Results
*
* Eigenvalues
* -16.00 -6.76 6.67 25.51
*
* Eigenvectors (stored columnwise)
* ( 0.34, 0.00) ( -0.55, 0.00) ( 0.31, 0.00) ( -0.70, 0.00)
* ( 0.44, -0.54) ( 0.26, 0.18) ( 0.45, 0.29) ( 0.22, -0.28)
* ( -0.48, -0.37) ( -0.52, -0.02) ( -0.05, 0.57) ( 0.15, 0.08)
* ( 0.10, -0.12) ( -0.50, 0.28) ( -0.23, -0.48) ( 0.34, -0.49)
* =============================================================================
*
* .. Parameters ..
INTEGER N
PARAMETER ( N = 4 )
INTEGER LDA
PARAMETER ( LDA = N )
INTEGER LWMAX
PARAMETER ( LWMAX = 1000 )
*
* .. Local Scalars ..
INTEGER INFO, LWORK
*
* .. Local Arrays ..
* RWORK dimension should be at least MAX(1,3*N-2)
DOUBLE PRECISION W( N ), RWORK( 3*N-2 )
COMPLEX*16 A( LDA, N ), WORK( LWMAX )
DATA A/
$ ( 9.14, 0.00),(-4.37, 9.22),(-1.98, 1.72),(-8.96, 9.50),
$ ( 0.00, 0.00),(-3.35, 0.00),( 2.25, 9.51),( 2.57,-2.40),
$ ( 0.00, 0.00),( 0.00, 0.00),(-4.82, 0.00),(-3.24,-2.04),
$ ( 0.00, 0.00),( 0.00, 0.00),( 0.00, 0.00),( 8.44, 0.00)
$ /
*
* .. External Subroutines ..
EXTERNAL ZHEEV
EXTERNAL PRINT_MATRIX, PRINT_RMATRIX
*
* .. Intrinsic Functions ..
INTRINSIC INT, MIN
*
* .. Executable Statements ..
WRITE(*,*)'ZHEEV Example Program Results'
*
* Query the optimal workspace.
*
LWORK = -1
CALL ZHEEV( 'Vectors', 'Lower', N, A, LDA, W, WORK, LWORK, RWORK,
$ INFO )
LWORK = MIN( LWMAX, INT( WORK( 1 ) ) )
*
* Solve eigenproblem.
*
CALL ZHEEV( 'Vectors', 'Lower', N, A, LDA, W, WORK, LWORK, RWORK,
$ INFO )
*
* Check for convergence.
*
IF( INFO.GT.0 ) THEN
WRITE(*,*)'The algorithm failed to compute eigenvalues.'
STOP
END IF
*
* Print eigenvalues.
*
CALL PRINT_RMATRIX( 'Eigenvalues', 1, N, W, 1 )
*
* Print eigenvectors.
*
CALL PRINT_MATRIX( 'Eigenvectors (stored columnwise)', N, N, A,
$ LDA )
STOP
END
*
* End of ZHEEV Example.
*
* =============================================================================
*
* Auxiliary routine: printing a matrix.
*
SUBROUTINE PRINT_MATRIX( DESC, M, N, A, LDA )
CHARACTER*(*) DESC
INTEGER M, N, LDA
COMPLEX*16 A( LDA, * )
*
INTEGER I, J
*
WRITE(*,*)
WRITE(*,*) DESC
DO I = 1, M
WRITE(*,9998) ( A( I, J ), J = 1, N )
END DO
*
9998 FORMAT( 11(:,1X,'(',F6.2,',',F6.2,')') )
RETURN
END
*
* Auxiliary routine: printing a real matrix.
*
SUBROUTINE PRINT_RMATRIX( DESC, M, N, A, LDA )
CHARACTER*(*) DESC
INTEGER M, N, LDA
DOUBLE PRECISION A( LDA, * )
*
INTEGER I, J
*
WRITE(*,*)
WRITE(*,*) DESC
DO I = 1, M
WRITE(*,9998) ( A( I, J ), J = 1, N )
END DO
*
9998 FORMAT( 11(:,1X,F6.2) )
RETURN
END
Parent topic: ZHEEV Example