ArrayViews might do what you are after:
https://github.com/JuliaLang/ArrayViews.jl
Kaj
On Wednesday, July 15, 2015 at 1:14:14 PM UTC+3, Ferran Mazzanti wrote:
>
> Hi folks,
>
> I have a little mess with the way arrays are being handled in Julia. I
> come from C and fortran95 and I know I can do the following things there
> using pointers: imagine I have a big array A. Then I can use pointers to
> define W a subsection of A, such that if I modify W then A is modified, and
> if I modify A then W is modified. In this way I have one and the same data,
> which I can manipulate by acting on A or on W.
>
> I'd like to do the same thing in Julia, but don't know how. Somehow it
> works if I use the whole array. For instance in this exemple:
>
> Wall = ones(2,2)
> 1.0 1.0
> 1.0 1.0
>
> W = Wall
> 1.0 1.0
> 1.0 1.0
>
> W[1,1] = 0.
> 0.0
>
> Wall
> 2x2 Array{Float64,2}:
> 0.0 1.0
> 1.0 1.0
>
> Wall[1,2] = 2.
> 0.0 2.0
> 1.0 1.0
>
> W
> 2x2 Array{Float64,2}:
> 0.0 2.0
> 1.0 1.0
>
> ...so it works both ways. That's exactly what I want, but now not just
> with W and Wall being the same, but with W being a part of Wall.
> I could try something like
>
> Wall = ones(3,3)
> 3x3 Array{Float64,2}:
> 1.0 1.0 1.0
> 1.0 1.0 1.0
> 1.0 1.0 1.0
>
> W = Wall[2:end,2:end]
> 1.0 1.0
> 1.0 1.0
>
> W[1,1] = 3.
> 3.0
>
> W
> 2x2 Array{Float64,2}:
> 3.0 1.0
> 1.0 1.0
>
> Wall
> 3x3 Array{Float64,2}:
> 1.0 1.0 1.0
> 1.0 1.0 1.0
> 1.0 1.0 1.0
>
> ...so W has been updated but not Wall. If I update W itdoesn't get copied
> to Wall either.
>
> So I know how to do automatic updating when the two arrays are of the same
> size, but can it be done with subsections of arrays as (I want it to be) in
> the example above?
>
> Thanks for your help and patience,
>
> Ferran.
>