File: specfun.f

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (624 lines) | stat: -rw-r--r-- 15,581 bytes parent folder | download | duplicates (2)
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
c     SCILAB function : besseli, fin = 1
c     Copyright INRIA
      subroutine intsbesseli(fname)
c     
      character*(*) fname
      include '../stack.h'
c     
      integer iadr, sadr
      integer topk,rhsk,topl
      logical checkrhs,checklhs,getmat,getscalar,cremat
      double precision infinity
      double precision alpha,EXPARG
      data EXPARG/709.0D0/
c
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1
      rhs = max(0,rhs)
c     
      if(.not.checkrhs(fname,2,3)) return
      if(.not.checklhs(fname,1,1)) return
c     
c     checking variable alpha (number 1)
      if(.not.getmat(fname,top,top-rhs+1,it1,m1,n1,lr1,lc1)) return
      if(m1*n1.eq.0) then
         top=top-rhs+1
         return
      endif
      if(it1.ne.0) then
         err=1
         call error(52)
         return
      endif
      nb1=int(stk(lr1))
      alpha=stk(lr1)-nb1
      if(alpha.lt.0.0d0.or.alpha.gt.1.0d0.or.nb1.lt.0) then
         err=1
         call error(116)
         return
      endif
      if(m1*n1.gt.1) then
         do 01 i=2,m1*n1
            if(stk(lr1+i-1)-stk(lr1+i-2).ne.1.0d0) then
               err=1
               call error(116)
               return
            endif
 01      continue
      endif
      nb=m1*n1+nb1
c     
c     checking variable x (number 2)
      if(.not.getmat(fname,top,top-rhs+2,it2,m2,n2,lr2,lc2)) return
      if(m2*n2.eq.0) then
         top=top-rhs+1
         if(.not.cremat(fname,top,0,0,0,lrs,lcs)) return
         return
      endif
      if(it2.ne.0) then
         err=2
         call error(52)
         return
      endif
      do 02 i=0,m2*n2-1
         if(stk(lr2+i).lt.0.0d0) then
            err=2
            call error(116)
            return
         endif
 02      continue
         
c
      if(rhs.eq.3) then
c     checking variable ize (number 3)
         if(.not.getscalar(fname,top,top-rhs+3,lr3)) return
         ice=stk(lr3)
         if(ice.ne.1.and.ice.ne.2) then 
            err=3
            call error(44)
            return
         endif
      else
         ice=1
      endif
c     cross variable size checking
c     

      if(.not.cremat(fname,top+1,0,n2*m2,n1*m1,lw4,lwc4)) return

      if(.not.cremat(fname,top+2,0,1,nb,lw5,lwc5)) return
      nn5=1
      
      do 10 i=0,n2*m2-1
            call ribesl(stk(lr2+i),alpha,nb,ice,stk(lw5),ncalc)
            if(ncalc.ne.nb) then
               if(ncalc.lt.0.and.ice.eq.1) then
                  call dset(m1*n1,infinity(0.0d0),stk(lw4+i),n2*m2)
                  goto 10
               endif
               call error(24)
               return
            endif
            call unsfdcopy(m1*n1,stk(lw5+nb1),1,stk(lw4+i),n2*m2)
 10   continue
c     
      if(lhs .ge. 1) then
c     --------------output variable: b
         top=top-rhs+1
         if(.not.cremat(fname,top,0,n2*m2,n1*m1,lrs,lcs)) return
         call unsfdcopy(n2*m2*n1*m1,stk(lw4),1,stk(lrs),1)
      endif
      return
      end
c     
c     SCILAB function : besselj, fin = 2
      subroutine intsbesselj(fname)
c     
      character*(*) fname
      include '../stack.h'
c     
      integer iadr, sadr
      integer topk,rhsk,topl
      logical checkrhs,checklhs,getmat,getscalar,cremat
      double precision alpha
c
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1
      rhs = max(0,rhs)
c     
      if(.not.checkrhs(fname,2,2)) return
      if(.not.checklhs(fname,1,1)) return
c     
c     checking variable alpha (number 1)
      if(.not.getmat(fname,top,top-rhs+1,it1,m1,n1,lr1,lc1)) return
      if(m1*n1.eq.0) then
         top=top-rhs+1
         return
      endif
      if(it1.ne.0) then
         err=1
         call error(52)
         return
      endif
      nb1=int(stk(lr1))
      alpha=stk(lr1)-nb1
      if(alpha.lt.0.0d0.or.alpha.gt.1.0d0.or.nb1.lt.0) then
         err=1
         call error(116)
         return
      endif
      if(m1*n1.gt.1) then
         do 01 i=2,m1*n1
            if(stk(lr1+i-1)-stk(lr1+i-2).ne.1.0d0) then
               err=1
               call error(116)
               return
            endif
 01      continue
      endif
      nb=m1*n1+nb1
