Hi Steven and Daniel, thank you so much for the corrections and suggestions!
> On Sep 2, 2016, at 9:17 AM, Steven G. Johnson wrote:
>
> Try:
>
> function foo_old!(a)
> for i in 1:size(a, 2)
> a[:, i] /= norm(a[:, i])
> end
> return a
> end
>
>
Try:
function foo_old!(a)
for i in 1:size(a, 2)
a[:, i] /= norm(a[:, i])
end
return a
end
function foo_new!(a)
for i in 1:size(a, 2)
s = zero(eltype(a))
@simd for j = 1:size(a,1)
@inbounds s += abs2(a[j, i])
end
scale_factor = 1
Yeah, that’s what I figured, I don’t even need the sin()
julia> f() = 42
f (generic function with 1 method)
julia> @time f()
0.001347 seconds (141 allocations: 10.266 KB)
42
julia> @time f()
0.02 seconds (4 allocations: 160 bytes)
42
julia> @time f()
0.02 seconds (4 allocations:
On Fri, Sep 2, 2016 at 7:41 AM, Mauro wrote:
> On Fri, 2016-09-02 at 13:34, Jong Wook Kim wrote:
> > Hi Yichao, what a nice idea :)
> >
> > But even if I write in the C++ way, @time sqrt(1) yields 5 allocations
> of 176
> > bytes, and in inner loops this
On Fri, 2016-09-02 at 13:34, Jong Wook Kim wrote:
> Hi Yichao, what a nice idea :)
>
> But even if I write in the C++ way, @time sqrt(1) yields 5 allocations of 176
> bytes, and in inner loops this could be a bottleneck.
Those are just allocations for the return value of sqrt.
Hi Yichao, what a nice idea :)
But even if I write in the C++ way, @time sqrt(1) yields 5 allocations of 176
bytes, and in inner loops this could be a bottleneck.
Is this an inevitable overhead of using ccall, or is it just a bogus that I can
ignore?
Jong Wook
> On Sep 2, 2016, at 7:14 AM,
On Fri, Sep 2, 2016 at 7:03 AM, Jong Wook Kim wrote:
> Hi,
>
> I'm using Julia 0.4.6 on OSX El Capitan, and was trying to normalize each
> column of matrix, so that the norm of each column becomes 1. Below is a
> isolated and simplified version of what I'm doing:
>
> function
Hi,
I'm using Julia 0.4.6 on OSX El Capitan, and was trying to normalize each
column of matrix, so that the norm of each column becomes 1. Below is a
isolated and simplified version of what I'm doing:
function foo1()
local a = rand(1000, 1)
@time for i in 1:size(a, 2)
a[:,