@@ -106,14 +106,14 @@ trait VecMathReal: Sized {
106106 fn minmag ( a : & [ Self ] , b : & [ Self ] , out : & mut [ Self ] ) ;
107107}
108108
109- trait VecMathComplex : Sized {
109+ trait VecMathComplex : Scalar {
110110 /* Arthmetic */
111- fn mulbyconj ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
111+ fn mul_by_conj ( a : & [ Self ] , b : & [ Self ] , out : & mut [ Self ] ) ;
112112 fn conj ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
113- fn arg ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
113+ fn arg ( in_ : & [ Self ] , out : & mut [ Self :: Real ] ) ;
114114
115115 /* Trigonometric */
116- fn cis ( in_ : & [ Self ] , out : & mut [ Self ] ) ;
116+ fn cis ( in_ : & [ Self :: Real ] , out : & mut [ Self ] ) ;
117117}
118118
119119macro_rules! impl_unary {
@@ -388,6 +388,22 @@ macro_rules! impl_unary_real_c {
388388 } ;
389389}
390390
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+
391407macro_rules! impl_binary_c {
392408 ( $scalar: ty, $mkl_complex: ty, $name: ident, $impl_name: ident) => {
393409 fn $name( a: & [ $scalar] , b: & [ $scalar] , out: & mut [ $scalar] ) {
@@ -507,3 +523,17 @@ impl VecMath for c64 {
507523 impl_unary_c ! ( c64, MKL_Complex16 , asinh, vzAsinh) ;
508524 impl_unary_c ! ( c64, MKL_Complex16 , atanh, vzAtanh) ;
509525}
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