c     
c     checking variable x (number 2)
      if(.not.getmat(fname,top,top-rhs+2,it2,m2,n2,lr2,lc2)) return
      if(m2*n2.eq.0) then
         top=top-rhs+1
         if(.not.cremat(fname,top,0,0,0,lrs,lcs)) return
         return
      endif
      if(it2.ne.0) then
         err=2
         call error(52)
         return
      endif
      do 02 i=0,m2*n2-1
         if(stk(lr2+i).lt.0.0d0) then
            err=2
            call error(116)
            return
         endif
 02      continue
c
      if(.not.cremat(fname,top+1,0,n2*m2,n1*m1,lw4,lwc4)) return

      if(.not.cremat(fname,top+2,0,1,nb,lw5,lwc5)) return
      nn5=1
      
      do 10 i=0,n2*m2-1
         call rjbesl(stk(lr2+i),alpha,nb,stk(lw5),ncalc)
         if(ncalc.ne.nb) then
            if (nbcalc.eq.-1) then
               call error(24)
               return
            else
               call msgs(4,0)
            endif
         endif
         call unsfdcopy(m1*n1,stk(lw5+nb1),1,stk(lw4+i),n2*m2)
 10   continue
c     
      if(lhs .ge. 1) then
c     --------------output variable: b
         top=top-rhs+1
         if(.not.cremat(fname,top,0,n2*m2,n1*m1,lrs,lcs)) return
         call unsfdcopy(n2*m2*n1*m1,stk(lw4),1,stk(lrs),1)
      endif
      return
      end


c     SCILAB function : besselk, fin = 3
      subroutine intsbesselk(fname)
c     
      character*(*) fname
      include '../stack.h'
c     
      integer iadr, sadr
      integer topk,rhsk,topl
      logical checkrhs,checklhs,getmat,getscalar,cremat
      double precision alpha,inf,un
      data un/1.0d0/
c
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1
      rhs = max(0,rhs)
c     
      inf=un/(1.0d0-un)

      if(.not.checkrhs(fname,2,3)) return
      if(.not.checklhs(fname,1,1)) return
c     
c     checking variable alpha (number 1)
      if(.not.getmat(fname,top,top-rhs+1,it1,m1,n1,lr1,lc1)) return
      if(m1*n1.eq.0) then
         top=top-rhs+1
         return
      endif
      if(it1.ne.0) then
         err=1
         call error(52)
         return
      endif
      nb1=int(stk(lr1))
      alpha=stk(lr1)-nb1
      if(alpha.lt.0.0d0.or.alpha.gt.1.0d0.or.nb1.lt.0) then
         err=1
         call error(116)
         return
      endif
      if(m1*n1.gt.1) then
         do 01 i=2,m1*n1
            if(stk(lr1+i-1)-stk(lr1+i-2).ne.1.0d0) then
               err=1
               call error(116)
               return
            endif
 01      continue
      endif
      nb=m1*n1+nb1
c     
c     checking variable x (number 2)
      if(.not.getmat(fname,top,top-rhs+2,it2,m2,n2,lr2,lc2)) return
      if(m2*n2.eq.0) then
         top=top-rhs+1
         if(.not.cremat(fname,top,0,0,0,lrs,lcs)) return
         return
      endif
      if(it2.ne.0) then
         err=2
         call error(52)
         return
      endif
      do 02 i=0,m2*n2-1
         if(stk(lr2+i).lt.0.0d0) then
            err=2
            call error(116)
            return
         endif
 02      continue
         
c
      if(rhs.eq.3) then
c     checking variable ize (number 3)
         if(.not.getscalar(fname,top,top-rhs+3,lr3)) return
         ice=stk(lr3)
         if(ice.ne.1.and.ice.ne.2) then 
            err=3
            call error(44)
            return
         endif
      else
         ice=1
      endif
