Python3でnextpow2を作る
fftに渡す信号のパディングに使用していたMatlabのnextpow2をPythonに移植しました。
nextpow2は、入力Aの絶対値以上の最小の2のべき乗の指数を計算します。
こんな感じになりました。
import numpy as np def nextpow2(n): m_f = np.log2(n) m_i = np.ceil(m_f) return int(np.log2(2**m_i))
うまく狙った感じで動いてそうです。
fftに渡す信号のパディングに使用していたMatlabのnextpow2をPythonに移植しました。
nextpow2は、入力Aの絶対値以上の最小の2のべき乗の指数を計算します。
こんな感じになりました。
import numpy as np def nextpow2(n): m_f = np.log2(n) m_i = np.ceil(m_f) return int(np.log2(2**m_i))
うまく狙った感じで動いてそうです。
This Post Has 0 Comments