mdarray_linalg_faer/qr/
context.rs1use super::simple::qr_faer;
10use faer_traits::ComplexField;
11use mdarray::{DSlice, DTensor, Layout, tensor};
12use mdarray_linalg::identity;
13use mdarray_linalg::qr::QR;
14use num_complex::ComplexFloat;
15
16use crate::Faer;
17
18impl<T> QR<T> for Faer
19where
20 T: ComplexFloat
21 + ComplexField
22 + Default
23 + std::convert::From<<T as num_complex::ComplexFloat>::Real>
24 + 'static,
25{
26 fn qr<L: Layout>(&self, a: &mut DSlice<T, 2, L>) -> (DTensor<T, 2>, DTensor<T, 2>) {
28 let (m, n) = *a.shape();
29 let mut q_mda = identity(m);
30 let mut r_mda = tensor![[T::default(); n]; m];
31
32 qr_faer(a, Some(&mut q_mda), &mut r_mda);
33 (q_mda, r_mda)
34 }
35
36 fn qr_overwrite<L: Layout, Lq: Layout, Lr: Layout>(
38 &self,
39 a: &mut DSlice<T, 2, L>,
40 q: &mut DSlice<T, 2, Lq>,
41 r: &mut DSlice<T, 2, Lr>,
42 ) {
43 qr_faer::<T, L, Lq, Lr>(a, Some(q), r)
44 }
45}