1 | PROGRAM CUBGCVMAIN
|
---|
2 | USE MODCUBGCV
|
---|
3 | C CUBGCV TEST DRIVER
|
---|
4 | C ------------------
|
---|
5 | C
|
---|
6 | C AUTHOR - M.F.HUTCHINSON
|
---|
7 | C CSIRO DIVISION OF WATER AND LAND RESOURCES
|
---|
8 | C GPO BOX 1666
|
---|
9 | C CANBERRA ACT 2601
|
---|
10 | C AUSTRALIA
|
---|
11 | C
|
---|
12 | C LATEST REVISION - 7 AUGUST 1986
|
---|
13 | C
|
---|
14 | C COMPUTER - VAX/DOUBLE
|
---|
15 | C
|
---|
16 | C USAGE - MAIN PROGRAM
|
---|
17 | C
|
---|
18 | C REQUIRED ROUTINES - CUBGCV,SPINT1,SPFIT1,SPCOF1,SPERR1,GGRAND
|
---|
19 | C
|
---|
20 | C REMARKS USES SUBROUTINE CUBGCV TO FIT A CUBIC SMOOTHING SPLINE
|
---|
21 | C TO 50 DATA POINTS WHICH ARE GENERATED BY ADDING A RANDOM
|
---|
22 | C VARIABLE WITH UNIFORM DENSITY IN THE INTERVAL [-0.3,0.3]
|
---|
23 | C TO 50 POINTS SAMPLED FROM THE CURVE Y=SIN(3*PI*X/2).
|
---|
24 | C RANDOM DEVIATES IN THE INTERVAL [0,1] ARE GENERATED BY THE
|
---|
25 | C DOUBLE PRECISION FUNCTION GGRAND (SIMILAR TO IMSL FUNCTION
|
---|
26 | C GGUBFS). THE ABSCISSAE ARE UNEQUALLY SPACED IN [0,1].
|
---|
27 | C
|
---|
28 | C POINT STANDARD ERROR ESTIMATES ARE RETURNED IN SE BY
|
---|
29 | C SETTING JOB=1. THE ERROR VARIANCE ESTIMATE IS RETURNED
|
---|
30 | C IN VAR. IT COMPARES FAVOURABLY WITH THE TRUE VALUE OF 0.03.
|
---|
31 | C SUMMARY STATISTICS FROM THE ARRAY WK ARE WRITTEN TO
|
---|
32 | C UNIT 6. DATA VALUES AND FITTED VALUES WITH ESTIMATED
|
---|
33 | C STANDARD ERRORS ARE ALSO WRITTEN TO UNIT 6.
|
---|
34 | C
|
---|
35 | PARAMETER (N=50, IC=49)
|
---|
36 | C
|
---|
37 | INTEGER JOB,IER
|
---|
38 | DOUBLE PRECISION X(N),F(N),Y(N),DF(N),C(IC,3),WK(7*(N+2)),
|
---|
39 | * VAR,SE(N)
|
---|
40 | DOUBLE PRECISION GGRAND,DSEED
|
---|
41 | C
|
---|
42 | C---INITIALIZE---
|
---|
43 | DSEED=1.2345D4
|
---|
44 | JOB=1
|
---|
45 | VAR=-1.0D0
|
---|
46 | C
|
---|
47 | C---CALCULATE DATA POINTS---
|
---|
48 | DO 10 I=1,N
|
---|
49 | X(I)=(I - 0.5)/N + (2.0*GGRAND(DSEED) - 1.0)/(3.0*N)
|
---|
50 | F(I)=DSIN(4.71238*X(I)) + (2.0*GGRAND(DSEED) - 1.0)*0.3
|
---|
51 | DF(I)=1.0D0
|
---|
52 | 10 CONTINUE
|
---|
53 | C
|
---|
54 | C---FIT CUBIC SPLINE---
|
---|
55 | CALL CUBGCV(X,F,DF,N,Y,C,IC,VAR,JOB,SE,WK,IER)
|
---|
56 | C
|
---|
57 | C---WRITE OUT RESULTS---
|
---|
58 | WRITE(6,20)
|
---|
59 | 20 FORMAT(' CUBGCV TEST DRIVER RESULTS:')
|
---|
60 | WRITE(6,30) IER,VAR,WK(3),WK(4),WK(2)
|
---|
61 | 30 FORMAT(/' IER =',I4/' VAR =',F7.4/
|
---|
62 | * ' GENERALIZED CROSS VALIDATION =',F7.4/
|
---|
63 | * ' MEAN SQUARE RESIDUAL =',F7.4/
|
---|
64 | * ' RESIDUAL DEGREES OF FREEDOM =',F7.2)
|
---|
65 | WRITE(6,40)
|
---|
66 | 40 FORMAT(/' INPUT DATA',17X,'OUTPUT RESULTS'//
|
---|
67 | * ' I X(I) F(I)',6X,' Y(I) SE(I)',
|
---|
68 | * ' C(I,1) C(I,2) C(I,3)')
|
---|
69 | DO 60 I=1,N-1
|
---|
70 | WRITE(6,50) I,X(I),F(I),Y(I),SE(I),(C(I,J),J=1,3)
|
---|
71 | 50 FORMAT(I4,2F8.4,6X,2F8.4,3E12.4)
|
---|
72 | 60 CONTINUE
|
---|
73 | WRITE(6,50) N,X(N),F(N),Y(N),SE(N)
|
---|
74 | STOP
|
---|
75 | END
|
---|
76 | DOUBLE PRECISION FUNCTION GGRAND(DSEED)
|
---|
77 | C
|
---|
78 | C DOUBLE PRECISION UNIFORM RANDOM NUMBER GENERATOR
|
---|
79 | C
|
---|
80 | C CONSTANTS: A = 7**5
|
---|
81 | C B = 2**31 - 1
|
---|
82 | C C = 2**31
|
---|
83 | C
|
---|
84 | C REFERENCE: IMSL MANUAL, CHAPTER G - GENERATION AND TESTING OF
|
---|
85 | C RANDOM NUMBERS
|
---|
86 | C
|
---|
87 | C---SPECIFICATIONS FOR ARGUMENTS---
|
---|
88 | DOUBLE PRECISION DSEED
|
---|
89 | C
|
---|
90 | C---SPECIFICATIONS FOR LOCAL VARIABLES---
|
---|
91 | DOUBLE PRECISION A,B,C,S
|
---|
92 | C
|
---|
93 | DATA A,B,C/16807.0D0, 2147483647.0D0, 2147483648.0D0/
|
---|
94 | C
|
---|
95 | S=DSEED
|
---|
96 | S=DMOD(A*S, B)
|
---|
97 | GGRAND=S/C
|
---|
98 | DSEED=S
|
---|
99 | RETURN
|
---|
100 | END
|
---|