-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Feature request: overloadable updating operators #3217
Comments
In the mean time, (similar in spirit to |
I've always thought not having this was an oversight, but when I asked someone about it, apparently it didn't play nice with type inference? Not sure. But if it is indeed not possible, would be good to document why. |
Nope, it's totally possible and would have no effect on type inference. What we didn't like about it is that it has to work on both mutable and immutable types (e.g. both arrays and numbers). The expression |
Ah I see, that does make sense. Just enough rope to hang oneself... |
As far as I can see,
+=
and the other updating operators are not handled via overloadable methods. For example,A += B
results inA = +(A,B)
. There is considerable scope for performance gains, especially for matrices, if one could tailor the behaviour of +=. As an example, consider the case ofA += B
, where both are1000 by 1000
matrices. I get (total elapsed time for 100 such operations) on an 8-core machine:A+=B
: 1sLinalg.BLAS.axpy!(1.0,A,B)
: 0.02s(The advantage of 2 over 1 is that it does not have to allocate a temporary matrix to accomodate the sum. The advantage of 3 over 2 is multiple threads and whatever other magic BLAS does.)
The text was updated successfully, but these errors were encountered: