The prop_assert* macros clean-up the assertion output by eliminating the extra panics while it’s reducing inputs.
Signed-off-by: Stephen Waits <steve@waits.net>
- Use array-init for the lowest level vector operations. Makes them nicer and less bug-prone, with zero performance impact.
- Remove unnecessary/unused ::new() functions on Vector and HeightVector.
- Update README with new dependency.
- Fix typo in README.
Signed-off-by: Stephen Waits <steve@waits.net>
- eliminated `f64` feature because Cargo doesn’t understand mutually exclusive features. So, we default to `f64`, and leave the `f32` feature there if people want to change to that.
- integrated tarpaulin for coverage
- added tests to get to 100% coverage
- fixed NetworkCoordinate Div impl safety checks (now acts like Add and Sub)
- update README to explain cargo feature change
- cleanup build script with the new simpler features model
Signed-off-by: Stephen Waits <steve@waits.net>
Realized about a 10x speedup.
- add benches/million-updates.rs
- optimization: use rand instead of nanorand (because of thread_rng() initialization being muchf aster)
- update README
Signed-off-by: Stephen Waits <steve@waits.net>
- add clippy to .build.yml to run on sr.ht
- add missing docs
- use core:: instead of std:: where possible
- use hypot() and mul_add() for better numeric stability
- make all float tests use asser_approx_eq() and explicitly check for NaN/Inf
- add missing semicolons here and there
- add #[must_use] to ensure caller uses returned value
- add const fn where appropriate
- change visibility from pub(crate) to pub (in private modules)
Signed-off-by: Stephen Waits <steve@waits.net>
This just adds a few type aliases for convenience, and slightly better ergonomics for the most common usage (2D or 3D).
Signed-off-by: Stephen Waits <steve@waits.net>
Goal: To make the serialization format more sensible instead of it being a reflection of our internal (ie private) data model.
- mostly handled with #[serde()] macros (renaming, flattening)
- renamed NetworkCoordinate::position to heightvec which is a better name, even if not seen in the published interface
- changed HeightVector from a tuple struct to a named struct so we can control serde on a field-by-field basis
- updated README, tests, and doc tests to match
Signed-off-by: Stephen Waits <steve@waits.net>
Made `HeightVector` numerically safe; while `Vector` remains numerically unsafe (i.e. it can divide by 0, NaN, Inf, etc).
When HeightVector runs into a problem, it just re-randomizes itself. Since the algorithm converges relatively quickly, this seems to work fine.
Also fixed a bug so that now height will always start as a positive number (and stay that way, else get re-randomized).
Added safety to `NetworkCoordinate` which now checks that its error didn’t pull a `HeightVector` into a negative height; in which case it also re-randomizes.
Clarified the `random` construction, tweaked the DEFAULT_ERROR constant, and updated tests accordingly.
Signed-off-by: Stephen Waits <steve@waits.net>
- public NetworkCoordinate so it’s easer to just `use vivaldi_nc::NetworkCoordinate`
- add module level docs and examples in lib.rs
- cleanup README
Signed-off-by: Stephen Waits <steve@waits.net>
Adds serialization/deserialization support via serde and serde_with.
Also:
- remove `license-file` in Cargo.toml (superfluous)
- update README with Getting Started section
- add `serde` and `serde_with` dependencies to README
- add tests to `HeightVector`
- tweak assertion in `NetworkCoordinate`
- refactor `Vector` to be a struct witn an `inner` instead of a tuple struct so that we can use `serde_as` (from `serde_with`) to help us derive SerDe implementations for the const generic sized array
- moved trait requirements (which are getting long) into where clauses
Signed-off-by: Stephen Waits <steve@waits.net>