c     cross variable size checking
c     

      if(.not.cremat(fname,top+1,0,n2*m2,n1*m1,lw4,lwc4)) return

      if(.not.cremat(fname,top+2,0,1,nb,lw5,lwc5)) return
      nn5=1
      
      do 10 i=0,n2*m2-1
         if (ice.eq.1.and.abs(stk(lr2+i)).gt.698.0d0) then
            call dset(m1*n1,0.0D0,stk(lw4+i),n2*m2)
         else
            call rkbesl(stk(lr2+i),alpha,nb,ice,stk(lw5),ncalc)
            if(ncalc.lt.nb) then
               call dset((nb-ncalc),inf,stk(lw5+ncalc),1)
            endif
            call unsfdcopy(m1*n1,stk(lw5+nb1),1,stk(lw4+i),n2*m2)
         endif
 10   continue
c     
      if(lhs .ge. 1) then
c     --------------output variable: b
         top=top-rhs+1
         if(.not.cremat(fname,top,0,n2*m2,n1*m1,lrs,lcs)) return
         call unsfdcopy(n2*m2*n1*m1,stk(lw4),1,stk(lrs),1)
      endif
      return
      end

c     SCILAB function : bessely, fin = 4
      subroutine intsbessely(fname)
c     
      character*(*) fname
      include '../stack.h'
c     
      integer iadr, sadr
      integer topk,rhsk,topl
      logical checkrhs,checklhs,getmat,getscalar,cremat
      double precision alpha,inf,un
      data un/1.0d0/
c
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1
      rhs = max(0,rhs)
c     
      inf=un/(1.0d0-un)
c     
      if(.not.checkrhs(fname,2,2)) return
      if(.not.checklhs(fname,1,1)) return
c     
c     checking variable alpha (number 1)
      if(.not.getmat(fname,top,top-rhs+1,it1,m1,n1,lr1,lc1)) return
      if(m1*n1.eq.0) then
         top=top-rhs+1
         return
      endif
      if(it1.ne.0) then
         err=1
         call error(52)
         return
      endif
      nb1=int(stk(lr1))
      alpha=stk(lr1)-nb1
      if(alpha.lt.0.0d0.or.alpha.gt.1.0d0.or.nb1.lt.0) then
         err=1
         call error(116)
         return
      endif
      if(m1*n1.gt.1) then
         do 01 i=2,m1*n1
            if(stk(lr1+i-1)-stk(lr1+i-2).ne.1.0d0) then
               err=1
               call error(116)
               return
            endif
 01      continue
      endif
      nb=m1*n1+nb1
c     
c     checking variable x (number 2)
      if(.not.getmat(fname,top,top-rhs+2,it2,m2,n2,lr2,lc2)) return
      if(m2*n2.eq.0) then
         top=top-rhs+1
         if(.not.cremat(fname,top,0,0,0,lrs,lcs)) return
         return
      endif
      if(it2.ne.0) then
         err=2
         call error(52)
         return
      endif
      do 02 i=0,m2*n2-1
         if(stk(lr2+i).lt.0.0d0) then
            err=2
            call error(116)
            return
         endif
 02      continue
c
      if(.not.cremat(fname,top+1,0,n2*m2,n1*m1,lw4,lwc4)) return

      if(.not.cremat(fname,top+2,0,1,nb,lw5,lwc5)) return
      nn5=1
      
      do 10 i=0,n2*m2-1
         call rybesl(stk(lr2+i),alpha,nb,stk(lw5),ncalc)
         if(ncalc.lt.nb) then
            if (ncalc.eq.-1) then
               call error(24)
               return
            elseif(ncalc.lt.-1) then
               call error(24)
               return
            endif
            call dset((nb-ncalc),inf,stk(lw5+ncalc),1)
            call msgs(4,0)
         endif
         call unsfdcopy(m1*n1,stk(lw5+nb1),1,stk(lw4+i),n2*m2)
 10   continue
c     
      if(lhs .ge. 1) then
c     --------------output variable: b
         top=top-rhs+1
         if(.not.cremat(fname,top,0,n2*m2,n1*m1,lrs,lcs)) return
         call unsfdcopy(n2*m2*n1*m1,stk(lw4),1,stk(lrs),1)
      endif
      return
      end






c     SCILAB function : lgamma, fin = 5
      subroutine intsgamma(fname)
c     
      character*(*) fname
      include '../stack.h'
c     
      integer iadr, sadr
      integer topk,rhsk,topl
      logical checkrhs,checklhs,getmat,getscalar,cremat
      double precision dgammacody
c
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1
      rhs = max(0,rhs)
c     
      if(.not.checkrhs(fname,1,1)) return
      if(.not.checklhs(fname,1,1)) return
c     
c     checking variable x (number 1)
      if(.not.getmat(fname,top,top-rhs+1,it1,m1,n1,lr1,lc1)) return
      if(m1*n1.eq.0) then
         return
      endif
      if(it1.ne.0) then
         err=1
         call error(52)
         return
      endif

