Closed wisp3rwind closed 3 months ago
that looks like a bug, i'll look into it this weekend
found the issue, seems to be due a comparison where im checking if values can be truncated to zero, and instead of comparing e < eps * sqrt(a * b)
, i was doing e < eps * sqrt(a + b)
published a fix in 0.19.1 on crates.io. lemme know if this fixes the issue on your side
Yes, looks like this fixes both the minimized reproducer as well as the original code. Thanks for the quick fix!
Describe the bug I'm encountering incorrect results of
selfadjoint_eigenvalues
andselfadjoint_eigendecomposition
. This is sensitive to the row/column ordering and the size of the matrix, as seen in the example below, where results change after re-ordering rows and columns.To Reproduce Steps to reproduce the behavior:
Reproducer
```rust use faer::{ prelude::*, ComplexField, perm::PermRef, dyn_stack::{GlobalPodBuffer, PodStack}, reborrow::ReborrowMut, }; use faer_ext::IntoNdarray; use ndarray_linalg::{EigValsh, UPLO}; use itertools::iproduct; fn make_perm(n: usize, x: usize, y: usize, z: usize) -> faer::perm::PermOutput
``` x [src/bin/faer_debug.rs:81:5] ex = [ 134.35681418431935, 135.177783778977, 135.71494078360752, 136.83815974377552, 136.83815974534346, 136.90812033100278, 136.9081205343555, 136.91034135407693, 136.91034135407693, 136.91430263263163, 136.91916394454478, 137.1666010493402, 137.17949833298053, 137.18352329745693, 137.31880708244452, 138.70927332950305, 138.7947565653805, 139.25129195618356, ] [src/bin/faer_debug.rs:82:5] exn.as_slice().unwrap() = [ 130.56674808283776, 134.20758866645116, 134.20758866645124, 136.8381597394066, 136.83815973940665, 136.90812016196418, 136.90812016196426, 136.9103413540768, 136.91034135407685, 136.9191641195197, 136.91916411951976, 137.1616717609603, 137.1793172918463, 137.18375967607145, 137.32368052118662, 140.2166259585811, 140.21662595858112, 142.58482266709748, ] y [src/bin/faer_debug.rs:84:5] ey = [ 130.56674808283785, 134.2075886664512, 134.20758866645127, 136.8381597394067, 136.83815973940676, 136.90812016196435, 136.90812016196452, 136.91034135407682, 136.91034135407693, 136.91916411951973, 136.91916411951996, 137.16167176096053, 137.1793172918464, 137.18375967607173, 137.32368052118667, 140.21662595858103, 140.21662595858115, 142.5848226670974, ] [src/bin/faer_debug.rs:85:5] eyn.as_slice().unwrap() = [ 130.5667480828378, 134.20758866645127, 134.2075886664513, 136.8381597394067, 136.8381597394067, 136.90812016196423, 136.90812016196426, 136.9103413540767, 136.91034135407682, 136.91916411951982, 136.91916411951982, 137.16167176096044, 137.17931729184647, 137.18375967607162, 137.3236805211866, 140.21662595858106, 140.21662595858115, 142.58482266709746, ] z [src/bin/faer_debug.rs:87:5] ez = [ 130.56674808283793, 134.2075886664514, 134.20758866645144, 136.83815973940685, 136.83815973940696, 136.90812016196423, 136.90812016196435, 136.91034135407696, 136.91034135407702, 136.9191641195197, 136.91916411951988, 137.16167176096025, 137.17931729184622, 137.18375967607116, 137.32368052118647, 140.21662595858115, 140.21662595858123, 142.58482266709768, ] [src/bin/faer_debug.rs:88:5] ezn.as_slice().unwrap() = [ 130.56674808283768, 134.20758866645124, 134.20758866645133, 136.83815973940668, 136.83815973940673, 136.9081201619642, 136.90812016196432, 136.91034135407682, 136.91034135407685, 136.91916411951982, 136.91916411951982, 137.1616717609604, 137.1793172918463, 137.18375967607145, 137.32368052118653, 140.21662595858106, 140.21662595858112, 142.58482266709743, ] ```Observe that the eigenvalues are not the same in all cases (for what it's worth, it appears that their sum (i.e. the trace of the matrix) is in fact identical in all cases).
Expected behavior Eigenvalues are identical in all cases.
Desktop (please complete the following information):