Re: [julia-users] Memory allocation free array slices ?

2016-02-09 Thread Daan Huybrechs
Wow, this trick to add CartesianRange's (or other isbits-immutable-iterators I guess) without allocation was very good to learn about, thanks a lot! Pending more efficient views, this is very helpful to me as well.

Re: [julia-users] Memory allocation free array slices ?

2016-02-08 Thread mschauer
A further possibility is to work with vector of FixedSizeArrays (a julia package). You can cast a dxn array to an n-array of immutable d-FixedSizeVectors (they have the same memory layout) and then access the columns directly using stack allocation (just the same as you would work with a

Re: [julia-users] Memory allocation free array slices ?

2016-02-07 Thread Stefan Karpinski
Being able to stack-allocate objects that refer to the heap is an important case that we need to address, but doing so is non-trivial and hasn't been done yet. On Sunday, February 7, 2016, Tim Holy wrote: > I filed an issue, https://github.com/JuliaLang/julia/issues/14955,

Re: [julia-users] Memory allocation free array slices ?

2016-02-07 Thread Tim Holy
I filed an issue, https://github.com/JuliaLang/julia/issues/14955, which you can check to learn about progress on this problem. Best, --Tim On Saturday, February 06, 2016 03:35:34 PM Nitin Arora wrote: > I see, thanks for the information. I think, if possible, this feature will > help the

Re: [julia-users] Memory allocation free array slices ?

2016-02-07 Thread Nitin Arora
Thanks and Tim and Stefan, if there is anyway I can contribute to help, do let me know. thanks, Nitin On Sunday, February 7, 2016 at 8:24:38 AM UTC-8, Stefan Karpinski wrote: > > Being able to stack-allocate objects that refer to the heap is an > important case that we need to address, but

Re: [julia-users] Memory allocation free array slices ?

2016-02-06 Thread Nitin Arora
I see, thanks for the information. I think, if possible, this feature will help the language a lot. I have recommended Julia to many of my colleagues (they all love it over Fortran and Matlab) and most of them seem to run into this issue. I think, a modern language with soo much elegance and

Re: [julia-users] Memory allocation free array slices ?

2016-02-06 Thread Cedric St-Jean
M1 = rand(7,3) M = view(M1,1:6,1:3) # some memory allocation occurs here a= rand(3) c1 = zeros(6) c =view(c1) # some memory allocation occurs here I don't think that either the M or c line allocates anything (on the heap). ArrayViews are immutables, so they are stack allocated (as far as I can

Re: [julia-users] Memory allocation free array slices ?

2016-02-06 Thread Tim Holy
On Friday, February 05, 2016 05:24:04 PM Nitin Arora wrote: > Thanks Tim, this is very useful. I will probably use CartesianRange now. > > Is Julia 0.5 Arraypocalypse planning to address this issue as well ? I don't think there's a way to solve this by changing our implementation of views; I

Re: [julia-users] Memory allocation free array slices ?

2016-02-05 Thread Kevin Squire
> > julia> @time bar > 0.01 seconds (3 allocations: 144 bytes) > bar (generic function with 1 method) > I think this needs to be @time bar(A). I get julia> @time bar(A) 0.000269 seconds (5 allocations: 176 bytes) 20010.937886591404

Re: [julia-users] Memory allocation free array slices ?

2016-02-05 Thread Tim Holy
On Friday, February 05, 2016 08:17:21 AM Kevin Squire wrote: > I think this needs to be @time bar(A). Yeah, sorry for the typo. > I get > > julia> @time bar(A) > 0.000269 seconds (5 allocations: 176 bytes) > 20010.937886591404 That's just REPL allocation. Since A has 1 columns, if this

Re: [julia-users] Memory allocation free array slices ?

2016-02-05 Thread Tim Holy
I imagine this will be possible some day, but I can't predict when. Currently, if your slices are contiguous (step size 1 in each range), there is in fact another option: encode the slice with a CartesianRange. See http://julialang.org/blog/2016/02/iteration/ Example: julia> function foo(A,

Re: [julia-users] Memory allocation free array slices ?

2016-02-05 Thread Nitin Arora
Thanks Tim, this is very useful. I will probably use CartesianRange now. Is Julia 0.5 Arraypocalypse planning to address this issue as well ? thanks, Nitin On Friday, February 5, 2016 at 3:24:34 PM UTC-8, Tim Holy wrote: > > On Friday, February 05, 2016 08:17:21 AM Kevin Squire wrote: > > I

[julia-users] Memory allocation free array slices ?

2016-02-04 Thread Nitin Arora
Hello, I realize that the current best way to do array slices is to either use ArrayViews or SubArrays. But will it ever be possible (in future) to have slice of contiguous arrays without memory allocation ? How do other compiled languages like Fortran or C deal with this issue ? For