Skip to content

Commit fa4ed55

Browse files
committed
add a new example
1 parent ce07884 commit fa4ed55

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

examples/solve_linear_system.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//-------------------------------------------------------------------------
2+
// @file solve_linear_system.rs
3+
//
4+
// @date 06/27/20 22:43:12
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::matrix6x6::M66;
29+
use static_math::traits::LinearAlgebra;
30+
use static_math::vector6::V6;
31+
32+
fn main() {
33+
34+
let a = m66_new!( 1.0, 1.0, 3.0, 4.0, 9.0, 3.0;
35+
10.0, 10.0, 1.0, 2.0, 2.0, 5.0;
36+
2.0, 9.0, 6.0, 10.0, 10.0, 9.0;
37+
10.0, 9.0, 9.0, 7.0, 3.0, 6.0;
38+
7.0, 6.0, 6.0, 2.0, 9.0, 5.0;
39+
3.0, 8.0, 1.0, 4.0, 1.0, 5.0);
40+
41+
let b = V6::new([0.0, 1.0, 3.0, 0.0, 1.0, 2.0]);
42+
43+
if let Some(inv) = a.inverse() {
44+
let solution = inv * b;
45+
println!("the solution is: {}", solution);
46+
println!("verification: a * solution = b?: {}", a * solution);
47+
println!("b: {}", b);
48+
}
49+
50+
}
51+

0 commit comments

Comments
 (0)