In this example the single allocation is when I create A? I.e. when I manipulate this inside the function ‘foo’ is this assigned a new block of memory or not?
function Foo!(X)
X.=X./2
return(X)
end
function FooLoop!(X)
for i=1:length(X)
X[i]= X[i]/2
end
return(X)
end
function TestFooAllocs()
A=[1. 2. 3.];
@time A=Foo!(A);
end
function TestFooLoopAllocs()
A=[1. 2. 3.];
@time A=FooLoop!(A);
end
TestFooAllocs()
TestFooLoopAllocs()