na::partial_cmp is incorrect / confusing
- Dominant language
- Rust
- Stars
- 4.8k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
Was writing some simple code using `nalgebra = "0.32.2"` and came across cases where `partial_cmp` was returning `None`. Is this an actual bug or is there some underlying mathematical "gotcha" where the partial cmp doesn't exist?
```rust
extern crate nalgebra as na;
fn main() {
pub type Pt2 = na::Point2;
// Succeeds
assert!(na::partial_cmp(&Pt2::new(0.0, 0.0), &Pt2::new(0.0, 0.0)).is_some());
assert!(na::partial_cmp(&Pt2::new(0.0, 0.0), &Pt2::new(0.0, 1.0)).is_some());
assert!(na::partial_cmp(&Pt2::new(1.0, 0.0), &Pt2::new(0.0, 0.0)).is_some());
// Fails
assert!(na::partial_cmp(&Pt2::new(1.0, 0.0), &Pt2::new(0.0, 1.0)).is_some());
assert!(na::partial_cmp(&Pt2::new(1.0, 0.0), &Pt2::new(0.0, 2.0)).is_some());
}
```
Edit: looking at the source it seems like it's checking that all axes have the same relationship. This is probably something that should be documented.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.