Comments (8)
it's not a user error. i forgot i should be detecting zeros at the head/tail of the matrix during the eigenvalue computation xP
from faer-rs.
Smaller bug witness ($N = 15$ )
let edges = [[2, 0], [6, 4], [7, 0], [8, 4], [9, 8], [10, 0], [11, 0], [12, 4], [13, 5], [13, 11], [13, 3], [14, 1], [14, 3], [14, 4]]
// ...
let correct_lambda_1 = 2.2950716903444595;
from faer-rs.
Smaller bug witness ($N = 8$ )
let edges = [[1, 0], [3, 0], [5, 2], [5, 0], [6, 0], [6, 4], [7, 6]]
// ...
let correct_lambda_1 = 2.2215832939527633;
from faer-rs.
Smaller bug witness ($N = 4$ )
let edges = [[1, 0], [2, 0], [3, 0]];
// [0.0 + 0.0 * I, -inf + 0.0 * I, 0.0 + 0.0 * I, 0.0 + 0.0 * I]
// [0.0, -inf, 0.0, 0.0]
from faer-rs.
Smaller bug witness ($N = 3$ )
let edges = [[1, 0], [0, 2]];
/*
[
[0.0, 1.0, 1.0],
[1.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
]
[0.0 + 0.0 * I, -inf + 0.0 * I, 0.0 + 0.0 * I]
[0.0, -inf, 0.0]
*/
However, after permutation, the values are correct
let edges = [[1, 0], [2, 1]];
/*
[
[0.0, 1.0, 0.0],
[1.0, 0.0, 1.0],
[0.0, 1.0, 0.0],
]
[-1.414213562373094 + 0.0 * I, 5.160802341031001e-17 + 0.0 * I, 1.414213562373095 + 0.0 * I]
[-1.414213562373094, 5.160802341031001e-17, 1.414213562373095]
*/
from faer-rs.
Unit test
#[test]
fn path_on_three_vertices_has_correct_eigenvalues_regardless_of_permutation() {
let all_edges = [
[(1, 0), (2, 0)],
[(2, 1), (1, 0)],
[(2, 1), (2, 0)],
];
let correct_eigenvalues = [2.0f64.sqrt(), 0., -2.0f64.sqrt()];
for edges in all_edges {
let mut a = faer::Mat::zeros(3, 3);
for (v, u) in edges.iter() {
a[(*v, *u)] = 1.0;
a[(*u, *v)] = 1.0;
}
let eigs_complex: Vec<faer::complex_native::c64> = a.eigenvalues();
let mut eigs_real = eigs_complex
.iter()
.map(|e| e.re)
.collect::<Vec<_>>();
eigs_real.sort_by(|a, b| b.partial_cmp(a).unwrap());
let error = correct_eigenvalues.iter().zip(eigs_real.iter()).map(|(a, b)| (a - b).powi(2)).sum::<f64>();
assert!(
error < 1e-10,
"error = {error}\nedges = {edges:?}\na = {a:?}\neigs = {eigs_complex:?}\neigs = {eigs_real:?}",
);
}
}
from faer-rs.
Patching with
const ZERO: f64 = 0.0000001;
let mut a = Mat::from_fn(N, N, |_, _| ZERO);
solve my problem.
If this is user error, feel free to close.
from faer-rs.
fixed in 0.15.0
thanks a bunch!
from faer-rs.
Related Issues (20)
- Does faer use SIMD api ? HOT 1
- `no_std` HOT 2
- Rename fill_with_constant to fill? HOT 2
- Improved ergonomics for `polars_to_faer_fxx`
- A specialized Diagonal type? HOT 2
- IntoNdarray depends on nalgebra feature flag instead of ndarray HOT 2
- Make `rayon` dependency optional? HOT 5
- Error `Assertion failed` when computing eigenvalues for a particular matrix HOT 3
- Specify MSRV HOT 1
- `i32` overflow when calling `Faer::selfadjoint_eigenvalues()` on a `20` x `20` matrix HOT 3
- Bump Polars Version to 0.34 HOT 1
- joss paper plots
- Low Level API with Pre Allocated Work Space Exposed HOT 1
- Implement `Index` for `Col`/`Row`
- Normal math operators can't be used with sparse matrices HOT 2
- PyArray2 into faer to simplify python interfaces to rust routines using faer
- More specific Cholesky error HOT 2
- Methods to read and write matrices from and to CSV
- some missing macros / convenience functions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from faer-rs.