1#ifndef STAN_MATH_PRIM_FUN_FFT_HPP
2#define STAN_MATH_PRIM_FUN_FFT_HPP
6#include <unsupported/Eigen/FFT>
33template <
typename V, require_eigen_vector_vt<is_complex, V>* =
nullptr,
34 require_not_var_t<base_type_t<value_type_t<V>>>* =
nullptr>
35inline Eigen::Matrix<scalar_type_t<V>, -1, 1>
fft(
const V& x) {
37 Eigen::Matrix<scalar_type_t<V>, -1, 1> xv = x;
40 Eigen::FFT<base_type_t<V>>
fft;
64template <
typename V, require_eigen_vector_vt<is_complex, V>* =
nullptr,
65 require_not_var_t<base_type_t<value_type_t<V>>>* =
nullptr>
66inline Eigen::Matrix<scalar_type_t<V>, -1, 1>
inv_fft(
const V& y) {
68 Eigen::Matrix<scalar_type_t<V>, -1, 1> yv = y;
71 Eigen::FFT<base_type_t<V>>
fft;
85template <
typename M, require_eigen_dense_dynamic_vt<is_complex, M>* =
nullptr,
86 require_not_var_t<base_type_t<value_type_t<M>>>* =
nullptr>
87inline Eigen::Matrix<scalar_type_t<M>, -1, -1>
fft2(
const M& x) {
88 Eigen::Matrix<scalar_type_t<M>, -1, -1> y(x.rows(), x.cols());
89 for (
int i = 0; i < y.rows(); ++i)
90 y.row(i) =
fft(x.row(i));
91 for (
int j = 0; j < y.cols(); ++j)
92 y.col(j) =
fft(y.col(j));
107template <
typename M, require_eigen_dense_dynamic_vt<is_complex, M>* =
nullptr,
108 require_not_var_t<base_type_t<value_type_t<M>>>* =
nullptr>
109inline Eigen::Matrix<scalar_type_t<M>, -1, -1>
inv_fft2(
const M& y) {
110 Eigen::Matrix<scalar_type_t<M>, -1, -1> x(y.rows(), y.cols());
111 for (
int j = 0; j < x.cols(); ++j)
113 for (
int i = 0; i < x.rows(); ++i)
Eigen::Matrix< scalar_type_t< M >, -1, -1 > fft2(const M &x)
Return the two-dimensional discrete Fourier transform of the specified complex matrix.
Eigen::Matrix< scalar_type_t< V >, -1, 1 > fft(const V &x)
Return the discrete Fourier transform of the specified complex vector.
Eigen::Matrix< scalar_type_t< V >, -1, 1 > inv_fft(const V &y)
Return the inverse discrete Fourier transform of the specified complex vector.
Eigen::Matrix< scalar_type_t< M >, -1, -1 > inv_fft2(const M &y)
Return the two-dimensional inverse discrete Fourier transform of the specified complex matrix.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...