Thanks, it fixed the speed issue right up:
@time threadedGram2(x);
# 0.728811 seconds (117 allocations: 947.766 KiB)
Thanks, it fixed the speed issue right up:
@time threadedGram2(x);
# 0.728811 seconds (117 allocations: 947.766 KiB)
Slightly off topic but I think it would probably be useful to have this in Base:
import Base.zeros
"""
x = rand(Float64, (4,4))
zeros(x)
"""
function zeros(x::AbstractArray)
T = eltype(x)
dim = size(x)
return zeros(T, dim)
end
import Base.ones
"""
x = rand(Float64, (4,4))
ones(x)
"""
function ones(x::AbstractArray)
T = eltype(x)
dim = size(x)
return ones(T, dim)
end
you can simply do:
zero(x)
" Get the additive identity element for the type of `x`"
although, one(x)
would give you identity matrix, not sure if you want that or not (because it’s the multiplicative identity, if not, you can always fill(one(eltype(x)), size(x))
or what you’re already doing.
Thanks. I didn’t know about zero
.