主题:求助,关于IMSL的问题
huangboy101
[专家分:0] 发布于 2010-07-29 16:24:00
我是Fortran新手,今天想用IMSL里面的EVCCG来算一个复数矩阵的特征值和特征向量。看了IMSL manual里面的例子照着做的,但是却报错了,不太懂,大概都是子程序参数传递方面的问题。
Error: The type of the actual argument differs from the type of the dummy argument.
Error: A non-optional actual argument must be present when invoking a procedure with an explicit interface.
Error: The shape matching rules of actual arguments and dummy arguments have been violated.
CVF6.6,原程序如下:谢谢各位高手!!
program ex0066
use IMSL
implicit none
integer m,N,LDA,LDEVEC
parameter(N=5,LDA=N,LDEVEC=N)
complex ::Ttre(LDA,N),EVAL(N),EVEC(LDEVEC,N)
Ttre=eye(N)
do m=1,N-1
Ttre(m,m)=(1.0,1.0)
Ttre(m+1,m)=-1.0
end do
call EVCCG(Ttre,EVAL,EVEC)
end program ex0066
沙发
asymptotic [专家分:16630] 发布于 2010-07-29 17:09:00
subroutine Test_EVCCG
use TypeKind, WP => SP
include 'link_fnl_shared.h'
use EVCCG_INT
implicit none
! order of the matrix A
integer(kind = IP), parameter:: N = 4
! leading dimension of A exactly as specified in the
! dimension statement in the calling program
integer(kind = IP), parameter:: LDA = N
! Leading dimension of EVEC exactly as specified in the
! dimension statement in the calling program
integer(kind = IP), parameter:: LDEVEC = N
! complex matrix of order N
complex(kind = WP):: A(LDA, N)
! complex vector of length N containing the eigenvalues
! of A in decreasing order of magnitude.
complex(kind = WP):: EVAL(N)
! complex matrix of order N
! 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.
complex(kind = WP):: EVEC(LDEVEC, N)
! *** *** *** *** *** intermediate variable *** *** *** *** ***
integer(kind = IP):: i ! for loop
real(kind = WP):: UU(LDEVEC, N)
A = reshape( (/ (5.0_WP, 9.0_WP), (3.0_WP, 3.0_WP), (2.0_WP, 2.0_WP), (1.0_WP, 1.0_WP), &
(5.0_WP, 5.0_WP), (6.0_WP, 10.0_WP), (3.0_WP, 3.0_WP), (2.0_WP, 2.0_WP), &
(-6.0_WP, -6.0_WP), (-5.0_WP, -5.0_WP), (-1.0_WP, 3.0_WP), (-3.0_WP, -3.0_WP), &
(-7.0_WP, -7.0_WP), (-6.0_WP, -6.0_WP), (-5.0_WP, -5.0_WP), ( 0.0_WP, 4.0_WP) /), &
(/LDA, N/) )
call EVCCG( A, EVAL, EVEC )
! if ( WP == kind(1.0) ) then
! call EVCCG( N, A, LDA, EVAL, EVEC, LDEVEC )
! else if ( WP == kind(1.0d0) ) then
! call DEVCCG( N, A, LDA, EVAL, EVEC, LDEVEC )
! end if
write(*, *) "Eigenvalue:"
do i = 1, N, 1
write(*, *) i, EVAL(i)
end do
write(*, *) "Eigenvector:"
write(*, *) EVEC(:, 1)
write(*, *) "Test real-orthogonal relation:"
UU = matmul( transpose(EVEC), EVEC )
do i = 1, N, 1
write(*, *) UU(i, :)
end do
UU = matmul( EVEC, transpose(EVEC) )
do i = 1, N, 1
write(*, *) UU(i, :)
end do
return
end subroutine