@@ -86,45 +86,56 @@ namespace numpy
8686 return out_array;
8787 }
8888
89- // These functions help handle None inputs for default values without relying on the C++ default mechanism.
90- bool testNorm (types::none_type param) { return false ; }
91- bool testNorm (types::str param) {
92- if (param == " ortho" ) return 1 ;
93- else {
94- throw types::ValueError (" norm should be None or \" ortho\" " );
95- return 0 ;
96- }
89+ // These functions help handle None inputs for default values without
90+ // relying on the C++ default mechanism.
91+ bool testNorm (types::none_type param)
92+ {
93+ return false ;
94+ }
95+ bool testNorm (types::str param)
96+ {
97+ if (param == " ortho" )
98+ return 1 ;
99+ else {
100+ throw types::ValueError (" norm should be None or \" ortho\" " );
101+ return 0 ;
97102 }
98-
99- long testLong (types::none_type param, long def_val) { return def_val;}
100- long testLong (long N, long def_val) { return N;}
103+ }
101104
102-
103- template <class T , class pS , typename U, typename V, typename W >
104- types::ndarray<double , types::array<long , std::tuple_size<pS>::value>>
105- irfft (types::ndarray<T, pS> const & in_array, U _NFFT, V _axis, W renorm)
105+ long testLong (types::none_type param, long def_val)
106+ {
107+ return def_val;
108+ }
109+ long testLong (long N, long def_val)
110+ {
111+ return N;
112+ }
113+
114+ template <class T , class pS , typename U, typename V, typename W>
115+ types::ndarray<double , types::array<long , std::tuple_size<pS>::value>>
116+ irfft (types::ndarray<T, pS> const &in_array, U _NFFT, V _axis, W renorm)
106117 {
107- auto constexpr N = std::tuple_size<pS>::value;
108- bool norm = testNorm (renorm);
109- // Handle None for axis input.
110- long axis = testLong (_axis,-1 );
111- long LN = (long ) N;
112- if (axis >= LN) throw types::ValueError ( " axis out of bounds1 " );
113- if (axis <= -LN- 1 ) throw types::ValueError (" axis out of bounds " );
114- // Handle None for NFFT. Map -1 -> N-1 etc...
115- axis = ( axis+N)%N ;
116- long def_val = 2 *( sutils::array (in_array. shape ())[axis] - 1 );
117- long NFFT = testLong (_NFFT,def_val) ;
118- if ( axis != N - 1 ) {
119- // Swap axis if the FFT must be computed on an axis that's not the last
120- // one.
121- auto swapped_array = swapaxes (in_array, axis, N - 1 );
122- return swapaxes ( _irfft (swapped_array, NFFT, norm), axis, N - 1 );
123- }
124- else {
125- return _irfft (in_array, NFFT, norm);
126-
127- }
118+ auto constexpr N = std::tuple_size<pS>::value;
119+ bool norm = testNorm (renorm);
120+ // Handle None for axis input.
121+ long axis = testLong (_axis, -1 );
122+ long LN = (long )N;
123+ if (axis >= LN)
124+ throw types::ValueError (" axis out of bounds1 " );
125+ if (axis <= -LN - 1 )
126+ throw types::ValueError ( " axis out of bounds " ) ;
127+ // Handle None for NFFT. Map -1 -> N-1 etc...
128+ axis = (axis + N) % N ;
129+ long def_val = 2 * ( sutils::array (in_array. shape ())[ axis] - 1 );
130+ long NFFT = testLong (_NFFT, def_val);
131+ if (axis != N - 1 ) {
132+ // Swap axis if the FFT must be computed on an axis that's not the last
133+ // one.
134+ auto swapped_array = swapaxes (in_array, axis, N - 1 );
135+ return swapaxes ( _irfft (swapped_array, NFFT, norm), axis, N - 1 );
136+ } else {
137+ return _irfft (in_array, NFFT, norm);
138+ }
128139 }
129140
130141 NUMPY_EXPR_TO_NDARRAY0_IMPL (irfft);
0 commit comments