sarah-quinones / faer-rs

Linear algebra foundation for the Rust programming language
https://faer-rs.github.io
MIT License
1.84k stars 60 forks source link

Any reason why Scale(..) is necessary for Mul and Div? #155

Open blag01 opened 12 hours ago

blag01 commented 12 hours ago

Is your feature request related to a problem? Please describe. I am trying to abstract over several different Matrix types and it's awkward to wrap scalars in Scale(..). I can understand the desire for a separate type for less obvious operations like Add, Sub, etc. but Mul/Div by scalars are mathematically a part of the vector space axioms.

Describe the solution you'd like Ideally, I would just like to be able to write the formulas as in maths, 0.5 * M1 + M2, etc.

Describe alternatives you've considered Maybe haveFrom<E> for Scale<E> and back so generic code can at least rely on this?

Additional context

sarah-quinones commented 11 hours ago

because Mul<Mat<T>> for T is forbidden due to the orphan rule

blag01 commented 9 hours ago

Ah yeah. But this only stops the Mat on RHS case. Are you opposed to adding support for the Mat * T case as a shortcut for scale?