-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite forward_substitution and back_substitution (#152)
* Add benchmarks for solve_?_triangular * Rewrite forward_substitution with utils::dot This lets us leverage the optimized implementation of dot, and the resulting code is a lot cleaner. Plus, we avoid an unnecessary allocation to boot. * Rewrite back_substitution with utils::dot * Update comments in back_substitution * Remove Any trait bounds for substitution * Remove Any import and restore utils import
- Loading branch information
1 parent
bd67aa6
commit 2239a6f
Showing
4 changed files
with
144 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use test::Bencher; | ||
use rulinalg::matrix::Matrix; | ||
use rulinalg::matrix::BaseMatrix; | ||
|
||
#[bench] | ||
fn solve_l_triangular_100x100(b: &mut Bencher) { | ||
let n = 100; | ||
let x = Matrix::<f64>::identity(n); | ||
b.iter(|| { | ||
x.solve_l_triangular(vector![0.0; n]) | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn solve_l_triangular_1000x1000(b: &mut Bencher) { | ||
let n = 1000; | ||
let x = Matrix::<f64>::identity(n); | ||
b.iter(|| { | ||
x.solve_l_triangular(vector![0.0; n]) | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn solve_l_triangular_10000x10000(b: &mut Bencher) { | ||
let n = 10000; | ||
let x = Matrix::<f64>::identity(n); | ||
b.iter(|| { | ||
x.solve_l_triangular(vector![0.0; n]) | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn solve_u_triangular_100x100(b: &mut Bencher) { | ||
let n = 100; | ||
let x = Matrix::<f64>::identity(n); | ||
b.iter(|| { | ||
x.solve_u_triangular(vector![0.0; n]) | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn solve_u_triangular_1000x1000(b: &mut Bencher) { | ||
let n = 1000; | ||
let x = Matrix::<f64>::identity(n); | ||
b.iter(|| { | ||
x.solve_u_triangular(vector![0.0; n]) | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn solve_u_triangular_10000x10000(b: &mut Bencher) { | ||
let n = 10000; | ||
let x = Matrix::<f64>::identity(n); | ||
b.iter(|| { | ||
x.solve_u_triangular(vector![0.0; n]) | ||
}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters