Skip to content
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

Changed meaning of .*= in Julia 0.5 #1

Closed
stevengj opened this issue Jul 22, 2016 · 1 comment
Closed

Changed meaning of .*= in Julia 0.5 #1

stevengj opened this issue Jul 22, 2016 · 1 comment

Comments

@stevengj
Copy link

stevengj commented Jul 22, 2016

Your test code uses x .*= y, so you should know that in Julia 0.5 this has changed meaning to be equivalent to broadcast!(identity, x, x .* y), so that it mutates the x array (see JuliaLang/julia#17510 … in Julia 0.6 the whole operation will occur in-place without temporaries). So .* should only be used if the left-hand side is a mutable array, and you don't mind mutating it.

At first glance, this looks like it is okay for you, because you use it in psi.data[i] .*=, where psi.data seems like an array that intend to mutate. But if it were a problem you could always change it to *=. For a scalar multiplication like this, in any case, *= is probably more efficient.

Note, however, that there is currently a bug in Julia 0.5, and psi.data[i] .*= won't work correctly until JuliaLang/julia#17546 is merged.

@bastikr
Copy link
Member

bastikr commented Nov 16, 2016

Thanks for the heads up! The place where this happens is dead code anyway but I still changed it.

@bastikr bastikr closed this as completed Nov 16, 2016
bastikr added a commit that referenced this issue Mar 31, 2017
sd109 referenced this issue in sd109/QuantumOptics.jl Apr 12, 2021
* 🐎 faster and more concise check for unique embedding indices

* 🎨 more conventional conditional return

* 🎨 more consise type checking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants