-
Notifications
You must be signed in to change notification settings - Fork 4
/
bilege.f90
1061 lines (887 loc) · 22.5 KB
/
bilege.f90
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
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! This file contains code for constructing and manipulating bivariate Legendre
! expansions --- that is, expressions of the form
!
!
! f(x,y) = \sum a_ij \tilde{P}_i(x) \tilde{P}_j(y), (1)
! 0 <= i+j <= n
!
! where \tilde{P}_i denotes the L^2 normalized Legendre polynomial of degree i.
! The expansions (1) can be either real or complex-valued.
!
! Expansions of the form (1) are represented in two different ways: via the
! vector
!
! ( a_00 )
! ( a_10 )
! ( a_01 )
! ( a_20 )
! ( a_11 ) (2)
! ( a_02 )
! ( a_30 )
! ...
! ( a_n0 )
! ( a_0n )
!
! of coefficients (note the ordering of the coefficients), and via the vector
!
! ( f(x_1,y_1) \sqrt{w1} )
! ( f(x_2,y_1) \sqrt{w1} )
! ( f(x_3,y_1) \sqrt{w1} )
! ...
! ( f(x_n,y_1) \sqrt{w1} ) (3)
! ( f(x_2,y_1) \sqrt{w1} )
! ( f(x_2,y_2) \sqrt{w1} )
! ...
! ( f(x_n,y_n) \sqrt{w1} ),
!
! where (x_1,y_1),...(x_n,y_n), w_1,...,w_n are the nodes and weights of a
! generalized Gaussian quadrature rule which integrates polynomials of degree
! somewhat higher than n-1.
!
! The quadrature rules and the matrices which takes the vector (3) to (2) are
! precomputed (the precomputed rules and matrices are stored in the file
! sqquads.f90). Consequently, only certain possible values of the order n,
! which controls the size of the expansion, are permitted (see the subroutine
! bilege_quad).
!
! The following subroutines are public:
!
! bilege_quad - return the generaized Gaussian quadrature rule used to
! represent expansions of the form (1)
!
! bilege_interpmatrix - return the matrix taking the vector (3) of *scaled*
! values of the expansion (1) to the *scaled* values of (1) at the nodes
! of a user-specified quadrature rule
!
! bilege_coefsmatrix - return the matrix taking the vector (3) of *scaled*
! values of the expansion (1) to the vector (2) of coefficients -- note that
! this matrix is orthogonal so its transpose is the matrix which takes (2) to
! (3)
!
! bilege_coefs - given the vector (3) of scaled values of an expansion of
! the form (1), compute the vector (2) of coefficients in the series (1)
!
! bilege_eval - evaluate one or more expansions of the form (1) given the
! their expansion coefficients
!
! bilege_evalder - evaluate one or more expansions of the form (1) and their
! derivatives given the expansions' coefficients
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
module bilege
use utils
use legendre
use sqquads
interface bilege_coefs
module procedure bilege_coefs1
module procedure bilege_coefs2
module procedure bilege_coefs3
module procedure bilege_coefs4
end interface bilege_coefs
interface bilege_eval
module procedure bilege_eval1
module procedure bilege_eval2
module procedure bilege_eval3
module procedure bilege_eval4
end interface bilege_eval
interface bilege_evalder
module procedure bilege_evalder1
module procedure bilege_evalder2
module procedure bilege_evalder3
module procedure bilege_evalder4
end interface bilege_evalder
contains
subroutine bilege_quad(n,nquad,xs,ys,whts)
implicit double precision (a-h,o-z)
double precision, allocatable, intent(out) :: xs(:),ys(:),whts(:)
!
! Return a quadrature rule used to discretize expansions of a given
! order.
!
! Input parameters:
! n - the desired order of the expansion (1), which must be 4, 6, 8, 10, 12,
! 14, 16, 18, 20, 22, 24 or 30
!
! Output parameters:
! nquad - the number of points in the discretization quadrature rule
! xs - an array specifying the x-coordinates of the quadrature nodes
! ys - an array specifying the y-coordinates of the quadrature nodes
! whts - an array specifying the quadrature weights
!
!double precision, allocatable :: xslege(:), whtslege(:)
if (n == 4) then
nquad = 15
allocate( xs(nquad), ys(nquad), whts(nquad) )
xs = sqxs4
ys = sqys4
whts = sqwhts4
return
endif
if (n == 6) then
nquad = 28
allocate( xs(nquad), ys(nquad), whts(nquad) )
xs = sqxs6
ys = sqys6
whts = sqwhts6
return
endif
if (n == 8) then
nquad = 45
allocate( xs(nquad), ys(nquad), whts(nquad) )
xs = sqxs8
ys = sqys8
whts = sqwhts8
return
endif
if (n == 10) then
nquad = 66
allocate( xs(nquad), ys(nquad), whts(nquad) )
xs = sqxs10
ys = sqys10
whts = sqwhts10
return
endif
if (n == 12) then
nquad = 91
!m = 20
allocate( xs(nquad), ys(nquad), whts(nquad) )
xs = sqxs12
ys = sqys12
whts = sqwhts12
return
endif
if (n == 14) then
nquad = 120
allocate( xs(nquad), ys(nquad), whts(nquad) )
xs = sqxs14
ys = sqys14
whts = sqwhts14
return
endif
if (n == 16) then
nquad = 153
!m = 27
allocate( xs(nquad), ys(nquad), whts(nquad) )
xs = sqxs16
ys = sqys16
whts = sqwhts16
return
endif
if (n == 18) then
nquad = 190
allocate( xs(nquad), ys(nquad), whts(nquad) )
xs = sqxs18
ys = sqys18
whts = sqwhts18
return
endif
if (n == 20) then
nquad = 231
allocate( xs(nquad), ys(nquad), whts(nquad) )
xs = sqxs20
ys = sqys20
whts = sqwhts20
return
endif
if (n == 22) then
nquad = 276
allocate( xs(nquad), ys(nquad), whts(nquad) )
xs = sqxs22
ys = sqys22
whts = sqwhts22
return
endif
if (n == 24) then
nquad = 325
!m = 34
allocate( xs(nquad), ys(nquad), whts(nquad) )
xs = sqxs24
ys = sqys24
whts = sqwhts24
return
endif
if (n == 30) then
nquad = 496
allocate( xs(nquad), ys(nquad), whts(nquad) )
xs = sqxs30
ys = sqys30
whts = sqwhts30
return
endif
call prini("bilege_quad: invalid order n = ",n)
stop
end subroutine
subroutine bilege_interpmatrix(n,nout,xsout,ysout,whtsout,amatr)
implicit double precision (a-h,o-z)
double precision :: xsout(nout),ysout(nout),whtsout(nout)
double precision, allocatable, intent(out) :: amatr(:,:)
!
! Construct the (nout,nquad) matrix which takes the vector (3) of scaled values
! of an expansion of the form (1) at the quadrature nodes to the scaled
! values of (1) at the nodes of a user-specified quadrature rule.
!
! Input parameters:
! n - the order of the bivarite expansion
! nout - the number of nodes in the target quadrature rule
! xsout - the x-coords of the target quadrature nodes
! ysout - the y-coords of the target quadrature nodes
! whtsout - the weights of the target quadrature rule
!
! Output parameters:
! amatr - the (nout,nquad) interpolation matrix
!
double precision :: polsx(0:n),polsy(0:n)
double precision, allocatable :: bmatr(:,:)
nquad = 0
if (n==4) nquad=15
if (n==6) nquad=28
if (n==8) nquad=45
if (n==10) nquad=66
if (n==12) nquad=91
if (n==14) nquad=120
if (n==16) nquad=153
if (n==18) nquad=190
if (n==20) nquad=231
if (n==22) nquad=276
if (n==24) nquad=325
if (n==30) nquad=496
if (nquad==0) then
call prini("bilege_intmatrix: invalid order n = ",n)
stop
endif
allocate(bmatr(nout,nquad))
!
! Build the matrix consisting of the scaled values of the basis functions
! at the nodes of the output quadrature
!
do i=1,nout
x = xsout(i)
y = ysout(i)
wht = whtsout(i)
call leges(n+1,x,polsx)
call leges(n+1,y,polsy)
j=0
do nn=0,n
do jj=0,nn
ii=nn-jj
j=j+1
bmatr(i,j) = polsx(ii)*polsy(jj)*sqrt(wht)
end do
end do
end do
if (n==4) amatr = matmul(bmatr,squmatr4)
if (n==6) amatr = matmul(bmatr,squmatr6)
if (n==8) amatr = matmul(bmatr,squmatr8)
if (n==10) amatr = matmul(bmatr,squmatr10)
if (n==12) amatr = matmul(bmatr,squmatr12)
if (n==14) amatr = matmul(bmatr,squmatr14)
if (n==16) amatr = matmul(bmatr,squmatr16)
if (n==18) amatr = matmul(bmatr,squmatr18)
if (n==20) amatr = matmul(bmatr,squmatr20)
if (n==22) amatr = matmul(bmatr,squmatr22)
if (n==24) amatr = matmul(bmatr,squmatr24)
if (n==30) amatr = matmul(bmatr,squmatr30)
end subroutine
subroutine bilege_coefsmatrix(n,umatr)
implicit double precision (a-h,o-z)
double precision, allocatable, intent(out) :: umatr(:,:)
!
! Return the (nquad,nquad) matrix which takes the vector (3) of scaled
! values of the expansion (1) to the vector (2) of expansion coefficients.
!
! Input parameters:
! n - the order of the expansion (1)
!
! Output parameters:
! umatr - the (nquad,nquad) matrix which takes (3) to (2)
!
if (n==4) then
allocate(umatr(15,15))
umatr = squmatr4
return
endif
if (n==6) then
allocate(umatr(28,28))
umatr = squmatr6
return
endif
if (n==8) then
allocate(umatr(45,45))
umatr = squmatr8
return
endif
if (n==10) then
allocate(umatr(66,66))
umatr = squmatr10
return
endif
if (n==12) then
allocate(umatr(91,91))
umatr = squmatr12
return
endif
if (n==14) then
allocate(umatr(120,120))
umatr = squmatr14
return
endif
if (n==16) then
allocate(umatr(153,153))
umatr = squmatr16
return
endif
if (n==18) then
allocate(umatr(190,190))
umatr = squmatr18
return
endif
if (n==20) then
allocate(umatr(231,231))
umatr = squmatr20
return
endif
if (n==22) then
allocate(umatr(276,276))
umatr = squmatr22
return
endif
if (n==24) then
allocate(umatr(325,325))
umatr = squmatr24
return
endif
if (n==30) then
allocate(umatr(496,496))
umatr = squmatr30
return
endif
call prini("bilege_coefsmatrix: invalid order n = ",n)
stop
end subroutine
subroutine bilege_coefs1(n,vals,coefs)
implicit double precision (a-h,o-z)
double complex :: vals(:),coefs(:)
!
! Compute the coefficients in a complex-valued expansion of the form (1) given the
! vector (3) of its *scaled* values at the nodes of the tensor product
! quadrature rule.
!
! Input parameters:
! n - the order of the expansion
! vals - the vector (3) of scaled values of the expansion
!
! Output parameters:
! coefs - the vector (2) of expansion coefficients
!
double precision :: polsx(n), polsy(n)
if (n == 4) then
coefs = matmul(squmatr4,vals)
return
endif
if (n == 6) then
coefs = matmul(squmatr6,vals)
return
endif
if (n == 8) then
coefs = matmul(squmatr8,vals)
return
endif
if (n == 10) then
coefs = matmul(squmatr10,vals)
return
endif
if (n == 12) then
coefs = matmul(squmatr12,vals)
return
endif
if (n == 14) then
coefs = matmul(squmatr14,vals)
return
endif
if (n == 16) then
coefs = matmul(squmatr16,vals)
return
endif
if (n == 18) then
coefs = matmul(squmatr18,vals)
return
endif
if (n == 20) then
coefs = matmul(squmatr20,vals)
return
endif
if (n == 22) then
coefs = matmul(squmatr22,vals)
return
endif
if (n == 24) then
coefs = matmul(squmatr24,vals)
return
endif
if (n == 30) then
coefs = matmul(squmatr30,vals)
return
endif
call prini("bilege_coefs: invalid order n = ",n)
stop
end subroutine
subroutine bilege_coefs2(n,vals,coefs)
implicit double precision (a-h,o-z)
double complex :: vals(:,:),coefs(:,:)
!
! Compute the coefficients in a collection of expansions (1) given the matrix
! whose columns are the vectors (3) of *scaled* values of the expansions at the
! nodes of the tensor product quadrature rule.
!
! Input parameters:
! n - the order of the expansion
! vals - the matrix whose jth column is the vector (3) of scaled values of the
! jth input expansion
!
! Output parameters:
! coefs - the matrix whose jth column is the vector (2) of expansion coefficients
! of the jth input expansion
!
double precision :: polsx(n), polsy(n)
if (n == 4) then
coefs = matmul(squmatr4,vals)
return
endif
if (n == 6) then
coefs = matmul(squmatr6,vals)
return
endif
if (n == 8) then
coefs = matmul(squmatr8,vals)
return
endif
if (n == 10) then
coefs = matmul(squmatr10,vals)
return
endif
if (n == 12) then
coefs = matmul(squmatr12,vals)
return
endif
if (n == 14) then
coefs = matmul(squmatr14,vals)
return
endif
if (n == 16) then
coefs = matmul(squmatr16,vals)
return
endif
if (n == 18) then
coefs = matmul(squmatr18,vals)
return
endif
if (n == 20) then
coefs = matmul(squmatr20,vals)
return
endif
if (n == 22) then
coefs = matmul(squmatr22,vals)
return
endif
if (n == 24) then
coefs = matmul(squmatr24,vals)
return
endif
if (n == 30) then
coefs = matmul(squmatr30,vals)
return
endif
call prini("bilege_coefs: invalid order n = ",n)
stop
end subroutine
subroutine bilege_coefs3(n,vals,coefs)
implicit double precision (a-h,o-z)
double precision :: vals(:),coefs(:)
!
! Compute the coefficients in a real-valued expansion of the form (1) given the
! vector (3) of its *scaled* values at the nodes of the tensor product
! quadrature rule.
!
! Input parameters:
! n - the order of the expansion
! vals - the vector (3) of scaled values of the expansion
!
! Output parameters:
! coefs - the vector (2) of expansion coefficients
!
double precision :: polsx(n), polsy(n)
if (n == 4) then
coefs = matmul(squmatr4,vals)
return
endif
if (n == 6) then
coefs = matmul(squmatr6,vals)
return
endif
if (n == 8) then
coefs = matmul(squmatr8,vals)
return
endif
if (n == 10) then
coefs = matmul(squmatr10,vals)
return
endif
if (n == 12) then
coefs = matmul(squmatr12,vals)
return
endif
if (n == 14) then
coefs = matmul(squmatr14,vals)
return
endif
if (n == 16) then
coefs = matmul(squmatr16,vals)
return
endif
if (n == 18) then
coefs = matmul(squmatr18,vals)
return
endif
if (n == 20) then
coefs = matmul(squmatr20,vals)
return
endif
if (n == 22) then
coefs = matmul(squmatr22,vals)
return
endif
if (n == 24) then
coefs = matmul(squmatr24,vals)
return
endif
if (n == 30) then
coefs = matmul(squmatr30,vals)
return
endif
call prini("bilege_coefs: invalid order n = ",n)
stop
end subroutine
subroutine bilege_coefs4(n,vals,coefs)
implicit double precision (a-h,o-z)
double precision :: vals(:,:),coefs(:,:)
!
! Compute the coefficients in a collection of expansions (1) given the matrix
! whose columns are the vectors (3) of *scaled* values of the expansions at the
! nodes of the tensor product quadrature rule.
!
! Input parameters:
! n - the order of the expansion
! vals - the matrix whose jth column is the vector (3) of scaled values of the
! jth input expansion
!
! Output parameters:
! coefs - the matrix whose jth column is the vector (2) of expansion coefficients
! of the jth input expansion
!
double precision :: polsx(n), polsy(n)
if (n == 4) then
coefs = matmul(squmatr4,vals)
return
endif
if (n == 6) then
coefs = matmul(squmatr6,vals)
return
endif
if (n == 8) then
coefs = matmul(squmatr8,vals)
return
endif
if (n == 10) then
coefs = matmul(squmatr10,vals)
return
endif
if (n == 12) then
coefs = matmul(squmatr12,vals)
return
endif
if (n == 14) then
coefs = matmul(squmatr14,vals)
return
endif
if (n == 16) then
coefs = matmul(squmatr16,vals)
return
endif
if (n == 18) then
coefs = matmul(squmatr18,vals)
return
endif
if (n == 20) then
coefs = matmul(squmatr20,vals)
return
endif
if (n == 22) then
coefs = matmul(squmatr22,vals)
return
endif
if (n == 24) then
coefs = matmul(squmatr24,vals)
return
endif
if (n == 30) then
coefs = matmul(squmatr30,vals)
return
endif
call prini("bilege_coefs: invalid order n = ",n)
stop
end subroutine
subroutine bilege_eval1(n,coefs,x,y,val)
implicit double precision (a-h,o-z)
double precision :: xslege(n), whtslege(n)
double complex :: coefs(:),val
!
! Given the vector (2) of coefficients of a complex-valued expansion of the
! form (1), evaluate the expansion at a specified point.
!
! Input parameters:
! n - the order of the bivariate expansion
! coefs - the vector (2) of expansion coefficients
! (x,y) - the point at which to evaluate the expansion (1)
!
! Output parameters:
! val - the value of the expansion
!
double precision :: polsx(0:n), polsy(0:n)
call leges(n+1,x,polsx)
call leges(n+1,y,polsy)
val = 0
idx = 1
do nn=0,n
do jj=0,nn
ii = nn-jj
val = val + coefs(idx)*polsx(ii)*polsy(jj)
idx = idx+1
end do
end do
end subroutine
subroutine bilege_eval2(n,coefs,x,y,val)
implicit double precision (a-h,o-z)
double precision :: xslege(n), whtslege(n)
double precision :: coefs(:),val
!
! Given the vector (2) of coefficients of a real-valued expansion of the
! form (1), evaluate the expansion at a specified point.
!
! Input parameters:
! n - the order of the bivariate expansion
! coefs - the vector (2) of expansion coefficients
! (x,y) - the point at which to evaluate the expansion (1)
!
! Output parameters:
! val - the value of the expansion
!
double precision :: polsx(0:n), polsy(0:n)
call leges(n+1,x,polsx)
call leges(n+1,y,polsy)
val = 0
idx = 1
do nn=0,n
do jj=0,nn
ii = nn-jj
val = val + coefs(idx)*polsx(ii)*polsy(jj)
idx = idx+1
end do
end do
end subroutine
subroutine bilege_eval3(n,coefs,x,y,vals)
implicit double precision (a-h,o-z)
double precision :: xslege(n), whtslege(n)
double precision :: coefs(:,:),vals(:)
!
! Given the expansion coefficients of a collection of real-valued expansions of the
! form (1), evaluate each at a specified point.
!
! Input parameters:
! n - the order of the bivariate expansion
! coefs - the vector (2) of expansion coefficients
! (x,y) - the point at which to evaluate the expansion (1)
!
! Output parameters:
! val - the value of the expansion
!
double precision :: polsx(0:n), polsy(0:n)
call leges(n+1,x,polsx)
call leges(n+1,y,polsy)
vals = 0
idx = 1
do nn=0,n
do jj=0,nn
ii = nn-jj
vals = vals + coefs(idx,:)*polsx(ii)*polsy(jj)
idx = idx+1
end do
end do
end subroutine
subroutine bilege_eval4(n,coefs,x,y,vals)
implicit double precision (a-h,o-z)
double precision :: xslege(n), whtslege(n)
double complex :: coefs(:,:),vals(:)
!
! Given the expansion coefficients of a collection of real-valued expansions of the
! form (1), evaluate each at a specified point.
!
! Input parameters:
! n - the order of the bivariate expansion
! coefs - the vector (2) of expansion coefficients
! (x,y) - the point at which to evaluate the expansion (1)
!
! Output parameters:
! val - the value of the expansion
!
double precision :: polsx(0:n), polsy(0:n)
call leges(n+1,x,polsx)
call leges(n+1,y,polsy)
vals = 0
idx = 1
do nn=0,n
do jj=0,nn
ii = nn-jj
vals = vals + coefs(idx,:)*polsx(ii)*polsy(jj)
idx = idx+1
end do
end do
end subroutine
subroutine bilege_evalder1(n,coefs,x,y,val,derx,dery)
implicit double precision (a-h,o-z)
double precision :: xslege(n), whtslege(n)
double complex :: coefs(:),val,derx,dery
!
! Given the vector (2) of coefficients of a complex-valued expansion of the
! form (1), evaluate the expansion at a specified point.
!
! Input parameters:
! n - the order of the bivariate expansion
! coefs - the vector (2) of expansion coefficients
! (x,y) - the point at which to evaluate the expansion (1)
!
! Output parameters:
! val - the value of the expansion
!
double precision :: polsx(0:n), polsy(0:n)
double precision :: dersx(0:n), dersy(0:n)
call legeders(n+1,x,polsx,dersx)
call legeders(n+1,y,polsy,dersy)
val = 0
derx = 0
dery = 0
idx = 1
do nn=0,n
do jj=0,nn
ii = nn-jj
val = val + coefs(idx)*polsx(ii)*polsy(jj)
derx = derx + coefs(idx)*dersx(ii)*polsy(jj)
dery = dery + coefs(idx)*polsx(ii)*dersy(jj)
idx = idx+1
end do
end do
end subroutine
subroutine bilege_evalder2(n,coefs,x,y,val,derx,dery)
implicit double precision (a-h,o-z)
double precision :: xslege(n), whtslege(n)
double precision :: coefs(:),val,derx,dery
!
! Given the vector (2) of coefficients of a real-valued expansion of the
! form (1), evaluate the expansion at a specified point.
!
! Input parameters:
! n - the order of the bivariate expansion
! coefs - the vector (2) of expansion coefficients
! (x,y) - the point at which to evaluate the expansion (1)
!
! Output parameters:
! val - the value of the expansion
!
double precision :: polsx(0:n), polsy(0:n)
double precision :: dersx(0:n), dersy(0:n)
call legeders(n+1,x,polsx,dersx)
call legeders(n+1,y,polsy,dersy)
val = 0
derx = 0
dery = 0
idx = 1
do nn=0,n
do jj=0,nn
ii = nn-jj
val = val + coefs(idx)*polsx(ii)*polsy(jj)
derx = derx + coefs(idx)*dersx(ii)*polsy(jj)
dery = dery + coefs(idx)*polsx(ii)*dersy(jj)
idx = idx+1
end do
end do
end subroutine
subroutine bilege_evalder3(n,coefs,x,y,vals,dersx,dersy)
implicit double precision (a-h,o-z)
double precision :: xslege(n), whtslege(n)
double precision :: coefs(:,:),vals(:),dersx(:),dersy(:)
!
! Given the coefficients of a collection of real-valued expansions of the
! form (1), evaluate them and their derivatives at a specified point.
!
! Input parameters:
! n - the order of the bivariate expansion
! coefs - the vector (2) of expansion coefficients
! (x,y) - the point at which to evaluate the expansion (1)
!
! Output parameters:
! val - the value of the expansion
!
double precision :: polsx(0:n), polsy(0:n)
double precision :: poldersx(0:n), poldersy(0:n)