-
Notifications
You must be signed in to change notification settings - Fork 84
test cholesky_solve ... FAILED #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Error in #98 thread 'rcond' panicked at 'called `Result::unwrap()` on an `Err` value: 0.23086353780922303'
|
If it helps, this is an instance problem that always fails. Copied from the cholesky test, but without randomness: use ndarray::{arr1,arr2};
#[test]
fn cholesky_solve_fail() {
let a: Array2<f64> = arr2(&[[2.7518138512052546, 0.0, 0.0],
[-3.0030534432813334, 0.5503895871967794, 0.0],
[0.0, 0.0, 0.4472135954999579]]);
let x: Array1<f64> = arr1(&[-0.3633966736383765772089, -9.2503560214093027980198, 0.0]);
let b = a.dot(&x);
println!("a = \n{:#?}", a);
println!("x = \n{:#?}", x);
println!("b = \n{:#?}", b);
println!("Solution = \n{:#?}", &a.solvec(&b).unwrap());
assert_close_l2!(&a.solvec(&b).unwrap(), &x, 1e-9);
assert_close_l2!(&a.solvec_into(b.clone()).unwrap(), &x, 1e-9);
assert_close_l2!(&a.solvec_inplace(&mut b.clone()).unwrap(), &x, 1e-9);
assert_close_l2!(&a.factorizec(UPLO::Upper).unwrap().solvec(&b).unwrap(), &x, 1e-9);
assert_close_l2!(&a.factorizec(UPLO::Lower).unwrap().solvec(&b).unwrap(), &x, 1e-9);
assert_close_l2!(&a.factorizec(UPLO::Upper).unwrap().solvec_into(b.clone()).unwrap(), &x, 1e-9);
assert_close_l2!(&a.factorizec(UPLO::Lower).unwrap().solvec_into(b.clone()).unwrap(), &x, 1e-9);
assert_close_l2!(&a.factorizec(UPLO::Upper).unwrap().solvec_inplace(&mut b.clone()).unwrap(), &x, 1e-9);
assert_close_l2!(&a.factorizec(UPLO::Lower).unwrap().solvec_inplace(&mut b.clone()).unwrap(), &x, 1e-9);
} Output:
First (and third) component are OK though. |
@davenza Thanks for taking a look at this. This particular example fails because This does bring up another question: In this particular example, a bad value is returned since |
@jturner314 Thanks, I didn't notice the symmetric requirement. I was trying to do a different thing, and I think I misunderstood the documentation. I had a covariance matrix (not created with random_hpd), let's call [7.572479471685095, -8.263844061131207, 0.0] I found the lower cholesky decomposition [2.7518138512052546, 0.0, 0.0] Then, I tried to solve Lx = [1 4 0] using solvec. However, related with the problem: while I was doing some cargo test runs, I sometimes had errors. I could try to reproduce the errors again, printing a failing matrix if it is interesting to you. |
Fwiw, if you need both the triangular factor ( Regarding the test failures: I think they're due to floating-point errors. (In the cases I've observed the tests failing, the errors have always been pretty small. If you see a case where the error is large, please post it here.) One idea to minimize issues associated with floating-point errors in the tests is to throw out randomly-generated matrices that are ill-conditioned (and generate new ones that are well-conditioned), but I haven't had a chance to try this. |
In two of my executions of the cholesky_solve() test, the test failed with these matrices: Fail 1---- cholesky_solve stdout ---- Fail 2 (with backtrace)---- cholesky_solve stdout ---- It seems that both failures happen with the f32 type and due to floating-point errors, as you said. |
It will be a right way. Since the implementations of LAPACK are trusted, we do not have to check the singular cases. |
Sometimes this test fails
https://app.wercker.com/termoshtt/ndarray-linalg/runs/test-openblas/59f195128e888f0001cf3ef5?step=59f19584791109000146172c
The text was updated successfully, but these errors were encountered: