如何使用Compaq visual Fortran中的IMSL

如题所述

如果已经安装了IMSL,在你编写的程序中使用use 语句调用你要用的函数所在的库就可以了.
下面是抄了的一个例子:
!lin_sol_gen_int 为IMSL mod文件,在include目录下
use lin_sol_gen_int
use rand_gen_int
use error_option_packet
implicit none
! This is Example 1 for LIN_SOL_GEN.
integer, parameter :: n=32
real(kind(1e0)), parameter :: one=1e0
real(kind(1e0)) err
real(kind(1e0)) A(n,n), b(n,n), x(n,n), res(n,n), y(n**2)
! Generate a random matrix.
call rand_gen(y)
A = reshape(y,(/n,n/))
! Generate random right-hand sides.
call rand_gen(y)
b = reshape(y,(/n,n/))
! Compute the solution matrix of Ax=b.
call lin_sol_gen(A, b, x)
! Check the results for small residuals.
res = b - matmul(A,x)
err = maxval(abs(res))/sum(abs(A)+abs(b))
if (err <= sqrt(epsilon(one))) then
write (*,*) 'Example 1 for LIN_SOL_GEN is correct.'
end if
end
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答