JuliaLang/julia — pull request #5042 by stevengj (2013-12-06 03:42:30+00:00)
Title: RFC: allow scale(b,A) or scale(A,b) when b is a scalar as well as a vector

We allow `scale(b,A)` and `scale(A,b)` when `A` is a matrix and `b` is a vector, but not when `b` is a scalar. It seems more consistent, especially since `scale(a,b)` behaves very similarly to `a .* b`, to allow either the first or second argument to be the scalar. (This is helpful to me because otherwise I always forget which argument is the scalar and have to look it up in the manual.) Similarly for `scale!`.

Also, `scale(A, b::Number)` was somewhat overtyped; there is no reason to restrict it to arrays of numbers, since you should be able to scale anything that supports multiplication by `b` (e.g. arrays of matrices).

Finally, I rewrote the documentation a bit, both to shorten it and to make the documentation for `scale!` more helpful (this involves a bit of repetition of the `scale` help, but previously `help(scale!)` was basically useless).