@@ -106,14 +106,14 @@ trait VecMathReal: Sized {
106
106
fn minmag ( a : & [ Self ] , b : & [ Self ] , out : & mut [ Self ] ) ;
107
107
}
108
108
109
- trait VecMathComplex : Sized {
109
+ trait VecMathComplex : Scalar {
110
110
/* Arthmetic */
111
- fn mulbyconj ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
111
+ fn mul_by_conj ( a : & [ Self ] , b : & [ Self ] , out : & mut [ Self ] ) ;
112
112
fn conj ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
113
- fn arg ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
113
+ fn arg ( in_ : & [ Self ] , out : & mut [ Self :: Real ] ) ;
114
114
115
115
/* Trigonometric */
116
- fn cis ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
116
+ fn cis ( in_ : & [ Self :: Real ] , out : & mut [ Self ] ) ;
117
117
}
118
118
119
119
macro_rules! impl_unary {
@@ -388,6 +388,22 @@ macro_rules! impl_unary_real_c {
388
388
} ;
389
389
}
390
390
391
+ macro_rules! impl_real_unary_c {
392
+ ( $scalar: ty, $mkl_complex: ty, $name: ident, $impl_name: ident) => {
393
+ fn $name( in_: & [ <$scalar as Scalar >:: Real ] , out: & mut [ $scalar] ) {
394
+ assert_eq!( in_. len( ) , out. len( ) ) ;
395
+ let n = in_. len( ) as i32 ;
396
+ unsafe {
397
+ $impl_name(
398
+ n,
399
+ in_. as_ptr( ) as * const <$scalar as Scalar >:: Real ,
400
+ out. as_mut_ptr( ) as * mut $mkl_complex,
401
+ )
402
+ }
403
+ }
404
+ } ;
405
+ }
406
+
391
407
macro_rules! impl_binary_c {
392
408
( $scalar: ty, $mkl_complex: ty, $name: ident, $impl_name: ident) => {
393
409
fn $name( a: & [ $scalar] , b: & [ $scalar] , out: & mut [ $scalar] ) {
@@ -507,3 +523,17 @@ impl VecMath for c64 {
507
523
impl_unary_c ! ( c64, MKL_Complex16 , asinh, vzAsinh) ;
508
524
impl_unary_c ! ( c64, MKL_Complex16 , atanh, vzAtanh) ;
509
525
}
526
+
527
+ impl VecMathComplex for c32 {
528
+ impl_binary_c ! ( c32, MKL_Complex8 , mul_by_conj, vcMulByConj) ;
529
+ impl_unary_c ! ( c32, MKL_Complex8 , conj, vcConj) ;
530
+ impl_unary_real_c ! ( c32, MKL_Complex8 , arg, vcArg) ;
531
+ impl_real_unary_c ! ( c32, MKL_Complex8 , cis, vcCIS) ;
532
+ }
533
+
534
+ impl VecMathComplex for c64 {
535
+ impl_binary_c ! ( c64, MKL_Complex16 , mul_by_conj, vzMulByConj) ;
536
+ impl_unary_c ! ( c64, MKL_Complex16 , conj, vzConj) ;
537
+ impl_unary_real_c ! ( c64, MKL_Complex16 , arg, vzArg) ;
538
+ impl_real_unary_c ! ( c64, MKL_Complex16 , cis, vzCIS) ;
539
+ }
0 commit comments