関数fft マニュアル

(The documentation of function fft)

Last Update: 2021/12/7


◆機能・用途(Purpose)

時系列データ\(f(t)\)のフーリエスペクトル \[\begin{equation} F(f) \equiv \int_{-\infty}^{\infty} f(t) e^{2\pi ift}dt \label{eq.continuous.definition} \end{equation}\] を高速フーリエ変換(FFT)のアルゴリズムを用いて計算する。 時系列データとして長さが2の巾乗で虚部が0.0の複素数値系列 (struct imsequence型構造体)を与える。
Compute the Fourier spectrum (eq. \ref{eq.continuous.definition}) of a time series data \(f(t)\) using the fast Fourier transformation (FFT) algorithm, where the time series data is given as a complex number series (struct imsequence-type structure) of a length of a power of 2 with values 0.0 for the imaginary parts.


◆形式(Format)

#include <sequence/fft.h>
inline struct imsequence fft(struct imsequence seq)


◆引数(Arguments)

seq 入力時系列データ\(f(t)\)。 虚部が0.0のstruct imsequence型構造体として与える。 メンバsizeは2の巾乗でなければならない (関数内で長さのチェックは行われる)。
The input time series data \(f(t)\), given as a struct imsequence-type structure with imaginary parts being 0.0. Member size must be a power of 2; the length is checked within the function.


◆戻り値(Return value)

\(f(t)\)のフーリエスペクトル。戻り値のメンバの値は以下のようになる。
The Fourier spectrum of \(f(t)\). The values of members of the return value are as below.

戻り値のメンバ
Member of the return value
値
Value
size seq.size
t0 0.0
dt (\ref{eq.df.definition})式の\(\Delta f\)
\(\Delta f\) of eq. (\ref{eq.df.definition})
各\(n\)に対するvalue[n]
value[n] for each \(n\)
(\ref{eq.discrete.definition})式の\(F_n\)
\(F_n\) of eq. (\ref{eq.discrete.definition})

ここで、(\ref{eq.discrete.definition})式の記号と 引数の対応関係は以下のようになる。
Here, relations between symbols in eq. (\ref{eq.discrete.definition}) and arguments are given as below.



◆使用例(Example)

struct imsequence f;
struct imsequence F=fft(f);


◆補足(Additional notes)

この関数では時系列データを長さが2の巾乗の 複素数値系列(struct imsequence型構造体)として与える必要がある。 \(f(t)\)として任意の長さの実数値の時系列データ(struct sequence型構造体) を直接与えてFFTを行うことができる関数fft_sequenceを別途用意している。 したがってユーザとしてFFTを行う分には通常は関数fft_sequenceを用いれば良い。 この関数(fft)は関数fft_sequenceの内部で用いられており、 ユーザが直接用いるための関数というよりは 関数fft_sequence内部で間接的に用いるための関数という位置づけである。
In this function, the time series data must be given as a complex number series (struct imsequence-type structure) of a length which is a power of 2. There is another, more convenient function fft_sequence, which can directly use a time series data of real numbers (a struct sequence-type structure) of arbitrary length as \(f(t)\) to perform FFT. Therefore users can usually use the function fft_sequence for FFT. This function (fft) is used internally within the function fft_sequence. The main assumed role of this function (fft) is this internal call, rather than being directly used by the users.


◆計算式(Formula)

時系列データ\(f(t)\)のフーリエ変換は (\ref{eq.continuous.definition})式で与えられる。 \(f(t)\)が有限の時刻範囲において 一定の時間刻み\(\Delta t\)で与えられているものとし、 データサンプル数を\(2^N\)(\(N\):自然数)、 先頭時刻を\(t_0\)とする。 このとき\(f(t)\)の定義域は\(t_0 \leq t < t_0+2^N\Delta t\)となる。 定義域外では\(f(t)=0\)であるものと仮定する。 離散化後の\(f(t)\)および\(F(f)\)をそれぞれ \[\begin{equation} f_k \equiv f(t_0+k\Delta t) \hspace{1em} (k=0,1,2,\cdots,2^N-1) \label{eq.discretize.t} \end{equation}\] \[\begin{equation} F_n \equiv F(n\Delta f) \label{eq.discretize.f} \end{equation}\] と表し、積分(\ref{eq.continuous.definition})を和で近似すれば \[\begin{equation} F_n = \sum_{k=0}^{2^N-1} f_k e^{2\pi i n\Delta f (t_0+k\Delta t)} \Delta t \label{eq.integral.approximated} \end{equation}\] となる。周波数刻みを \[\begin{equation} \Delta f \equiv \frac{1}{2^N \Delta t} \label{eq.df.definition} \end{equation}\] で与えることにすれば \[\begin{equation} F_n = e^{\frac{2\pi i n t_0}{2^N \Delta t}}\Delta t \sum_{k=0}^{2^N-1} f_k e^{\frac{2\pi ink}{2^N}} \hspace{1em} (n=0,1,2,\cdots,2^N-1) \label{eq.discrete.definition} \end{equation}\] を得る。 この関数では(\ref{eq.discrete.definition})式を用いて フーリエ変換を実行する。
The Fourier transformation of a time series data \(f(t)\) is given by eq. (\ref{eq.continuous.definition}). Let \(f(t)\) be given in a finite time range at a constant time interval \(\Delta t\), and let the number of data samples and start time be \(2^N\) (where \(N\) is a natural number) and \(t_0\), respectively. In this case, the definition range of \(f(t)\) is \(t_0\leq t<t_0+2^N\Delta t\). Outside of the definition range, \(f(t)=0\) is assumed. Let the values of \(f(t)\) and \(F(f)\) after discretizations be represented by eqs. (\ref{eq.discretize.t}) and (\ref{eq.discretize.f}), respectively. Then the integration in eq. (\ref{eq.continuous.definition}) can be approximated as (\ref{eq.integral.approximated}). Let the frequency interval be given by eq. (\ref{eq.df.definition}). Then eq. (\ref{eq.discrete.definition}) is obtained. This function calculates the Fourier transformation based on eq. (\ref{eq.discrete.definition}).

計算方法の詳細については関数fft2のマニュアル参照。
For more detail of the computation method, see the documentation of function fft2.