update 37

This commit is contained in:
Connor Olding 2018-02-16 04:04:24 -08:00
parent 413b156e8f
commit 1ceab58844
2 changed files with 6 additions and 5 deletions

View File

@ -1,4 +1,4 @@
from . import tau
from . import tau, ceil2
import numpy as np
@ -37,15 +37,16 @@ def tsp(N, m=0.5):
if N < 0:
raise Exception("The number of length must be the positive number")
NN = int(2**np.floor(np.log2(N))) # nearest
NN = ceil2(N)
NN2 = NN // 2
M = int(np.round(NN2 * m))
nn2 = np.square(np.arange(NN2 + 1))
# this has been tweaked to prevent overflow:
s = np.square(np.arange(NN2 + 1) / NN)
j = np.complex(0, 1)
H = np.exp(j * 4 * M * np.pi * nn2 / np.square(NN))
H = np.exp(j * 4 * M * np.pi * s)
H2 = np.r_[H, np.conj(H[1:NN2][::-1])]
x = np.fft.ifft(H2)

View File

@ -36,7 +36,7 @@ def warp(w):
def ceil2(x):
return np.power(2, np.ceil(np.log2(x)))
return np.power(2, np.ceil(np.log2(x)).astype(int))
def pad2(x):