1#ifndef STAN_MATH_REV_FUN_FFT_HPP
2#define STAN_MATH_REV_FUN_FFT_HPP
39template <
typename V, require_eigen_vector_vt<is_complex, V>* =
nullptr,
40 require_var_t<base_type_t<value_type_t<V>>>* =
nullptr>
51 adj_inv_fft *= res.size();
52 arena_v.real().adj() += adj_inv_fft.real();
53 arena_v.imag().adj() += adj_inv_fft.imag();
84template <
typename V, require_eigen_vector_vt<is_complex, V>* =
nullptr,
85 require_var_t<base_type_t<value_type_t<V>>>* =
nullptr>
96 auto adj_fft =
fft(
to_complex(res.real().adj(), res.imag().adj()));
97 adj_fft /= res.size();
99 arena_v.real().adj() += adj_fft.real();
100 arena_v.imag().adj() += adj_fft.imag();
120template <
typename M, require_eigen_dense_dynamic_vt<is_complex, M>* =
nullptr,
121 require_var_t<base_type_t<value_type_t<M>>>* =
nullptr>
128 adj_inv_fft *= res.size();
129 arena_v.real().adj() += adj_inv_fft.real();
130 arena_v.imag().adj() += adj_inv_fft.imag();
152template <
typename M, require_eigen_dense_dynamic_vt<is_complex, M>* =
nullptr,
153 require_var_t<base_type_t<value_type_t<M>>>* =
nullptr>
160 auto adj_fft =
fft2(
to_complex(res.real().adj(), res.imag().adj()));
161 adj_fft /= res.size();
163 arena_v.real().adj() += adj_fft.real();
164 arena_v.imag().adj() += adj_fft.imag();
Eigen::Matrix< scalar_type_t< M >, -1, -1 > fft2(const M &x)
Return the two-dimensional discrete Fourier transform of the specified complex matrix.
constexpr std::complex< stan::real_return_t< T, S > > to_complex(const T &re=0, const S &im=0)
Return a complex value from a real component and an imaginary component.
void reverse_pass_callback(F &&functor)
Puts a callback on the autodiff stack to be called in reverse pass.
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.
typename plain_type< T >::type plain_type_t
typename internal::arena_type_impl< std::decay_t< T > >::type arena_t
Determines a type that can be used in place of T that does any dynamic allocations on the AD stack.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...