@@ -112,75 +112,117 @@ public static Array Count(Array arr, int dim = -1)
112112 }
113113
114114 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
115- public static Complex SumAll ( Array arr )
115+ public static Complex SumAll ( Array arr ) => SumAll < Complex > ( arr ) ;
116+
117+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
118+ public static returnType SumAll < returnType > ( Array arr )
116119 {
117120 double r , i ;
118121 Internal . VERIFY ( AFAlgorithm . af_sum_all ( out r , out i , arr . _ptr ) ) ;
119- return new Complex ( r , i ) ;
122+ if ( typeof ( returnType ) == typeof ( Complex ) )
123+ return ( returnType ) Convert . ChangeType ( new Complex ( r , i ) , typeof ( returnType ) ) ;
124+ else
125+ return ( returnType ) Convert . ChangeType ( r , typeof ( returnType ) ) ;
120126 }
121127
122128 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
123- public static Complex SumAll ( Array arr , double nanval )
129+ public static Complex SumAll ( Array arr , double nanval ) => SumAll < Complex > ( arr , nanval ) ;
130+
131+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
132+ public static returnType SumAll < returnType > ( Array arr , double nanval )
124133 {
125134 double r , i ;
126135 Internal . VERIFY ( AFAlgorithm . af_sum_nan_all ( out r , out i , arr . _ptr , nanval ) ) ;
127- return new Complex ( r , i ) ;
136+ if ( typeof ( returnType ) == typeof ( Complex ) )
137+ return ( returnType ) Convert . ChangeType ( new Complex ( r , i ) , typeof ( returnType ) ) ;
138+ else
139+ return ( returnType ) Convert . ChangeType ( r , typeof ( returnType ) ) ;
128140 }
129141
130142 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
131- public static Complex ProductAll ( Array arr )
143+ public static Complex ProductAll ( Array arr ) => ProductAll < Complex > ( arr ) ;
144+
145+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
146+ public static returnType ProductAll < returnType > ( Array arr )
132147 {
133148 double r , i ;
134149 Internal . VERIFY ( AFAlgorithm . af_product_all ( out r , out i , arr . _ptr ) ) ;
135- return new Complex ( r , i ) ;
150+ if ( typeof ( returnType ) == typeof ( Complex ) )
151+ return ( returnType ) Convert . ChangeType ( new Complex ( r , i ) , typeof ( returnType ) ) ;
152+ else
153+ return ( returnType ) Convert . ChangeType ( r , typeof ( returnType ) ) ;
136154 }
137155
138156 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
139- public static Complex ProductAll ( Array arr , double nanval )
157+ public static Complex ProductAll ( Array arr , double nanval ) => ProductAll < Complex > ( arr , nanval ) ;
158+
159+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
160+ public static returnType ProductAll < returnType > ( Array arr , double nanval )
140161 {
141162 double r , i ;
142163 Internal . VERIFY ( AFAlgorithm . af_product_nan_all ( out r , out i , arr . _ptr , nanval ) ) ;
143- return new Complex ( r , i ) ;
164+ if ( typeof ( returnType ) == typeof ( Complex ) )
165+ return ( returnType ) Convert . ChangeType ( new Complex ( r , i ) , typeof ( returnType ) ) ;
166+ else
167+ return ( returnType ) Convert . ChangeType ( r , typeof ( returnType ) ) ;
144168 }
145169
146170 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
147- public static Complex MinAll ( Array arr )
171+ public static Complex MinAll ( Array arr ) => MinAll < Complex > ( arr ) ;
172+
173+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
174+ public static returnType MinAll < returnType > ( Array arr )
148175 {
149176 double r , i ;
150177 Internal . VERIFY ( AFAlgorithm . af_min_all ( out r , out i , arr . _ptr ) ) ;
151- return new Complex ( r , i ) ;
178+ if ( typeof ( returnType ) == typeof ( Complex ) )
179+ return ( returnType ) Convert . ChangeType ( new Complex ( r , i ) , typeof ( returnType ) ) ;
180+ else
181+ return ( returnType ) Convert . ChangeType ( r , typeof ( returnType ) ) ;
152182 }
153183
154184 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
155- public static Complex MaxAll ( Array arr )
185+ public static Complex MaxAll ( Array arr ) => MaxAll < Complex > ( arr ) ;
186+
187+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
188+ public static returnType MaxAll < returnType > ( Array arr )
156189 {
157190 double r , i ;
158191 Internal . VERIFY ( AFAlgorithm . af_max_all ( out r , out i , arr . _ptr ) ) ;
159- return new Complex ( r , i ) ;
192+ if ( typeof ( returnType ) == typeof ( Complex ) )
193+ return ( returnType ) Convert . ChangeType ( new Complex ( r , i ) , typeof ( returnType ) ) ;
194+ else
195+ return ( returnType ) Convert . ChangeType ( r , typeof ( returnType ) ) ;
160196 }
161197
162198 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
163- public static Complex AllTrueAll ( Array arr )
199+ public static bool AllTrueAll ( Array arr )
164200 {
165201 double r , i ;
166202 Internal . VERIFY ( AFAlgorithm . af_all_true_all ( out r , out i , arr . _ptr ) ) ;
167- return new Complex ( r , i ) ;
203+ if ( r == 0 )
204+ return false ;
205+ else
206+ return true ;
168207 }
169208
170209 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
171- public static Complex AnyTrueAll ( Array arr )
210+ public static bool AnyTrueAll ( Array arr )
172211 {
173212 double r , i ;
174213 Internal . VERIFY ( AFAlgorithm . af_any_true_all ( out r , out i , arr . _ptr ) ) ;
175- return new Complex ( r , i ) ;
214+ if ( r == 0 )
215+ return false ;
216+ else
217+ return true ;
176218 }
177219
178220 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
179- public static Complex CountAll ( Array arr )
221+ public static long CountAll ( Array arr )
180222 {
181223 double r , i ;
182224 Internal . VERIFY ( AFAlgorithm . af_count_all ( out r , out i , arr . _ptr ) ) ;
183- return new Complex ( r , i ) ;
225+ return ( long ) r ;
184226 }
185227
186228 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
@@ -204,19 +246,31 @@ public static Array Max(Array arr, out Array idx, int dim = -1)
204246 }
205247
206248 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
207- public static Complex MinAll ( Array arr , out uint idx )
249+ public static Complex MinAll ( Array arr , out uint idx ) => MinAll < Complex > ( arr , out idx ) ;
250+
251+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
252+ public static returnType MinAll < returnType > ( Array arr , out uint idx )
208253 {
209254 double r , i ;
210- Internal . VERIFY ( AFAlgorithm . af_imin_all ( out r , out i , out idx , arr . _ptr ) ) ;
211- return new Complex ( r , i ) ;
255+ Internal . VERIFY ( AFAlgorithm . af_imin_all ( out r , out i , out idx , arr . _ptr ) ) ;
256+ if ( typeof ( returnType ) == typeof ( Complex ) )
257+ return ( returnType ) Convert . ChangeType ( new Complex ( r , i ) , typeof ( returnType ) ) ;
258+ else
259+ return ( returnType ) Convert . ChangeType ( r , typeof ( returnType ) ) ;
212260 }
213261
214262 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
215- public static Complex MaxAll ( Array arr , out uint idx )
263+ public static Complex MaxAll ( Array arr , out uint idx ) => MaxAll < Complex > ( arr , out idx ) ;
264+
265+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
266+ public static returnType MaxAll < returnType > ( Array arr , out uint idx )
216267 {
217268 double r , i ;
218269 Internal . VERIFY ( AFAlgorithm . af_imax_all ( out r , out i , out idx , arr . _ptr ) ) ;
219- return new Complex ( r , i ) ;
270+ if ( typeof ( returnType ) == typeof ( Complex ) )
271+ return ( returnType ) Convert . ChangeType ( new Complex ( r , i ) , typeof ( returnType ) ) ;
272+ else
273+ return ( returnType ) Convert . ChangeType ( r , typeof ( returnType ) ) ;
220274 }
221275
222276 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
0 commit comments