-
-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8651982
commit e8cc257
Showing
6 changed files
with
90 additions
and
15 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
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
7 changes: 7 additions & 0 deletions
7
nalgebra-sparse/tests/unit_tests/left_looking_lu.proptest-regressions
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,7 @@ | ||
# Seeds for failure cases proptest has generated in the past. It is | ||
# automatically read and these particular cases re-run before any | ||
# novel cases are generated. | ||
# | ||
# It is recommended to check this file in to source control so that | ||
# everyone who runs the test benefits from these saved cases. | ||
cc b8e49f3fa66a3568e1c29a47de5f3d2f67866d59b39329e2a0da1537a9c6d584 # shrinks to matrix = CscMatrix { cs: CsMatrix { sparsity_pattern: SparsityPattern { major_offsets: [0, 4, 8, 11, 16, 21], minor_indices: [0, 1, 3, 4, 0, 1, 3, 4, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4], minor_dim: 5 }, values: [1.0, 0.0, 0.0, 0.0, 0.0, 8.445226477445164, 0.0, 5.072108001361104, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 5.072108001361104, 0.0, 0.0, 4.455405910808415] } } |
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,41 @@ | ||
use crate::unit_tests::cholesky::positive_definite; | ||
|
||
use nalgebra_sparse::factorization::LeftLookingLUFactorization; | ||
|
||
use matrixcompare::{assert_matrix_eq, prop_assert_matrix_eq}; | ||
use proptest::prelude::*; | ||
|
||
use nalgebra_sparse::CscMatrix; | ||
|
||
proptest! { | ||
#[test] | ||
fn lu_factorization_correct_for_positive_def_matrices( | ||
matrix in positive_definite() | ||
) { | ||
let lu = LeftLookingLUFactorization::new(&matrix); | ||
|
||
let l = lu.l(); | ||
prop_assert!(l.triplet_iter().all(|(i, j, _)| j <= i)); | ||
let u = lu.u(); | ||
prop_assert!(u.triplet_iter().all(|(i, j, _)| j >= i)); | ||
prop_assert_matrix_eq!(l * u, matrix, comp = abs, tol = 1e-7); | ||
} | ||
} | ||
|
||
#[test] | ||
fn minimized_lu() { | ||
let major_offsets = vec![0, 1, 3, 4, 5, 8]; | ||
let minor_indices = vec![0, 1, 4, 2, 3, 1, 2, 4]; | ||
let values = vec![1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 3.0, 1.0]; | ||
assert_eq!(minor_indices.len(), values.len()); | ||
let mat = CscMatrix::try_from_unsorted_csc_data(5, 5, major_offsets, minor_indices, values); | ||
let mat = mat.unwrap(); | ||
|
||
let lu = LeftLookingLUFactorization::new(&mat); | ||
|
||
let l = lu.l(); | ||
assert!(l.triplet_iter().all(|(i, j, _)| j <= i)); | ||
let u = lu.u(); | ||
assert!(u.triplet_iter().all(|(i, j, _)| j >= i)); | ||
assert_matrix_eq!(l * u, mat, comp = abs, tol = 1e-7); | ||
} |
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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
// factorization tests | ||
mod cholesky; | ||
mod left_looking_lu; | ||
|
||
mod convert_serial; | ||
mod coo; | ||
mod csc; | ||
|