主题:[讨论]关于evchf求复厄米矩阵的特征值和特征向量
tianhy2010
[专家分:60] 发布于 2010-09-06 10:15:00
evchf可以用来求复数厄米矩阵的特征值和特征向量,书中也给出了一个例题说明。我在用这个例题的时候出现一个情况,说error LNK2001: unresolved external symbol _EVCHF@24,我用的是带imsl数据库的fortran6.6,难道是我库里没有这些函数?
! declare variables
integer lda,ldevec,n
parameter(n=3,lda=n,ldevec=n)
integer nout
real epihf,eval(n),pi
complex a(lda,n),evec(ldevec,n)
! external evchf
external epihf,evchf,umach,wrcrn,wrrrn
! set values of a
data a/(1.0,0.0),(1.0,7.0),(0.0,1.0),(1.0,-7.0),(5.0,0.0),(10.0,3.0),(0.0,-1.0),(10.0,-3.0),(-2.0,0.0)/
! find 特征值和特征向量
call evchf(n,a,lda,eval,evec,ldevec)
!compute performance index
pi=epihf(n,n,a,lda,eval,evec,ldevec)
write(*,*) eval,evec
!print result
call umach(2,nout)
call wrrrn('eval',1,n,eval,1,0)
call wrcrn('evec',n,n,evec,ldevec,0)
write(nout,'(/,a,f6.3)') 'performance index=', pi
end[em1][em21][em21][em21][em21][em21][em21][em21][em21][em21][em22][em22][em22][em22][em22][em22][em22][em18][em18][em18][em18][em18]
我查了一下EVCHF的说明,不知是否有用。
Computes all of the eigenvalues and eigenvectors of a complex Hermitian matrix.
Required Arguments
A — Complex Hermitian matrix of order N. (Input)
Only the upper triangle is used.
EVAL — Real vector of length N containing the eigenvalues of A in decreasing order of magnitude. (Output)
EVEC — Complex matrix of order N. (Output)
The J-th eigenvector, corresponding to EVAL(J), is stored in the J-th column. Each vector is normalized to have Euclidean length equal to the value one.
Optional Arguments
N — Order of the matrix A. (Input)
Default: N = size (A,2).
LDA — Leading dimension of A exactly as specified in the dimension statement in the calling program. (Input)
Default: LDA = size (A,1).
LDEVEC — Leading dimension of EVEC exactly as specified in the dimension statement in the calling program. (Input)
Default: LDEVEC = size (EVEC,1).
FORTRAN 90 Interface
Generic: CALL EVCHF (A, EVAL, EVEC [,…])
Specific: The specific interface names are S_EVCHF and D_EVCHF.
FORTRAN 77 Interface
Single: CALL EVCHF (N, A, LDA, EVAL, EVEC, LDEVEC)
Double: The double precision name is DEVCHF.
回复列表 (共15个回复)
沙发
tianhy2010 [专家分:60] 发布于 2010-09-06 10:16:00
Description
Routine EVCHF computes the eigenvalues and eigenvectors of a complex Hermitian matrix. Unitary similarity transformations are used to reduce the matrix to an equivalent real symmetric tridiagonal matrix. The implicit QL algorithm is used to compute the eigenvalues and eigenvectors of this tridiagonal matrix. These eigenvectors and the transformations used to reduce the matrix to tridiagonal form are combined to obtain the eigenvectors for the user’s problem. The underlying code is based on either EISPACK or LAPACK code depending upon which supporting libraries are used during linking. For a detailed explanation, see “Using ScaLAPACK, LAPACK, LINPACK, and EISPACK” in the Introduction section of this manual.
Comments
1. Workspace may be explicitly provided, if desired, by use of E5CHF/DE5CHF. The reference is:
CALL E5CHF (N, A, LDA, EVAL, EVEC, LDEVEC, ACOPY, RWK, CWK, IWK)
The additional arguments are as follows:
ACOPY — Complex work array of length N2. A and ACOPY may be the same, in which case A will be destroyed.
RWK — Work array of length N2 + N.
CWK — Complex work array of length 2N.
IWK — Integer work array of length N.
2. Informational error
Type Code
3 1 The matrix is not Hermitian. It has a diagonal entry with a small imaginary part.
4 1 The iteration for an eigenvalue failed to converge.
4 2 The matrix is not Hermitian. It has a diagonal entry with an imaginary part.
3. The success of this routine can be checked using EPIHF.
4. Integer Options with Chapter 11 Options Manager
1 This option uses eight values to solve memory bank conflict (access inefficiency) problems. In routine E5CHF, the internal or working leading dimensions of ACOPY and ECOPY are both increased by IVAL(3) when N is a multiple of IVAL(4). The values IVAL(3) and IVAL(4) are temporarily replaced by IVAL(1) and IVAL(2), respectively, in routine EVCHF. Additional memory allocation and option value restoration are automatically done in EVCHF. There is no requirement that users change existing applications that use EVCHF or E5CHF. Default values for the option are IVAL(*) = 1, 16, 0, 1, 1, 16, 0, 1. Items 5-8 in IVAL(*) are for the generalized eigenvalue problem and are not used in EVCHF.
板凳
tianhy2010 [专家分:60] 发布于 2010-09-06 10:19:00
这是
jstzhurj老师给出的例子,怎么跟我的例子差个
USE IMSL_libraries
啊。我把她的例子带到fortran里,提示没有这个IMSL_libraries,是版本问题吗?
[em2][em2][em2][em2][em2]
Example
In this example, a DATA statement is used to set A to a complex Hermitian matrix. The eigenvalues and eigenvectors of this matrix are computed and printed. The performance index is also computed and printed. This serves as a check on the computations, for more details, see routine EPIHF.
USE IMSL_libraries
IMPLICIT NONE
! Declare variables
INTEGER LDA, LDEVEC, N
PARAMETER (N=3, LDA=N, LDEVEC=N)
!
INTEGER NOUT
REAL EVAL(N), PI
COMPLEX A(LDA,N), EVEC(LDEVEC,N)
! Set values of A
!
! A = ((1, 0) ( 1,-7i) ( 0,- i))
! ((1,7i) ( 5, 0) (10,-3i))
! ((0, i) ( 10, 3i) (-2, 0))
!
DATA A/(1.0,0.0), (1.0,7.0), (0.0,1.0), (1.0,-7.0), (5.0,0.0), &
(10.0, 3.0), (0.0,-1.0), (10.0,-3.0), (-2.0,0.0)/
!
! Find eigenvalues and vectors of A
CALL EVCHF (A, EVAL, EVEC)
! Compute performance index
PI = EPIHF(N,A,EVAL,EVEC)
! Print results
CALL UMACH (2, NOUT)
CALL WRRRN ('EVAL', EVAL, 1, N, 1)
CALL WRCRN ('EVEC', EVEC)
WRITE (NOUT,'(/,A,F6.3)') ' Performance index = ', PI
END
Output
EVAL
1 2 3
15.38 -10.63 -0.75
EVEC
1 2 3
1 ( 0.0631,-0.4075) (-0.0598,-0.3117) ( 0.8539, 0.0000)
2 ( 0.7703, 0.0000) (-0.5939, 0.1841) (-0.0313,-0.1380)
3 ( 0.4668, 0.1366) ( 0.7160, 0.0000) ( 0.0808,-0.4942)
Performance index = 0.093
3 楼
tianhy2010 [专家分:60] 发布于 2010-09-06 10:20:00
另外请问,这些函数什么用呢?尤其是pi
CALL UMACH (2, NOUT)
CALL WRRRN ('EVAL', EVAL, 1, N, 1)
CALL WRCRN ('EVEC', EVEC)
WRITE (NOUT,'(/,A,F6.3)') ' Performance index = ', PI
4 楼
tianhy2010 [专家分:60] 发布于 2010-09-06 10:21:00
这个程序要在什么版本的fortra 下才能运行通过啊?
5 楼
cgl_lgs [专家分:21040] 发布于 2010-09-06 11:03:00
4回复,还以为回复了几回合了呢,合着半天都是您一人啊:)
这程序需要在带有IMSL的FORTRAN下运行。具体函数是做什么用的,那个帮助里不是说有么:)您都找到帮助了,看看不就知道了么:)
6 楼
yeg001 [专家分:14390] 发布于 2010-09-06 12:42:00
楼主不妨翻翻旧帖
http://www.programfan.com/club/showtxt.asp?id=265968
相信是那个例子用的IMSL版本跟cvf的不同. IMSL是一个外部函数库, 跟fortran本身版本关系不大.
调用函数库一般需要一定的自学能力. 看看文档, 不明白再交流讨论, 收获才比较大.
7 楼
BiCGSTAB [专家分:780] 发布于 2010-09-06 14:27:00
你试试use imsl或use msimsl
[quote]
这是
jstzhurj老师给出的例子,怎么跟我的例子差个
USE IMSL_libraries
啊。我把她的例子带到fortran里,提示没有这个IMSL_libraries,是版本问题吗?
[em2][em2][em2][em2][em2]
Example
In this example, a DATA statement is used to set A to a complex Hermitian matrix. The eigenvalues and eigenvectors of this matrix are computed and printed. The performance index is also computed and printed. This serves as a check on the computations, for more details, see routine EPIHF.
USE IMSL_libraries
IMPLICIT NONE
! Declare variables
INTEGER LDA, LDEVEC, N
PARAMETER (N=3, LDA=N, LDEVEC=N)
!
INTEGER NOUT
REAL EVAL(N), PI
COMPLEX A(LDA,N), EVEC(LDEVEC,N)
! Set values of A
!
! A = ((1, 0) ( 1,-7i) ( 0,- i))
! ((1,7i) ( 5, 0) (10,-3i))
! ((0, i) ( 10, 3i) (-2, 0))
!
DATA A/(1.0,0.0), (1.0,7.0), (0.0,1.0), (1.0,-7.0), (5.0,0.0), &
(10.0, 3.0), (0.0,-1.0), (10.0,-3.0), (-2.0,0.0)/
!
! Find eigenvalues and vectors of A
CALL EVCHF (A, EVAL, EVEC)
! Compute performance index
PI = EPIHF(N,A,EVAL,EVEC)
! Print results
CALL UMACH (2, NOUT)
CALL WRRRN ('EVAL', EVAL, 1, N, 1)
CALL WRCRN ('EVEC', EVEC)
WRITE (NOUT,'(/,A,F6.3)') ' Performance index = ', PI
END
Output
EVAL
1 2 3
15.38 -10.63 -0.75
EVEC
1 2 3
1 ( 0.0631,-0.4075) (-0.0598,-0.3117) ( 0.8539, 0.0000)
2 ( 0.7703, 0.0000) (-0.5939, 0.1841) (-0.0313,-0.1380)
3 ( 0.4668, 0.1366) ( 0.7160, 0.0000) ( 0.0808,-0.4942)
Performance index = 0.093
[/quote]
8 楼
BiCGSTAB [专家分:780] 发布于 2010-09-06 14:35:00
给您推荐一个网站vni
http://www.vni.com/products/imsl/documentation/index.php#fort
UMACH WRRRN WRCRN三个函数在
http://www.vni.com/products/imsl/documentation/fort06/math/NetHelp/default.htm?turl=umach.htm
http://www.vni.com/products/imsl/documentation/fort06/math/NetHelp/default.htm?turl=wrrrn.htm
http://www.vni.com/products/imsl/documentation/fort06/math/NetHelp/default.htm?turl=wrcrn.htm
好好利用vni可以解决imsl使用过程中许多问题。
[quote]另外请问,这些函数什么用呢?尤其是pi
CALL UMACH (2, NOUT)
CALL WRRRN ('EVAL', EVAL, 1, N, 1)
CALL WRCRN ('EVEC', EVEC)
WRITE (NOUT,'(/,A,F6.3)') ' Performance index = ', PI
[/quote]
9 楼
tianhy2010 [专家分:60] 发布于 2010-09-06 15:56:00
这些帮助信息都是从论坛上粘贴的,我没有那个帮助。你们谁有能否发我一份啊?我校内网,只能进有限的几个网站。谢谢啦!!
tianhy2010@163.com
[em28][em28][em28][em28][em28][em28][em28][em28][em28][em28][em28]
10 楼
tianhy2010 [专家分:60] 发布于 2010-09-06 15:57:00
[quote]楼主不妨翻翻旧帖
http://www.programfan.com/club/showtxt.asp?id=265968
相信是那个例子用的IMSL版本跟cvf的不同. IMSL是一个外部函数库, 跟fortran本身版本关系不大.
调用函数库一般需要一定的自学能力. 看看文档, 不明白再交流讨论, 收获才比较大.[/quote]
能否传我一份啊?帮助文档,我校内网,只能进有限几个网站。tianhy2010@163.com。多谢啦
我来回复