lapack_traits/lapack/
geqrf.rs

1use crate::Scalar;
2use lapacke::{Layout,
3              sgeqrf, dgeqrf, cgeqrf, zgeqrf,
4              sorgqr, dorgqr, cungqr, zungqr};
5use num_complex::Complex32 as c32;
6use num_complex::Complex64 as c64;
7
8pub trait Tgeqrf: Scalar {
9    unsafe fn geqrf(layout: Layout,
10             m: i32,
11             n: i32,
12             a: &mut [Self],
13             lda: i32,
14             tau: &mut [Self]) -> i32;
15
16    unsafe fn ungqr(layout: Layout,
17             m: i32,
18             n: i32,
19             k: i32,
20             a: &mut [Self],
21             lda: i32,
22             tau: &[Self]) -> i32;
23}
24
25macro_rules! impl_tgeqrf(
26($N: ty, $tgeqrf: path, $torungqr: path) => (
27        impl Tgeqrf for $N{
28            #[inline]
29            unsafe fn geqrf(
30                layout: Layout,
31                m: i32,
32                n: i32,
33                a: &mut [Self],
34                lda: i32,
35                tau: &mut [Self]) -> i32
36            {
37                    $tgeqrf(layout, m, n, a, lda, tau)
38            }
39
40            unsafe fn ungqr(
41                layout: Layout,
42                m: i32,
43                n: i32,
44                k: i32,
45                a: &mut [Self],
46                lda: i32,
47                tau: &[Self]) -> i32
48            {
49                    $torungqr(layout, m, n, k, a, lda, tau)
50            }
51        }
52    )
53);
54
55impl_tgeqrf!(f32, sgeqrf, sorgqr);
56impl_tgeqrf!(f64, dgeqrf, dorgqr);
57impl_tgeqrf!(c32, cgeqrf, cungqr);
58impl_tgeqrf!(c64, zgeqrf, zungqr);
59