|
| 1 | +//------------------------------------------------------------------------- |
| 2 | +// @file qr_example.rs |
| 3 | +// |
| 4 | +// @date 06/25/20 19:30:44 |
| 5 | +// @author Martin Noblia |
| 6 | +// @email mnoblia@disroot.org |
| 7 | +// |
| 8 | +// @brief |
| 9 | +// |
| 10 | +// @detail |
| 11 | +// |
| 12 | +// Licence: |
| 13 | +// This program is free software: you can redistribute it and/or modify |
| 14 | +// it under the terms of the GNU General Public License as published by |
| 15 | +// the Free Software Foundation, either version 3 of the License, or (at |
| 16 | +// your option) any later version. |
| 17 | +// |
| 18 | +// This program is distributed in the hope that it will be useful, but |
| 19 | +// WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | +// General Public License for more details. |
| 22 | +// |
| 23 | +// You should have received a copy of the GNU General Public License |
| 24 | +//-------------------------------------------------------------------------- |
| 25 | +#[macro_use] |
| 26 | +extern crate static_math; |
| 27 | + |
| 28 | +use static_math::matrix2x2::M22; |
| 29 | +use static_math::matrix3x3::M33; |
| 30 | +use static_math::matrix4x4::M44; |
| 31 | +use static_math::matrix5x5::M55; |
| 32 | +use static_math::matrix6x6::M66; |
| 33 | +use static_math::traits::LinearAlgebra; |
| 34 | + |
| 35 | +fn main() { |
| 36 | + |
| 37 | + let m22 = m22_new!(1.0, 2.0; |
| 38 | + 3.0, 4.0); |
| 39 | + |
| 40 | + let m33 = m33_new!(10.0, -1.0, 2.0; |
| 41 | + 3.0, 3.0, 1.0; |
| 42 | + 1.0, 2.0, 5.0); |
| 43 | + |
| 44 | + let m44 = m44_new!( 0.0, 1.0, 2.0, 3.0; |
| 45 | + 4.0, 0.0, 1.0, 7.0; |
| 46 | + 10.0, 9.0, 10.0, 11.0; |
| 47 | + 12.0, 13.0, 14.0, 15.0); |
| 48 | + |
| 49 | + let m55 = m55_new!(10.0, 1.0, 7.0, 1.0, 5.0; |
| 50 | + 2.0, 4.0, 8.0, 3.0, 2.0; |
| 51 | + 5.0, 1.0, 2.0, 9.0, 10.0; |
| 52 | + 6.0, 9.0, 1.0, 7.0, 3.0; |
| 53 | + 1.0, 8.0, 8.0, 10.0, 5.0); |
| 54 | + |
| 55 | + let m66 = m66_new!( 1.0, 1.0, 3.0, 4.0, 9.0, 3.0; |
| 56 | + 10.0, 10.0, 1.0, 2.0, 2.0, 5.0; |
| 57 | + 2.0, 9.0, 6.0, 10.0, 10.0, 9.0; |
| 58 | + 10.0, 9.0, 9.0, 7.0, 3.0, 6.0; |
| 59 | + 7.0, 6.0, 6.0, 2.0, 9.0, 5.0; |
| 60 | + 3.0, 8.0, 1.0, 4.0, 1.0, 5.0); |
| 61 | + |
| 62 | + if let Some(qr) = m22.qr() { |
| 63 | + println!("q: {}", qr.0); |
| 64 | + println!("r: {}", qr.1); |
| 65 | + println!("m44: {}", qr.0 * qr.1); |
| 66 | + println!("q.det(): {}", qr.0.det()); |
| 67 | + } |
| 68 | + |
| 69 | + if let Some(qr) = m33.qr() { |
| 70 | + println!("q: {}", qr.0); |
| 71 | + println!("r: {}", qr.1); |
| 72 | + println!("m44: {}", qr.0 * qr.1); |
| 73 | + println!("q.det(): {}", qr.0.det()); |
| 74 | + } |
| 75 | + |
| 76 | + if let Some(qr) = m44.qr() { |
| 77 | + println!("q: {}", qr.0); |
| 78 | + println!("r: {}", qr.1); |
| 79 | + println!("m44: {}", qr.0 * qr.1); |
| 80 | + println!("q.det(): {}", qr.0.det()); |
| 81 | + } |
| 82 | + |
| 83 | + if let Some(qr) = m55.qr() { |
| 84 | + println!("q: {}", qr.0); |
| 85 | + println!("r: {}", qr.1); |
| 86 | + println!("m55: {}", qr.0 * qr.1); |
| 87 | + println!("q.det(): {}", qr.0.det()); |
| 88 | + } |
| 89 | + |
| 90 | + if let Some(qr) = m66.qr() { |
| 91 | + println!("q: {}", qr.0); |
| 92 | + println!("r: {}", qr.1); |
| 93 | + println!("m66: {}", qr.0 * qr.1); |
| 94 | + println!("q.det(): {}", qr.0.det()); |
| 95 | + } |
| 96 | + |
| 97 | +} |
0 commit comments