声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2565|回复: 0

[Fortran] 用REMEZ算法求交错点组

[复制链接]
发表于 2006-8-12 07:40 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
  1.         subroutine remez1
  2. c--------------------------------------------------------------------
  3. c  from Ref. [31] of chapter 5
  4. c                                      in chapter 8
  5. c--------------------------------------------------------------------
  6.         dimension iext(66),ad(66),alpha(66),x(66),y(66)
  7.         dimension des(1045),grid(1045),wt(1045)
  8.         dimension a(66),p(66),q(66)
  9.         common pi2,ad,dev,x,y,grid,des,wt,alpha,iext,nfcns,ngrid
  10.         common /oops/niter
  11.         itrmax=25
  12.         devl=-1.
  13.         nz=nfcns+1
  14.         nzz=nfcns+2
  15.         niter=0
  16. 100     continue
  17.         iext(nzz)=ngrid+1
  18.         niter=niter+1
  19.         if(niter.gt.itrmax) goto 400
  20.         do 110 j=1,nz
  21.            jxt=iext(j)
  22.            dtemp=grid(jxt)
  23.            dtemp=cos(dtemp*pi2)
  24.            x(j)=dtemp
  25. 110     continue
  26.         jet=(nfcns-1)/15+1
  27.         do 120 j=1,nz
  28.            ad(j)=d(j,nz,jet)
  29. 120     continue
  30.         dnum=0.0
  31.         dden=0.0
  32.         k=1
  33.         do 130 j=1,nz
  34.            l=iext(j)
  35.            dtemp=ad(j)*des(l)
  36.            dnum=dnum+dtemp
  37.            dtemp=k*ad(j)/wt(l)
  38.            dden=dden+dtemp
  39.            k=-k
  40. 130     continue
  41.         dev=dnum/dden
  42.         nu=1
  43.         if(dev.gt.0.)nu=-1
  44.         dev=-nu*dev
  45.         k=nu
  46.         do 140 j=1,nz
  47.            l=iext(j)
  48.            dtemp=k*dev/wt(l)
  49.            y(j)=des(l)+dtemp
  50.            k=-k
  51. 140     continue
  52.         if(dev.gt.devl)goto 150
  53.         call ouch
  54.         goto 400
  55. 150     devl=dev
  56.         jchneg=0
  57.         k1=iext(1)
  58.         knz=iext(nz)
  59.         klow=0
  60.         nut=-nu
  61.         j=1
  62. 200     if(j.eq.nzz)ynz=comp
  63.         if(j.ge.nzz) goto 300
  64.         kup=iext(j+1)
  65.         l=iext(j)+1
  66.         nut=-nut
  67.         if(j.eq.2)y1=comp
  68.         comp=dev
  69.         if(l.ge.kup) goto 220
  70.         err=gee(l,nz)
  71.         err=(err-des(l))*wt(l)
  72.         dtemp=nut*err-comp
  73.         if(dtemp.le.0.)goto 220
  74.         comp=nut*err
  75. 210     l=l+1
  76.         if(l.ge.kup) goto 215
  77.         err=gee(l,nz)
  78.         err=(err-des(l))*wt(l)
  79.         dtemp=nut*err-comp
  80.         if(dtemp.le.0.)goto 215
  81.         comp=nut*err
  82.         goto 210
  83. 215     iext(j)=l-1
  84.         j=j+1
  85.         klow=l-1
  86.         jchnge=jchnge+1
  87.         goto 200
  88. 220     l=l-1
  89. 225     l=l-1
  90.         if(l.le.klow) goto 250
  91.         err=gee(l,nz)
  92.         err=(err-des(l))*wt(l)
  93.         dtemp=nut*err-comp
  94.         if(dtemp.gt.0.)goto 230
  95.         if(jchnge.le.0.)goto 225
  96.         goto 260
  97. 230     comp=nut*err
  98. 235     l=l-1
  99.         if(l.le.klow) goto 240
  100.         err=gee(l,nz)
  101.         err=(err-des(l))*wt(l)
  102.         dtemp=nut*err-comp
  103.         if(dtemp.le.0.)goto 240
  104.         comp=nut*err
  105.         goto 235
  106. 240     klow=iext(j)
  107.         iext(j)=l+1
  108.         j=j+1
  109.         jchnge=jchnge+1
  110.         goto 200
  111. 250     l=iext(j)+1
  112.         if(jchnge.gt.0.)goto 215
  113. 255     l=l+1
  114.         if(l.ge.kup) goto 260
  115.         err=gee(l,nz)
  116.         err=(err-des(l))*wt(l)
  117.         dtemp=nut*err-comp
  118.         if(dtemp.le.0.)goto 255
  119.         comp=nut*err
  120.         goto 210
  121. 260     klow=iext(j)
  122.         j=j+1
  123.         goto 200
  124. 300     if(j.gt.nzz)goto 320
  125.         if(k1.gt.iext(1)) k1=iext(1)
  126.         if(knz.lt.iext(nz)) knz=iext(nz)
  127.         nut1=nut
  128.         nut=-nu
  129.         l=0
  130.         kup=k1
  131.         comp=ynz*1.00001
  132.         luck=1
  133. 310     l=l+1
  134.         if(l.ge.kup) goto 315
  135.         err=gee(l,nz)
  136.         err=(err-des(l))*wt(l)
  137.         dtemp=nut*err-comp
  138.         if(dtemp.le.0.)goto 310
  139.         comp=nut*err
  140.         j=nzz
  141.         goto 210
  142. 315     luck=6
  143.         goto 325
  144. 320     if(luck.gt.9) goto 350
  145.         if(comp.gt.y1) y1=comp
  146.         k1=iext(nzz)
  147. 325     l=ngrid+1
  148.         klow=knz
  149.         nut=-nut1
  150.         comp=y1*1.00001
  151. 330     l=l-1
  152.         if(l.le.klow) goto 340
  153.         err=gee(l,nz)
  154.         err=(err-des(l))*wt(l)
  155.         dtemp=nut*err-comp
  156.         if(dtemp.le.0.)goto 330
  157.         j=nzz
  158.         comp=nut*err
  159.         luck=luck+10
  160.         goto 235
  161. 340     if(luck.eq.6)goto 370
  162.         do 345 j=1,nfcns
  163.            nzzmj=nzz-j
  164.            nzmj=nz-j
  165.            iext(nzzmj)=iext(nzmj)
  166. 345     continue
  167.         iext(1)=k1
  168.         goto 100
  169. 350     kn=iext(nzz)
  170.         do 360 j=1,nfcns
  171.            iext(j)=iext(j+1)
  172. 360     continue
  173.         iext(nz)=kn
  174.         goto 100
  175. 370     if(jchnge.gt.0) goto 100
  176. 400     continue
  177.         nm1=nfcns-1
  178.         fsh=1.e-06
  179.         gtemp=grid(1)
  180.         x(nzz)=-2.
  181.         cn=2*nfcns-1
  182.         delf=1./cn
  183.         l=1
  184.         kkk=0
  185.         if(grid(1).le..01.and.grid(ngrid).gt.0.49) kkk=1
  186.         if(nfcns.le.3)kkk=1
  187.         if(kkk.eq.1)goto 405
  188.         dtemp=cos(pi2*grid(1))
  189.         dnum=cos(pi2*grid(ngrid))
  190.         aa=2./(dtemp-dnum)
  191.         bb=-(dtemp+dnum)/(dtemp-dnum)
  192. 405     continue
  193.         do 430 j=1,nfcns
  194.            ft=j-1
  195.            ft=ft*delf
  196.            xt=cos(pi2*ft)
  197.            if(kkk.eq.1)goto 410
  198.            xt=(xt-bb)/aa
  199.            xt1=sqrt(1.-xt*xt)
  200.            ft=atan2(xt1,xt)/pi2
  201. 410        xe=x(l)
  202.            if(xt.gt.xe)goto 420
  203.            if((xe-xt).lt.fsh)goto 415
  204.            l=l+1
  205.            goto 410
  206. 415        a(j)=y(l)
  207.            goto 425
  208. 420        if((xt-xe).lt.fsh)goto 415
  209.            grid(1)=ft
  210.            a(j)=gee(1,nz)
  211. 425        if(l.gt.1)l=l-1
  212. 430     continue
  213.         grid(1)=gtemp
  214.         dden=pi2/cn
  215.         do 510 j=1,nfcns
  216.            dtemp=0.
  217.            dnum=j-1
  218.            dnum=dnum*dden
  219.            if(nm1.lt.1)goto 505
  220.            do 500 k=1,nm1
  221.               dak=a(k+1)
  222.               dk=k
  223.               dtemp=dtemp+dak*cos(dnum*dk)
  224. 500        continue
  225. 505        dtemp=dtemp*2.+a(1)
  226.            alpha(j)=dtemp
  227. 510     continue
  228.         do 550 j=2,nfcns
  229.            alpha(j)=alpha(j)*2./cn
  230. 550     continue
  231.         alpha(1)=alpha(1)/cn
  232.         if(kkk.eq.1) goto 545
  233.         p(1)=2.*alpha(nfcns)*bb+alpha(nm1)
  234.         p(2)=2.*alpha(nfcns)*aa
  235.         q(1)=alpha(nfcns-2)-alpha(nfcns)
  236.         do 540 j=2,nm1
  237.            if(j.lt.nm1) goto 515
  238.            aa=.5*aa
  239.            bb=.5*bb
  240. 515        continue
  241.            p(j+1)=0.
  242.            do 520 k=1,j
  243.               a(k)=p(k)
  244.               p(k)=2.*bb*a(k)
  245. 520        continue
  246.            p(2)=p(2)+a(1)*2.*aa
  247.            jm1=j-1
  248.            do 525 k=1,jm1
  249.               p(k)=p(k)+q(k)+aa*a(k+1)
  250. 525        continue
  251.            jp1=j+1
  252.            do 530 k=3,jp1
  253.               p(k)=p(k)+aa*a(k-1)
  254. 530        continue
  255.            if(j.eq.nm1) goto 540
  256.            do 535 k=1,j
  257.               q(k)=-a(k)
  258. 535        continue
  259.            nf1j=nfcns-j-1
  260.            q(1)=q(1)+alpha(nf1j)
  261. 540     continue
  262.         do 543 j=1,nfcns
  263.            alpha(j)=p(j)
  264. 543     continue
  265. 545     continue
  266.         if(nfcns.gt.3) return
  267.         alpha(nfcns+1)=0.0
  268.         alpha(nfcns+2)=0.0
  269.         return
  270.         end
  271. c----------------------------------------------------------------------
  272.         function d(k,n,m)
  273.         dimension iext(66),ad(66),alpha(66),x(66),y(66)
  274.         dimension des(1045),grid(1045),wt(1045)
  275.         common pi2,ad,dev,x,y,grid,des,wt,alpha,iext,nfcns,ngrid
  276.         d=1.
  277.         q=x(k)
  278.         do 3 l=1,m
  279.            do 2 j=l,n,m
  280.               if(j-k)1,2,1
  281. 1          d=2.*d*(q-x(j))
  282. 2          continue
  283. 3       continue
  284.         d=1./d
  285.         return
  286.         end
  287. c----------------------------------------------------------------------
  288.         function gee(k,n)
  289.         dimension iext(66),ad(66),alpha(66),x(66),y(66)
  290.         dimension des(1045),grid(1045),wt(1045)
  291. c        double precision ad,dev,x,y,p12,p,c,d,xf
  292.         common pi2,ad,dev,x,y,grid,des,wt,alpha,iext,nfcns,ngrid
  293.         p=0.0
  294.         xf=grid(k)
  295.         xf=cos(pi2*xf)
  296.         d1=0.
  297.         do 1 j=1,n
  298.            c=xf-x(j)
  299.            c=ad(j)/c
  300.            d1=d1+c
  301.            p=p+c*y(j)
  302. 1       continue
  303.         gee=p/d1
  304.         return
  305.         end
  306. c----------------------------------------------------------------------
  307.         subroutine ouch
  308.         common /oops/niter
  309.         return
  310.         end
复制代码
回复
分享到:

使用道具 举报

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-25 23:04 , Processed in 0.047947 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表