JuliaLang/julia — pull request #1471 by toivoh (2012-10-29 19:47:56+00:00)
Title: Make more Array methods preserve element type

Some methods for `ref, reverse, transpose` and `ctranspose` are implemented using array comprehensions. This patch changes them to use typed comprehensions, to preserve the element type of the input array. (As do already other methods for these functions.)

I've looked through the comprehensions in array.jl, but I didn't change

./(x::Array, y::Array ) = reshape( [ x[i] ./ y[i] for i=1:numel(x) ], size(x) )
./(x::Number,y::Array ) = reshape( [ x ./ y[i] for i=1:numel(y) ], size(y) )
./(x::Array, y::Number) = reshape( [ x[i] ./ y for i=1:numel(x) ], size(x) )

.^(x::Array, y::Array ) = reshape( [ x[i] ^ y[i] for i=1:numel(x) ], size(x) )
.^(x::Number,y::Array ) = reshape( [ x ^ y[i] for i=1:numel(y) ], size(y) )
.^(x::Array, y::Number) = reshape( [ x[i] ^ y for i=1:numel(x) ], size(x) )

because I wasn't sure what should be done with those. (I'm not sure how easy it is to derive the proper result type for these)