@@ -40,9 +40,17 @@ trait VecMath: Scalar {
4040trait VecMathReal : Sized {
4141 /* Arthmetic */
4242 fn sqr ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
43- fn linear_frac ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
44- fn fmod ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
45- fn remainder ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
43+ fn linear_frac (
44+ a : & [ Self ] ,
45+ b : & [ Self ] ,
46+ scale_a : Self ,
47+ shift_a : Self ,
48+ scale_b : Self ,
49+ shift_b : Self ,
50+ out : & mut [ Self ] ,
51+ ) ;
52+ fn fmod ( a : & [ Self ] , b : & [ Self ] , out : & mut [ Self ] ) ;
53+ fn remainder ( a : & [ Self ] , b : & [ Self ] , out : & mut [ Self ] ) ;
4654
4755 /* Power and Root */
4856 fn inv ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
@@ -51,20 +59,21 @@ trait VecMathReal: Sized {
5159 fn inv_cbrt ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
5260 fn pow2o3 ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
5361 fn pow3o2 ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
54- fn powr ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
55- fn hypot ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
62+ fn powr ( a : & [ Self ] , b : & [ Self ] , out : & mut [ Self ] ) ;
63+ fn hypot ( a : & [ Self ] , b : & [ Self ] , out : & mut [ Self ] ) ;
5664
5765 /* Exponential and Logarithmic */
5866 fn exp2 ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
5967 fn exp10 ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
6068 fn expm1 ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
6169 fn log2 ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
70+ fn log10 ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
6271 fn log1p ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
6372 fn logb ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
6473
6574 /* Trigonometric */
66- fn sin_cos ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
67- fn atan2 ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
75+ fn sin_cos ( theta : & [ Self ] , sin : & mut [ Self ] , cos : & mut [ Self ] ) ;
76+ fn atan2 ( sin : & [ Self ] , cos : & [ Self ] , theta : & mut [ Self ] ) ;
6877
6978 /* Special */
7079 fn erf ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
@@ -84,17 +93,17 @@ trait VecMathReal: Sized {
8493 fn round ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
8594 fn near_by_int ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
8695 fn rint ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
87- fn modf ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
96+ fn modf ( a : & [ Self ] , y : & mut [ Self ] , z : & mut [ Self ] ) ;
8897 fn frac ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
8998
9099 /* Miscellaneous */
91- fn copy_sign ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
92- fn next_after ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
93- fn fdim ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
94- fn fmax ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
95- fn fmin ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
96- fn maxmag ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
97- fn minmag ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
100+ fn copy_sign ( a : & [ Self ] , b : & [ Self ] , out : & mut [ Self ] ) ;
101+ fn next_after ( a : & [ Self ] , b : & [ Self ] , out : & mut [ Self ] ) ;
102+ fn fdim ( a : & [ Self ] , b : & [ Self ] , out : & mut [ Self ] ) ;
103+ fn fmax ( a : & [ Self ] , b : & [ Self ] , out : & mut [ Self ] ) ;
104+ fn fmin ( a : & [ Self ] , b : & [ Self ] , out : & mut [ Self ] ) ;
105+ fn maxmag ( a : & [ Self ] , b : & [ Self ] , out : & mut [ Self ] ) ;
106+ fn minmag ( a : & [ Self ] , b : & [ Self ] , out : & mut [ Self ] ) ;
98107}
99108
100109trait VecMathComplex : Sized {
@@ -128,7 +137,7 @@ macro_rules! impl_binary {
128137 } ;
129138}
130139
131- macro_rules! impl_binary_scalar {
140+ macro_rules! impl_powx {
132141 ( $scalar: ty, $name: ident, $impl_name: ident) => {
133142 fn $name( a: & [ $scalar] , b: $scalar, out: & mut [ $scalar] ) {
134143 assert_eq!( a. len( ) , out. len( ) ) ;
@@ -147,7 +156,7 @@ impl VecMath for f32 {
147156 impl_binary ! ( f32 , div, vsDiv) ;
148157 impl_unary ! ( f32 , sqrt, vsSqrt) ;
149158 impl_binary ! ( f32 , pow, vsPow) ;
150- impl_binary_scalar ! ( f32 , powx, vsPowx) ;
159+ impl_powx ! ( f32 , powx, vsPowx) ;
151160
152161 impl_unary ! ( f32 , exp, vsExp) ;
153162 impl_unary ! ( f32 , ln, vsLn) ;
@@ -177,7 +186,7 @@ impl VecMath for f64 {
177186 impl_binary ! ( f64 , div, vdDiv) ;
178187 impl_unary ! ( f64 , sqrt, vdSqrt) ;
179188 impl_binary ! ( f64 , pow, vdPow) ;
180- impl_binary_scalar ! ( f64 , powx, vdPowx) ;
189+ impl_powx ! ( f64 , powx, vdPowx) ;
181190
182191 impl_unary ! ( f64 , exp, vdExp) ;
183192 impl_unary ! ( f64 , ln, vdLn) ;
@@ -198,6 +207,155 @@ impl VecMath for f64 {
198207 impl_unary ! ( f64 , atanh, vdAtanh) ;
199208}
200209
210+ macro_rules! impl_unary2 {
211+ ( $scalar: ty, $name: ident, $impl_name: ident) => {
212+ fn $name( in_: & [ $scalar] , out1: & mut [ $scalar] , out2: & mut [ $scalar] ) {
213+ assert_eq!( in_. len( ) , out1. len( ) ) ;
214+ assert_eq!( in_. len( ) , out2. len( ) ) ;
215+ let n = in_. len( ) as i32 ;
216+ unsafe { $impl_name( n, in_. as_ptr( ) , out1. as_mut_ptr( ) , out2. as_mut_ptr( ) ) }
217+ }
218+ } ;
219+ }
220+
221+ macro_rules! impl_linearfrac {
222+ ( $scalar: ty, $name: ident, $impl_name: ident) => {
223+ fn $name(
224+ a: & [ $scalar] ,
225+ b: & [ $scalar] ,
226+ scale_a: $scalar,
227+ shift_a: $scalar,
228+ scale_b: $scalar,
229+ shift_b: $scalar,
230+ out: & mut [ $scalar] ,
231+ ) {
232+ assert_eq!( a. len( ) , out. len( ) ) ;
233+ assert_eq!( b. len( ) , out. len( ) ) ;
234+ let n = out. len( ) as i32 ;
235+ unsafe {
236+ $impl_name(
237+ n,
238+ a. as_ptr( ) ,
239+ b. as_ptr( ) ,
240+ scale_a,
241+ shift_a,
242+ scale_b,
243+ shift_b,
244+ out. as_mut_ptr( ) ,
245+ )
246+ }
247+ }
248+ } ;
249+ }
250+
251+ impl VecMathReal for f32 {
252+ impl_unary ! ( f32 , sqr, vsSqr) ;
253+ impl_linearfrac ! ( f32 , linear_frac, vsLinearFrac) ;
254+ impl_binary ! ( f32 , fmod, vsFmod) ;
255+ impl_binary ! ( f32 , remainder, vsRemainder) ;
256+
257+ impl_unary ! ( f32 , inv, vsInv) ;
258+ impl_unary ! ( f32 , inv_sqrt, vsInvSqrt) ;
259+ impl_unary ! ( f32 , cbrt, vsCbrt) ;
260+ impl_unary ! ( f32 , inv_cbrt, vsInvCbrt) ;
261+ impl_unary ! ( f32 , pow2o3, vsPow2o3) ;
262+ impl_unary ! ( f32 , pow3o2, vsPow3o2) ;
263+ impl_binary ! ( f32 , powr, vsPowr) ;
264+ impl_binary ! ( f32 , hypot, vsHypot) ;
265+
266+ impl_unary ! ( f32 , exp2, vsExp2) ;
267+ impl_unary ! ( f32 , exp10, vsExp10) ;
268+ impl_unary ! ( f32 , expm1, vsExpm1) ;
269+ impl_unary ! ( f32 , log2, vsLog2) ;
270+ impl_unary ! ( f32 , log10, vsLog10) ;
271+ impl_unary ! ( f32 , log1p, vsLog1p) ;
272+ impl_unary ! ( f32 , logb, vsLogb) ;
273+
274+ impl_unary2 ! ( f32 , sin_cos, vsSinCos) ;
275+ impl_binary ! ( f32 , atan2, vsAtan2) ;
276+
277+ impl_unary ! ( f32 , erf, vsErf) ;
278+ impl_unary ! ( f32 , erfc, vsErfc) ;
279+ impl_unary ! ( f32 , cdf_normal, vsCdfNorm) ;
280+ impl_unary ! ( f32 , erf_inv, vsErfInv) ;
281+ impl_unary ! ( f32 , erfc_inv, vsErfcInv) ;
282+ impl_unary ! ( f32 , cdf_normal_inv, vsCdfNormInv) ;
283+ impl_unary ! ( f32 , ln_gamma, vsLGamma) ;
284+ impl_unary ! ( f32 , gamma, vsTGamma) ;
285+ impl_unary ! ( f32 , exp_integral, vsExpInt1) ;
286+
287+ impl_unary ! ( f32 , floor, vsFloor) ;
288+ impl_unary ! ( f32 , ceil, vsCeil) ;
289+ impl_unary ! ( f32 , trunc, vsTrunc) ;
290+ impl_unary ! ( f32 , round, vsRound) ;
291+ impl_unary ! ( f32 , near_by_int, vsNearbyInt) ;
292+ impl_unary ! ( f32 , rint, vsRint) ;
293+ impl_unary2 ! ( f32 , modf, vsModf) ;
294+ impl_unary ! ( f32 , frac, vsFrac) ;
295+
296+ impl_binary ! ( f32 , copy_sign, vsCopySign) ;
297+ impl_binary ! ( f32 , next_after, vsNextAfter) ;
298+ impl_binary ! ( f32 , fdim, vsFdim) ;
299+ impl_binary ! ( f32 , fmax, vsFmax) ;
300+ impl_binary ! ( f32 , fmin, vsFmin) ;
301+ impl_binary ! ( f32 , maxmag, vsMaxMag) ;
302+ impl_binary ! ( f32 , minmag, vsMinMag) ;
303+ }
304+
305+ impl VecMathReal for f64 {
306+ impl_unary ! ( f64 , sqr, vdSqr) ;
307+ impl_linearfrac ! ( f64 , linear_frac, vdLinearFrac) ;
308+ impl_binary ! ( f64 , fmod, vdFmod) ;
309+ impl_binary ! ( f64 , remainder, vdRemainder) ;
310+
311+ impl_unary ! ( f64 , inv, vdInv) ;
312+ impl_unary ! ( f64 , inv_sqrt, vdInvSqrt) ;
313+ impl_unary ! ( f64 , cbrt, vdCbrt) ;
314+ impl_unary ! ( f64 , inv_cbrt, vdInvCbrt) ;
315+ impl_unary ! ( f64 , pow2o3, vdPow2o3) ;
316+ impl_unary ! ( f64 , pow3o2, vdPow3o2) ;
317+ impl_binary ! ( f64 , powr, vdPowr) ;
318+ impl_binary ! ( f64 , hypot, vdHypot) ;
319+
320+ impl_unary ! ( f64 , exp2, vdExp2) ;
321+ impl_unary ! ( f64 , exp10, vdExp10) ;
322+ impl_unary ! ( f64 , expm1, vdExpm1) ;
323+ impl_unary ! ( f64 , log2, vdLog2) ;
324+ impl_unary ! ( f64 , log10, vdLog10) ;
325+ impl_unary ! ( f64 , log1p, vdLog1p) ;
326+ impl_unary ! ( f64 , logb, vdLogb) ;
327+
328+ impl_unary2 ! ( f64 , sin_cos, vdSinCos) ;
329+ impl_binary ! ( f64 , atan2, vdAtan2) ;
330+
331+ impl_unary ! ( f64 , erf, vdErf) ;
332+ impl_unary ! ( f64 , erfc, vdErfc) ;
333+ impl_unary ! ( f64 , cdf_normal, vdCdfNorm) ;
334+ impl_unary ! ( f64 , erf_inv, vdErfInv) ;
335+ impl_unary ! ( f64 , erfc_inv, vdErfcInv) ;
336+ impl_unary ! ( f64 , cdf_normal_inv, vdCdfNormInv) ;
337+ impl_unary ! ( f64 , ln_gamma, vdLGamma) ;
338+ impl_unary ! ( f64 , gamma, vdTGamma) ;
339+ impl_unary ! ( f64 , exp_integral, vdExpInt1) ;
340+
341+ impl_unary ! ( f64 , floor, vdFloor) ;
342+ impl_unary ! ( f64 , ceil, vdCeil) ;
343+ impl_unary ! ( f64 , trunc, vdTrunc) ;
344+ impl_unary ! ( f64 , round, vdRound) ;
345+ impl_unary ! ( f64 , near_by_int, vdNearbyInt) ;
346+ impl_unary ! ( f64 , rint, vdRint) ;
347+ impl_unary2 ! ( f64 , modf, vdModf) ;
348+ impl_unary ! ( f64 , frac, vdFrac) ;
349+
350+ impl_binary ! ( f64 , copy_sign, vdCopySign) ;
351+ impl_binary ! ( f64 , next_after, vdNextAfter) ;
352+ impl_binary ! ( f64 , fdim, vdFdim) ;
353+ impl_binary ! ( f64 , fmax, vdFmax) ;
354+ impl_binary ! ( f64 , fmin, vdFmin) ;
355+ impl_binary ! ( f64 , maxmag, vdMaxMag) ;
356+ impl_binary ! ( f64 , minmag, vdMinMag) ;
357+ }
358+
201359macro_rules! impl_unary_c {
202360 ( $scalar: ty, $mkl_complex: ty, $name: ident, $impl_name: ident) => {
203361 fn $name( in_: & [ $scalar] , out: & mut [ $scalar] ) {
0 commit comments