rust-num / num-traits

Numeric traits for generic mathematics in Rust
Apache License 2.0
732 stars 135 forks source link

Add traits for generic norms and distances #130

Open Nuramon27 opened 5 years ago

Nuramon27 commented 5 years ago

This is the implementation mentioned in #121. Regarding the issue that there are many possible norms for a certain type (see comment https://github.com/rust-num/num-traits/issues/121#issuecomment-526777142 ): I think these traits would only be intended to be implemented on very basic types for which there is some notion of a standard norm, like the absolute value on floating point numbers and the euclidean norm on complex numbers and one-dimensional arrays.

Indeed in the meantime I started working a separate crate Norman which handles exactly this issue and provides a set of different norms on a single type.

I hoped that both might go well with each other: having num-traits for a simple answer to the question “how far are these two vectors apart” and a dedicated crate if full control is necessary over how this distance is calculated.

jsmith628 commented 5 years ago

You could check out my maths-traits crate. While it doesn't currently have impls for the structs in the num collection, there are norm, metric, and inner product traits, and I'd be open to contributions or feature requests.