-
-
Notifications
You must be signed in to change notification settings - Fork 468
-
-
Notifications
You must be signed in to change notification settings - Fork 468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Add<&Self> for all types #145
Comments
Do you have an example where such performance gains can be observed ? I tend to think that llvm would manage to inline the addition whenever the cost of copying (and function call) could be an issue. |
You're right, in the few cases I tried, LLVM did a good job of optimizing the copying away. I still think this might be good to add for a few reasons.
I don't see any downsides of adding this, and while the upsides are minor, they're not trivial. |
👍 This would be useful for large |
It looks like the standard library does implement |
Fixed by #218. |
Did I miss some impl in the docs? log:
code excerpt: // type declaration from function signature: filter_coefs: &'a mut DVector<f64>, signal: &'a [f64]
//
let sig_slice: &'a _ = &signal[sig_ind..slice_end];
let sig_sub = DVector::from_column_slice(1, sig_slice);
let cur_err = signal[sig_ind] - filter_coefs.dot(&sig_sub);
filter_coefs = filter_coefs + step_size * cur_err * sig_sub.clone() / sig_sub.dot(&sig_sub); nalgebra = "0.12.0" Fixable by iterating through the inds, but that seems sad: let delta = step_size * cur_err * sig_sub.clone() / sig_sub.dot(&sig_sub);
for ind in 0..filter_coefs.len() {
filter_coefs[ind] += delta[ind]
} |
This must be because you are using a mutable reference. The following should work (note the
|
This would allow adding a
Vec3
with a&Vec3
. This will help reduce unnecessary copies, which in some cases can lead to non-trivial performance gains.The text was updated successfully, but these errors were encountered: