def mdft(n):
 mat = [[None for x in range(n)] for y in range(n)]
 base = exp(((((-2) * pi) * I) / n))
 mat[0] = ([1] * n)
 for i in range(n):
  mat[i][0] = 1
 for i in range(1, n):
  for j in range(i, n):
   mat[i][j] = mat[j][i] = (base ** (i * j))
 return ((1 / sqrt(n)) * Matrix(mat))

def mdft ( n ) : mat = [ [ None for x in range ( n ) ] for y in range ( n ) ] base = exp ( ( ( ( ( - 2 ) * pi ) * I ) / n ) ) mat [ 0 ] = ( [ 1 ] * n ) for i in range ( n ) : mat [ i ] [ 0 ] = 1 for i in range ( 1 , n ) : for j in range ( i , n ) : mat [ i ] [ j ] = mat [ j ] [ i ] = ( base ** ( i * j ) ) return ( ( 1 / sqrt ( n ) ) * Matrix ( mat ) )
returns an expression of a discrete fourier transform as a matrix multiplication .