Skip to content

Commit

Permalink
Fix inverse crash (#102)
Browse files Browse the repository at this point in the history
* Added inverse test

* Make larger dimension for inverse test to see if crash triggered on CI

* exactly the same code in a test gives a stack overflow!?

* Increased stack size to make sure tests can work on CI

* Fmt fixes

* Adjusted accuracy of c32 test for CI

* Adjusted accuracy of c32 test for CI

---------

Co-authored-by: Timo Betcke <[email protected]>
  • Loading branch information
mscroggs and tbetcke authored Dec 4, 2024
1 parent 5be4a73 commit 42cf074
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

- uses: actions/checkout@v3
with:
submodules: 'true'
submodules: "true"

- name: Install Clang
run: sudo apt-get install -y libclang-dev
Expand All @@ -51,9 +51,9 @@ jobs:
cargo clippy --examples -- -D warnings
- name: Run unit tests (debug)
run: cargo test --features "mpi,strict"
run: RUST_MIN_STACK=8388608 cargo test --features "mpi,strict"
- name: Run tests (release)
run: cargo test --examples --release --features "mpi,strict"
run: RUST_MIN_STACK=8388608 cargo test --examples --release --features "mpi,strict"
- name: Run examples
run: |
python3 find_examples.py --features "strict"
Expand Down Expand Up @@ -81,5 +81,4 @@ jobs:
run: cargo install cargo-upgrades
- uses: actions/checkout@v3
- name: Check that dependencies are up to date
run:
cargo upgrades
run: cargo upgrades
16 changes: 16 additions & 0 deletions tests/large_matrix.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use rlst::rlst_dynamic_array2;

#[test]
fn inverse_100() {
let size = 100;

let mut mat = rlst_dynamic_array2!(f64, [size, size]);

for index in 0..size {
mat[[index, index]] = 1.0;
}

mat.view_mut()
.into_inverse_alloc()
.expect("Inverse could not be computed.");
}
4 changes: 2 additions & 2 deletions tests/linalg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ macro_rules! impl_inverse_tests {

#[test]
fn [<test_inverse_$scalar>]() {
let n = 4;
let n = 100;

let mut a = rlst_dynamic_array2!($scalar, [n, n]);
let mut b = rlst_dynamic_array2!($scalar, [n, n]);
Expand All @@ -35,7 +35,7 @@ macro_rules! impl_inverse_tests {

impl_inverse_tests!(f64, 1E-12);
impl_inverse_tests!(f32, 5E-6);
impl_inverse_tests!(c32, 5E-6);
impl_inverse_tests!(c32, 5E-5);
impl_inverse_tests!(c64, 1E-12);

macro_rules! impl_lu_tests {
Expand Down

0 comments on commit 42cf074

Please sign in to comment.