-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path125runlisting.txt
778 lines (721 loc) · 23.1 KB
/
125runlisting.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
ian@ian-HP-Stream-Laptop-11-y0XX:~/CodeCode$ cd
ian@ian-HP-Stream-Laptop-11-y0XX:~$ cd 125.gz
ian@ian-HP-Stream-Laptop-11-y0XX:~/125.gz$ sloccount 125.sh
Have a non-directory at the top, so creating directory top_dir
Adding /home/ian/125.gz/125.sh to top_dir
Categorizing files.
Finding a working MD5 command....
Found a working MD5 command.
Computing results.
SLOC Directory SLOC-by-Language (Sorted)
308 top_dir sh=308
Totals grouped by language (dominant language first):
sh: 308 (100.00%)
Total Physical Source Lines of Code (SLOC) = 308
Development Effort Estimate, Person-Years (Person-Months) = 0.06 (0.70)
(Basic COCOMO model, Person-Months = 2.4 * (KSLOC**1.05))
Schedule Estimate, Years (Months) = 0.18 (2.18)
(Basic COCOMO model, Months = 2.5 * (person-months**0.38))
Estimated Average Number of Developers (Effort/Schedule) = 0.32
Total Estimated Cost to Develop = $ 7,845
(average salary = $56,286/year, overhead = 2.40).
SLOCCount, Copyright (C) 2001-2004 David A. Wheeler
SLOCCount is Open Source Software/Free Software, licensed under the GNU GPL.
SLOCCount comes with ABSOLUTELY NO WARRANTY, and you are welcome to
redistribute it under certain conditions as specified by the GNU GPL license;
see the documentation for details.
Please credit this data as "generated using David A. Wheeler's 'SLOCCount'."
ian@ian-HP-Stream-Laptop-11-y0XX:~/125.gz$ sloccount driver.f
Have a non-directory at the top, so creating directory top_dir
Adding /home/ian/125.gz/driver.f to top_dir
Categorizing files.
Finding a working MD5 command....
Found a working MD5 command.
Computing results.
SLOC Directory SLOC-by-Language (Sorted)
42 top_dir fortran=42
Totals grouped by language (dominant language first):
fortran: 42 (100.00%)
Total Physical Source Lines of Code (SLOC) = 42
Development Effort Estimate, Person-Years (Person-Months) = 0.01 (0.09)
(Basic COCOMO model, Person-Months = 2.4 * (KSLOC**1.05))
Schedule Estimate, Years (Months) = 0.08 (0.98)
(Basic COCOMO model, Months = 2.5 * (person-months**0.38))
Estimated Average Number of Developers (Effort/Schedule) = 0.09
Total Estimated Cost to Develop = $ 968
(average salary = $56,286/year, overhead = 2.40).
SLOCCount, Copyright (C) 2001-2004 David A. Wheeler
SLOCCount is Open Source Software/Free Software, licensed under the GNU GPL.
SLOCCount comes with ABSOLUTELY NO WARRANTY, and you are welcome to
redistribute it under certain conditions as specified by the GNU GPL license;
see the documentation for details.
Please credit this data as "generated using David A. Wheeler's 'SLOCCount'."
ian@ian-HP-Stream-Laptop-11-y0XX:~/125.gz$ sloccount src.f
Have a non-directory at the top, so creating directory top_dir
Adding /home/ian/125.gz/src.f to top_dir
Categorizing files.
Finding a working MD5 command....
Found a working MD5 command.
Computing results.
SLOC Directory SLOC-by-Language (Sorted)
124 top_dir fortran=124
Totals grouped by language (dominant language first):
fortran: 124 (100.00%)
Total Physical Source Lines of Code (SLOC) = 124
Development Effort Estimate, Person-Years (Person-Months) = 0.02 (0.27)
(Basic COCOMO model, Person-Months = 2.4 * (KSLOC**1.05))
Schedule Estimate, Years (Months) = 0.13 (1.52)
(Basic COCOMO model, Months = 2.5 * (person-months**0.38))
Estimated Average Number of Developers (Effort/Schedule) = 0.18
Total Estimated Cost to Develop = $ 3,018
(average salary = $56,286/year, overhead = 2.40).
SLOCCount, Copyright (C) 2001-2004 David A. Wheeler
SLOCCount is Open Source Software/Free Software, licensed under the GNU GPL.
SLOCCount comes with ABSOLUTELY NO WARRANTY, and you are welcome to
redistribute it under certain conditions as specified by the GNU GPL license;
see the documentation for details.
Please credit this data as "generated using David A. Wheeler's 'SLOCCount'."
ian@ian-HP-Stream-Laptop-11-y0XX:~/125.gz$ gfortran driver.f src.f -o 125run3
ian@ian-HP-Stream-Laptop-11-y0XX:~/125.gz$ ./125run3
1
2
n= 1 eps= 2.0000000000000000
m= 0.0000000000000000
2.0000000000000000 0.3333333333333333
4 Exact= 0.4000000000000000 Quadrature= 0.0246913580246913 Error= 0.3753086E+00
3
4
n= 3 eps= 4.0000000000000000
m= 1.0000000000000000
1.5000000000000000 0.3333333333333333
0.2777777777777778 -0.1000000000000000
0.2222222222222222 -0.6666666666666667
4 Exact= 0.4000000000000000 Quadrature= 0.0624420438957476 Error= 0.3375580E+00
5
6
n= 5 eps= 6.0000000000000000
m= 1.0000000000000000
1.5000000000000000 0.3333333333333333
0.2777777777777778 -0.1000000000000000
0.0972222222222222 -0.2380952380952381
0.0450000000000000 -0.3055555555555556
0.0800000000000000 -0.8000000000000000
4 Exact= 0.4000000000000000 Quadrature= 0.0520189968594654 Error= 0.3479810E+00
99
99
STOP 99
ian@ian-HP-Stream-Laptop-11-y0XX:~/125.gz$ cat 125.sh
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# driver.f
# src.f
# This archive created: Sun Jul 20 16:32:26 1997
export PATH; PATH=/bin:$PATH
if test -f 'driver.f'
then
echo shar: will not over-write existing file "'driver.f'"
else
cat << \SHAR_EOF > 'driver.f'
PROGRAM MAIN
C Driver for CACM Alg 125 Rutishauser
C Author [email protected]
C ANUSF, Australian National University
Canberra Australia
C
C Tidied up to use workspace arrays, real parameter values
C and put through nag tools
C
C trh (20/07/97)
C
C ..
C .. Parameters ..
INTEGER NM
PARAMETER (NM=100)
DOUBLE PRECISION ZERO,ONE,TWO,THREE
PARAMETER (ZERO=0.0D0,ONE=1.0D0,TWO=2.0D0,THREE=3.0D0)
C .. Local Scalars ..
DOUBLE PRECISION A,B,EPS,EXACT,S
INTEGER I,N,P
C ..
C .. Local Arrays ..
DOUBLE PRECISION E(NM),Q(NM),W(NM),WORK(9*NM+8),X(NM)
C ..
C .. External Subroutines ..
EXTERNAL WEIGHTCOEFF
C ..
C .. Intrinsic Functions ..
INTRINSIC MIN
C ..
10 READ (5,FMT=*,END=20) N,EPS
IF (EPS.LE.ZERO) EPS = 1D-15
IF (N.GE.NM-1) STOP 99
WRITE (6,FMT=*) 'n=',N,' eps=',EPS
C
C q,e for w=1/2 interval (0,2)
C Ref: W.Jones & W.Thron Continued Fractions ...
C Encyclopedia of maths...vol 11 p24
C Continued Fraction expansion of log(1+x),
C transformed to Rutishauser form p33
C
DO I = 2,NM
Q(I) = TWO*I*I/ (TWO*I* (TWO*I-ONE))
E(I) = TWO*I*I/ (TWO*I* (TWO*I+ONE))
END DO
Q(1) = ONE
E(1) = ONE/THREE
CALL WEIGHTCOEFF(N,Q,E,EPS,W,X,WORK)
C Adjust weights, zeros for w=1, interval (-1,1)
DO I = 1,N
W(I) = TWO*W(I)
X(I) = X(I) - ONE
END DO
DO I = 1,MIN(N,10)
WRITE (6,FMT=9000) W(I),X(I)
END DO
C Check for x^4
P = 4
A = -ONE
B = ONE
EXACT = (B** (P+1)-A** (P+1))/ (P+1)
S = ZERO
DO I = 1,N
S = S + W(I)*X(I)**P
END DO
WRITE (6,FMT=9010) P,EXACT,S,EXACT - S
GO TO 10
20 STOP
9000 FORMAT (F20.16,2X,F20.16)
9010 FORMAT (I3,' Exact=',F20.16,' Quadrature=',F20.16,' Error=',E14.7)
END
SHAR_EOF
fi # end of overwriting check
if test -f 'src.f'
then
echo shar: will not over-write existing file "'src.f'"
else
cat << \SHAR_EOF > 'src.f'
C Original Fortran translation donated by
C
C ANUSF, Australian National University
C Canberra Australia
C
C Tidied up to use workspace arrays, dimension arrays to
C required lengths, use 0: for dimensions of A, add comments,
C and NAG tools to layout source
C
C trh (20/07/97)
SUBROUTINE WEIGHTCOEFF(N,Q,E,EPS,W,X,WORK)
C
C This is just a wrapper routine to split up the workspace array
C
C .. Scalar Arguments ..
DOUBLE PRECISION EPS
INTEGER N
C ..
C .. Array Arguments ..
DOUBLE PRECISION E(N-1),Q(N),W(N),WORK(9*N+8),X(N)
C ..
C .. External Subroutines ..
EXTERNAL WEIGHTC
C ..
CALL WEIGHTC(N,Q,E,EPS,W,X,WORK,WORK(N+1))
END
SUBROUTINE WEIGHTC(N,Q,E,EPS,W,X,G,A)
C
C Computes the abscissae x(i) and the weight coefficients w(i) for a
C Gaussian quadrature method
C \int_0^b w(x)f(x) dx \approx \sum_{i=1}^{n}w_if(x_i) where
C \int_0^b w(x) dx = 1 and w(x)>= 0. The method requires the order n, a
C tolerance eps and the 2n-1 first coefficients of the continued fraction
C \int_0^b {w(x) \over z-x} = { 1| \over |z} - {q_1 | \over |1} -
C {e_1 | \over |z} - {q_2 | \over |1} -
C {e_2 | \over |z} - \cdots
C to be given, the latter in the two arrays q(n) and e(n-1) all
C components of which are automatically positive by virtue of the
C condition w(x)>= 0. The method works as well if the upper bound b is
C actually infinity (note that b does not appear directly as an
C argument!) or if the density function w(x) dx is replaced by da(x) with
C a monotonically increasing a(x) with at least n points of of variation.
C The tolerance eps should be given in accordance to the machines
C accuracy (preferably by using the value of d1mach(4)). The result is
C delivered as two arrays w(n) (the weight coefficients) and x(n) (the
C abscissae). For a description of the method see H Rutishauser, ``On a
C modification of the QD-algorithm with Graeffe-type convergence''
C [Proceedings of the IFIPS Congress, Munich, 1962].
C .. Scalar Arguments ..
DOUBLE PRECISION EPS
INTEGER N
C ..
C .. Array Arguments ..
DOUBLE PRECISION A(0:N,0:7),E(N-1),G(N),Q(N),W(N),X(N)
C ..
C .. Local Scalars ..
DOUBLE PRECISION M,P
INTEGER K
C ..
C .. External Subroutines ..
EXTERNAL QDGRAEFFE
C ..
C .. Intrinsic Functions ..
INTRINSIC ABS,EXP,LOG
C ..
X(1) = Q(1) + E(1)
DO K = 2,N
G(K-1) = E(K-1)*Q(K)/X(K-1)
IF (K.EQ.N) THEN
X(K) = Q(K) - G(K-1)
ELSE
X(K) = Q(K) + E(K) - G(K-1)
END IF
G(K-1) = G(K-1)/X(K)
W(K-1) = X(K)/X(K-1)
X(K-1) = LOG(X(K-1))
END DO
X(N) = LOG(X(N))
P = 1
30 DO K = 1,N - 1
IF (ABS(G(K)*W(K)).GT.EPS) GO TO 40
END DO
GO TO 50
40 CALL QDGRAEFFE(N,X,G,W,A)
P = 2*P
GO TO 30
C
C What follows is a peculiar method to compute the w(k) from
C the given ratios g_k = w_{k+1}/w_k such that
C \sum_{k=1}^n w_k = 1, but the straightforward formulae to do
C this might well produce overflow of exponent
C
50 W(1) = 1
M = 0
DO K = 1,N - 1
W(K+1) = W(K)*G(K)
IF (W(K).GT.M) M = W(K)
END DO
WRITE (6,FMT=*) 'm=',M
C /*do k=1,n w(k)=exp(w(k)-m) */
M = 0
DO K = 1,N
M = M + W(K)
END DO
DO K = 1,N
W(K) = W(K)/M
X(K) = EXP(X(K)/P)
END DO
RETURN
END
SUBROUTINE RED(A,F,N)
C
C Subroutine RED reduces a heptadiagonal matrix a to tridiagonal form as
C described in the paper referenced above.
C
C .. Scalar Arguments ..
INTEGER N
C ..
C .. Array Arguments ..
DOUBLE PRECISION A(0:N,0:7),F(N)
C ..
C .. Local Scalars ..
DOUBLE PRECISION C
INTEGER J,K
C ..
C .. Intrinsic Functions ..
INTRINSIC ABS
C ..
DO K = 1,N - 1
DO J = K,N - 1
C = -F(J)*A(J,7)/A(J,2)
A(J,7) = 0
A(J+1,2) = A(J+1,2) + C*A(J,5)
A(J,1) = A(J,1) - C*F(J)*A(J,4)
A(J,6) = A(J,6) - C*A(J+1,1)
A(J+1,3) = A(J+1,3) - C*A(J+1,6)
END DO
DO J = K,N - 1
C = -F(J)*A(J,4)/A(J,1)
A(J,4) = 0
A(J+1,1) = A(J+1,1) + C*A(J,6)
A(J+1,6) = A(J+1,6) + C*A(J+1,3)
A(J,5) = A(J,5) - C*A(J+1,2)
A(J+1,0) = A(J+1,0) - C*A(J+1,5)
END DO
DO J = K + 1,N - 1
C = -A(J,3)/A(J-1,6)
A(J,3) = 0
A(J,6) = A(J,6) + C*A(J,1)
A(J-1,5) = A(J-1,5) - C*F(J)*F(J)*A(J,0)
A(J,2) = A(J,2) - C*F(J)*F(J)*A(J,5)
A(J,7) = A(J,7) - C*F(J)*A(J+1,2)
END DO
DO J = K + 1,N - 1
C = -A(J,0)/A(J-1,5)
A(J,0) = 0
A(J+1,2) = A(J+1,2) + C*F(J)*A(J,7)
A(J,5) = A(J,5) + C*A(J,2)
A(J,1) = A(J,1) - C*F(J)*F(J)*A(J,6)
A(J,4) = A(J,4) - C*F(J)*A(J+1,1)
END DO
END DO
RETURN
END
SUBROUTINE QDGRAEFFE(N,H,G,F,A)
C
C Subroutine QDGRAEFFE computes for a given continued fraction
C f(z) = { 1| \over |z} - {q_1 | \over |1} -
C {e_1 | \over |z} - {q_2 | \over |1} -
C {e_2 | \over |z} - \cdots - {q_n | \over |1}
C another one, the poles of which are the squares of the poles of f(z)
C However QDGRAEFFE uses not the coefficients q_1 ... q_n and
C e_1 ... e_{n-1} of f(z) but the quotients f_k = q_{k+1}/q_k and
C g_k = e_k/q_{k+1} for k=1,2,...,n-1 and the h_k = ln(abs(q_k)) for
C k=1,2,...,n, and the results are delivered in the same form. Routine
C QDGRAEFFE can be used independently, but requires subroutine RED
C
C .. Scalar Arguments ..
INTEGER N
C ..
C .. Array Arguments ..
DOUBLE PRECISION A(0:N,0:7),F(N),G(N),H(N)
C ..
C .. Local Scalars ..
INTEGER K
C ..
C .. External Subroutines ..
EXTERNAL RED
C ..
C .. Intrinsic Functions ..
INTRINSIC ABS,LOG
C ..
G(N) = 0
F(N) = 0
DO K = 1,N
A(K-1,4) = 1
A(K-1,5) = 1
A(K,2) = 1 + G(K)*F(K)
A(K,1) = 1 + G(K)*F(K)
A(K,6) = G(K)
A(K,7) = G(K)
A(K,0) = 0
A(K,3) = 0
END DO
A(N,5) = 0
C
C The array a represents the heptadiagonal matrix Q of the paper
C cited above, but with the modifications needed to avoid large numbers
C and with a peculiar arrangement.
C
CALL RED(A,F,N)
DO K = 1,N
H(K) = 2*H(K) + LOG(ABS(A(K,1)*A(K,2)))
END DO
DO K = 1,N - 1
F(K) = F(K)*F(K)*A(K+1,2)*A(K+1,1)/ (A(K,1)*A(K,2))
G(K) = A(K,5)*A(K,6)/ (A(K+1,1)*A(K+1,2))
END DO
RETURN
END
SHAR_EOF
fi # end of overwriting check
# End of shell archive
exit 0
ian@ian-HP-Stream-Laptop-11-y0XX:~/125.gz$ cat driver.sh
cat: driver.sh: No such file or directory
ian@ian-HP-Stream-Laptop-11-y0XX:~/125.gz$ cat driver.f
PROGRAM MAIN
C Driver for CACM Alg 125 Rutishauser
C Author [email protected]
C ANUSF, Australian National University
Canberra Australia
C
C Tidied up to use workspace arrays, real parameter values
C and put through nag tools
C
C trh (20/07/97)
C
C ..
C .. Parameters ..
INTEGER NM
PARAMETER (NM=100)
DOUBLE PRECISION ZERO,ONE,TWO,THREE
PARAMETER (ZERO=0.0D0,ONE=1.0D0,TWO=2.0D0,THREE=3.0D0)
C .. Local Scalars ..
DOUBLE PRECISION A,B,EPS,EXACT,S
INTEGER I,N,P
C ..
C .. Local Arrays ..
DOUBLE PRECISION E(NM),Q(NM),W(NM),WORK(9*NM+8),X(NM)
C ..
C .. External Subroutines ..
EXTERNAL WEIGHTCOEFF
C ..
C .. Intrinsic Functions ..
INTRINSIC MIN
C ..
10 READ (5,FMT=*,END=20) N,EPS
IF (EPS.LE.ZERO) EPS = 1D-15
IF (N.GE.NM-1) STOP 99
WRITE (6,FMT=*) 'n=',N,' eps=',EPS
C
C q,e for w=1/2 interval (0,2)
C Ref: W.Jones & W.Thron Continued Fractions ...
C Encyclopedia of maths...vol 11 p24
C Continued Fraction expansion of log(1+x),
C transformed to Rutishauser form p33
C
DO I = 2,NM
Q(I) = TWO*I*I/ (TWO*I* (TWO*I-ONE))
E(I) = TWO*I*I/ (TWO*I* (TWO*I+ONE))
END DO
Q(1) = ONE
E(1) = ONE/THREE
CALL WEIGHTCOEFF(N,Q,E,EPS,W,X,WORK)
C Adjust weights, zeros for w=1, interval (-1,1)
DO I = 1,N
W(I) = TWO*W(I)
X(I) = X(I) - ONE
END DO
DO I = 1,MIN(N,10)
WRITE (6,FMT=9000) W(I),X(I)
END DO
C Check for x^4
P = 4
A = -ONE
B = ONE
EXACT = (B** (P+1)-A** (P+1))/ (P+1)
S = ZERO
DO I = 1,N
S = S + W(I)*X(I)**P
END DO
WRITE (6,FMT=9010) P,EXACT,S,EXACT - S
GO TO 10
20 STOP
9000 FORMAT (F20.16,2X,F20.16)
9010 FORMAT (I3,' Exact=',F20.16,' Quadrature=',F20.16,' Error=',E14.7)
END
ian@ian-HP-Stream-Laptop-11-y0XX:~/125.gz$ cat src.f
C Original Fortran translation donated by
C
C ANUSF, Australian National University
C Canberra Australia
C
C Tidied up to use workspace arrays, dimension arrays to
C required lengths, use 0: for dimensions of A, add comments,
C and NAG tools to layout source
C
C trh (20/07/97)
SUBROUTINE WEIGHTCOEFF(N,Q,E,EPS,W,X,WORK)
C
C This is just a wrapper routine to split up the workspace array
C
C .. Scalar Arguments ..
DOUBLE PRECISION EPS
INTEGER N
C ..
C .. Array Arguments ..
DOUBLE PRECISION E(N-1),Q(N),W(N),WORK(9*N+8),X(N)
C ..
C .. External Subroutines ..
EXTERNAL WEIGHTC
C ..
CALL WEIGHTC(N,Q,E,EPS,W,X,WORK,WORK(N+1))
END
SUBROUTINE WEIGHTC(N,Q,E,EPS,W,X,G,A)
C
C Computes the abscissae x(i) and the weight coefficients w(i) for a
C Gaussian quadrature method
C \int_0^b w(x)f(x) dx \approx \sum_{i=1}^{n}w_if(x_i) where
C \int_0^b w(x) dx = 1 and w(x)>= 0. The method requires the order n, a
C tolerance eps and the 2n-1 first coefficients of the continued fraction
C \int_0^b {w(x) \over z-x} = { 1| \over |z} - {q_1 | \over |1} -
C {e_1 | \over |z} - {q_2 | \over |1} -
C {e_2 | \over |z} - \cdots
C to be given, the latter in the two arrays q(n) and e(n-1) all
C components of which are automatically positive by virtue of the
C condition w(x)>= 0. The method works as well if the upper bound b is
C actually infinity (note that b does not appear directly as an
C argument!) or if the density function w(x) dx is replaced by da(x) with
C a monotonically increasing a(x) with at least n points of of variation.
C The tolerance eps should be given in accordance to the machines
C accuracy (preferably by using the value of d1mach(4)). The result is
C delivered as two arrays w(n) (the weight coefficients) and x(n) (the
C abscissae). For a description of the method see H Rutishauser, ``On a
C modification of the QD-algorithm with Graeffe-type convergence''
C [Proceedings of the IFIPS Congress, Munich, 1962].
C .. Scalar Arguments ..
DOUBLE PRECISION EPS
INTEGER N
C ..
C .. Array Arguments ..
DOUBLE PRECISION A(0:N,0:7),E(N-1),G(N),Q(N),W(N),X(N)
C ..
C .. Local Scalars ..
DOUBLE PRECISION M,P
INTEGER K
C ..
C .. External Subroutines ..
EXTERNAL QDGRAEFFE
C ..
C .. Intrinsic Functions ..
INTRINSIC ABS,EXP,LOG
C ..
X(1) = Q(1) + E(1)
DO K = 2,N
G(K-1) = E(K-1)*Q(K)/X(K-1)
IF (K.EQ.N) THEN
X(K) = Q(K) - G(K-1)
ELSE
X(K) = Q(K) + E(K) - G(K-1)
END IF
G(K-1) = G(K-1)/X(K)
W(K-1) = X(K)/X(K-1)
X(K-1) = LOG(X(K-1))
END DO
X(N) = LOG(X(N))
P = 1
30 DO K = 1,N - 1
IF (ABS(G(K)*W(K)).GT.EPS) GO TO 40
END DO
GO TO 50
40 CALL QDGRAEFFE(N,X,G,W,A)
P = 2*P
GO TO 30
C
C What follows is a peculiar method to compute the w(k) from
C the given ratios g_k = w_{k+1}/w_k such that
C \sum_{k=1}^n w_k = 1, but the straightforward formulae to do
C this might well produce overflow of exponent
C
50 W(1) = 1
M = 0
DO K = 1,N - 1
W(K+1) = W(K)*G(K)
IF (W(K).GT.M) M = W(K)
END DO
WRITE (6,FMT=*) 'm=',M
C /*do k=1,n w(k)=exp(w(k)-m) */
M = 0
DO K = 1,N
M = M + W(K)
END DO
DO K = 1,N
W(K) = W(K)/M
X(K) = EXP(X(K)/P)
END DO
RETURN
END
SUBROUTINE RED(A,F,N)
C
C Subroutine RED reduces a heptadiagonal matrix a to tridiagonal form as
C described in the paper referenced above.
C
C .. Scalar Arguments ..
INTEGER N
C ..
C .. Array Arguments ..
DOUBLE PRECISION A(0:N,0:7),F(N)
C ..
C .. Local Scalars ..
DOUBLE PRECISION C
INTEGER J,K
C ..
C .. Intrinsic Functions ..
INTRINSIC ABS
C ..
DO K = 1,N - 1
DO J = K,N - 1
C = -F(J)*A(J,7)/A(J,2)
A(J,7) = 0
A(J+1,2) = A(J+1,2) + C*A(J,5)
A(J,1) = A(J,1) - C*F(J)*A(J,4)
A(J,6) = A(J,6) - C*A(J+1,1)
A(J+1,3) = A(J+1,3) - C*A(J+1,6)
END DO
DO J = K,N - 1
C = -F(J)*A(J,4)/A(J,1)
A(J,4) = 0
A(J+1,1) = A(J+1,1) + C*A(J,6)
A(J+1,6) = A(J+1,6) + C*A(J+1,3)
A(J,5) = A(J,5) - C*A(J+1,2)
A(J+1,0) = A(J+1,0) - C*A(J+1,5)
END DO
DO J = K + 1,N - 1
C = -A(J,3)/A(J-1,6)
A(J,3) = 0
A(J,6) = A(J,6) + C*A(J,1)
A(J-1,5) = A(J-1,5) - C*F(J)*F(J)*A(J,0)
A(J,2) = A(J,2) - C*F(J)*F(J)*A(J,5)
A(J,7) = A(J,7) - C*F(J)*A(J+1,2)
END DO
DO J = K + 1,N - 1
C = -A(J,0)/A(J-1,5)
A(J,0) = 0
A(J+1,2) = A(J+1,2) + C*F(J)*A(J,7)
A(J,5) = A(J,5) + C*A(J,2)
A(J,1) = A(J,1) - C*F(J)*F(J)*A(J,6)
A(J,4) = A(J,4) - C*F(J)*A(J+1,1)
END DO
END DO
RETURN
END
SUBROUTINE QDGRAEFFE(N,H,G,F,A)
C
C Subroutine QDGRAEFFE computes for a given continued fraction
C f(z) = { 1| \over |z} - {q_1 | \over |1} -
C {e_1 | \over |z} - {q_2 | \over |1} -
C {e_2 | \over |z} - \cdots - {q_n | \over |1}
C another one, the poles of which are the squares of the poles of f(z)
C However QDGRAEFFE uses not the coefficients q_1 ... q_n and
C e_1 ... e_{n-1} of f(z) but the quotients f_k = q_{k+1}/q_k and
C g_k = e_k/q_{k+1} for k=1,2,...,n-1 and the h_k = ln(abs(q_k)) for
C k=1,2,...,n, and the results are delivered in the same form. Routine
C QDGRAEFFE can be used independently, but requires subroutine RED
C
C .. Scalar Arguments ..
INTEGER N
C ..
C .. Array Arguments ..
DOUBLE PRECISION A(0:N,0:7),F(N),G(N),H(N)
C ..
C .. Local Scalars ..
INTEGER K
C ..
C .. External Subroutines ..
EXTERNAL RED
C ..
C .. Intrinsic Functions ..
INTRINSIC ABS,LOG
C ..
G(N) = 0
F(N) = 0
DO K = 1,N
A(K-1,4) = 1
A(K-1,5) = 1
A(K,2) = 1 + G(K)*F(K)
A(K,1) = 1 + G(K)*F(K)
A(K,6) = G(K)
A(K,7) = G(K)
A(K,0) = 0
A(K,3) = 0
END DO
A(N,5) = 0
C
C The array a represents the heptadiagonal matrix Q of the paper
C cited above, but with the modifications needed to avoid large numbers
C and with a peculiar arrangement.
C
CALL RED(A,F,N)
DO K = 1,N
H(K) = 2*H(K) + LOG(ABS(A(K,1)*A(K,2)))
END DO
DO K = 1,N - 1
F(K) = F(K)*F(K)*A(K+1,2)*A(K+1,1)/ (A(K,1)*A(K,2))
G(K) = A(K,5)*A(K,6)/ (A(K+1,1)*A(K+1,2))
END DO
RETURN
END
ian@ian-HP-Stream-Laptop-11-y0XX:~/125.gz$