1 #ifndef PYTHONIC_NUMPY_FFT_IFFT_HPP
2 #define PYTHONIC_NUMPY_FFT_IFFT_HPP
3 
4 #include "pythonic/include/numpy/fft/ifft.hpp"
5 #include "pythonic/utils/functor.hpp"
6 #include "pythonic/include/utils/array_helper.hpp"
7 #include "pythonic/types/ndarray.hpp"
8 #include "pythonic/builtins/None.hpp"
9 #include "pythonic/numpy/fft/c2c.hpp"
10 
11 PYTHONIC_NS_BEGIN
12 
13 namespace numpy
14 {
15   namespace fft
16   {
17 
18     template <class T, class pS>
19     types::ndarray<
20         typename std::enable_if<types::is_complex<T>::value, T>::type,
21         types::array<long, std::tuple_size<pS>::value>>
ifft(types::ndarray<T,pS> const & in_array,types::none_type n,long axis,types::str const & norm)22     ifft(types::ndarray<T, pS> const &in_array, types::none_type n, long axis,
23          types::str const &norm)
24     {
25       return c2c(in_array, -1, axis, norm, false);
26     }
27 
28     template <class T, class pS>
29     types::ndarray<
30         typename std::enable_if<types::is_complex<T>::value, T>::type,
31         types::array<long, std::tuple_size<pS>::value>>
ifft(types::ndarray<T,pS> const & in_array,types::none_type n,long axis,types::none_type norm)32     ifft(types::ndarray<T, pS> const &in_array, types::none_type n, long axis,
33          types::none_type norm)
34     {
35       return c2c(in_array, -1, axis, "", false);
36     }
37 
38     template <class T, class pS>
39     types::ndarray<
40         typename std::enable_if<types::is_complex<T>::value, T>::type,
41         types::array<long, std::tuple_size<pS>::value>>
ifft(types::ndarray<T,pS> const & in_array,long n,long axis,types::none_type norm)42     ifft(types::ndarray<T, pS> const &in_array, long n, long axis,
43          types::none_type norm)
44     {
45       return c2c(in_array, n, axis, "", false);
46     }
47 
48     template <class T, class pS>
49     types::ndarray<
50         typename std::enable_if<types::is_complex<T>::value, T>::type,
51         types::array<long, std::tuple_size<pS>::value>>
ifft(types::ndarray<T,pS> const & in_array,long n,long axis,types::str const & norm)52     ifft(types::ndarray<T, pS> const &in_array, long n, long axis,
53          types::str const &norm)
54     {
55       return c2c(in_array, n, axis, norm, false);
56     }
57 
58     template <class T, class pS>
59     types::ndarray<typename std::enable_if<std::is_floating_point<T>::value,
60                                            std::complex<T>>::type,
61                    types::array<long, std::tuple_size<pS>::value>>
ifft(types::ndarray<T,pS> const & in_array,types::none_type n,long axis,types::str const & norm)62     ifft(types::ndarray<T, pS> const &in_array, types::none_type n, long axis,
63          types::str const &norm)
64     {
65       return r2c(in_array, -1, axis, norm, false);
66     }
67 
68     template <class T, class pS>
69     types::ndarray<typename std::enable_if<std::is_floating_point<T>::value,
70                                            std::complex<T>>::type,
71                    types::array<long, std::tuple_size<pS>::value>>
ifft(types::ndarray<T,pS> const & in_array,types::none_type n,long axis,types::none_type norm)72     ifft(types::ndarray<T, pS> const &in_array, types::none_type n, long axis,
73          types::none_type norm)
74     {
75       return r2c(in_array, -1, axis, "", false, true);
76     }
77 
78     template <class T, class pS>
79     types::ndarray<typename std::enable_if<std::is_floating_point<T>::value,
80                                            std::complex<T>>::type,
81                    types::array<long, std::tuple_size<pS>::value>>
ifft(types::ndarray<T,pS> const & in_array,long n,long axis,types::none_type norm)82     ifft(types::ndarray<T, pS> const &in_array, long n, long axis,
83          types::none_type norm)
84     {
85       return r2c(in_array, n, axis, "", false, true);
86     }
87 
88     template <class T, class pS>
89     types::ndarray<typename std::enable_if<std::is_floating_point<T>::value,
90                                            std::complex<T>>::type,
91                    types::array<long, std::tuple_size<pS>::value>>
ifft(types::ndarray<T,pS> const & in_array,long n,long axis,types::str const & norm)92     ifft(types::ndarray<T, pS> const &in_array, long n, long axis,
93          types::str const &norm)
94     {
95       return r2c(in_array, n, axis, norm, false, true);
96     }
97 
98     template <class T, class pS>
99     types::ndarray<typename std::enable_if<std::is_integral<T>::value,
100                                            std::complex<double>>::type,
101                    types::array<long, std::tuple_size<pS>::value>>
ifft(types::ndarray<T,pS> const & in_array,types::none_type n,long axis,types::str const & norm)102     ifft(types::ndarray<T, pS> const &in_array, types::none_type n, long axis,
103          types::str const &norm)
104     {
105       auto tmp_array = _copy_to_double(in_array);
106       return r2c(tmp_array, -1, axis, norm, false, true);
107     }
108 
109     template <class T, class pS>
110     types::ndarray<typename std::enable_if<std::is_integral<T>::value,
111                                            std::complex<double>>::type,
112                    types::array<long, std::tuple_size<pS>::value>>
ifft(types::ndarray<T,pS> const & in_array,types::none_type n,long axis,types::none_type norm)113     ifft(types::ndarray<T, pS> const &in_array, types::none_type n, long axis,
114          types::none_type norm)
115     {
116       auto tmp_array = _copy_to_double(in_array);
117       return r2c(tmp_array, -1, axis, "", false, true);
118     }
119 
120     template <class T, class pS>
121     types::ndarray<typename std::enable_if<std::is_integral<T>::value,
122                                            std::complex<double>>::type,
123                    types::array<long, std::tuple_size<pS>::value>>
ifft(types::ndarray<T,pS> const & in_array,long n,long axis,types::none_type norm)124     ifft(types::ndarray<T, pS> const &in_array, long n, long axis,
125          types::none_type norm)
126     {
127       auto tmp_array = _copy_to_double(in_array);
128       return r2c(tmp_array, n, axis, "", false, true);
129     }
130 
131     template <class T, class pS>
132     types::ndarray<typename std::enable_if<std::is_integral<T>::value,
133                                            std::complex<double>>::type,
134                    types::array<long, std::tuple_size<pS>::value>>
ifft(types::ndarray<T,pS> const & in_array,long n,long axis,types::str const & norm)135     ifft(types::ndarray<T, pS> const &in_array, long n, long axis,
136          types::str const &norm)
137     {
138       auto tmp_array = _copy_to_double(in_array);
139       return r2c(tmp_array, n, axis, norm, false, true);
140     }
141 
142     NUMPY_EXPR_TO_NDARRAY0_IMPL(ifft);
143   }
144 }
145 PYTHONIC_NS_END
146 
147 #endif
148