ETS  \$Id: Doxyfile 2162 2020-02-26 14:16:09Z g2dpc $
 All Classes Files Functions Variables Pages
NAG.f
Go to the documentation of this file.
1  REAL*8 FUNCTION s21bbf(X, Y, Z, IFAIL)
2 
3 C MARK 8 RELEASE. NAG COPYRIGHT 1979.
4 
5 C
6 
7 C ******************************************************************
8 
9 C
10 
11 C CALCULATES AN APPROXIMATE VALUE FOR THE ELLIPTIC INTEGRAL OF
12 
13 C THE FIRST KIND, RF(X,Y,Z), AS DEFINED BY B.C.CARLSON.
14 
15 C -SPECIAL FUNCTIONS OF APPLIED MATHS-ACADEMIC PRESS(1977).
16 
17 C THE ALGORITHM IS ALSO DUE TO CARLSON BUT HAS BEEN RECODED BY
18 
19 C J.L.SCHONFELDER TO AVOID INTERMEDIATE UNDER AND OVERFLOWS
20 
21 C
22 
23 C RF(X,Y,Z)=INTEGRAL(ZERO TO INFINITY) OF
24 
25 C 0.5/SQRT((T+X)*(T+Y)*(T+Z)) DT
26 
27 C
28 
29 C FOR X,Y,Z ALL .GE. ZERO AND AT MOST ONE EQUAL TO ZERO
30 
31 C
32 
33 C **************************************************************** *
34 
35 C
36 
37 C ******************************************************************
38 
39 C PRECISION-DEPENDENT CONSTANT
40 
41 C
42 
43 C ACC CONTROLS FINAL TRUNCATION ACCURACY. AN ACCURACY
44 
45 C CLOSE TO FULL MACHINE PRECISION CAN BE OBTAINED
46 
47 C FOR ALL LEGAL ARGUMENTS IF ACC IS CHOSEN SO THAT
48 
49 C 0.25*ACC**6/(1.0-ACC).LE.X02AAF/X02BAF
50 
51 C
52 
53 C TO SELECT THE CORRECT VALUE FOR A PARTICULAR MACHINE-RANGE,
54 
55 C ACTIVATE THE STATEMENT CONTAINED IN A COMMENT BEGINNING CDD ,
56 
57 C WHERE DD IS THE APPROXIMATE NUMBER OF SIGNIFICANT DECIMAL
58 
59 C DIGITS REPRESENTED BY THE MACHINE.
60 
61 C ******************************************************************
62 
63 C
64 
65 C .. SCALAR ARGUMENTS ..
66 
67 * REAL X, Y, Z
68 
69  REAL*8 x, y, z
70 
71  INTEGER ifail
72 
73 C ..
74 
75 C .. LOCAL SCALARS ..
76 
77 *+SELF,IF=IBM.
78 
79  CHARACTER*8 srname
80 
81 *+SELF.
82 
83 * REAL ACC, C1, C2, C3, CXN, CYN, CZN, E2, E3, LAMDA, LOLIM,
84 
85  REAL*8 acc, c1, c2, c3, cxn, cyn, czn, e2, e3, lamda, lolim,
86 
87  * mu, rscale, rtx, rty, rtz, uplim, xn, yn, zn
88 
89  INTEGER ind
90 
91 C .. FUNCTION REFERENCES ..
92 
93 * REAL SQRT, X02ABE, X02ACE
94 
95  REAL*8 sqrt, x02abf, x02acf
96 
97  INTEGER p01aae
98 
99 *
100 
101  REAL*8 xarg
102 
103  sqrt(xarg)=dsqrt(xarg)
104 
105 *
106 
107 C ..
108 
109 * DATA SRNAME /8H S21BBE /
110 
111  DATA srname /8h s21bbf /
112 
113 *+SELF,IF=E09.
114 
115 * DATA ACC/5.7E-2/
116 
117 *+SELF,IF=E10.
118 
119 * DATA ACC/3.9E-2/
120 
121 *+SELF,IF=E13.
122 
123 * DATA ACC/1.2E-2/
124 
125 *+SELF,IF=E16.
126 
127  DATA acc/3.9e-3/
128 
129 *+SELF,IF=E18.
130 
131 * DATA ACC/1.8E-3/
132 
133 *+SELF,IF=E20.
134 
135 * DATA ACC/8.5E-4/
136 
137 *+SELF.
138 
139 C
140 
141 C ORDER X,Y,Z INTO XN,YN,ZN ST. XN.LE.YN.LE.ZN
142 
143  IF (x.LE.y) go to 20
144 
145  xn = y
146 
147  yn = x
148 
149  go to 40
150 
151  20 xn = x
152 
153  yn = y
154 
155  40 zn = z
156 
157  IF (yn.LE.zn) go to 60
158 
159  zn = yn
160 
161  yn = z
162 
163  IF (xn.LE.yn) go to 60
164 
165  yn = xn
166 
167  xn = z
168 
169 C
170 
171 C TEST FOR VALID ARGUMENTS
172 
173  60 ind = 1
174 
175  IF (xn.LT.0.0) go to 180
176 
177  ind = 2
178 
179  IF (yn.LE.0.0) go to 180
180 
181 C
182 
183 C VALID CALL
184 
185  ifail = 0
186 
187  rscale = 1.0
188 
189 * LOLIM = 16.0*X02ABE(0.0)
190 
191  lolim = 16.0*x02abf(0.0d0)
192 
193 * UPLIM = 0.0625*X02ACE(0.0)
194 
195  uplim = 0.0625*x02acf(0.0d0)
196 
197 C
198 
199 C FOR EXTREME ARGUMENTS SCALE TO AVOID UNDER AND OVERFLOWS
200 
201  IF (zn.LE.uplim) go to 120
202 
203  rscale = 0.25
204 
205  zn = zn*0.0625
206 
207  IF (yn.LE.lolim) go to 80
208 
209  yn = yn*0.0625
210 
211  IF (xn.LE.lolim) go to 100
212 
213  xn = xn*0.0625
214 
215  go to 140
216 
217  80 lamda = (sqrt(xn)+sqrt(yn))*(sqrt(zn)*0.25)
218 
219  xn = lamda*0.25
220 
221  yn = xn
222 
223  zn = (zn+lamda)*0.25
224 
225  go to 140
226 
227  100 rtz = sqrt(zn)
228 
229  rty = sqrt(yn)
230 
231  lamda = rtz*rty + ((rtz+rty)*0.25)*sqrt(xn)
232 
233  xn = lamda*0.25
234 
235  yn = (yn+lamda)*0.25
236 
237  zn = (zn+lamda)*0.25
238 
239  go to 140
240 
241  120 IF (zn.GT.lolim) go to 140
242 
243  rscale = 4.0
244 
245  xn = xn*16.0
246 
247  yn = yn*16.0
248 
249  zn = zn*16.0
250 
251 C
252 
253 C MAIN RECURSION
254 
255  140 mu = (xn+yn+zn)/3.0
256 
257  czn = 2.0 - (zn+mu)/mu
258 
259  cxn = 2.0 - (xn+mu)/mu
260 
261  IF (dmax1(cxn,-czn).LE.acc) go to 160
262 
263  rtx = sqrt(xn)
264 
265  rty = sqrt(yn)
266 
267  rtz = sqrt(zn)
268 
269  lamda = rtz*(rtx+rty) + rtx*rty
270 
271  xn = (xn+lamda)*0.25
272 
273  yn = (yn+lamda)*0.25
274 
275  zn = (zn+lamda)*0.25
276 
277  go to 140
278 
279 C
280 
281 C POWER SERIES EXPANSION
282 
283  160 c1 = 1.0/24.0
284 
285  c2 = 3.0/44.0
286 
287  c3 = 1.0/14.0
288 
289  cyn = -cxn - czn
290 
291  e2 = cxn*cyn - czn*czn
292 
293  e3 = cxn*czn*cyn
294 
295 * S21BBE = RSCALE*(1.0+(C1*E2-0.1-C2*E3)*E2+C3*E3)/SQRT(MU)
296 
297  s21bbf = rscale*(1.0+(c1*e2-0.1-c2*e3)*e2+c3*e3)/sqrt(mu)
298 
299  go to 200
300 
301 C
302 
303 C FAILURE EXITS
304 
305  180 ifail = p01aae(ifail,ind,srname)
306 
307 * S21BBE = 0.0
308 
309  s21bbf = 0.0
310 
311  200 RETURN
312 
313  END
314 
315 
316 
317  REAL*8 FUNCTION s21bcf(X, Y, Z, IFAIL)
318 
319 C MARK 8 RELEASE. NAG COPYRIGHT 1979.
320 
321 C
322 
323 C ******************************************************************
324 
325 C
326 
327 C CALCULATES AN APPROXIMATE VALUE FOR THE ELLIPTIC INTEGRAL OF
328 
329 C THE SECOND KIND, RD(X,Y,Z), AS DEFINED BY B.C.CARLSON.
330 
331 C -SPECIAL FUNCTIONS OF APPLIED MATHS-ACADEMIC PRESS(1977).
332 
333 C THE ALGORITHM IS ALSO DUE TO CARLSON.
334 
335 C
336 
337 C RD(X,Y,Z)=INTEGRAL(ZERO TO INFINITY) OF
338 
339 C 1.5/SQRT((T+X)*(T+Y)*(T+Z)**3) DT
340 
341 C
342 
343 C FOR X.GE.0.0 , Y.GE.0.0, Z.GT.0.0 AND AT MOST ONE OF X
344 
345 C AND Y EQUAL TO 0.0.
346 
347 C
348 
349 C ******************************************************************
350 
351 C
352 
353 C ******************************************************************
354 
355 C PRECISION-DEPENDENT CONSTANT
356 
357 C
358 
359 C ACC CONTROLS FINAL TRUNCATION ACCURACY. AN ACCURACY
360 
361 C CLOSE TO FULL MACHINE PRECISION CAN BE OBTAINED
362 
363 C FOR ALL LEGAL ARGUMENTS IF ACC IS CHOSEN SO THAT
364 
365 C 3.0*ACC**6/(1.0-ACC)**1.5.LE.X02AAF/X02BAF
366 
367 C
368 
369 C TO SELECT THE CORRECT VALUE FOR A PARTICULAR MACHINE-RANGE,
370 
371 C ACTIVATE THE STATEMENT CONTAINED IN A COMMENT BEGINNING CDD ,
372 
373 C WHERE DD IS THE APPROXIMATE NUMBER OF SIGNIFICANT DECIMAL
374 
375 C DIGITS REPRESENTED BY THE MACHINE.
376 
377 C ******************************************************************
378 
379 C
380 
381 C .. SCALAR ARGUMENTS ..
382 
383 * REAL X, Y, Z
384 
385  REAL*8 x, y, z
386 
387  INTEGER ifail
388 
389 C ..
390 
391 C .. LOCAL SCALARS ..
392 
393 *+SELF,IF=IBM.
394 
395  CHARACTER*8 srname
396 
397 *+SELF.
398 
399 * REAL ACC, C1, C2, C3, C4, C5, C6, CXN, CYN, CZN, EA, EB, EC,
400 
401  REAL*8 acc, c1, c2, c3, c4, c5, c6, cxn, cyn, czn, ea, eb, ec,
402 
403  * ed, ef, lamda, lolim, mu, pow4, rtx, rty, rtz, sigma, uplim,
404 
405  * xn, yn, zn
406 
407  INTEGER ind
408 
409 C .. FUNCTION REFERENCES ..
410 
411 * REAL SQRT, X02ABE, X02ACE
412 
413  REAL*8 sqrt, x02abf, x02acf
414 
415  INTEGER p01aae
416 
417 *
418 
419  REAL*8 xarg
420 
421  sqrt(xarg)=dsqrt(xarg)
422 
423 *
424 
425 C ..
426 
427 * DATA SRNAME /8H S21BCE /
428 
429  DATA srname /8h s21bcf /
430 
431 *+SELF,IF=E09.
432 
433 * DATA ACC/3.8E-2/
434 
435 *+SELF,IF=E10.
436 
437 * DATA ACC/2.6E-2/
438 
439 *+SELF,IF=E13.
440 
441 * DATA ACC/8.3E-3/
442 
443 *+SELF,IF=E16.
444 
445  DATA acc/2.6e-3/
446 
447 *+SELF,IF=E18.
448 
449 * DATA ACC/1.2E-3/
450 
451 *+SELF,IF=E20.
452 
453 * DATA ACC/5.6E-4/
454 
455 *+SELF.
456 
457 C
458 
459 C TEST FOR VALID ARGUMENTS
460 
461  ind = 1
462 
463  IF (x.LT.0.0 .OR. y.LT.0.0 .OR. x+y.EQ.0.0) go to 60
464 
465  ind = 2
466 
467  IF (z.LE.0.0) go to 60
468 
469  ind = 3
470 
471 * LOLIM = 2.0/X02ACE(0.0)**0.66667
472 
473  lolim = 2.0/x02acf(0.0d0)**0.66667
474 
475  IF (dmin1(x+y,z).LT.lolim) go to 60
476 
477  ind = 4
478 
479 * UPLIM = (0.1*ACC/X02ABE(0.0))**0.66667
480 
481  uplim = (0.1*acc/x02abf(0.0d0))**0.66667
482 
483  IF (dmax1(x,y,z).GE.uplim) go to 60
484 
485 C
486 
487 C VALID CALL
488 
489  ifail = 0
490 
491  xn = x
492 
493  yn = y
494 
495  zn = z
496 
497  sigma = 0.0
498 
499  pow4 = 1.0
500 
501 C
502 
503 C MAIN RECURSION
504 
505  20 mu = (xn+yn+3.0*zn)*0.2
506 
507  cxn = (mu-xn)/mu
508 
509  cyn = (mu-yn)/mu
510 
511  czn = (mu-zn)/mu
512 
513  IF (dmax1(abs(cxn),abs(cyn),abs(czn)).LT.acc) go to 40
514 
515  rtx = sqrt(xn)
516 
517  rty = sqrt(yn)
518 
519  rtz = sqrt(zn)
520 
521  lamda = rtx*rty + rty*rtz + rtz*rtx
522 
523  zn = zn + lamda
524 
525  sigma = sigma + pow4/(rtz*zn)
526 
527  pow4 = pow4*0.25
528 
529  zn = zn*0.25
530 
531  xn = (xn+lamda)*0.25
532 
533  yn = (yn+lamda)*0.25
534 
535  go to 20
536 
537 C
538 
539 C POWER SERIES EVALUATION
540 
541  40 c1 = 3.0/14.0
542 
543  c2 = 9.0/88.0
544 
545  c3 = 9.0/52.0
546 
547  c4 = 1.0/6.0
548 
549  c5 = 9.0/22.0
550 
551  c6 = 3.0/26.0
552 
553  ea = cxn*cyn
554 
555  eb = czn*czn
556 
557  ec = 3.0*ea - 8.0*eb
558 
559  ed = ea - eb
560 
561  ef = ea - 6.0*eb
562 
563 * S21BCE = 3.0*SIGMA + POW4*(1.0+EF*(C2*EF-C1-C3*EC*CZN)+CZN*
564 
565  s21bcf = 3.0*sigma + pow4*(1.0+ef*(c2*ef-c1-c3*ec*czn)+czn*
566 
567  * (c4*ec+czn*(czn*c6*ea-c5*ed)))/(mu*sqrt(mu))
568 
569  go to 80
570 
571 C
572 
573 C FAILURE EXITS
574 
575  60 ifail = p01aae(ifail,ind,srname)
576 
577 * S21BCE = 0.0
578 
579  s21bcf = 0.0
580 
581  80 RETURN
582 
583  END
584 
585  INTEGER FUNCTION p01aae(IFAIL, ERROR, SRNAME)
586 
587 C MARK 1 RELEASE. NAG COPYRIGHT 1971
588 
589 C MARK 3 REVISED
590 
591 C MARK 4A REVISED, IER-45
592 
593 C MARK 4.5 REVISED
594 
595 C MARK 7 REVISED (DEC 1978)
596 
597 C RETURNS THE VALUE OF ERROR OR TERMINATES THE PROGRAM.
598 
599  INTEGER error, ifail, nout
600 
601 C+SELF,IF=IBM.
602 
603  CHARACTER*8 srname
604 
605 C+SELF.
606 
607 C TEST IF NO ERROR DETECTED
608 
609  IF (error.EQ.0) go to 20
610 
611 C DETERMINE OUTPUT UNIT FOR MESSAGE
612 
613  CALL x04aae(0,nout)
614 
615 C TEST FOR SOFT FAILURE
616 
617  IF (mod(ifail,10).EQ.1) go to 10
618 
619 C HARD FAILURE
620 
621  WRITE (nout,99999) srname, error
622 
623 C STOPPING MECHANISM MAY ALSO DIFFER
624 
625  stop
626 
627 C SOFT FAIL
628 
629 C TEST IF ERROR MESSAGES SUPPRESSED
630 
631  10 IF (mod(ifail/10,10).EQ.0) go to 20
632 
633  WRITE (nout,99999) srname, error
634 
635  20 p01aae = error
636 
637  RETURN
638 
639 99999 FORMAT (1h0, 38herror detected by nag library routine , a8,
640 
641  * 11h - ifail = , i5//)
642 
643  END
644 
645 
646 
647  REAL*8 FUNCTION x02abf(X)
648 
649 C NAG COPYRIGHT 1975
650 
651 C MARK 4.5 RELEASE
652 
653 * REAL X, Z
654 
655  REAL*8 x, z
656 
657 *+SELF,IF=R01.
658 
659 * DATA Z/Z00100000/
660 
661 *+SELF,IF=R04.
662 
663 * DATA Z/0001 4000 0000 0000 0000B/
664 
665  DATA z/1.d-15/
666 
667 *+SELF.
668 
669 C * RMIN *
670 
671 C RETURNS THE VALUE OF THE SMALLEST POSITIVE REAL FLOATING-
672 
673 C POINT NUMBER EXACTLY REPRESENTABLE ON THE COMPUTER
674 
675 C THE X PARAMETER IS NOT USED
676 
677 * X02ABE = Z
678 
679  x02abf = z
680 
681  RETURN
682 
683  END
684 
685 *+DECK,X02ACE.
686 
687 * REAL FUNCTION X02ACE(X)
688 
689  REAL*8 FUNCTION x02acf(X)
690 
691 C NAG COPYRIGHT 1975
692 
693 C MARK 4.5 RELEASE
694 
695 * REAL X, Z
696 
697  REAL*8 x, z
698 
699 *+SELF,IF=R01.
700 
701 * DATA Z/Z7FFFFFFF/
702 
703 *+SELF,IF=R04.
704 
705 * DATA Z/3776 7777 7777 7777 7777B/
706 
707  DATA z/1.d+15/
708 
709 *+SELF.
710 
711 C * RMAX *
712 
713 C RETURNS THE VALUE OF THE LARGEST POSITIVE REAL FLOATING-
714 
715 C POINT NUMBER REPRESENTABLE ON THE COMPUTER
716 
717 * X02ACE = Z
718 
719  x02acf = z
720 
721  RETURN
722 
723  END
724 
725 
726 
727  SUBROUTINE x04aae(I,NERR)
728 
729 C MARK 7 RELEASE. NAG COPYRIGHT 1978
730 
731 C MARK 7C REVISED IER-190 (MAY 1979)
732 
733 C IF I = 0, SETS NERR TO CURRENT ERROR MESSAGE UNIT NUMBER
734 
735 C (STORED IN NERR1).
736 
737 C IF I = 1, CHANGES CURRENT ERROR MESSAGE UNIT NUMBER TO
738 
739 C VALUE SPECIFIED BY NERR.
740 
741 C
742 
743 C *** NOTE ***
744 
745 C THIS ROUTINE ASSUMES THAT THE VALUE OF NERR1 IS SAVED
746 
747 C BETWEEN CALLS. IN SOME IMPLEMENTATIONS IT MAY BE
748 
749 C NECESSARY TO STORE NERR1 IN A LABELLED COMMON
750 
751 C BLOCK /AX04AA/ TO ACHIEVE THIS.
752 
753 C
754 
755 C .. SCALAR ARGUMENTS ..
756 
757  INTEGER i, nerr
758 
759 C ..
760 
761 C .. LOCAL SCALARS ..
762 
763  INTEGER nerr1
764 
765 C ..
766 
767 C DATA NERR1 /5/
768 
769  DATA nerr1 /6/
770 
771  IF (i.EQ.0) nerr = nerr1
772 
773  IF (i.EQ.1) nerr1 = nerr
774 
775  RETURN
776 
777  END
778 
779 * SUBROUTINE F02AFE(A, IA, N, RR, RI, INTGER, LFAIL)
780 
781  SUBROUTINE f02aff(A, IA, N, RR, RI, INTGER, LFAIL)
782 
783 C MARK 2 RELEASE. NAG COPYRIGHT 1972
784 
785 C MARK 3 REVISED.
786 
787 C MARK 4.5 REVISED
788 
789 C
790 
791 C EIGENVALUES OF A REAL UNSYMMETRIC MATRIX
792 
793 C 1ST AUGUST 1971
794 
795 C
796 
797  INTEGER p01aae, isave, lfail, n, ia, intger(n)
798 
799  CHARACTER*8 srname
800 
801  REAL*8 acc, xxxx, a(ia,n), rr(n), ri(n), x02aae
802 
803  DATA srname /' F02AFE'/
804 
805  isave = lfail
806 
807  lfail = 1
808 
809  acc = x02aae(xxxx)
810 
811  CALL f01akf(n, 1, n, a, ia, intger)
812 
813  CALL f02apf(n, acc, a, ia, rr, ri, intger, lfail)
814 
815  IF (lfail.NE.0) lfail = p01aae(isave,lfail,srname)
816 
817  RETURN
818 
819  END
820 
821 * SUBROUTINE F02APE(NN, ACC, H, IH, WR, WI, ICNT, LFAIL)
822 
823  SUBROUTINE f02apf(NN, ACC, H, IH, WR, WI, ICNT, LFAIL)
824 
825 C MARK 2 RELEASE. NAG COPYRIGHT 1972
826 
827 C MARK 3 REVISED.
828 
829 C MARK 4 REVISED.
830 
831 C MARK 4.5 REVISED
832 
833 C MARK 7D REVISED IER-197 (JUL 1979)
834 
835 C MARK 7E REVISED IER-203 (JUL 1979)
836 
837 C MARK 8 REVISED. IER-234 (APR 1980).
838 
839 C MARK 9 REVISED. IER-326 (SEP 1981).
840 
841 C
842 
843 C HQR
844 
845 C FINDS THE EIGENVALUES OF A REAL UPPER HESSENBERG MATRIX, H,
846 
847 C STORED IN THE ARRAY H(N,N), AND STORES THE REAL PARTS IN
848 
849 C THE ARRAY WR(N) AND THE IMAGINARY PARTS IN THE ARRAY
850 
851 C WI(N). ACC IS THE RELATIVE MACHINE PRECISION. THE
852 
853 C SUBROUTINE FAILS IF ALL EIGENVALUES TAKE MORE THAN 30*N
854 
855 C ITERATIONS.
856 
857 C 1ST DECEMBER 1971
858 
859 C
860 
861  INTEGER p01aae, isave, lfail, n, nn, its, na, l, ll, i, m,
862 
863  * n2, mm, m2, m3, k, j, ih, icnt(nn), nhs, itn
864 
865  CHARACTER*8 srname
866 
867  REAL*8 t, acc, x, y, w, s, z, r, p, q, h(ih,nn), wr(nn), wi(nn)
868 
869  REAL*8 norm, x02ade
870 
871  LOGICAL notlst
872 
873  DATA srname /' F02APE'/
874 
875  isave = lfail
876 
877  lfail = 0
878 
879  t = 0.0
880 
881  n = nn
882 
883  itn = 30*n
884 
885 C COMPUTE MATRIX NORM
886 
887  norm = 0.0
888 
889  k = 1
890 
891  DO 30 i = 1,n
892 
893  DO 25 j = k,n
894 
895  norm = norm + abs(h(i,j))
896 
897  25 CONTINUE
898 
899  k = i
900 
901  30 CONTINUE
902 
903  nhs = n*(n+1)/2 + n - 1
904 
905  20 IF (n.EQ.0) go to 600
906 
907  its = 0
908 
909  na = n - 1
910 
911 C LOOK FOR SINGLE SMALL SUB-DIAGONAL ELEMENT
912 
913  40 l = n + 1
914 
915  IF (n.LT.2) go to 80
916 
917  DO 60 ll=2,n
918 
919  l = l - 1
920 
921  s = abs(h(l-1,l-1)) + abs(h(l,l))
922 
923  IF (s.LT.x02ade(0.0d0)) s = norm/float(nhs)
924 
925  IF (abs(h(l,l-1)).LE.acc*s) go to 100
926 
927  60 CONTINUE
928 
929  80 l = 1
930 
931  100 x = h(n,n)
932 
933  IF (l.EQ.n) go to 520
934 
935  y = h(na,na)
936 
937  w = h(n,na)*h(na,n)
938 
939  IF (l.EQ.na) go to 540
940 
941  IF (itn.GT.0) go to 120
942 
943  lfail = p01aae(isave,1,srname)
944 
945  RETURN
946 
947  120 IF ((its.EQ.10) .OR. (its.EQ.20)) go to 140
948 
949  go to 200
950 
951 C FORM EXCEPTIONAL SHIFT
952 
953  140 t = t + x
954 
955  IF (na.LT.1) go to 180
956 
957  DO 160 i=1,na
958 
959  h(i,i) = h(i,i) - x
960 
961  160 CONTINUE
962 
963  180 h(n,n) = 0.0
964 
965  s = abs(h(n,na)) + abs(h(na,n-2))
966 
967  x = 0.75*s
968 
969  y = 0.75*s
970 
971  w = -0.4375*s**2
972 
973  200 its = its + 1
974 
975  itn = itn - 1
976 
977 C LOOK FOR TWO SMALL CONSECUTIVE SUB-DIAGONAL ELEMENTS
978 
979  IF (l.GT.(n-2)) go to 240
980 
981  m = n - 1
982 
983  n2 = n - 2
984 
985  DO 220 mm=l,n2
986 
987  m = m - 1
988 
989  z = h(m,m)
990 
991  r = x - z
992 
993  s = y - z
994 
995  p = (r*s-w)/h(m+1,m) + h(m,m+1)
996 
997  q = h(m+1,m+1) - z - r - s
998 
999  r = h(m+2,m+1)
1000 
1001  s = abs(p) + abs(q) + abs(r)
1002 
1003  p = p/s
1004 
1005  q = q/s
1006 
1007  r = r/s
1008 
1009  IF (m.EQ.l) go to 240
1010 
1011  IF ((abs(h(m,m-1))*(abs(q)+abs(r))).LE.(acc*abs(p)*
1012 
1013  * (abs(h(m-1,m-1))+abs(z)+abs(h(m+1,m+1))))) go to 240
1014 
1015  220 CONTINUE
1016 
1017  240 m2 = m + 2
1018 
1019  IF (m2.GT.n) go to 280
1020 
1021  DO 260 i=m2,n
1022 
1023  h(i,i-2) = 0.0
1024 
1025  260 CONTINUE
1026 
1027  280 m3 = m + 3
1028 
1029  IF (m3.GT.n) go to 320
1030 
1031  DO 300 i=m3,n
1032 
1033  h(i,i-3) = 0.0
1034 
1035  300 CONTINUE
1036 
1037  320 IF (m.GT.na) go to 40
1038 
1039 C DOUBLE QR STEP INVOLVING ROWS L TO N AND COLUMNS M TO N
1040 
1041  DO 500 k=m,na
1042 
1043  notlst = .true.
1044 
1045  IF (k.EQ.na) notlst = .false.
1046 
1047  IF (k.EQ.m) go to 340
1048 
1049  p = h(k,k-1)
1050 
1051  q = h(k+1,k-1)
1052 
1053  r = 0.0
1054 
1055  IF (notlst) r = h(k+2,k-1)
1056 
1057  x = abs(p) + abs(q) + abs(r)
1058 
1059  IF (x.EQ.0.0) go to 500
1060 
1061  p = p/x
1062 
1063  q = q/x
1064 
1065  r = r/x
1066 
1067  340 s = sqrt(p**2+q**2+r**2)
1068 
1069  IF (p.LT.0.0) s = -s
1070 
1071  IF (k.NE.m) go to 360
1072 
1073  IF (l.NE.m) h(k,k-1) = -h(k,k-1)
1074 
1075  go to 380
1076 
1077  360 h(k,k-1) = -s*x
1078 
1079  380 p = p + s
1080 
1081  x = p/s
1082 
1083  y = q/s
1084 
1085  z = r/s
1086 
1087  q = q/p
1088 
1089  r = r/p
1090 
1091  IF (k.GT.n) go to 440
1092 
1093 C ROW MODIFICATION
1094 
1095  DO 420 j=k,n
1096 
1097  p = h(k,j) + q*h(k+1,j)
1098 
1099  IF (.NOT.notlst) go to 400
1100 
1101  p = p + r*h(k+2,j)
1102 
1103  h(k+2,j) = h(k+2,j) - p*z
1104 
1105  400 h(k+1,j) = h(k+1,j) - p*y
1106 
1107  h(k,j) = h(k,j) - p*x
1108 
1109  420 CONTINUE
1110 
1111  440 j = n
1112 
1113  IF ((k+3).LT.n) j = k + 3
1114 
1115  IF (l.GT.j) go to 500
1116 
1117 C COLUMN MODIFICATION
1118 
1119  DO 480 i=l,j
1120 
1121  p = x*h(i,k) + y*h(i,k+1)
1122 
1123  IF (.NOT.notlst) go to 460
1124 
1125  p = p + z*h(i,k+2)
1126 
1127  h(i,k+2) = h(i,k+2) - p*r
1128 
1129  460 h(i,k+1) = h(i,k+1) - p*q
1130 
1131  h(i,k) = h(i,k) - p
1132 
1133  480 CONTINUE
1134 
1135  500 CONTINUE
1136 
1137  go to 40
1138 
1139 C ONE ROOT FOUND
1140 
1141  520 wr(n) = x + t
1142 
1143  wi(n) = 0.0
1144 
1145  icnt(n) = its
1146 
1147  n = na
1148 
1149  go to 20
1150 
1151 C TWO ROOTS FOUND
1152 
1153  540 p = (y-x)/2.0
1154 
1155  q = p**2 + w
1156 
1157  y = sqrt(abs(q))
1158 
1159  x = x + t
1160 
1161  icnt(n) = -its
1162 
1163  icnt(na) = its
1164 
1165  IF (q.GT.0.0) go to 560
1166 
1167 C COMPLEX PAIR
1168 
1169  wr(na) = x + p
1170 
1171  wr(n) = x + p
1172 
1173  wi(na) = y
1174 
1175  wi(n) = -y
1176 
1177  go to 580
1178 
1179 C REAL PAIR
1180 
1181  560 IF (p.LT.0.0) y = -y
1182 
1183  y = p + y
1184 
1185  wr(na) = x + y
1186 
1187  wr(n) = x - w/y
1188 
1189  wi(n) = 0.0
1190 
1191  wi(na) = 0.0
1192 
1193  580 n = n - 2
1194 
1195  go to 20
1196 
1197  600 RETURN
1198 
1199  END
1200 
1201 * SUBROUTINE F01AKE(N, K, L, A, IA, INTGER)
1202 
1203  SUBROUTINE f01akf(N, K, L, A, IA, INTGER)
1204 
1205 C MARK 2 RELEASE. NAG COPYRIGHT 1972
1206 
1207 C MARK 4 REVISED.
1208 
1209 C MARK 4.5 REVISED
1210 
1211 C MARK 8 REVISED. IER-248 (JUN 1980).
1212 
1213 C
1214 
1215 C DIRHES
1216 
1217 C AUGUST 1ST, 1971 .
1218 
1219 C GIVEN THE UNSYMMETRIC MATRIX, A, STORED IN THE ARRAY A(N,N),
1220 
1221 C THIS SUBROUTINE REDUCES THE SUB-MATRIX OF ORDER L - K + 1,
1222 
1223 C WHICH STARTS AT THE ELEMENT A(K,K) AND FINISHES AT THE
1224 
1225 C ELEMENT A(L,L), TO HESSENBERG FORM, H, BY THE DIRECT
1226 
1227 C METHOD(AN = NH). THE MATRIX H IS OVERWRITTEN ON A WITH
1228 
1229 C DETAILS OF THE TRANSFORMATIONS (N) STORED IN THE REMAINING
1230 
1231 C TRIANGLE UNDER H AND IN ELEMENTS K TO L OF THE ARRAY
1232 
1233 C INTGER(N).
1234 
1235 C 1ST AUGUST 1971
1236 
1237 C
1238 
1239  INTEGER ifail1, k1, k, l, j, m, i, n, j1, ia, ij, intger(n)
1240 
1241  REAL*8 x, y, d2, a(ia,n)
1242 
1243  ifail1 = 0
1244 
1245  k1 = k + 1
1246 
1247  IF (k1.GT.n) RETURN
1248 
1249  DO 200 j=k1,n
1250 
1251  m = j
1252 
1253  x = 0.0
1254 
1255  IF (j.GT.l) go to 120
1256 
1257  DO 20 i=j,l
1258 
1259  IF (abs(a(i,j-1)).LE.abs(x)) go to 20
1260 
1261  x = a(i,j-1)
1262 
1263  m = i
1264 
1265  20 CONTINUE
1266 
1267  intger(j) = m
1268 
1269  IF (m.EQ.j) go to 80
1270 
1271 C INTERCHANGE ROWS AND COLUMNS OF A.
1272 
1273  DO 40 i=k,n
1274 
1275  y = a(m,i)
1276 
1277  a(m,i) = a(j,i)
1278 
1279  a(j,i) = y
1280 
1281  40 CONTINUE
1282 
1283  DO 60 i=1,l
1284 
1285  y = a(i,m)
1286 
1287  a(i,m) = a(i,j)
1288 
1289  a(i,j) = y
1290 
1291  60 CONTINUE
1292 
1293  80 IF (x.EQ.0.0) go to 120
1294 
1295  IF (j.EQ.l) go to 120
1296 
1297  j1 = j + 1
1298 
1299  DO 100 i=j1,l
1300 
1301  a(i,j-1) = a(i,j-1)/x
1302 
1303  100 CONTINUE
1304 
1305  120 DO 180 i=1,l
1306 
1307  y = a(i,j)
1308 
1309  d2 = 0.0
1310 
1311  IF (x.EQ.0.0) go to 140
1312 
1313  IF (j.GE.l) go to 140
1314 
1315  j1 = j + 1
1316 
1317  CALL x03aaf(a(i,j1), (n-j)*ia-i+1, a(j1,j-1),
1318 
1319  * (n-j+2)*ia-j, l-j, ia, 1, y, d2, y, d2, .true., ifail1)
1320 
1321  140 ij = j
1322 
1323  IF (i.LE.j) ij = i - 1
1324 
1325  y = -y
1326 
1327  d2 = -d2
1328 
1329  IF ((k+1).GT.ij) go to 160
1330 
1331  CALL x03aaf(a(i,k), (n-k+1)*ia-i+1, a(k1,j),
1332 
1333  * (n-j+1)*ia-k, ij-k, ia, 1, y, d2, y, d2, .true.,
1334 
1335  * ifail1)
1336 
1337  160 a(i,j) = -y
1338 
1339  180 CONTINUE
1340 
1341  200 CONTINUE
1342 
1343  RETURN
1344 
1345  END
1346 
1347 *+PATCH,TEXTX03.
1348 
1349 *+DECK,X03AAE.
1350 
1351 * SUBROUTINE X03AAE(A, ISIZEA, B, ISIZEB, N, ISTEPA, ISTEPB,
1352 
1353  SUBROUTINE x03aaf(A, ISIZEA, B, ISIZEB, N, ISTEPA, ISTEPB,
1354 
1355  * c1, c2, d1, d2, sw, ifail)
1356 
1357 C NAG COPYRIGHT 1975
1358 
1359 C MARK 4.5 RELEASE
1360 
1361 C MARK 6 REVISED
1362 
1363 C
1364 
1365 C CALCULATES THE VALUE OF A SCALAR PRODUCT USING BASIC
1366 
1367 C OR ADDITIONAL PRECISION AND ADDS IT TO A BASIC OR ADDITIONAL
1368 
1369 C PRECISION INITIAL VALUE.
1370 
1371 C
1372 
1373  INTEGER p01aae, isave, isizea, isizeb, istepa, istepb, ifail,
1374 
1375  * is, it, n, i
1376 
1377  DOUBLE PRECISION sum
1378 
1379 *+SELF,IF=IBM.
1380 
1381  CHARACTER*8 srname
1382 
1383 *+SELF.
1384 
1385  REAL*8 a(isizea), b(isizeb), c1, c2, d1, d2, x
1386 
1387  LOGICAL sw
1388 
1389  DATA srname /8h x03aae /
1390 
1391  isave = ifail
1392 
1393  ifail = 0
1394 
1395  IF (istepa.GT.0 .AND. istepb.GT.0) go to 20
1396 
1397  ifail = p01aae(isave,1,srname)
1398 
1399  RETURN
1400 
1401  20 is = 1 - istepa
1402 
1403  it = 1 - istepb
1404 
1405  IF (sw) go to 80
1406 
1407  x = 0.0
1408 
1409  IF (n.LT.1) go to 60
1410 
1411  DO 40 i=1,n
1412 
1413  is = is + istepa
1414 
1415  it = it + istepb
1416 
1417  x = x + a(is)*b(it)
1418 
1419  40 CONTINUE
1420 
1421  60 d1 = x + (c1+c2)
1422 
1423  d2 = 0.0
1424 
1425  RETURN
1426 
1427  80 sum = 0.0d0
1428 
1429  IF (n.LT.1) go to 120
1430 
1431  DO 100 i=1,n
1432 
1433  is = is + istepa
1434 
1435  it = it + istepb
1436 
1437  sum = sum + dble(a(is))*b(it)
1438 
1439  100 CONTINUE
1440 
1441  120 sum = sum + (dble(c1)+c2)
1442 
1443  d1 = sum + sum - dble(sngl(sum))
1444 
1445 C THE LAST STATEMENT ASSUMES THAT THE MACHINE SIMPLY
1446 
1447 C TRUNCATES WHEN ASSIGNING A DOUBLE PRECISION QUANTITY
1448 
1449 C TO A SINGLE PRECISION VARIABLE. IF INSTEAD THE MACHINE
1450 
1451 C ROUNDS, REPLACE THE LAST STATEMENT BY
1452 
1453 C D1 = SUM
1454 
1455  d2 = sum - d1
1456 
1457  RETURN
1458 
1459  END
1460 
1461 *PATCH,TEXTX02.
1462 
1463 *DECK,X02AAE.
1464 
1465  REAL*8 FUNCTION x02aae(X)
1466 
1467 C NAG COPYRIGHT 1975
1468 
1469 C MARK 4.5 RELEASE
1470 
1471  REAL*8 x, z
1472 
1473 *SELF,IF=R01.
1474 
1475 C DATA Z/Z3C100000/
1476 
1477 *SELF,IF=R04.
1478 
1479 C DATA Z/1641 4000 0000 0000 0000B/
1480 
1481  DATA z/1.d-15/
1482 
1483 *SELF.
1484 
1485 C * EPS *
1486 
1487 C RETURNS THE VALUE EPS WHERE EPS IS THE SMALLEST
1488 
1489 C POSITIVE
1490 
1491 C NUMBER SUCH THAT 1.0 + EPS > 1.0
1492 
1493 C THE X PARAMETER IS NOT USED
1494 
1495  x02aae = z
1496 
1497  RETURN
1498 
1499  END
1500 
1501 *+DECK,X02ADE.
1502 
1503  REAL*8 FUNCTION x02ade(X)
1504 
1505 C NAG COPYRIGHT 1975
1506 
1507 C MARK 4.5 RELEASE
1508 
1509  REAL*8 x, z
1510 
1511 *+SELF,IF=R01.
1512 
1513 * DATA Z/Z05100000/
1514 
1515 *+SELF,IF=R04.
1516 
1517 * DATA Z/0060 4000 0000 0000 0000B/
1518 
1519 *+SELF.
1520 
1521  DATA z/1.d-15/
1522 
1523 C * TOL *
1524 
1525 C RETURNS THE RATIO OF THE SMALLEST POSITIVE REAL FLOATING-
1526 
1527 C POINT NUMBER REPRESENTABLE ON THE COMPUTER TO EPS
1528 
1529  x02ade = z
1530 
1531  RETURN
1532 
1533  END
1534 
1535 *+DECK,X02ADE.
1536 
1537  SUBROUTINE e04abe(FUN, EPS, T, A, B, MAXCAL, X, F, IFAIL)
1538 
1539 C
1540 
1541 C MARK 6 RELEASE NAG COPYRIGHT 1977
1542 
1543 C MARK 8 REVISED. IER-231 (MAR 1980).
1544 
1545 C MARK 8D REVISED. IER-272 (DEC 1980).
1546 
1547 C
1548 
1549 C **************************************************************
1550 
1551 C
1552 
1553 C E04ABE ATTEMPTS TO FIND A MINIMUM IN AN INTERVAL A .LE. X .LE.
1554 
1555 C B OF A FUNCTION F(X) OF THE SCALAR X, USING FUNCTION VALUES
1556 
1557 C ONLY.
1558 
1559 C
1560 
1561 C IT IS BASED ON THE SUBROUTINE UNIFUN IN THE NPL ALGORITHMS
1562 
1563 C LIBRARY (REF. NO. E4/13/F). THE FUNCTION F(X) IS DEFINED BY
1564 
1565 C THE USER-SUPPLIED SUBROUTINE FUN. T AND EPS DEFINE A TOLERANCE
1566 
1567 C TOL = EPS * ABS(X) + T, AND FUN IS NEVER EVALUATED AT TWO
1568 
1569 C POINTS CLOSER THAN TOL. IF FUN IS DELTA-UNIMODAL, FOR SOME
1570 
1571 C DELTA LESS THAN TOL, THEN X APPROXIMATES THE GLOBAL MINIMUM OF
1572 
1573 C FUN WITH AN ERROR LESS THAN 3*TOL. IF FUN IS NOT DELTA-
1574 
1575 C UNIMODAL ON (A, B), THEN X MAY APPROXIMATE A LOCAL, BUT NON
1576 
1577 C GLOBAL, MINIMUM. EPS SHOULD BE NO SMALLER THAN 2*EPSMCH, AND
1578 
1579 C PREFERABLY NOT MUCH LESS THAN SQRT(EPSMCH), WHERE EPSMCH IS
1580 
1581 C THE RELATIVE MACHINE PRECISION. T SHOULD BE POSITIVE. NOTE
1582 
1583 C THAT, FOR CONSISTENCY WITH OTHER E04 DOCUMENTATION, THE NAME
1584 
1585 C FUNCT IS USED INSTEAD OF FUN IN THE WRITE-UP.
1586 
1587 C
1588 
1589 C PHILIP E. GILL, WALTER MURRAY, SUSAN M. PICKEN, HAZEL M.
1590 
1591 C BARBER AND MARGARET H. WRIGHT, D.N.A.C., NATIONAL PHYSICAL
1592 
1593 C LABORATORY, ENGLAND
1594 
1595 C
1596 
1597 C **************************************************************
1598 
1599 C
1600 
1601 C .. SCALAR ARGUMENTS ..
1602 
1603  REAL*8 a, b, eps, f, t, x
1604 
1605  INTEGER ifail, maxcal
1606 
1607 C .. SUBROUTINE ARGUMENTS ..
1608 
1609 C FUN
1610 
1611 C ..
1612 
1613 C .. LOCAL SCALARS ..
1614 
1615  CHARACTER*8 srname
1616 
1617  REAL*8 b1, d, e, epsmch, f1, f2, fa, fu, fv, fw, gtest1,
1618 
1619  * gtest2, gu, oldf, pt2, pt4, pt6, rr, rteps, scxbd, ss, tol,
1620 
1621  * u, x1, x2, xlamda, xv, xw, sftbnd
1622 
1623  INTEGER iflag, iloc, isave, numf
1624 
1625 C .. FUNCTION REFERENCES ..
1626 
1627  REAL*8 sqrt, xarg, x02aae
1628 
1629  INTEGER p01aae
1630 
1631  sqrt(xarg)=dsqrt(xarg)
1632 
1633 
1634 
1635 C .. SUBROUTINE REFERENCES ..
1636 
1637 C ABZE04
1638 
1639 C ..
1640 
1641  DATA srname /' E04ABE'/
1642 
1643  isave = ifail
1644 
1645 C
1646 
1647 C A MACHINE-DEPENDENT CONSTANT IS SET HERE. EPSMCH IS THE
1648 
1649 C SMALLEST POSITIVE REAL NUMBER SUCH THAT 1.0 + EPSMCH .GT. 1.0
1650 
1651 C
1652 
1653  epsmch = x02aae(u)
1654 
1655  rteps = sqrt(epsmch)
1656 
1657  IF (eps.LT.epsmch) eps = rteps
1658 
1659  IF (t.LT.epsmch) t = rteps
1660 
1661 C
1662 
1663 C ERROR IN INPUT PARAMETERS
1664 
1665 C
1666 
1667  ifail = 1
1668 
1669  IF (a+t.GE.b .OR. maxcal.LT.3 .OR. ifail.LT.0 .OR.
1670 
1671  * ifail.GT.1) go to 140
1672 
1673  sftbnd = a
1674 
1675  pt2 = (b-a)*2.0e-1
1676 
1677  pt4 = pt2 + pt2
1678 
1679  pt6 = pt2 + pt4
1680 
1681  x1 = a + pt4
1682 
1683  CALL fun(x1, f1)
1684 
1685  x2 = b - pt4
1686 
1687  CALL fun(x2, f2)
1688 
1689  xlamda = b
1690 
1691  IF (f1.GT.f2) go to 20
1692 
1693  x = x1
1694 
1695  a = -pt4
1696 
1697  b = pt2
1698 
1699  xw = pt2
1700 
1701  b1 = pt2
1702 
1703  rr = 1.0e+0
1704 
1705  d = -pt2
1706 
1707  fw = f2
1708 
1709  fv = f1
1710 
1711  f = f1
1712 
1713 C
1714 
1715 C SET STEP TO NEW POINT
1716 
1717 C
1718 
1719  u = -pt2
1720 
1721  go to 40
1722 
1723  20 x = x2
1724 
1725  a = -pt2
1726 
1727  b = pt4 + eps*abs(xlamda) + t
1728 
1729  xw = -pt2
1730 
1731  b1 = b
1732 
1733  rr = -1.0e+0
1734 
1735  d = pt2
1736 
1737  fw = f1
1738 
1739  fv = f2
1740 
1741  f = f2
1742 
1743 C
1744 
1745 C SET STEP TO NEW POINT
1746 
1747 C
1748 
1749  u = pt2
1750 
1751  40 xv = 0.0e+0
1752 
1753  scxbd = pt4
1754 
1755  e = pt6
1756 
1757  ss = 0.0e+0
1758 
1759  fa = fw + t
1760 
1761  oldf = fa
1762 
1763  gtest1 = 0.0e+0
1764 
1765  gtest2 = 0.0e+0
1766 
1767  tol = eps*abs(x) + t
1768 
1769  CALL fun(x+u, fu)
1770 
1771  gu = 0.0e+0
1772 
1773  numf = 3
1774 
1775 C
1776 
1777 C SET ILOC TO 3 SO THAT THE MAIN SECTION OF ABZE04 IS EXECUTED
1778 
1779 C AS THE INITIAL 3 POINTS HAVE ALREADY BEEN SET UP
1780 
1781 C
1782 
1783  iloc = 3
1784 
1785  60 CALL abze04(eps, t, 0.0d+0, sftbnd, xlamda, u, fu, gu, x, f,
1786 
1787  * xw, fw, xv, fv, a, fa, b, oldf, b1, scxbd, e, d, rr, ss,
1788 
1789  * gtest1, gtest2, tol, iloc, iflag)
1790 
1791  IF (iflag.NE.1) go to 100
1792 
1793  IF (numf.GE.maxcal) go to 80
1794 
1795  CALL fun(x+u, fu)
1796 
1797  numf = numf + 1
1798 
1799  go to 60
1800 
1801  80 ifail = 2
1802 
1803  go to 120
1804 
1805  100 ifail = 0
1806 
1807  120 maxcal = numf
1808 
1809  a = a + x
1810 
1811  b = b + x
1812 
1813  140 CONTINUE
1814 
1815  IF (ifail.EQ.0) RETURN
1816 
1817  ifail = p01aae(isave,ifail,srname)
1818 
1819  RETURN
1820 
1821 C
1822 
1823 C END OF E04ABE (UNIFUN)
1824 
1825 C
1826 
1827  END
1828 
1829  SUBROUTINE abze04(EPS, T, ETA, SFTBND, XLAMDA, U, FU, GU,
1830 
1831  * xmin, fmin, xw, fw, xv, fv, a, fa, b, oldf, b1, scxbd, e, d,
1832 
1833  * rr, ss, gtest1, gtest2, tol, iloc, itest)
1834 
1835 C
1836 
1837 C MARK 6 RELEASE NAG COPYRIGHT 1977
1838 
1839 C MARK 7 REISSUE
1840 
1841 C MARK 8 REVISED. IER-239 (APR 1980).
1842 
1843 C MARK 8 REVISED. IER-244 (MAY 1980).
1844 
1845 C MARK 9 REVISED. IER-317 (SEP 1981).
1846 
1847 C
1848 
1849 C **************************************************************
1850 
1851 C
1852 
1853 C ABZE04 (NEWPTQ), AN ALGORITHM FOR FINDING A STEPLENGTH, CALLED
1854 
1855 C REPEATEDLY BY NPL OPTIMIZATION ROUTINES WHICH REQUIRE A STEP-
1856 
1857 C LENGTH TO BE COMPUTED USING QUADRATIC INTERPOLATION.
1858 
1859 C THE PARAMETERS SET UP BEFORE THE CALL OF ABZE04 CONTAIN
1860 
1861 C INFORMATION ABOUT THE INTERVAL IN WHICH A LOWER POINT IS TO BE
1862 
1863 C FOUND AND FROM THIS ABZE04 PRODUCES A POINT AT WHICH THE
1864 
1865 C FUNCTION CAN BE EVALUATED OUTSIDE THIS SUBROUTINE.
1866 
1867 C THE VALUE OF THE INTEGER PARAMETER ILOC DETERMINES THE PATH
1868 
1869 C TAKEN THROUGH THE CODE. FOR A FURTHER DESCRIPTION OF ILOC
1870 
1871 C AND THE OTHER PARAMETERS SEE NPL ALGORITHMS LIBRARY REF. NO.
1872 
1873 C E4/15/F.
1874 
1875 C
1876 
1877 C PHILIP E. GILL, WALTER MURRAY, SUSAN M. PICKEN,
1878 
1879 C MARGARET H. WRIGHT AND ENID M. LONG
1880 
1881 C D.N.A.C. NATIONAL PHYSICAL LABORATORY, ENGLAND
1882 
1883 C
1884 
1885 C **************************************************************
1886 
1887 C
1888 
1889 C .. SCALAR ARGUMENTS ..
1890 
1891  REAL*8 a, b1, b, d, e, eps, eta, fa, fmin, fu, fv, fw, gtest1,
1892 
1893  * gtest2, gu, oldf, rr, scxbd, sftbnd, ss, t, tol, u, xlamda,
1894 
1895  * xmin, xv, xw
1896 
1897  INTEGER iloc, itest
1898 
1899 C ..
1900 
1901 C .. LOCAL SCALARS ..
1902 
1903  REAL*8 a1, d1, d2, q, r, s, t2, xm
1904 
1905 C .. FUNCTION REFERENCES ..
1906 
1907  REAL*8 sqrt, xarg
1908 
1909  sqrt(xarg)=dsqrt(xarg)
1910 
1911 C ..
1912 
1913 C
1914 
1915 C BRANCH TO APPROPRIATE SECTION OF CODE DEPENDING ON THE
1916 
1917 C VALUE OF THE FLAG ILOC
1918 
1919 C THE SIGNIFICANCE OF THE FLAGS ILOC AND ITEST ARE DESCRIBED IN
1920 
1921 C NPL ALGORITHMS LIBRARY DOCUMENT REF. NO. E4/15/F.
1922 
1923 C
1924 
1925  go to(20, 40, 40, 460, 440), iloc
1926 
1927 C
1928 
1929 C ILOC = 1
1930 
1931 C
1932 
1933 C CHECK INPUT PARAMETERS
1934 
1935 C
1936 
1937  20 itest = 2
1938 
1939  tol = t
1940 
1941  t2 = tol + tol
1942 
1943  IF (u.LE.0.0e+0 .OR. xlamda.LE.t2 .OR. gu.GT.0.0e+0) RETURN
1944 
1945  itest = 1
1946 
1947 C
1948 
1949 C A AND B DEFINE THE INTERVAL OF UNCERTAINTY. XMIN DENOTES
1950 
1951 C THE LOWEST POINT OBTAINED SO FAR, XW THE LAST VALUE
1952 
1953 C OF XMIN AND XV THE SCALED VALUE OF ALPHA CORRESPONDING TO
1954 
1955 C THE HIGHEST FUNCTION VALUE OF THE THREE POINTS THROUGH
1956 
1957 C WHICH A PARABOLA MAY BE FITTED. INITIALIZE A, XV, XW, XMIN
1958 
1959 C AT ORIGIN AND CORRESPONDING FUNCTION VALUES AT LATEST
1960 
1961 C ESTIMATE OF MINIMUM.
1962 
1963 C
1964 
1965  xmin = 0.0e+0
1966 
1967  xw = 0.0e+0
1968 
1969  xv = 0.0e+0
1970 
1971  a = 0.0e+0
1972 
1973  oldf = fu
1974 
1975  fmin = fu
1976 
1977  fw = fu
1978 
1979  fv = fu
1980 
1981  fa = fu
1982 
1983  d = u
1984 
1985 C
1986 
1987 C THE PARAMETER RR HAS TWO USES DURING THE EXECUTION OF THIS
1988 
1989 C SUBROUTINE. INITIALLY THE SIGN OF RR INDICATES WHETHER OR NOT
1990 
1991 C THE MINIMUM HAS BEEN BRACKETED. LATER, WHEN A POINT SATISFYING
1992 
1993 C THE GTEST2 CRITERION HAS BEEN FOUND, RR IS USED TO COMPUTE A
1994 
1995 C STEPLENGTH WHICH SATISFIES THE SECOND CRITERION INVOLVING
1996 
1997 C GTEST1.
1998 
1999 C
2000 
2001  rr = -1.0e+0
2002 
2003 C
2004 
2005 C SET UP XBND AS A BOUND ON THE STEP TO BE TAKEN. (XBND IS NOT
2006 
2007 C COMPUTED EXPLICITLY BUT SCXBD IS ITS SCALED VALUE.) SET THE
2008 
2009 C UPPER BOUND ON THE INTERVAL OF UNCERTAINTY INITIALLY TO
2010 
2011 C XLAMDA + TOL(XLAMDA).
2012 
2013 C
2014 
2015  scxbd = xlamda
2016 
2017  b = scxbd + eps*abs(scxbd) + t
2018 
2019  e = 2.0e+0*b
2020 
2021  b1 = b
2022 
2023 C
2024 
2025 C COMPUTE THE CONSTANTS REQUIRED FOR THE TWO CONVERGENCE
2026 
2027 C CRITERIA.
2028 
2029 C
2030 
2031  gtest1 = -1.0e-4*gu
2032 
2033  gtest2 = -eta*gu
2034 
2035 C
2036 
2037 C SET ILOC TO INDICATE THAT ONLY TWO POINTS ARE AVAILABLE
2038 
2039 C
2040 
2041  iloc = 2
2042 
2043  go to 380
2044 
2045 C
2046 
2047 C ILOC = 2 OR 3
2048 
2049 C
2050 
2051 C UPDATE A, B, XV, XW, AND XMIN.
2052 
2053 C
2054 
2055  40 IF (fu.GT.fmin) go to 100
2056 
2057 C
2058 
2059 C IF FUNCTION VALUE NOT INCREASED, NEW POINT BECOMES
2060 
2061 C NEXT ORIGIN AND OTHER POINTS ARE SCALED ACCORDINGLY.
2062 
2063 C
2064 
2065  IF (u.LT.0.0e+0) go to 60
2066 
2067  a = 0.0e+0
2068 
2069  fa = fmin
2070 
2071  IF (xw.EQ.xv .AND. fmin.EQ.fu) rr = 1.0e+0
2072 
2073  go to 80
2074 
2075  60 b = 0.0e+0
2076 
2077  rr = 1.0e+0
2078 
2079  80 xv = xw
2080 
2081  fv = fw
2082 
2083  fw = fmin
2084 
2085  fmin = fu
2086 
2087  xmin = xmin + u
2088 
2089  a = a - u
2090 
2091  b = b - u
2092 
2093  xv = xv - u
2094 
2095  xw = 0.0e+0 - u
2096 
2097 C
2098 
2099 C THIS MAY BE CHANGED TO XW = - U IF THE COMPUTER IS
2100 
2101 C SUCH THAT - U AND 0.0 - U ARE IDENTICAL.
2102 
2103 C
2104 
2105  scxbd = scxbd - u
2106 
2107  tol = eps*abs(xmin) + t
2108 
2109  go to 180
2110 
2111 C
2112 
2113 C IF FUNCTION VALUE INCREASED, ORIGIN REMAINS UNCHANGED
2114 
2115 C BUT OTHER POINTS MAY BE INTERCHANGED.
2116 
2117 C
2118 
2119  100 IF (u.GE.0.0e+0) go to 120
2120 
2121  a = u
2122 
2123  fa = fu
2124 
2125  go to 140
2126 
2127  120 b = u
2128 
2129  rr = 1.0e+0
2130 
2131  140 IF (fu.GT.fw .AND. xw.NE.0.0e+0) go to 160
2132 
2133  xv = xw
2134 
2135  fv = fw
2136 
2137  xw = u
2138 
2139  fw = fu
2140 
2141  go to 180
2142 
2143  160 xv = u
2144 
2145  fv = fu
2146 
2147  180 t2 = tol + tol
2148 
2149  xm = 5.0e-1*(a+b)
2150 
2151 C
2152 
2153 C CHECK TERMINATION CRITERIA.
2154 
2155 C
2156 
2157  IF (abs(xm).LE.t2-5.0e-1*(b-a) .OR. xmin+b.LE.sftbnd .OR.
2158 
2159  * fa-fmin.LE.abs(a)*gtest2 .AND. fmin.LT.oldf .AND.
2160 
2161  * (abs(xmin-xlamda).GT.tol .OR. rr.LT.0.0e+0)) go to 420
2162 
2163  r = 0.0e+0
2164 
2165  q = 0.0e+0
2166 
2167  s = 0.0e+0
2168 
2169  IF (abs(e).LE.tol) go to 240
2170 
2171 C
2172 
2173 C FIT PARABOLA THROUGH XMIN, XV, XW.
2174 
2175 C
2176 
2177  IF (iloc.NE.2) go to 200
2178 
2179 C
2180 
2181 C SPECIAL CASE. ONLY TWO POINTS ARE AVAILABLE FOR
2182 
2183 C QUADRATIC INTERPOLATION
2184 
2185 C
2186 
2187  q = 2.0e+0*(fw-fmin-xw*gu)
2188 
2189  s = gu*xw*xw
2190 
2191  IF (xmin.NE.0.0e+0) s = (2.0e+0*(fmin-fw)+xw*gu)*xw
2192 
2193  go to 220
2194 
2195  200 r = xw*(fv-fmin)
2196 
2197  q = xv*(fw-fmin)
2198 
2199  s = r*xw - q*xv
2200 
2201  q = 2.0e+0*(q-r)
2202 
2203  220 IF (q.GT.0.0e+0) s = -s
2204 
2205  IF (q.LE.0.0e+0) q = -q
2206 
2207  r = e
2208 
2209 C
2210 
2211 C IF THE LAST STEP EXPANDED THE INTERVAL OR THE MINIMUM HAS
2212 
2213 C ALREADY BEEN BRACKETED SET E AS THE LAST STEP TAKEN
2214 
2215 C
2216 
2217  IF (d.NE.b1 .OR. rr.GT.0.0e+0) e = d
2218 
2219 C
2220 
2221 C CONSTRUCT AN ARTIFICIAL BOUND ON THE ESTIMATED STEPLENGTH.
2222 
2223 C
2224 
2225  240 a1 = a
2226 
2227  b1 = b
2228 
2229  IF (xmin.NE.a) go to 260
2230 
2231  d = xm
2232 
2233  go to 330
2234 
2235  260 IF (rr.GT.0.0e+0) go to 280
2236 
2237  d = -4.0e+0*a
2238 
2239  IF (d.GE.scxbd) d = scxbd
2240 
2241  go to 320
2242 
2243 C
2244 
2245 C DETERMINE INTERVAL OF LENGTH D2 IN WHICH TO SET
2246 
2247 C ARTIFICIAL BOUND.
2248 
2249 C
2250 
2251  280 d1 = a
2252 
2253  d2 = b
2254 
2255  IF (abs(d2).GT.tol .AND. (xw.LE.0.0e+0 .OR. abs(d1).LE.tol))
2256 
2257  * go to 300
2258 
2259  u = d1
2260 
2261  d1 = d2
2262 
2263  d2 = u
2264 
2265  300 u = -d1/d2
2266 
2267  IF (u.GE.1.0e+0) d = 5.0e+0*d2*(1.0e-1+1.0e+0/u)/1.1e+1
2268 
2269  IF (u.LT.1.0e+0) d = 5.0e-1*d2*sqrt(u)
2270 
2271 C
2272 
2273 C IF THE MINIMUM IS BRACKETED BY XV AND XW THE STEP MUST LIE
2274 
2275 C WITHIN (A, B).
2276 
2277 C
2278 
2279  320 IF (xw.LT.0.0e+0 .AND. xv.GT.0.0e+0 .OR. xw.GT.0.0e+0 .AND.
2280 
2281  * xv.LT.0.0e+0) go to 330
2282 
2283 C
2284 
2285 C IF THE MINIMUM IS NOT BRACKETED BY XV AND XW THE STEP MUST LIE
2286 
2287 C WITHIN (A1, B1).
2288 
2289 C
2290 
2291  IF (d.LE.0.0e+0) a1 = d
2292 
2293  IF (d.GT.0.0e+0) b1 = d
2294 
2295 C
2296 
2297 C REJECT THE STEP OBTAINED BY INTERPOLATION IF IT LIES OUTSIDE
2298 
2299 C THE REQUIRED INTERVAL OR IT IS GREATER THAN HALF THAT
2300 
2301 C OBTAINED DURING THE LAST-BUT-ONE ITERATION.
2302 
2303 C
2304 
2305  330 IF (abs(s).GE.abs(5.0e-1*q*r) .OR. s.LE.q*a1 .OR. s.GE.q*b1)
2306 
2307  * go to 340
2308 
2309 C
2310 
2311 C A PARABOLIC INTERPOLATION STEP.
2312 
2313 C
2314 
2315  d = s/q
2316 
2317 C
2318 
2319 C F MUST NOT BE EVALUATED TOO CLOSE TO A OR B.
2320 
2321 C
2322 
2323  IF (d-a.GE.t2 .AND. b-d.GE.t2) go to 360
2324 
2325  d = tol
2326 
2327  IF (xm.LE.0.0e+0) d = -tol
2328 
2329  go to 360
2330 
2331 C
2332 
2333 C A NON-INTERPOLATION STEP.
2334 
2335 C
2336 
2337  340 e = b
2338 
2339  IF (xm.LE.0.0e+0) e = a
2340 
2341  360 iloc = 3
2342 
2343 C
2344 
2345 C CHECK THAT THE NEW STEP LENGTH WILL NOT BE GREATER THAN
2346 
2347 C XLAMDA.
2348 
2349 C
2350 
2351  380 IF (d.LT.scxbd) go to 400
2352 
2353 C
2354 
2355 C REPLACE THE STEP LENGTH BY THE SCALED BOUND (SO AS TO COMPUTE
2356 
2357 C THE NEW POINT ON THE BOUNDARY.
2358 
2359 C
2360 
2361  d = scxbd
2362 
2363 C
2364 
2365 C MOVE SCXBD TO THE LEFT SO THAT NEWXBND + TOL(NEWXBND) = XBND.
2366 
2367 C
2368 
2369  scxbd = (scxbd - tol)/(1.0e+0 + eps)
2370 
2371  400 u = d
2372 
2373  IF (abs(d).LT.tol .AND. d.LE.0.0e+0) u = -tol
2374 
2375  IF (abs(d).LT.tol .AND. d.GT.0.0e+0) u = tol
2376 
2377  itest = 1
2378 
2379  RETURN
2380 
2381 C
2382 
2383 C THE FIRST CONVERGENCE CRITERION HAS BEEN SATISFIED. NOW CHECK
2384 
2385 C THAT THE FUNCTION VALUE HAS BEEN REDUCED SUFFICIENTLY. THE
2386 
2387 C VARIABLE RR IS NOW USED TO REDUCE THE STEP LENGTH.
2388 
2389 C
2390 
2391  420 d = rr
2392 
2393  rr = xmin
2394 
2395  ss = 5.0e-1
2396 
2397  fu = fmin
2398 
2399  IF (xmin.EQ.0.0e+0) xmin = t
2400 
2401 C
2402 
2403 C IF XMIN LIES WITHIN TOL OF THE BOUNDARY AND THE MINIMUM HAS
2404 
2405 C BEEN BRACKETED, THEN RECOMPUTE THE POINT ON THE BOUNDARY.
2406 
2407 C
2408 
2409  440 IF (abs(xmin-xlamda).GE.tol .OR. xmin.EQ.t) go to 460
2410 
2411  IF (scxbd.LT.0.0e+0 .AND. xw.LT.0.0e+0 .AND. xv.LT.0.0e+0)
2412 
2413  * xmin = xlamda
2414 
2415  IF (d.LT.0.0e+0) go to 460
2416 
2417  u = 0.0e+0
2418 
2419  iloc = 4
2420 
2421  itest = 1
2422 
2423  RETURN
2424 
2425 C
2426 
2427 C CHECK THAT THE NEW POINT SATISFIES SAFEGUARD CONDITIONS.
2428 
2429 C IF NECESSARY ATTEMPT TO FIND A SUFFICIENTLY LOWER POINT
2430 
2431 C BY SUCCESSIVELY DECREASING THE STEPLENGTH.
2432 
2433 C
2434 
2435  460 IF (xmin+b.GT.sftbnd) go to 480
2436 
2437  itest = 4
2438 
2439 C
2440 
2441 C ITEST = 4 IMPLIES THAT THE REQUIRED STEP LENGTH IS SMALLER
2442 
2443 C THAN SFTBND.
2444 
2445 C
2446 
2447  RETURN
2448 
2449  480 IF (oldf-fu.LE.gtest1*xmin) go to 500
2450 
2451  fmin = fu
2452 
2453  itest = 0
2454 
2455 C
2456 
2457 C THE ALGORITHM HAS SUCCESSFULLY FOUND A SUFFICIENTLY LOWER
2458 
2459 C POINT.
2460 
2461 C
2462 
2463  RETURN
2464 
2465  500 IF (xmin.NE.t) go to 520
2466 
2467  itest = 3
2468 
2469 C
2470 
2471 C DESPITE REPEATED REDUCTIONS IN THE STEP SIZE, A LOWER POINT
2472 
2473 C COULD NOT BE FOUND.
2474 
2475 C
2476 
2477  RETURN
2478 
2479 C
2480 
2481 C A SUFFICIENT REDUCTION IN THE FUNCTION VALUE HAS NOT YET BEEN
2482 
2483 C FOUND, TRY A FURTHER REDUCTION IN THE STEP LENGTH.
2484 
2485 C
2486 
2487  520 xmin = rr*ss
2488 
2489  ss = ss*ss
2490 
2491  IF (xmin.LT.t) xmin = t
2492 
2493  itest = 1
2494 
2495  u = 0.0e+0
2496 
2497  iloc = 5
2498 
2499  RETURN
2500 
2501 C
2502 
2503 C END OF ABZE04 (NEWPTQ)
2504 
2505 C
2506 
2507  END
2508 
2509 C
2510 
2511  SUBROUTINE e01baf(M, X, Y, K, C, LCK, WRK, LWRK, IFAIL)
2512 
2513 C MARK 8 RELEASE. NAG COPYRIGHT 1979.
2514 
2515 C
2516 
2517 C ******************************************************
2518 
2519 C
2520 
2521 C NPL ALGORITHMS LIBRARY ROUTINE SP3INT
2522 
2523 C
2524 
2525 C CREATED 16/5/79. RELEASE 00/00
2526 
2527 C
2528 
2529 C AUTHORS ... GERALD T. ANTHONY, MAURICE G.COX
2530 
2531 C J.GEOFFREY HAYES AND MICHAEL A. SINGER.
2532 
2533 C NATIONAL PHYSICAL LABORATORY, TEDDINGTON,
2534 
2535 C MIDDLESEX TW11 OLW, ENGLAND
2536 
2537 C
2538 
2539 C ******************************************************
2540 
2541 C
2542 
2543 C E01BAE. AN ALGORITHM, WITH CHECKS, TO DETERMINE THE
2544 
2545 C COEFFICIENTS IN THE B-SPLINE REPRESENTATION OF A CUBIC
2546 
2547 C SPLINE WHICH INTERPOLATES (PASSES EXACTLY THROUGH) A
2548 
2549 C GIVEN SET OF POINTS.
2550 
2551 C
2552 
2553 C INPUT PARAMETERS
2554 
2555 C M THE NUMBER OF DISTINCT POINTS WHICH THE
2556 
2557 C SPLINE IS TO INTERPOLATE.
2558 
2559 C (M MUST BE AT LEAST 4.)
2560 
2561 C X ARRAY CONTAINING THE DISTINCT VALUES OF THE
2562 
2563 C INDEPENDENT VARIABLE. NB X(I) MUST BE
2564 
2565 C STRICTLY GREATER THAN X(J) WHENEVER I IS
2566 
2567 C STRICTLY GREATER THAN J.
2568 
2569 C Y ARRAY CONTAINING THE VALUES OF THE DEPENDENT
2570 
2571 C VARIABLE.
2572 
2573 C LCK THE SMALLER OF THE ACTUALLY DECLARED DIMENSIONS
2574 
2575 C OF K AND C. MUST BE AT LEAST M + 4.
2576 
2577 C
2578 
2579 C OUTPUT PARAMETERS
2580 
2581 C K ON SUCCESSFUL EXIT, K CONTAINS THE KNOTS
2582 
2583 C SET UP BY THE ROUTINE. IF THE SPLINE IS
2584 
2585 C TO BE EVALUATED (BY NPL ROUTINE E02BEF,
2586 
2587 C FOR EXAMPLE) THE ARRAY K MUST NOT BE
2588 
2589 C ALTERED BEFORE CALLING THAT ROUTINE.
2590 
2591 C C ON SUCCESSFUL EXIT, C CONTAINS THE B-SPLINE
2592 
2593 C COEFFICIENTS OF THE INTERPOLATING SPLINE.
2594 
2595 C THESE ARE ALSO REQUIRED BY THE EVALUATING
2596 
2597 C ROUTINE E02BEF.
2598 
2599 C IFAIL FAILURE INDICATOR
2600 
2601 C 0 - SUCCESSFUL TERMINATION.
2602 
2603 C 1 - ONE OF THE FOLLOWING CONDITIONS HAS
2604 
2605 C BEEN VIOLATED -
2606 
2607 C M AT LEAST 4
2608 
2609 C LK AT LEAST M + 4
2610 
2611 C LWORK AT LEAST 6 * M + 16
2612 
2613 C 2 - THE VALUES OF THE INDEPENDENT VARIABLE
2614 
2615 C ARE DISORDERED. IN OTHER WORDS, THE
2616 
2617 C CONDITION MENTIONED UNDER X IS NOT
2618 
2619 C SATISFIED.
2620 
2621 C
2622 
2623 C WORKSPACE (AND ASSOCIATED DIMENSION) PARAMETERS
2624 
2625 C WRK WORKSPACE ARRAY, OF LENGTH LWRK.
2626 
2627 C LWRK ACTUAL DECLARED DIMENSION OF WRK.
2628 
2629 C MUST BE AT LEAST 6 * M + 16.
2630 
2631 C
2632 
2633 C .. SCALAR ARGUMENTS ..
2634 
2635  INTEGER ifail, lck, lwrk, m
2636 
2637 C .. ARRAY ARGUMENTS ..
2638 
2639  REAL*8 c(lck), k(lck), wrk(lwrk), x(m), y(m)
2640 
2641 C ..
2642 
2643 C .. LOCAL SCALARS ..
2644 
2645 
2646 
2647 c DOUBLE PRECISION SRNAME
2648 
2649  CHARACTER*8 srname
2650 
2651 
2652 
2653  REAL*8 one, ss
2654 
2655  INTEGER i, ierror, m1, m2
2656 
2657 C .. FUNCTION REFERENCES ..
2658 
2659  INTEGER p01aae
2660 
2661 C .. SUBROUTINE REFERENCES ..
2662 
2663 C E02BAE
2664 
2665 C ..
2666 
2667  DATA one /1.0e+0/
2668 
2669  DATA srname /' E01BAE'/
2670 
2671  ierror = 1
2672 
2673 C
2674 
2675 C TESTS FOR ADEQUACY OF ARRAY LENGTHS AND THAT M IS GREATER
2676 
2677 C THAN 4.
2678 
2679 C
2680 
2681  IF (lwrk.LT.6*m+16 .OR. m.LT.4) go to 80
2682 
2683  IF (lck.LT.m+4) go to 80
2684 
2685 C
2686 
2687 C TESTS FOR THE CORRECT ORDERING OF THE X(I)
2688 
2689 C
2690 
2691  ierror = 2
2692 
2693  DO 20 i=2,m
2694 
2695  IF (x(i).LE.x(i-1)) go to 80
2696 
2697  20 CONTINUE
2698 
2699 C
2700 
2701 C INITIALISE THE ARRAY OF KNOTS AND THE ARRAY OF WEIGHTS
2702 
2703 C
2704 
2705  wrk(1) = one
2706 
2707  wrk(2) = one
2708 
2709  wrk(3) = one
2710 
2711  wrk(4) = one
2712 
2713  IF (m.EQ.4) go to 60
2714 
2715  DO 40 i=5,m
2716 
2717  k(i) = x(i-2)
2718 
2719  wrk(i) = one
2720 
2721  40 CONTINUE
2722 
2723  60 m1 = m + 1
2724 
2725  m2 = m1 + m
2726 
2727 C
2728 
2729 C CALL THE SPLINE FITTING ROUTINE
2730 
2731 C
2732 
2733  ierror = 0
2734 
2735  CALL e02baf(m, m+4, x, y, wrk, k, wrk(m1), wrk(m2), c, ss,
2736 
2737  * ierror)
2738 
2739 C
2740 
2741 C ALL THE TESTS PERFORMED BY E02BAE ARE REDUNDANT
2742 
2743 C BECAUSE OF THE ABOVE TESTS AND ASSIGNMENTS, AND SO
2744 
2745 C IERROR = 0 AFTER THIS CALL.
2746 
2747 C
2748 
2749  80 ifail = p01aae(ifail,ierror,srname)
2750 
2751  RETURN
2752 
2753 C
2754 
2755 C END OF E01BAE.
2756 
2757 C
2758 
2759  END
2760 
2761  SUBROUTINE e02bcf(NCAP7, K, C, X, LEFT, S, IFAIL)
2762 
2763 C MARK 7 RELEASE. NAG COPYRIGHT 1978.
2764 
2765 C
2766 
2767 C **************************************************
2768 
2769 C * *
2770 
2771 C * NAG LIBRARY SUBROUTINE E02BCE *
2772 
2773 C * *
2774 
2775 C * EVALUATION OF CUBIC SPLINE AND ITS *
2776 
2777 C * DERIVATIVES FROM ITS B-SPLINE REPRESENTATION *
2778 
2779 C * *
2780 
2781 C * ROUTINE CREATED ... 17 NOV 1977 *
2782 
2783 C * LATEST UPDATE .... 24 APR 1978 *
2784 
2785 C * RELEASE NUMBER ... 01 *
2786 
2787 C * AUTHORS ... MAURICE G. COX AND *
2788 
2789 C * J. GEOFFREY HAYES, N.P.L. *
2790 
2791 C * *
2792 
2793 C **************************************************
2794 
2795 C
2796 
2797 C .. SCALAR ARGUMENTS ..
2798 
2799  REAL*8 x
2800 
2801  INTEGER ifail, left, ncap7
2802 
2803 C .. ARRAY ARGUMENTS ..
2804 
2805  REAL*8 c(ncap7), k(ncap7), s(4)
2806 
2807 C ..
2808 
2809 C .. LOCAL SCALARS ..
2810 
2811 c DOUBLE PRECISION SRNAME
2812 
2813  CHARACTER*8 srname
2814 
2815  REAL*8 c1, c2, c3, c4, d1n41, d1n42, d1n43, d1n44, d2n41,
2816 
2817  * d2n42, d2n43, d2n44, d3n41, d3n42, d3n43, d3n44, e2, e3, e4,
2818 
2819  * e5, half, k1, k2, k3, k4, k5, k6, m11, m21, m22, m32, n41,
2820 
2821  * n42, n43, n44, p4, p5, p6, six, three
2822 
2823  INTEGER ierror, j1, j, l
2824 
2825 C .. FUNCTION REFERENCES ..
2826 
2827  INTEGER p01aae
2828 
2829 C ..
2830 
2831  DATA srname /' E02BCE'/
2832 
2833  half = 0.5e+00
2834 
2835  three = 3.0e+00
2836 
2837  six = 6.0e+00
2838 
2839 C
2840 
2841 C ********* DATA VALIDATION *********
2842 
2843 C
2844 
2845 C CHECK WHETHER AT LEAST ONE INTERVAL HAS BEEN SPECIFIED -
2846 
2847 C
2848 
2849  ierror = 1
2850 
2851  IF (ncap7.LT.8) go to 80
2852 
2853 C
2854 
2855 C CHECK WHETHER THE RANGE OF DEFINITION OF THE SPLINE IS
2856 
2857 C STRICTLY POSITIVE IN LENGTH -
2858 
2859 C
2860 
2861  ierror = 2
2862 
2863  IF (k(4).GE.k(ncap7-3)) go to 80
2864 
2865 C
2866 
2867 C CHECK WHETHER X IS A VALID ARGUMENT -
2868 
2869 C
2870 
2871  IF (x.LT.k(4) .OR. x.GT.k(ncap7-3)) go to 80
2872 
2873 C
2874 
2875 C ********* COMPUTATION *********
2876 
2877 C
2878 
2879 C BINARY SEARCH FOR INTERVAL CONTAINING X -
2880 
2881 C
2882 
2883 C IF RIGHT-HAND DERIVATIVES ARE REQUIRED (LEFT .NE. 1)
2884 
2885 C SEARCH FOR J SATISFYING
2886 
2887 C K(J + 3) .LE. X .LT. K(J + 4)
2888 
2889 C (SETTING J = NCAP IN THE EXCEPTIONAL CASE X = K(NCAP +
2890 
2891 C 4)).
2892 
2893 C
2894 
2895 C IF LEFT-HAND DERIVATIVES ARE REQUIRED (LEFT .EQ. 1)
2896 
2897 C SEARCH FOR J SATISFYING
2898 
2899 C K(J + 3) .LT. X .LE. K(J + 4)
2900 
2901 C (SETTING J = 1 IN THE EXCEPTIONAL CASE X = K(4)).
2902 
2903 C
2904 
2905  ierror = 0
2906 
2907  j1 = 4
2908 
2909  j = ncap7 - 3
2910 
2911  20 l = (j1+j)/2
2912 
2913  IF (j-j1.LE.1) go to 60
2914 
2915  IF (left.NE.1 .AND. x.GE.k(l)) go to 40
2916 
2917  IF (left.EQ.1 .AND. x.GT.k(l)) go to 40
2918 
2919  j = l
2920 
2921  go to 20
2922 
2923  40 j1 = l
2924 
2925  go to 20
2926 
2927  60 j = j - 4
2928 
2929 C
2930 
2931 C FORM CERTAIN CONSTANTS -
2932 
2933 C
2934 
2935  k1 = k(j+1)
2936 
2937  k2 = k(j+2)
2938 
2939  k3 = k(j+3)
2940 
2941  k4 = k(j+4)
2942 
2943  k5 = k(j+5)
2944 
2945  k6 = k(j+6)
2946 
2947  e2 = x - k2
2948 
2949  e3 = x - k3
2950 
2951  e4 = k4 - x
2952 
2953  e5 = k5 - x
2954 
2955  p4 = k4 - k1
2956 
2957  p5 = k5 - k2
2958 
2959  p6 = k6 - k3
2960 
2961 C
2962 
2963 C FORM BASIS FUNCTIONS AND THEIR DERIVATIVES -
2964 
2965 C
2966 
2967 C THE VALUES OF THE NON-ZERO UN-NORMALIZED B-SPLINES OF ORDER R
2968 
2969 C ARE DENOTED BY MR1, MR2,... . THE CORRESPONDING NORMALIZED
2970 
2971 C B-SPLINES ARE DENOTED BY NR1, NR2,... AND THEIR DERIVATIVES
2972 
2973 C OF ORDER L BY DLNR1, DLNR2,... .
2974 
2975 C
2976 
2977  m11 = six/(k4-k3)
2978 
2979  m21 = -m11/(k4-k2)
2980 
2981  m22 = m11/(k5-k3)
2982 
2983  d3n41 = m21/p4
2984 
2985  m32 = (m21-m22)/p5
2986 
2987  d3n44 = m22/p6
2988 
2989  d3n42 = -d3n41 - m32
2990 
2991  d3n43 = m32 - d3n44
2992 
2993  m21 = -e4*m21
2994 
2995  m22 = e3*m22
2996 
2997  d2n41 = m21/p4
2998 
2999  m32 = (m21-m22)/p5
3000 
3001  d2n44 = m22/p6
3002 
3003  d2n42 = -d2n41 - m32
3004 
3005  d2n43 = m32 - d2n44
3006 
3007  m21 = half*m21
3008 
3009  m22 = half*m22
3010 
3011  d1n41 = -e4*m21/p4
3012 
3013  m32 = (e2*m21+e5*m22)/p5
3014 
3015  d1n44 = e3*m22/p6
3016 
3017  d1n42 = -d1n41 - m32
3018 
3019  d1n43 = m32 - d1n44
3020 
3021  n41 = -e4*d1n41/three
3022 
3023  n42 = (-(x-k1)*d1n41+e5*m32)/three
3024 
3025  n43 = (e2*m32+(k6-x)*d1n44)/three
3026 
3027  n44 = e3*d1n44/three
3028 
3029 C
3030 
3031 C FORM THE VALUES OF THE CUBIC SPLINE AND ITS DERIVATIVES -
3032 
3033 C
3034 
3035  c1 = c(j)
3036 
3037  c2 = c(j+1)
3038 
3039  c3 = c(j+2)
3040 
3041  c4 = c(j+3)
3042 
3043  s(1) = c1*n41 + c2*n42 + c3*n43 + c4*n44
3044 
3045  s(2) = c1*d1n41 + c2*d1n42 + c3*d1n43 + c4*d1n44
3046 
3047  s(3) = c1*d2n41 + c2*d2n42 + c3*d2n43 + c4*d2n44
3048 
3049  s(4) = c1*d3n41 + c2*d3n42 + c3*d3n43 + c4*d3n44
3050 
3051 C
3052 
3053 C ********* ERROR DIAGNOSTICS *********
3054 
3055 C
3056 
3057  80 ifail = p01aae(ifail,ierror,srname)
3058 
3059  RETURN
3060 
3061 C
3062 
3063 C END OF SUBROUTINE E02BCF
3064 
3065 C
3066 
3067  END
3068 
3069  SUBROUTINE e02baf(M, NCAP7, X, Y, W, K, WORK1, WORK2, C, SS,
3070 
3071  * ifail)
3072 
3073 C NAG COPYRIGHT 1975
3074 
3075 C MARK 5 RELEASE
3076 
3077 C MARK 6 REVISED IER-84
3078 
3079 C MARK 8 RE-ISSUE. IER-224 (APR 1980).
3080 
3081 C MARK 9A REVISED. IER-356 (NOV 1981)
3082 
3083 C
3084 
3085 C NAG LIBRARY SUBROUTINE E02BAE
3086 
3087 C
3088 
3089 C E02BAE COMPUTES A WEIGHTED LEAST-SQUARES APPROXIMATION
3090 
3091 C TO AN ARBITRARY SET OF DATA POINTS BY A CUBIC SPLINE
3092 
3093 C WITH KNOTS PRESCRIBED BY THE USER. CUBIC SPLINE
3094 
3095 C INTERPOLATION CAN ALSO BE CARRIED OUT.
3096 
3097 C
3098 
3099 C COX-DE BOOR METHOD FOR EVALUATING B-SPLINES WITH
3100 
3101 C ADAPTATION OF GENTLEMAN*S PLANE ROTATION SCHEME FOR
3102 
3103 C SOLVING OVER-DETERMINED LINEAR SYSTEMS.
3104 
3105 C
3106 
3107 C USES NAG LIBRARY ROUTINE P01AAE.
3108 
3109 C
3110 
3111 C STARTED - 1973.
3112 
3113 C COMPLETED - 1976.
3114 
3115 C AUTHOR - MGC AND JGH.
3116 
3117 C
3118 
3119 C REDESIGNED TO USE CLASSICAL GIVENS ROTATIONS IN
3120 
3121 C ORDER TO AVOID THE OCCASIONAL UNDERFLOW (AND HENCE
3122 
3123 C OVERFLOW) PROBLEMS EXPERIENCED BY GENTLEMAN*S 3-
3124 
3125 C MULTIPLICATION PLANE ROTATION SCHEME
3126 
3127 C
3128 
3129 C WORK1 AND WORK2 ARE WORKSPACE AREAS.
3130 
3131 C WORK1(R) CONTAINS THE VALUE OF THE R TH DISTINCT DATA
3132 
3133 C ABSCISSA AND, SUBSEQUENTLY, FOR R = 1, 2, 3, 4, THE
3134 
3135 C VALUES OF THE NON-ZERO B-SPLINES FOR EACH SUCCESSIVE
3136 
3137 C ABSCISSA VALUE.
3138 
3139 C WORK2(L, J) CONTAINS, FOR L = 1, 2, 3, 4, THE VALUE OF
3140 
3141 C THE J TH ELEMENT IN THE L TH DIAGONAL OF THE
3142 
3143 C UPPER TRIANGULAR MATRIX OF BANDWIDTH 4 IN THE
3144 
3145 C TRIANGULAR SYSTEM DEFINING THE B-SPLINE COEFFICIENTS.
3146 
3147 C
3148 
3149 C .. SCALAR ARGUMENTS ..
3150 
3151  REAL*8 ss
3152 
3153  INTEGER ifail, m, ncap7
3154 
3155 C .. ARRAY ARGUMENTS ..
3156 
3157  REAL*8 c(ncap7), k(ncap7), w(m), work1(m), work2(4,ncap7),
3158 
3159  * x(m), y(m)
3160 
3161 C ..
3162 
3163 C .. LOCAL SCALARS ..
3164 
3165 c DOUBLE PRECISION SRNAME
3166 
3167  CHARACTER*8 srname
3168 
3169  REAL*8 acol, arow, ccol, cosine, crow, d4, d5, d6, d7, d8, d9,
3170 
3171  * d, dprime, e2, e3, e4, e5, k0, k1, k2, k3, k4, k5, k6, n1,
3172 
3173  * n2, n3, relemt, s, sigma, sine, wi, xi
3174 
3175  INTEGER i, ierror, iplusj, iu, j, jold, jplusl, jrev, l4,
3176 
3177  * l, lplus1, lplusu, ncap3, ncap, ncapm1, r
3178 
3179 C .. FUNCTION REFERENCES ..
3180 
3181  REAL*8 sqrt
3182 
3183  INTEGER p01aae
3184 
3185 C ..
3186 
3187  DATA srname /' E02BAE'/
3188 
3189  ierror = 4
3190 
3191 C CHECK THAT THE VALUES OF M AND NCAP7 ARE REASONABLE
3192 
3193  IF (ncap7.LT.8 .OR. m.LT.ncap7-4) go to 420
3194 
3195  ncap = ncap7 - 7
3196 
3197  ncapm1 = ncap - 1
3198 
3199  ncap3 = ncap + 3
3200 
3201 C
3202 
3203 C IN ORDER TO DEFINE THE FULL B-SPLINE BASIS, AUGMENT THE
3204 
3205 C PRESCRIBED INTERIOR KNOTS BY KNOTS OF MULTIPLICITY FOUR
3206 
3207 C AT EACH END OF THE DATA RANGE.
3208 
3209 C
3210 
3211  DO 20 j=1,4
3212 
3213  i = ncap3 + j
3214 
3215  k(j) = x(1)
3216 
3217  k(i) = x(m)
3218 
3219  20 CONTINUE
3220 
3221 C
3222 
3223 C TEST THE VALIDITY OF THE DATA.
3224 
3225 C
3226 
3227 C CHECK THAT THE KNOTS ARE ORDERED AND ARE INTERIOR
3228 
3229 C TO THE DATA INTERVAL.
3230 
3231 C
3232 
3233  ierror = 1
3234 
3235  IF (k(5).LE.x(1) .OR. k(ncap3).GE.x(m)) go to 420
3236 
3237  DO 40 j=4,ncap3
3238 
3239  IF (k(j).GT.k(j+1)) go to 420
3240 
3241  40 CONTINUE
3242 
3243 C
3244 
3245 C CHECK THAT THE WEIGHTS ARE STRICTLY POSITIVE.
3246 
3247 C
3248 
3249  ierror = 2
3250 
3251  DO 60 i=1,m
3252 
3253  IF (w(i).LE.0.0) go to 420
3254 
3255  60 CONTINUE
3256 
3257 C
3258 
3259 C CHECK THAT THE DATA ABSCISSAE ARE ORDERED, THEN FORM THE
3260 
3261 C ARRAY WORK1 FROM THE ARRAY X. THE ARRAY WORK1 CONTAINS
3262 
3263 C THE
3264 
3265 C SET OF DISTINCT DATA ABSCISSAE.
3266 
3267 C
3268 
3269  ierror = 3
3270 
3271  work1(1) = x(1)
3272 
3273  j = 2
3274 
3275  DO 80 i=2,m
3276 
3277  IF (x(i).LT.work1(j-1)) go to 420
3278 
3279  IF (x(i).EQ.work1(j-1)) go to 80
3280 
3281  work1(j) = x(i)
3282 
3283  j = j + 1
3284 
3285  80 CONTINUE
3286 
3287  r = j - 1
3288 
3289 C
3290 
3291 C CHECK THAT THERE ARE SUFFICIENT DISTINCT DATA ABSCISSAE FOR
3292 
3293 C THE PRESCRIBED NUMBER OF KNOTS.
3294 
3295 C
3296 
3297  ierror = 4
3298 
3299  IF (r.LT.ncap3) go to 420
3300 
3301 C
3302 
3303 C CHECK THE FIRST S AND THE LAST S SCHOENBERG-WHITNEY
3304 
3305 C CONDITIONS ( S = MIN(NCAP - 1, 4) ).
3306 
3307 C
3308 
3309  ierror = 5
3310 
3311  DO 100 j=1,4
3312 
3313  IF (j.GE.ncap) go to 160
3314 
3315  i = ncap3 - j + 1
3316 
3317  l = r - j + 1
3318 
3319  IF (work1(j).GE.k(j+4) .OR. k(i).GE.work1(l)) go to 420
3320 
3321  100 CONTINUE
3322 
3323 C
3324 
3325 C CHECK ALL THE REMAINING SCHOENBERG-WHITNEY CONDITIONS.
3326 
3327 C
3328 
3329  IF (ncap.LE.5) go to 160
3330 
3331  r = r - 4
3332 
3333  i = 4
3334 
3335  DO 140 j=5,ncapm1
3336 
3337  k0 = k(j+4)
3338 
3339  k4 = k(j)
3340 
3341  120 i = i + 1
3342 
3343  IF (work1(i).LE.k4) go to 120
3344 
3345  IF (i.GT.r .OR. work1(i).GE.k0) go to 420
3346 
3347  140 CONTINUE
3348 
3349 C
3350 
3351 C INITIALISE A BAND TRIANGULAR SYSTEM (I.E. A
3352 
3353 C MATRIX AND A RIGHT HAND SIDE) TO ZERO. THE
3354 
3355 C PROCESSING OF EACH DATA POINT IN TURN RESULTS
3356 
3357 C IN AN UPDATING OF THIS SYSTEM. THE SUBSEQUENT
3358 
3359 C SOLUTION OF THE RESULTING BAND TRIANGULAR SYSTEM
3360 
3361 C YIELDS THE COEFFICIENTS OF THE B-SPLINES.
3362 
3363 C
3364 
3365  160 DO 200 i=1,ncap3
3366 
3367  DO 180 l=1,4
3368 
3369  work2(l,i) = 0.0
3370 
3371  180 CONTINUE
3372 
3373  c(i) = 0.0
3374 
3375  200 CONTINUE
3376 
3377  sigma = 0.0
3378 
3379  j = 0
3380 
3381  jold = 0
3382 
3383  DO 340 i=1,m
3384 
3385 C
3386 
3387 C FOR THE DATA POINT (X(I), Y(I)) DETERMINE AN INTERVAL
3388 
3389 C K(J + 3) .LE. X .LT. K(J + 4) CONTAINING X(I). (IN THE
3390 
3391 C CASE J + 4 .EQ. NCAP THE SECOND EQUALITY IS RELAXED TO
3392 
3393 C INCLUDE
3394 
3395 C EQUALITY).
3396 
3397 C
3398 
3399  wi = w(i)
3400 
3401  xi = x(i)
3402 
3403  220 IF (xi.LT.k(j+4) .OR. j.GT.ncapm1) go to 240
3404 
3405  j = j + 1
3406 
3407  go to 220
3408 
3409  240 IF (j.EQ.jold) go to 260
3410 
3411 C
3412 
3413 C SET CERTAIN CONSTANTS RELATING TO THE INTERVAL
3414 
3415 C K(J + 3) .LE. X .LE. K(J + 4).
3416 
3417 C
3418 
3419  k1 = k(j+1)
3420 
3421  k2 = k(j+2)
3422 
3423  k3 = k(j+3)
3424 
3425  k4 = k(j+4)
3426 
3427  k5 = k(j+5)
3428 
3429  k6 = k(j+6)
3430 
3431  d4 = 1.0/(k4-k1)
3432 
3433  d5 = 1.0/(k5-k2)
3434 
3435  d6 = 1.0/(k6-k3)
3436 
3437  d7 = 1.0/(k4-k2)
3438 
3439  d8 = 1.0/(k5-k3)
3440 
3441  d9 = 1.0/(k4-k3)
3442 
3443  jold = j
3444 
3445 C
3446 
3447 C COMPUTE AND STORE IN WORK1(L) (L = 1, 2, 3, 4) THE VALUES
3448 
3449 C OF
3450 
3451 C THE FOUR NORMALIZED CUBIC B-SPLINES WHICH ARE NON-ZERO AT
3452 
3453 C X=X(I).
3454 
3455 C
3456 
3457  260 e5 = k5 - xi
3458 
3459  e4 = k4 - xi
3460 
3461  e3 = xi - k3
3462 
3463  e2 = xi - k2
3464 
3465  n1 = wi*d9
3466 
3467  n2 = e3*n1*d8
3468 
3469  n1 = e4*n1*d7
3470 
3471  n3 = e3*n2*d6
3472 
3473  n2 = (e2*n1+e5*n2)*d5
3474 
3475  n1 = e4*n1*d4
3476 
3477  work1(4) = e3*n3
3478 
3479  work1(3) = e2*n2 + (k6-xi)*n3
3480 
3481  work1(2) = (xi-k1)*n1 + e5*n2
3482 
3483  work1(1) = e4*n1
3484 
3485  crow = y(i)*wi
3486 
3487 C
3488 
3489 C ROTATE THIS ROW INTO THE BAND TRIANGULAR SYSTEM USING PLANE
3490 
3491 C ROTATIONS.
3492 
3493 C
3494 
3495  DO 320 lplus1=1,4
3496 
3497  l = lplus1 - 1
3498 
3499  relemt = work1(lplus1)
3500 
3501  IF (relemt.EQ.0.0) go to 320
3502 
3503  jplusl = j + l
3504 
3505  l4 = 4 - l
3506 
3507  d = work2(1,jplusl)
3508 
3509  IF (abs(relemt).GE.d) dprime =
3510 
3511  * abs(relemt)*sqrt(1.0+(d/relemt)**2)
3512 
3513  IF (abs(relemt).LT.d) dprime = d*sqrt(1.0+(relemt/d)**2)
3514 
3515  work2(1,jplusl) = dprime
3516 
3517  cosine = d/dprime
3518 
3519  sine = relemt/dprime
3520 
3521  IF (l4.LT.2) go to 300
3522 
3523  DO 280 iu=2,l4
3524 
3525  lplusu = l + iu
3526 
3527  acol = work2(iu,jplusl)
3528 
3529  arow = work1(lplusu)
3530 
3531  work2(iu,jplusl) = cosine*acol + sine*arow
3532 
3533  work1(lplusu) = cosine*arow - sine*acol
3534 
3535  280 CONTINUE
3536 
3537  300 ccol = c(jplusl)
3538 
3539  c(jplusl) = cosine*ccol + sine*crow
3540 
3541  crow = cosine*crow - sine*ccol
3542 
3543  320 CONTINUE
3544 
3545  sigma = sigma + crow**2
3546 
3547  340 CONTINUE
3548 
3549  ss = sigma
3550 
3551 C
3552 
3553 C SOLVE THE BAND TRIANGULAR SYSTEM FOR THE B-SPLINE
3554 
3555 C COEFFICIENTS. IF A DIAGONAL ELEMENT IS ZERO, AND HENCE
3556 
3557 C THE TRIANGULAR SYSTEM IS SINGULAR, THE IMPLICATION IS
3558 
3559 C THAT THE SCHOENBERG-WHITNEY CONDITIONS ARE ONLY JUST
3560 
3561 C SATISFIED. THUS IT IS APPROPRIATE TO EXIT IN THIS
3562 
3563 C CASE WITH THE SAME VALUE (IFAIL=5) OF THE ERROR
3564 
3565 C INDICATOR.
3566 
3567 C
3568 
3569  l = -1
3570 
3571  DO 400 jrev=1,ncap3
3572 
3573  j = ncap3 - jrev + 1
3574 
3575  d = work2(1,j)
3576 
3577  IF (d.EQ.0.0) go to 420
3578 
3579  IF (l.LT.3) l = l + 1
3580 
3581  s = c(j)
3582 
3583  IF (l.EQ.0) go to 380
3584 
3585  DO 360 i=1,l
3586 
3587  iplusj = i + j
3588 
3589  s = s - work2(i+1,j)*c(iplusj)
3590 
3591  360 CONTINUE
3592 
3593  380 c(j) = s/d
3594 
3595  400 CONTINUE
3596 
3597  ierror = 0
3598 
3599  420 IF (ierror) 440, 460, 440
3600 
3601  440 ifail = p01aae(ifail,ierror,srname)
3602 
3603  RETURN
3604 
3605  460 ifail = 0
3606 
3607  RETURN
3608 
3609  END
3610 
3611 
3612 
REAL *8 function s21bbf(X, Y, Z, IFAIL)
Definition: NAG.f:1
subroutine e02bcf(NCAP7, K, C, X, LEFT, S, IFAIL)
Definition: NAG.f:2761
REAL *8 function x02aae(X)
Definition: NAG.f:1465
subroutine f02apf(NN, ACC, H, IH, WR, WI, ICNT, LFAIL)
Definition: NAG.f:823
subroutine fun(X, F)
Definition: Ev2.f:10
subroutine x03aaf(A, ISIZEA, B, ISIZEB, N, ISTEPA, ISTEPB,
Definition: NAG.f:1353
subroutine e01baf(M, X, Y, K, C, LCK, WRK, LWRK, IFAIL)
Definition: NAG.f:2511
INTEGER function p01aae(IFAIL, ERROR, SRNAME)
Definition: NAG.f:585
subroutine e04abe(FUN, EPS, T, A, B, MAXCAL, X, F, IFAIL)
Definition: NAG.f:1537
REAL *8 function x02ade(X)
Definition: NAG.f:1503
subroutine f01akf(N, K, L, A, IA, INTGER)
Definition: NAG.f:1203
subroutine abze04(EPS, T, ETA, SFTBND, XLAMDA, U, FU, GU,
Definition: NAG.f:1829
subroutine f02aff(A, IA, N, RR, RI, INTGER, LFAIL)
Definition: NAG.f:781
real(r8) function p(a, x, xr, xs, yr, ys, psi, psir, F_dia)
REAL *8 function x02abf(X)
Definition: NAG.f:647
subroutine x04aae(I, NERR)
Definition: NAG.f:727
subroutine e02baf(M, NCAP7, X, Y, W, K, WORK1, WORK2, C, SS,
Definition: NAG.f:3069
REAL *8 function s21bcf(X, Y, Z, IFAIL)
Definition: NAG.f:317
REAL *8 function x02acf(X)
Definition: NAG.f:689