lapack_traits/blas/
herk.rs

1use crate::Scalar;
2use cblas::{Layout, Part, Transpose, cherk, zherk};
3use num_complex::Complex32 as c32;
4use num_complex::Complex64 as c64;
5use crate::blas::syrk::Tsyrk;
6
7pub trait Therk : Scalar + Tsyrk{
8    /// Hermitian rank k update
9    /// For real scalars, herk casts Transpose::Conjugate into Transpose::Ordinary and is
10    /// completely equivalent to syrk
11    unsafe fn herk(layout: Layout,
12                   uplo: Part,
13                   trans: Transpose,
14                   n: i32,
15                   k: i32,
16                   alpha: Self::Real,
17                   a: &[Self],
18                   lda: i32,
19                   beta: Self::Real,
20                   c: &mut [Self],
21                   ldc: i32,
22    );
23}
24
25macro_rules! impl_therk_real{
26    ($N: ty) => (
27        impl Therk for $N{
28            #[inline]
29            unsafe fn herk(
30                layout: Layout,
31                uplo: Part,
32                trans: Transpose,
33                n: i32,
34                k: i32,
35                alpha: Self::Real,
36                a: &[Self],
37                lda: i32,
38                beta: Self::Real,
39                c: &mut [Self],
40                ldc: i32
41            )
42            {
43                let real_trans = if let Transpose::Conjugate = trans { Transpose::Ordinary }
44                                 else { trans };
45                <$N>::syrk(layout, uplo, real_trans, n, k, alpha, a, lda, beta, c, ldc)
46            }
47        }
48    )
49}
50
51macro_rules! impl_therk_complex{
52    ($N: ty, $therk: path) => (
53        impl Therk for $N{
54            #[inline]
55            unsafe fn herk(
56                layout: Layout,
57                uplo: Part,
58                trans: Transpose,
59                n: i32,
60                k: i32,
61                alpha: Self::Real,
62                a: &[Self],
63                lda: i32,
64                beta: Self::Real,
65                c: &mut [Self],
66                ldc: i32
67            )
68            {
69                $therk(layout, uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
70            }
71        }
72    )
73}
74
75impl_therk_real!(f32);
76impl_therk_real!(f64);
77impl_therk_complex!(c32, cherk);
78impl_therk_complex!(c64, zherk);