Part_III_IMSL数值分析程序库

  • 格式:doc
  • 大小:1.81 MB
  • 文档页数:81

1 数值分析程序设计

Part III IMSL数值分析函数库

数值方法中常遇到的问题,有专门的函数链接库可以使用。IMSL是一套在数值方法上经常被使用的商业函数链接库。Visual Fortran的专业版内含IMSL。

IMSL的函数名称中,第一个字母可以用来判断参数的类型。如果第一个字母是D会使用双精度浮点数来计算并返回答案。第一个字母不是D,则使用单精度浮点数计算。

为准确理解函数中各参数的意义和功能,下面的函数介绍采用英文原文。必要时增加中文注释。

0 IMSL函数库

The IMSL Libraries

IMSL函数库包含两个独立部分:

•MATH/LIBRARY general applied mathematics and special functions

(应用数学和特殊函数函数库)

•STAT/LIBRARY statistics(统计函数库)

The IMSL MATH/LIBRARY User’s Manual has two parts: MATH/LIBRARY

and MATH/LIBRARY Special Functions.

Most of the routines are available in both single and double precision versions.

The same user interface is found on the many hardware versions that span the range

from personal computer to supercomputer. Note that some IMSL routines are not

distributed for FORTRAN compiler environments that do not support double

precision complex data.

The names of the IMSL routines that return or accept the type double complex

begin with the letter “Z” and, occasionally, “DC.” 数值分析程序设计

2 Getting Started

The IMSL MATH/LIBRARY is a collection of FORTRAN routines and

functions useful in research and mathematical analysis.

To use any of these routines, you must write a program in FORTRAN (or

possibly some other language) to call the MATH/LIBRARY routine.(使用IMSL函数库必须编写Fortran程序调用相应的子程序)

在Fortran安装目录的DF98\IMSL\Help目录下提供PDF版本IMSL帮助文件MATH.pdf和F9040.pdf。前者为IMSL数学分析函数库帮助文件,后者为Fortran90新增的一些函数库帮助文件。需要IMSL使用的详细情况,请查阅帮助文件。 3 1 线性系统(Linear Systems)

IMSL提供了大量的求解线性方程组的函数,可以用于求解数值分析中常见的各种问题。例如,线性方程求解的直接法和迭代法、逆矩阵和行列式计算、最小二乘拟和问题、三角矩阵问题、矩阵的QR分解、奇异值分解和Cholesky分解等。

可以处理一般矩阵、对称矩阵、复矩阵、三角矩阵等的数值分析计算问题。

1.1 线性系统求解、逆矩阵与行列式计算

1.1.1高精度线性系统求解——LSARG/DLSARG (Single/Double precision)

功能:Solve a real general system of linear equations with iterative refinement.

语法:CALL LSARG (N, A, LDA, B, IPATH, X)

参数:

N — Number of equations. (Input)(方程个数)

A — N by N matrix containing the coefficients of the linear system. (Input)(系数矩阵)

LDA — Leading dimension of A exactly as specified in the dimension

statement of the calling program. (Input)(调用程序所需要的矩阵主维数——一般为矩阵行数)

B — Vector of length N containing the right-hand side of the linear

system.(Input)(方程右边矩阵向量)

IPATH — Path indicator. (Input)(求解指示器)

IPATH = 1 means the system AX = B is solved.

IPATH = 2 means the system A7X = B is solved.

X — Vector of length N containing the solution to the linear system. (Output)(求解的未知量向量)

算法:Routine LSARG solves a system of linear algebraic equations having a real

general coefficient matrix. It first uses the routine LFCRG, to compute an LU

factorization of the coefficient matrix and to estimate the condition number of the

matrix. The solution of the linear system is then found using the iterative refinement

routine LFIRG.(LU分解法加上迭代改进解的精度) 数值分析程序设计

4 算例:求解线性方程组33167212924105796181178.5xyz

program main

use IMSL

! Declare variables

PARAMETER (IPATH=1, LDA=3, N=3)

REAL A(LDA,LDA), B(N), X(N)

! Set values for A and B

! A = ( 33.0 16.0 72.0)

! (-24.0 -10.0 -57.0)

! ( 18.0 -11.0 7.0)

! B = (129.0 -96.0 8.5)

DATA A/33.0, -24.0, 18.0, 16.0, -10.0, -11.0, 72.0, -57.0, 7.0/

DATA B/129.0, -96.0, 8.5/

CALL LSARG (N, A, LDA, B, IPATH, X)

write(*,*)x

END

1.1.2 求解线性方程组——LSLRG/DLSLRG (Single/Double precision)

功能:Solve a real general system of linear equations without iterative

refinement.

Usage:CALL LSLRG (N, A, LDA, B, IPATH, X)

参数:同上 5 算法:Routine LSLRG solves a system of linear algebraic equations having a real

general coefficient matrix. It first uses the routine LFCRG to compute an LU

factorization of the coefficient matrix based on Gauss elimination with partial

pivoting.

上一算例的计算结果:

1.1.3 LU分解和矩阵条件数——LFCRG/DLFCRG

功能:Compute the LU factorization of a real general matrix and estimate its L1

condition number.

语法:CALL LFCRG (N, A, LDA, FAC, LDFAC, IPVT, RCOND)

参数:

N — Order of the matrix. (Input)

A — N by N matrix to be factored. (Input)

LDA — Leading dimension of A exactly as specified in the dimension statement

of the calling program. (Input)

FAC— N by N matrix containing the LU factorization of the matrix A. (Output)

If A is not needed, A and FAC can share the same storage locations.

LDFAC — Leading dimension of FAC exactly as specified in the dimension

statement of the calling program. (Input)

IPVT — Vector of length N containing the pivoting information for the LU

factorization. (Output)

RCOND — Scalar containing an estimate of the reciprocal of the L1 condition

number of A. (Output)

算法:Routine LFCRG performs an LU factorization of a real general coefficient

matrix. It also estimates the condition number of the matrix. The LU factorization is