home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frostbyte's 1980s DOS Shareware Collection
/
floppyshareware.zip
/
floppyshareware
/
DOOG
/
PCSSP1.ZIP
/
NUMDIFF.ZIP
/
DDET3.FOR
< prev
next >
Wrap
Text File
|
1985-11-29
|
3KB
|
87 lines
C
C ..................................................................
C
C SUBROUTINE DDET3
C
C PURPOSE
C TO COMPUTE A VECTOR OF DERIVATIVE VALUES GIVEN A VECTOR OF
C FUNCTION VALUES WHOSE ENTRIES CORRESPOND TO EQUIDISTANTLY
C SPACED ARGUMENT VALUES.
C
C USAGE
C CALL DDET3(H,Y,Z,NDIM,IER)
C
C DESCRIPTION OF PARAMETERS
C H - DOUBLE PRECISION CONSTANT DIFFERENCE BETWEEN
C SUCCESSIVE ARGUMENT VALUES (H IS POSITIVE IF THE
C ARGUMENT VALUES INCREASE AND NEGATIVE OTHERWISE)
C Y - GIVEN VECTOR OF DOUBLE PRECISION FUNCTION VALUES
C (DIMENSION NDIM)
C Z - RESULTING VECTOR OF DOUBLE PRECISION DERIVATIVE
C VALUES (DIMENSION NDIM)
C NDIM - DIMENSION OF VECTORS Y AND Z
C IER - RESULTING ERROR PARAMETER
C IER = -1 - NDIM IS LESS THAN 3
C IER = 0 - NO ERROR
C IER = 1 - H = 0
C
C REMARKS
C (1) IF IER = -1,1, THEN THERE IS NO COMPUTATION.
C (2) Z CAN HAVE THE SAME STORAGE ALLOCATION AS Y. IF Y IS
C DISTINCT FROM Z, THEN IT IS NOT DESTROYED.
C
C SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED
C NONE
C
C METHOD
C IF X IS THE (SUPPRESSED) VECTOR OF ARGUMENT VALUES, THEN
C EXCEPT AT THE ENDPOINTS X(1) AND X(NDIM), Z(I) IS THE
C DERIVATIVE AT X(I) OF THE LAGRANGIAN INTERPOLATION
C POLYNOMIAL OF DEGREE 2 RELEVANT TO THE 3 SUCCESSIVE POINTS
C (X(I+K),Y(I+K)) K = -1,0,1. (SEE HILDEBRAND, F.B.,
C INTRODUCTION TO NUMERICAL ANALYSIS, MC-GRAW-HILL, NEW YORK/
C TORONTO/LONDON, 1956, PP.82-84.)
C
C ..................................................................
C
SUBROUTINE DDET3(H,Y,Z,NDIM,IER)
C
C
DIMENSION Y(1),Z(1)
DOUBLE PRECISION H,Y,Z,HH,YY,A,B
C
C TEST OF DIMENSION
IF(NDIM-3)4,1,1
C
C TEST OF STEPSIZE
1 IF(H)2,5,2
C
C PREPARE DIFFERENTIATION LOOP
2 HH=.5D0/H
YY=Y(NDIM-2)
B=Y(2)+Y(2)
B=HH*(B+B-Y(3)-Y(1)-Y(1)-Y(1))
C
C START DIFFERENTIATION LOOP
DO 3 I=3,NDIM
A=B
B=HH*(Y(I)-Y(I-2))
3 Z(I-2)=A
C END OF DIFFERENTIATION LOOP
C
C NORMAL EXIT
IER=0
A=Y(NDIM-1)+Y(NDIM-1)
Z(NDIM)=HH*(Y(NDIM)+Y(NDIM)+Y(NDIM)-A-A+YY)
Z(NDIM-1)=B
RETURN
C
C ERROR EXIT IN CASE NDIM IS LESS THAN 3
4 IER=-1
RETURN
C
C ERROR EXIT IN CASE OF ZERO STEPSIZE
5 IER=1
RETURN
END