Fpolesnzeroes.f 5.9 KB
Newer Older
Tilman Steinweg's avatar
Tilman Steinweg committed
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
c this is <polesnzeroes.f>
c ----------------------------------------------------------------------------
c   ($Id: Fpolesnzeroes.f 4966 2013-02-01 13:46:50Z lrehor $)
c
c Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) 
c
c pole and zero access subroutines
c
c ----
c This program is free software; you can redistribute it and/or modify
c it under the terms of the GNU General Public License as published by
c the Free Software Foundation; either version 2 of the License, or
c (at your option) any later version. 
c 
c This program is distributed in the hope that it will be useful,
c but WITHOUT ANY WARRANTY; without even the implied warranty of
c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c GNU General Public License for more details.
c 
c You should have received a copy of the GNU General Public License
c along with this program; if not, write to the Free Software
c Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
c ----
c
c
c REVISIONS and CHANGES
c    11/11/2002   V1.0   Thomas Forbriger
c    13/11/2002   V1.1   introduce waterlevel to omega
c
cS
c ============================================================================
c
      subroutine fou_revision
c 
c print library code revision
c
cE
      print *,
     &  '$Id: Fpolesnzeroes.f 4966 2013-02-01 13:46:50Z lrehor $'
      return
      end
c
cS
c----------------------------------------------------------------------
c
      subroutine fou_clear
c
c initialize poles and zeros database
c
      include 'polesnzeros.inc'
c
cE
      call fou_normal
      fourier_numer=(1.d0,0.d0)
      fourier_denom=(1.d0,0.d0)
      fourier_npoles=0
      fourier_nzeros=0
c
      return
      end
c
cS
c----------------------------------------------------------------------
c
      subroutine fou_inverse
c
c set inverse flag
c all following coefficients will be treated as inverse filters
c
      include 'polesnzeros.inc'
c
cE
c
      fourier_normal=.false.
c
      return
      end
c
cS
c----------------------------------------------------------------------
c
      subroutine fou_normal
c
c reset inverse flag
c all following coefficients will be treated as normal filters
c
      include 'polesnzeros.inc'
c
cE
c
      fourier_normal=.true.
c
      return
      end
c
cS
c----------------------------------------------------------------------
c
      subroutine fou_pole(pole)
c
c set one pole
c
      double complex pole
c
      include 'polesnzeros.inc'
c
cE
c
      if (fourier_normal) then
        if (fourier_npoles.lt.fourier_nmax) then
          fourier_npoles=fourier_npoles+1
          fourier_poles(fourier_npoles)=pole
        else
          stop 'ERROR (fourier_pole): too many poles'
        endif
      else
        if (fourier_nzeros.lt.fourier_nmax) then
          fourier_nzeros=fourier_nzeros+1
          fourier_zeros(fourier_nzeros)=pole
        else
          stop 'ERROR (fourier_pole): too many zeros'
        endif
      endif
c
      return
      end
c
cS
c----------------------------------------------------------------------
c
      subroutine fou_zero(zero)
c
c set one zero
c
      double complex zero
c
      include 'polesnzeros.inc'
c
cE
c
      if (fourier_normal) then
        if (fourier_nzeros.lt.fourier_nmax) then
          fourier_nzeros=fourier_nzeros+1
          fourier_zeros(fourier_nzeros)=zero
        else
          stop 'ERROR (fourier_zero): too many zeros'
        endif
      else
        if (fourier_npoles.lt.fourier_nmax) then
          fourier_npoles=fourier_npoles+1
          fourier_poles(fourier_npoles)=zero
        else
          stop 'ERROR (fourier_zero): too many poles'
        endif
      endif
c
      return
      end
c
cS
c----------------------------------------------------------------------
c
      subroutine fou_numer(factor)
c
c set one numerator factor
c
      double precision factor
c
      include 'polesnzeros.inc'
c
cE
c
      if (fourier_normal) then
        fourier_numer=factor*fourier_numer
      else
        fourier_denom=factor*fourier_denom
      endif
c
      return
      end
c
cS
c----------------------------------------------------------------------
c
      subroutine fou_denom(factor)
c
c set one denominator factor
c
      double precision factor
c
      include 'polesnzeros.inc'
c
cE
c
      if (fourier_normal) then
        fourier_denom=factor*fourier_denom
      else
        fourier_numer=factor*fourier_numer
      endif
c
      return
      end
c
cS
c----------------------------------------------------------------------
c
      subroutine fou_cnumer(factor)
c
c set one complex numerator factor
c
      double complex factor
c
      include 'polesnzeros.inc'
c
cE
c
      if (fourier_normal) then
        fourier_numer=factor*fourier_numer
      else
        fourier_denom=factor*fourier_denom
      endif
c
      return
      end
c
cS
c----------------------------------------------------------------------
c
      subroutine fou_cdenom(factor)
c
c set one complex denominator factor
c
      double complex factor
c
      include 'polesnzeros.inc'
c
cE
c
      if (fourier_normal) then
        fourier_denom=factor*fourier_denom
      else
        fourier_numer=factor*fourier_numer
      endif
c
      return
      end
c
cS
c----------------------------------------------------------------------
c
      double complex function fou_eval(om)
c
c evaluate filter response coefficient at real frequency om
c the function applies a waterlevel of 1.d-30 to om
c
      double precision om
c
      include 'polesnzeros.inc'
c
cE
      double complex value, thenumer, thedenom, omega
      integer i
c 
      omega=max(1.d-30,om)
c 
      thenumer=(1.d0,0.d0)
      do i=1,fourier_nzeros
        thenumer=thenumer*(omega-fourier_zeros(i))
      enddo
c 
      thedenom=(1.d0,0.d0)
      do i=1,fourier_npoles
        thedenom=thedenom*(omega-fourier_poles(i))
      enddo
c 
      value=thenumer*fourier_numer/(fourier_denom*thedenom)
c
      fou_eval=value
c
      return
      end
c
c ----- END OF polesnzeroes.f -----