*** modif bruno : reused Cody 's gamma (waiting final decision...)
*      So I have commented the following line (needed when using the
*      gamma func from Slatec)
c$$$      if (setslatecjmp().ne.0) then
c$$$         buf='Slatec fatal error'
c$$$         call error(999)
c$$$         return
c$$$      endif
      
      do 10 i=0,n1*m1-1
         stk(lr1+i)=dgammacody(stk(lr1+i))
 10   continue
***end bruno 's modif
c     
      return
      end
c     SCILAB function : gamma, fin = 6
      subroutine intslgamma(fname)
c     
      character*(*) fname
      include '../stack.h'
c     
      integer iadr, sadr
      integer topk,rhsk,topl
      logical checkrhs,checklhs,getmat,getscalar,cremat
      double precision dlgama
c
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1
      rhs = max(0,rhs)
c     
      if(.not.checkrhs(fname,1,1)) return
      if(.not.checklhs(fname,1,1)) return
c     
c     checking variable x (number 1)
      if(.not.getmat(fname,top,top-rhs+1,it1,m1,n1,lr1,lc1)) return
      if(m1*n1.eq.0) then
         return
      endif
      if(it1.ne.0) then
         err=1
         call error(52)
         return
      endif

*** message for Serge : here you well use the Cody 's log(gamma)
*      So I have only commented the following line (needed if one use the
*      log(gamma) func from Slatec)
c$$$      if (setslatecjmp().ne.0) then
c$$$         buf='Slatec fatal error'
c$$$         call error(999)
c$$$         return
c$$$      endif
*** end bruno s' modif      
      do 10 i=0,n1*m1-1
         stk(lr1+i)=dlgama(stk(lr1+i))
 10   continue
c     
      return
      end

c     SCILAB function : calerf, fin = 7
      subroutine intscalerf(fname)
c     
      character*(*) fname
      include '../stack.h'
c     
      integer iadr, sadr
      integer topk,rhsk,topl
      logical checkrhs,checklhs,getmat,getscalar,cremat
      double precision alpha
c
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1
      rhs = max(0,rhs)
c     
      if(.not.checkrhs(fname,2,2)) return
      if(.not.checklhs(fname,1,1)) return
c     
c     checking variable x (number 1)
      if(.not.getmat(fname,top,top-rhs+1,it1,m1,n1,lr1,lc1)) return
      if(m1*n1.eq.0) then
         top=top-rhs+1
         return
      endif
      if(it1.ne.0) then
         err=1
         call error(52)
         return
      endif
c     checking variable jint (number 2)
      if(.not.getscalar(fname,top,top-rhs+2,lr2)) return
      jint=stk(lr2)
      if(jint.lt.0.or.jint.gt.2) then 
         err=2
         call error(44)
         return
      endif

      do 10 i=0,n1*m1-1
         call calerf(stk(lr1+i),stk(lr1+i),jint)
 10   continue
      top=top-1
c     
      return
      end


c     SCILAB function : dlgamma, fin = 8
      subroutine intsdlgamma(fname)
c     
      character*(*) fname
      include '../stack.h'
c     
      integer iadr, sadr
      integer topk,rhsk,topl
      logical checkrhs,checklhs,getmat,getscalar,cremat
      double precision psi
c
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1
      rhs = max(0,rhs)
c     
      if(.not.checkrhs(fname,1,1)) return
      if(.not.checklhs(fname,1,1)) return
c     
c     checking variable x (number 1)
      if(.not.getmat(fname,top,top-rhs+1,it1,m1,n1,lr1,lc1)) return
      if(m1*n1.eq.0) then
         top=top-rhs+1
         return
      endif
      if(it1.ne.0) then
         err=1
         call error(52)
         return
      endif
      do 10 i=0,n1*m1-1
         stk(lr1+i)=psi(stk(lr1+i))
 10   continue
c     
      return
      end


c  interface function 
c   ********************
       subroutine specfun
       include '../stack.h'
       rhs = max(0,rhs)
c
       goto (1,2,3,4,5,6,7,8) fin
       return
 1     call intsbesseli('besseli')
       return
 2     call intsbesselj('besselj')
       return
 3     call intsbesselk('besselk')
       return
 4     call intsbessely('bessely')
       return
 5     call intsgamma('gamma')
       return
 6     call intslgamma('lgamma')
       return
 7     call intsdlgamma('dlgamma')
       return
 8     call intscalerf('calerf')
       return
       end