sarah-ek / faer-rs

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

add implement add for Mat<T> (#6) #14

Closed MasahiroKato71 closed 1 year ago

MasahiroKato71 commented 1 year ago

implement addition for Mat, about core::ops::Add.

sarah-ek commented 1 year ago

hi! thank you for your contribution. the code looks good, and i love the test coverage. the one thing i would change is replace shape check + panic if mismatch with an assert

the fancy_assert macro gives pretty good diagnostics so you could write

fancy_assert!((self.nrows(), self.ncols()) == (rhs.nrows(), rhs.ncols()));

what do you think?

MasahiroKato71 commented 1 year ago

Hi! Thank you for your review. Using 'fancy_assert' macro is very clear and convenient. Not only can it be used for testing, but it can also be used for error handling! It would be better to access the field through the getter like you do. I'll try it.

sarah-ek commented 1 year ago

this looks great! i'll go ahead and merge it