def zpkfreqd(z, p, k, worN=None):
 if ((worN is None) or isinstance(worN, int)):
  N = (worN or 512)
  ws = [((mpmath.pi * mpmath.mpf(j)) / N) for j in range(N)]
 else:
  ws = worN
 h = []
 for wk in ws:
  zm1 = mpmath.exp((1j * wk))
  numer = _prod([(zm1 - t) for t in z])
  denom = _prod([(zm1 - t) for t in p])
  hk = ((k * numer) / denom)
  h.append(hk)
 return (ws, h)

def zpkfreqd ( z , p , k , worN = None ) : if ( ( worN is None ) or isinstance ( worN , int ) ) : N = ( worN or 512 ) ws = [ ( ( mpmath . pi * mpmath . mpf ( j ) ) / N ) for j in range ( N ) ] else : ws = worN h = [ ] for wk in ws : zm1 = mpmath . exp ( ( 1j * wk ) ) numer = _prod ( [ ( zm1 - t ) for t in z ] ) denom = _prod ( [ ( zm1 - t ) for t in p ] ) hk = ( ( k * numer ) / denom ) h . append ( hk ) return ( ws , h )
frequency response of a filter in zpk format .