/******************************************************** * ██████╗ ██████╗████████╗██╗ * ██╔════╝ ██╔════╝╚══██╔══╝██║ * ██║ ███╗██║ ██║ ██║ * ██║ ██║██║ ██║ ██║ * ╚██████╔╝╚██████╗ ██║ ███████╗ * ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝ * Geophysical Computational Tools & Library (GCTL) * * Copyright (c) 2023 Yi Zhang (yizhang-geo@zju.edu.cn) * * GCTL is distributed under a dual licensing scheme. You can redistribute * it and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation, either version 2 * of the License, or (at your option) any later version. You should have * received a copy of the GNU Lesser General Public License along with this * program. If not, see . * * If the terms and conditions of the LGPL v.2. would prevent you from using * the GCTL, please consider the option to obtain a commercial license for a * fee. These licenses are offered by the GCTL's original author. As a rule, * licenses are provided "as-is", unlimited in time for a one time fee. Please * send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget * to include some description of your company and the realm of its activities. * Also add information on how to contact you by electronic and paper mail. ******************************************************/ #ifndef _GCTL_FFT_H #define _GCTL_FFT_H // library head file #include "../gctl_config.h" #include "../core/array.h" #include "../core/matrix.h" #include "../core/exceptions.h" #ifdef GCTL_FFTW3 // fftw head file #include "fftw3.h" namespace gctl { /** * @brief 1D Discrete Fourier Transform (DFT) from real data to complex spectrum. * * @param[in] in_real Input real data array of size n * @param out_spectrum Output complex spectrum of size n/2+1 * @param sampling Sampling freqency, this is needed to calculate the output frequency index * @param freq_ptr Output frequency index of size n/2+1 */ void dft_r2c_1d(const _1d_array &in_real, _1cd_array &out_spectrum, double sampling = 0, _1d_array *freq_ptr = nullptr); /** * @brief 1D Discrete Fourier Transform (DFT) from complex spectrum to real data. * * @param in_spectrum Intput complex spectrum of size n * @param out_real Output real data array of size 2*(n-1) */ void dft_c2r_1d(const _1cd_array &in_spectrum, _1d_array &out_real); /** * @brief 2D Discrete Fourier Transform * * @param[in] in_arr Input real array * @param out_arr Output complex array */ void dft2d(const _2d_matrix &in_arr, _1cd_array &out_arr); /** * @brief 2D Inverse Discrete Fourier Transform * * @param[in] in_arr Input complex array * @param[in] m Row size of the 2D matrix * @param[in] n Column size of the 2D matrix * @param out_arr Output real array */ void idft2d(const _1cd_array &in_arr, int m, int n, _2d_matrix &out_arr); /** * @brief 1D Discrete Cosine Transform * * @param[in] in_arr Input real array * @param out_arr Output real array */ void dct1d(const _1d_array &in_arr, _1d_array &out_arr); /** * @brief 1D Inverse Cosine Fourier Transform * * @param[in] in_arr Input real array * @param out_arr Output real array */ void idct1d(const _1d_array &in_arr, _1d_array &out_arr); } #endif // GCTL_FFTW3 #endif // _GCTL_FFT_H