-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgpsfexps.f
3716 lines (3045 loc) · 79.4 KB
/
gpsfexps.f
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
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
implicit real*8 (a-h,o-z)
call prini(6,13)
call testit(n)
stop
end
subroutine testit(n)
implicit real*8 (a-h,o-z)
real*8 w(2 000 000)
call test_tbar_56(w)
ccc call test_gammas_4(w)
ccc call test_lnc_93(w)
ccc call test_mnc_90(w)
ccc call plot_phi_88(w)
ccc call test_ode_268(w)
ccc call phi_quad_test(w)
ccc call exp_quad_test(w)
stop
end
c
c
c
c
c
subroutine plot_phi_88(w)
implicit real *8 (a-h,o-z)
real*8 rs(100 000),phis(100 000),w(1),phis2(10 000),
1 vect(100 000),ws(100 000),zerns(100 000),
1 big_phis(10 000)
c
c with gnuplot, plot the radial gpsfs, phis (88) and
c big_phis(87) of the preprint --
c https://arxiv.org/pdf/1811.02733.pdf
c
neig=10
nn=20
ip=3
c=200
c
c compute eigenfunction expansion
c
call dprol_ln_n_eigen_eval(neig,nn,ip,c,w,nmat,rlam,vect)
c
c lay down gauss legendre nodes on (0,1)
c
nnodes=400
call legeexps(1,nnodes,rs,u,v,ws)
a=0.0
b=1.0
do i=1,nnodes
rs(i)=rs(i)/(2.0d0/(b-a))+(b+a)/2.0d0
enddo
c
c evaluate integrand at nodes
c
do i=1,nnodes
call dprol_t_bar_coef2exp(vect,rs(i),nmat,nn,ip,w,phii)
phis(i)=phii
call dprol_normd_zern_exp_eval2(vect,rs(i),nn,ip,nmat,val0,
1 val1,val2)
big_phis(i)=val0
call dprol_zern_normd_pol(rs(i),neig,nn,ip,val)
zerns(i)=val
enddo
c
c print tikzpicture coordinates for latex
c
ccc call print_gpsfs(nnodes, rs, phis)
c
c . . . plot phis
c
iw=15
call quagraph(iw,rs,phis,nnodes,3,'title*')
iw=16
call quagraph(iw,rs,big_phis,nnodes,3,'title*')
return
end
c
c
c
c
c
subroutine print_gpsfs(n, rs, fs)
implicit real *8 (a-h,o-z)
real*8 rs(n), fs(n)
iu = 6
open(iu)
210 format('(',f8.5,','f8.5,')')
do i=1,n
write(iu, 210) rs(i), fs(i)/sqrt(rs(i))
enddo
return
end
c
c
c
c
c
subroutine phi_quad_test(w)
implicit real*8 (a-h,o-z)
real*8 w(1),droots(10 000),ws(10 000),rints(10 000)
real*8 vect(10 000),fs(10 000),rs(10 000),djs(10 000)
c
c check for ip=0, that a quadrature that integrates the gpsfs
c
c \Phi_{0,0}(r)*r,...,\Phi_{0,n-1}(r)*r
c
c will also integrate J_0(c*r*rho)*r as long as we have enough
c nodes. enough nodes means the eigenvalue of \Phi_{0,n} is small
c
nn=2
ip=2
c=20
rho=0.8
c
c first use n nodes and then double to check accuracy
c
n=20
call dprol_bigphi_exps(n,nn,ip,c,w,rs,ws)
c
c . . . check that eigenvalue is small
c
neig=n+1
call dprol_gamma_n_eval(neig,nn,ip,c,w,nmat,rlam,dgam,vect)
call prin2('dgam*',dgam,1)
c
c tabulate function to be integrated
c
eps=1.0d-75
do i=1,n
r=rs(i)
call dprol_normd_zern_exp_eval(vect,r,nn,ip,nmat,val)
fs(i)=val
call rjbvals(c*r*rho,eps,djs,nvals,nmax)
fs(i)=djs(1)*r
enddo
c
c . . . compute integral
c
rint=0
do i=1,n
rint=rint+fs(i)*ws(i)
enddo
call prin2('rint*',rint,1)
c
c . . . double nodes to compare
c
n=2*n
call dprol_bigphi_exps(n,nn,ip,c,w,rs,ws)
c
c tabulate function to be integrated
c
do 600 i=1,n
r=rs(i)
call dprol_normd_zern_exp_eval(vect,r,nn,ip,nmat,val)
fs(i)=val
call rjbvals(c*r*rho,eps,djs,nvals,nmax)
fs(i)=djs(1)*r
600 continue
c
c . . . compute integral
c
rint2=0
do 800 i=1,n
rint2=rint2+fs(i)*ws(i)
800 continue
call prin2('rint2*',rint2,1)
dd=(rint2-rint)/rint2
call prin2('dd*',dd,1)
iw=19
call quagraph(iw,rs,fs,n,3,'title*')
return
end
c
c
c
c
c
subroutine test_gammas_4(w)
implicit real *8 (a-h,o-z)
real*8 w(1),vect(100 000),dgams(10 000)
real*8 rlams(10 000),vects(100 000)
c
c compute an eigenvalue of the integral operator m,
c in 2 ways. first, by computing the single eigenvalue
c method of section 4.1 of the preprint --
c https://arxiv.org/pdf/1811.02733.pdf -- then
c by computing all of the first n eigenvalues using
c the method of section 4.2.
c
nn=2
ip=1
c=10.0d0
c
c compute the first neigs eigenvalues using ratios
c
neigs=24
call dprol_gammas_eval(neigs,nn,ip,c,w,nmat,rlams,dgams,vects)
call prin2('dgams*',dgams,neigs)
do i=1,neigs
call dprol_gamma_n_eval(i,nn,ip,c,w,nmat,rlam,dgam1,vect)
dgams(i) = dgam1
enddo
call prin2('dgams2*', dgams, neigs)
c
c evaluate just the neig^th eigenvalue using a_0, the first
c component of the eigenvector
c
neig=neigs
do i=1,neigs
neig = i
call dprol_gamma_n_eval(neig,nn,ip,c,w,nmat,rlam,dgam1,vect)
enddo
call prin2('dgam1*',dgam1,1)
call prin2('dgam2*',dgams(neig),1)
dd=(dgams(neig)-dgam1)/dgam1
call prin2('relative difference*',dd,1)
c
c . . . evaluate the neig^th eigenvalue in a primative way, by
c applying the integral operator using integration via legendre
c nodes and checking ratio at some point
ccc call m_n_eigen_eval_rough(neig,nn,ip,c,w,dgam3,vect)
ccc call prin2('dgam3*',dgam3,1)
ccc call prin2('dd*',(dgams(neig)-dgam3)/dgam3,1)
return
end
c
c
c
c
c
subroutine test_tbar_56(w)
implicit real*8 (a-h,o-z)
real*8 w(1), vect(10 000)
c
c check equation (56) of the preprint
c https://arxiv.org/pdf/1811.02733.pdf. note that the
c equation in the original arxiv paper from 2018 is
c wrong. the correct equation was added to the next version.
c
n=4
nn=2
ip=1
c=100
r = 0.6
c
c set variables used in formula
c
a = nn + ip/2.0d0
at = -2.0d0*n*(2*n + a + 2)
bt = 2.0d0*a*(2*n + a + 1)
ct = 2.0d0*(n + a + 1) * (2*n + a)
a1 = n*(2.0d0*a + 4*n - 1)*(2*n + a + 2)
b1 = a*(2.0d0*n + a + 1) - 2*(2*n+a)*(2*n+a+1)*(2*n+a+2)
c1 = (2.0d0*a + 4*n + 5)*(n + a + 1)*(2*n+a)
c
c evaluate tbar functions
c
nm = n - 1
np = n + 1
call dprol_tbar_deriv(r,n,nn,ip,t0,t1)
call dprol_tbar_deriv(r,nm,nn,ip,t0m,t1m)
call dprol_tbar_deriv(r,np,nn,ip,t0p,t1p)
c
c scale tbar functions to be t functions
c
const = sqrt(2.0d0*(2.0d0*n + a + 1.0d0))
constm = sqrt(2.0d0*(2.0d0*nm + a + 1.0d0))
constp = sqrt(2.0d0*(2.0d0*np + a + 1.0d0))
t0 = t0 / const
t0m = t0m / constm
t0p = t0p / constp
t1 = t1 / const
t1m = t1m / constm
t1p = t1p / constp
c
c check formula
c
dlhs = at*r*t1m - bt*r*t1 + ct*r*t1p
rhs = a1*t0m - b1*t0 + c1*t0p
dd = dlhs - rhs
call prin2('dlhs*', dlhs, 1)
call prin2('rhs*', rhs, 1)
call prin2('dd*', dd, 1)
return
end
c
c
c
c
c
subroutine test_ode_268(w)
implicit real*8 (a-h,o-z)
real*8 w(1), vect(10 000)
c
c check second order ode (268) of the original arxiv
c paper https://arxiv.org/pdf/1811.02733.pdf
c
neig=20
nn=1
ip=2
c=100
c
c compute eigenfunction expansion of one eigenfunction
c phi as well as the corresponding eigenvalue of the
c differential operator L_{N, c}
c
call dprol_ln_n_eigen_eval(neig,nn,ip,c,w,nmat,rlam,vect)
c
c evaluate phi and its first two derivatives
c
r = 0.2
nmat1 = nmat + 1
call dprol_normd_zern_exp_eval2(vect,r,nn,ip,nmat1,val0,
1 val1,val2)
c
c check second order ode (268)
c
t2 = (1 - r**2) * r**2 * val2
t1 = (ip + 1.0d0) * r - (ip + 3.0d0)*r**3
t1 = t1 * val1
t0 = -rlam*r**2 - (ip+1)*(ip+3)/4.0d0*r**2
t0 = t0 - 1.0d0*nn*(nn + ip) - c**2*r**4
t0 = t0 * val0
dd = t0 + t1 + t2
call prin2('dd*', dd, 1)
return
end
c
c
c
c
c
subroutine test_mnc_90(w)
implicit real*8 (a-h,o-z)
real*8 rhos(10000),vals(10000), djs(10000),deigs(10000)
real*8 ws(10000),dds(10000),vect(10 000),w(1)
real*8 dphis(10000),dmphis(10000),dmphis_scaled(10000)
c
c test that \phi is an eigenfunction of the integral
c operator M_{N, c}. in particular, test formula (90)
c of https://arxiv.org/1811.02733
c
neig=5
nn=1
ip=2
c=100
c
c find zernike expansion of eigenfucntion phi
c
call dprol_ln_n_eigen_eval(neig,nn,ip,c,w,nmat,rlam,vect)
c
c find corresponding eigenvalue of integral operator M_{N, c}
c
call dprol_gamma_n_eval(neig,nn,ip,c,w,nmat,rlam,dgam,vect)
call prin2('dgam*',dgam,1)
c
c check that phi is in fact an eigenfunction by computing
c integral operator applied to phi using legendre quadrature
c
nnodes=250
call legeexps(1,nnodes,rhos,u,v,ws)
do i=1,nnodes
rhos(i)=rhos(i)/2.0d0+1/2.0d0
enddo
c
c tabulate integrand at nodes, rhos
c
eps=1.0d-50
do 4500 k=1,nnodes
do 4000 i=1,nnodes
call dprol_t_bar_coef2exp(vect,rhos(i),nmat,nn,ip,w,val0i)
dphis(i)=val0i
x=c*rhos(k)*rhos(i)
if (mod(ip,2) .eq. 0) then
call rjbvals(x,eps,djs,nvals,nmax)
endif
if (mod(ip,2) .eq. 1) then
call rjbvals_half(x,eps,djs,nvals,nmax)
endif
vals(i)=djs(nn+ip/2)*val0i*sqrt(x)
4000 continue
c
c compute integral by multiplying tabulation at gaussian
c nodes by weights
c
rint=0
do j=1,nnodes
rint=rint+ws(j)*vals(j)
enddo
rint=rint/2.0d0
c
c compute approximate eigenvalue
c
call dprol_t_bar_coef2exp(vect,rhos(k),nmat,nn,ip,w,val0)
deigs(k)=rint/val0
dmphis(k)=rint
4500 continue
ccc call prin2('deigs*', deigs, nnodes)
c
c make sure that we do in fact have an eigenfunction by
c comparing M_{N, c}[\phi] to \gamma_{N, n} \phi
c
do i=1,nnodes
dmphis_scaled(i)=dmphis(i)
dds(i)=dmphis_scaled(i) - dphis(i) * dgam
enddo
call prin2('dds*',dds,nnodes)
return
end
c
c
c
c
c
subroutine m_n_eigen_eval_rough(neig,nn,ip,c,w,dgam,vect)
implicit real *8 (a-h,o-z)
real*8 rhos(10000),vals(10000), djs(10000),deigs(10000)
real*8 ws(10000),dds(10000),vect(1),w(1)
real*8 dphis(10000),dmphis(10000),dmphis_scaled(10000)
c
c evaluate an eigenvalue of the integral operator m in a
c primative way.
c n.b. this subroutine only works for very small n,nn,c,ip
c and is only used to verify forumlas, not compute
c
c
c find eigenvectors of matrix corresponding to differential
c operator l
c
call dprol_ln_n_eigen_eval(neig,nn,ip,c,w,nmat,rlam,vect)
c
c find corresponding eigenvalue of integral operator M_{N, c}
c
call dprol_gamma_n_eval(neig,nn,ip,c,w,nmat,rlam,dgam,vect)
call prin2('dgam*',dgam,1)
c
c lay down gauss legendre nodes on (0,1)
c
nnodes=250
call legeexps(1,nnodes,rhos,u,v,ws)
do i=1,nnodes
rhos(i)=rhos(i)/2.0d0+1/2.0d0
enddo
c
c tabulate integrand at nodes, rhos
c
eps=1.0d-50
do 4500 k=1,nnodes
do 4000 i=1,nnodes
call dprol_t_bar_coef2exp(vect,rhos(i),nmat,nn,ip,w,val0i)
dphis(i)=val0i
x=c*rhos(k)*rhos(i)
if (mod(ip,2) .eq. 0) then
call rjbvals(x,eps,djs,nvals,nmax)
endif
if (mod(ip,2) .eq. 1) then
call rjbvals_half(x,eps,djs,nvals,nmax)
endif
vals(i)=djs(nn+ip/2)*val0i*sqrt(x)
4000 continue
c
c compute integral by multiplying tabulation at gaussian
c nodes by weights
c
rint=0
do 4100 j=1,nnodes
rint=rint+ws(j)*vals(j)
4100 continue
rint=rint/2.0d0
c
c compute approximate eigenvalue
c
call dprol_t_bar_coef2exp(vect,rhos(k),nmat,nn,ip,w,val0)
deigs(k)=rint/val0
dmphis(k)=rint
ccc call prin2('rint2*',rint2,1)
ccc call prin2('function at nodes*',vals,nnodes)
4500 continue
ccc call prin2('deigs*', deigs, nnodes)
c
c make sure that we do in fact have an eigenfunction by
c comparing M_{N, c}[\phi] to \gamma_{N, n} \phi
c
do i=1,nnodes
dmphis_scaled(i)=dmphis(i)
dds(i)=dmphis_scaled(i) - dphis(i) * dgam
enddo
call prin2('dds*',dds,nnodes)
c
c and plot
c
iw=18
call quagraph2(iw,rhos,dphis,nnodes,3,
1 rhos,dmphis_scaled,nnodes,3,'title*')
return
end
c
c
c
c
c
subroutine test_lnc_93(w)
implicit real*8 (a-h,o-z)
real*8 w(1), vect(10 000)
c
c check that \phi is an eigenfunction of the linear
c operator L_{N, c} of https://arxiv.org/pdf/1811.02733.pdf
c (see (92)) of the original arxiv version.
c
neig=8
nn=2
ip=0
c=0
c
c compute zernike expansion of the eigenfunction
c phi as well as the corresponding eigenvalue of the
c differential operator L_{N, c}
c
call dprol_ln_n_eigen_eval(neig,nn,ip,c,w,nmat,rlam,vect)
ccc call prin2('vect*',vect,nmat)
c
c evaluate phi and its first two derivatives
c
r = 0.2
call dprol_t_bar_coef2exp2(vect,r,nmat,nn,ip,w,val0,val1,
1 val2)
t1 = (1 - r**2) * val2 + val1 * (-2*r)
t2 = (0.25 - (nn + ip/2.0d0)**2)/r**2 - c**2*r**2
t2 = t2 * val0
dd = t1 + t2 - rlam * val0
call prin2('rlam*', rlam, 1)
call prin2('dd*', dd, 1)
return
end
c
c
c
c
c
subroutine exp_quad_test(w)
implicit real*8 (a-h,o-z)
real*8 w(*),droots(10 000),ws(10 000),rints(10 000)
real*8 vect(10 000),fs(10 000),rs(10 000),djs(10 000)
real*8 dthetas(10 000)
complex*16 ima,fs_comp(100 000),rint_comp,rint_comp2,dd
data ima/(0.0d0,1.0d0)/
c
c integrate a complex exponential on the unit disk using
c prolate quadrature in the radial direction and equispaced
c nodes in the angular direction. check accuracy by doubling
c nodes in both angular and radial directions and integrating
c again
c
nn=0
ip=1
c=20
nrad=20
nang=50
xx=0.9d0
xy=0.2d0
c
c generate radial nodes and weights
c
call dprol_bigphi_exps(nrad,nn,ip,c,w,rs,ws)
ccc call dprol_gausquad(nrad,ip,c,w,rs,ws)
dsum=0
do i=1,nrad
dsum=dsum+ws(i)
enddo
c
c and angular ones
c
done=1
pi=atan(done)*4
do i=1,nang
dthetas(i)=2*pi*(i-1)/nang
enddo
eps=1.0d-20
call rjbvals(c*xx,eps,djs,nvals,nmax)
val=pi*2*djs(1)/(c*xx)
c
c . . . and start quadrature
c
rint_comp=0
icount=1
do j=1,nrad
do i=1,nang
tx=rs(j)*cos(dthetas(i))
ty=rs(j)*sin(dthetas(i))
scap=tx*xx+ty*xy
fs_comp(icount)=exp(ima*c*scap)
rint_comp=rint_comp+ws(j)*2*pi/nang*fs_comp(icount)
icount=icount+1
enddo
enddo
ccc call prin2('fs_comp*',fs_comp,nrad*nang*2)
call prin2('rint_comp*',rint_comp,2)
c
c now do the same thing, except with double the number of nodes
c in both the radial and angular directions
c
nrad=nrad*2
nang=nang*2
c
c generate radial nodes and weights
c
call dprol_bigphi_exps(nrad,nn,ip,c,w,rs,ws)
ccc call dprol_gausquad(nrad,ip,c,w,rs,ws)
c
c and angular ones
c
done=1
pi=atan(done)*4
do 1200 i=1,nang
dthetas(i)=2*pi*(i-1)/nang
1200 continue
c
c . . . and start quadrature
c
rint_comp2=0
icount=1
do j=1,nrad
do i=1,nang
tx=rs(j)*cos(dthetas(i))
ty=rs(j)*sin(dthetas(i))
scap=tx*xx+ty*xy
fs_comp(icount)=exp(ima*c*scap)
rint_comp2=rint_comp2+ws(j)*2*pi/nang*fs_comp(icount)
icount=icount+1
enddo
enddo
ccc call prin2('fs_comp*',fs_comp,nrad*nang*2)
call prin2('rint_comp2*',rint_comp2,2)
dd=(rint_comp2-rint_comp)/rint_comp2
call prin2('dd*',dd,2)
return
end
c
c
c
c
c
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
c this is the end of the debugging code and the beginning
c of the prolate routines
c
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
c
c This file contains a set of subroutines for the handling
c of prolate spheroidal wave functions. The following is a brief
c description of the user-callable subroutines contained in
c this file.
c
c dprol_gausquad - generates the n nodes and weights that integrate the
c first 2n gpsfs of an inputted bandlimit
c
c dprol_gammas_eval - evaluates the first n eigenvalues of differential
c operator L, the first n eigenvalues of integral operator m,
c and the coefficients of the t-bar expansions of the first n
c eigenfunctions. Note that operators m and L commute and have
c the same eigenfunctions.
c
c dprol_gamma_n_eval - evaluates the n^th eigenvalue of differential
c operator L, the n^th eigenvalue of integral operator m, and
c the expansion of the n^th eigenfunction in t bar functions.
c
c dprol_t_bar_coef2exp - given a user-provided array of coefficients,
c this subroutine evaluates an expansion in t bar functions at a
c user-provided point on the interval [0,1].
c
c dprol_log_phi_star_eval - evaluates log(phi^*), that is, the
c coefficient of the r^{nn+2n} term of \phi_{nn,n}.
c
c dprol_ln_all_eigen_eval - evaluates the first n eigenvalues and
c the first n eigenvectors of the symmetric tridiagonal matrix
c corresponding to the differential operator L using sturm
c bisection
c
c dprol_ln_n_eigen_eval - evaluates the n^th eigenvalue and the n^th
c eigenvector of the symmetric tridiagonal matrix corresponding
c to the differential operator L using sturm bisection
c
c dprol_mat_size_evalq - this subroutine determines a number of terms
c in the t-bar expansion of the n^th eigenfunction
c of integral operator m (and differential operator L) sufficient
c to capture all terms with coefficients of magnitude greater
c than 1.0d-35. This subroutine is used to determine the size of
c the (symmetric and tridiagonal) matrix corresponding to the
c differential operator L whose eigenvectors form the coefficients
c of the t-bar expansions of eigenfunctions of L and m.
c
c dprol_ratio_eval - evaluates the ratio \gamma_{nn,i}/\gamma_{nn,j},
c given the user-provided coefficients of the expansions in
c t bar functions of the two corresponding eigenfunctions
c phi_{nn,i} and phi_{nn,j}.
c
c dprol_t_bar - evaluates a t bar function. that is, a normalized
c zernike polynomial multiplied by r^{(p+1)/2}
c
c dprol_zern_pol - evaluates the (non-normalized) zernike
c polynomial R_{nn,n}
c
c dprol_zern_normd_pol - evaluates a normalized zernike polynomial.
c that is, \sqrt{2(2n+nn+p/2+1)}*R_{nn,n}, which is l2
c normalized with weight function r^{p+1}
c
c dprol_jac_pol - evaluates a jacobi polynomial with parameter \Beta=0
c and user provided \alpha
c
c dprol_t_bar_derivs - evaluates the first n t bar functions and their
c derivatives
c
c dprol_zern_pol_derivs - evaluates the first n non-normalized zernike
c polynomials along with their derivatives
c
c dprol_jac_pol_derivs - evaluates the first n jacobi polynomials (with
c parameter \Beta=0) along with their derivatives
c
c dprol_zern_pol_deriv2 - evaluates a non-normalized zernike
c polynomial along with its first and second derivatives
c
c dprol_jac_pol_deriv2 - evaluates a jacobi polynomial
c (with parameter \Beta=0) along with its first and second
c derivatives
c
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
c
c
c
c
subroutine dprol_gausquad(n,ip,c,w,rs,ws)
implicit real*8 (a-h,o-z)
real*8 w(1),ws(1),rs(1),vect(10 000),a2(100 000),
1 rints(10 000),rints_true(10 000),dds(10 000),adws(10 000),
1 adrs(100 000),rints2(10 000),rhs(10 000),dders(10 000),
1 rws(10 000),rnorms(10 000),a(100 000),x2(10 000),u(10 000),
1 v(10 000),s(10 000),rs2(10 000),ws2(10 000)
c
c generate a gaussian quadrature for the gpsfs with bandlimit c
c
c \Phi_{0,0}, \Phi_{0,1},..., \Phi_{0,2n-1}
c
c by first generating a chebyshev quadrature for gpsfs with
c bandlimit c/2 and then doing newton on the first 2n gpsfs
c with bandlimit c
c
c
c generate n nodes and weights corresponding to c/2
c
nn=0
c2=c/2.0d0
call dprol_bigphi_exps(n,nn,ip,c2,w,rs,ws)
call dprol_copy(rs,rs2,n)
call dprol_copy(ws,ws2,n)
c
c ...and start newton
c
do 1400 ijk=1,10
call dprol_gaus_newtstep(n,nn,ip,c2,w,rs,ws,scap_new)
c
c if you start to see some convergence do 3 more steps
c
if (scap_new .lt. 1.0d-16*n) goto 2200
if (scap_new .lt. 1.0d-5*n) then
do 2000 ijkl=1,3
call dprol_gaus_newtstep(n,nn,ip,c2,w,rs,ws,scap_new)
2000 continue
goto 2200
endif
1400 continue
2200 continue
return
end
c
c
c
c
c
subroutine dprol_gaus_newtstep(n,nn,ip,c,w,rs,ws,scap_new)
implicit real*8 (a-h,o-z)
real*8 w(1),ws(1),rs(1),vect(10 000),a2(100 000),
1 rints(10 000),rints_true(10 000),dds(10 000),adws(10 000),
1 adrs(100 000),rints2(10 000),rhs(10 000),dders(10 000),
1 rws(10 000),rnorms(10 000),a(100 000),x2(10 000),u(10 000),
1 v(10 000),s(10 000),rs2(10 000),ws2(10 000)
c
c does one newton step in generating gpsf guassian quadratures.
c takes in n nodes (rs) and n weights (ws) and modifies them
c by taking one newton step
c note: nn should be 0
c
c first evaluate the discrepencies
c
call dprol_discrep_eval(rs,ws,n,nn,ip,c,w,rints,
1 rints_true,adws,adrs,dds)
call dprol_scap(dds,dds,2*n,scap)
c
c combine nodes and weights matrices into matrix a and copy
c
call dprol_copy(adrs,a,2*n*n)
call dprol_copy(adws,a(2*n*n+1),2*n*n)
call dprol_copy(a,a2,2*n*2*n)
c
c . . . now do a step of newton
c
do i=1,2*n
x2(i)=-dds(i)
enddo
call qrsolv(a,2*n,x2,rcond)
c
c now tweak rs and ws accordingly
c
h=1.0d0
350 continue
do i=1,n
rs2(i)=rs(i)+h*x2(i)
ws2(i)=ws(i)+h*x2(n+i)
enddo
c
c check new discrepencies
c
call dprol_discrep_eval(rs2,ws2,n,nn,ip,c,w,rints,
1 rints_true,adws,adrs,dds)
call dprol_scap(dds,dds,2*n,scap_new)
c
c if vector of discrepencies has smaller l2 norm then continue
c
if (scap_new .lt. scap) then
call dprol_copy(rs2,rs,2*n)
call dprol_copy(ws2,ws,2*n)
goto 1300
endif