Impl `QR` for `O3`
@@ -2847,8 +2847,42 @@ impl LinearAlgebra for Matrix {
/// QR Decomposition
///
/// Translation of [RosettaCode#Python](https://rosettacode.org/wiki/QR_decomposition#Python)
+ ///
+ /// # Example
+ /// ```
+ /// extern crate peroxide;
+ /// use peroxide::fuga::*;
+ ///
+ /// fn main() {
+ /// let a = ml_matrix("12 -51 4;6 167 -68; -4 24 -41");
+ /// let qr = a.qr();
+ /// let r = ml_matrix("-14 -21 14; 0 -175 70; 0 0 -35");
+ /// #[cfg(feature="O3")]
+ /// {
+ /// assert_eq!(r, qr.r);
+ /// }
+ /// qr.r.print();
+ /// }
+ /// ```
#[allow(non_snake_case)]
fn qr(&self) -> QR {
+ match () {
+ #[cfg(feature="O3")]
+ () => {
+ let opt_dgeqrf = lapack_dgeqrf(self);
+ match opt_dgeqrf {
+ None => panic!("Serious problem in QR decomposition"),
+ Some(dgeqrf) => {
+ let q = dgeqrf.get_Q();
+ let r = dgeqrf.get_R();
+ QR {
+ q,
+ r
+ }
+ }
+ }
+ }
+ _ => {
let m = self.row;
let n = self.col;
@@ -2869,6 +2903,8 @@ impl LinearAlgebra for Matrix {
QR { q, r }
}
+ }
+ }
/// Reduced Row Echelon Form
///
