def dft(n, scale=None):
 if (scale not in [None, 'sqrtn', 'n']):
  raise ValueError(("scale must be None, 'sqrtn', or 'n'; %r is not valid." % (scale,)))
 omegas = np.exp(((((-2j) * np.pi) * np.arange(n)) / n)).reshape((-1), 1)
 m = (omegas ** np.arange(n))
 if (scale == 'sqrtn'):
  m /= math.sqrt(n)
 elif (scale == 'n'):
  m /= n
 return m

def dft ( n , scale = None ) : if ( scale not in [ None , 'sqrtn' , 'n' ] ) : raise ValueError ( ( "scale must be None, 'sqrtn', or 'n'; %r is not valid." % ( scale , ) ) ) omegas = np . exp ( ( ( ( ( - 2j ) * np . pi ) * np . arange ( n ) ) / n ) ) . reshape ( ( - 1 ) , 1 ) m = ( omegas ** np . arange ( n ) ) if ( scale == 'sqrtn' ) : m /= math . sqrt ( n ) elif ( scale == 'n' ) : m /= n return m
discrete fourier transform matrix .