Hi,

Tim Holy <tim.h...@gmail.com> writes:
> That document is aimed at developers to tell them how to make their package
> ready for arrays that have custom indices. As a user, the key line is:
>
>> Such array types are expected to be supplied through packages.
>
> I recommend the OffsetArrays package.
>
> Great to see someone interested in trying this. Definitely report any bugs you
> find; as Isaiah said, this is still experimental functionality, and many
> packages probably aren't fully ready yet. It will mostly take users who want
> that functionality to notice where it needs to be added.

OK, great, I just tried the example of my first mail, and things seem to
work OK. For my use case, obviously not as convenient as the native
support of Fortran, but great that it works. If I find things that don't
work I will let you know. For the moment, from my brief testing, the
only thing I found is that something like mg[:,:] = 0 raises an error,
as you can see below (due to its dependence on "size").

Thanks a lot (Julia looks like a great language with a great
community! :-) )

,----
| julia> m=rand(1:10,(3,3))
| 3×3 Array{Int64,2}:
|  4   1  3
|  4  10  9
|  8   6  6
| 
| julia> mg=OffsetArray(Int,0:4,0:4)
| OffsetArrays.OffsetArray{Int64,2,Array{Int64,2}} with indices 0:4×0:4:
|  140473481981296  140473483139344  140473481980240  140473481980528  
140473481980752
|  140473481981392  140473483138224  140473481980304  140473481980592  
140473481980784
|  140473481981456  140473481979952  140473481980432  140473481980624  
140473481980816
|  140473481981520  140473481979984  140473481980464  140473481980656  
140473481980848
|  140473481981648  140473481980208  140473481980496  140473481980720  
140473481980880
| 
| julia> mg[:,:]=0
| ERROR: size not supported for arrays with indices (0:4,0:4); see 
http://docs.julialang.org/en/latest/devdocs/offset-arrays/
|  in errmsg(::OffsetArrays.OffsetArray{Int64,2,Array{Int64,2}}) at 
/home/angelv/.julia/v0.5/OffsetArrays/src/OffsetArrays.jl:47
|  in trailingsize(::OffsetArrays.OffsetArray{Int64,2,Array{Int64,2}}, ::Int64) 
at ./abstractarray.jl:201
|  in macro expansion at ./multidimensional.jl:424 [inlined]
|  in 
_unsafe_batchsetindex!(::OffsetArrays.OffsetArray{Int64,2,Array{Int64,2}}, 
::Base.Repeated{Int64}, ::Colon, ::Colon) at ./multidimensional.jl:421
|  in setindex!(::OffsetArrays.OffsetArray{Int64,2,Array{Int64,2}}, ::Int64, 
::Colon, ::Colon) at ./abstractarray.jl:832
| 
| julia> mg[indices(mg,1),indices(mg,2)]=0
| 0
| 
| julia> mg[1:3,1:3]=m
| 3×3 Array{Int64,2}:
|  4   1  3
|  4  10  9
|  8   6  6
| 
| julia> mg
| OffsetArrays.OffsetArray{Int64,2,Array{Int64,2}} with indices 0:4×0:4:
|  0  0   0  0  0
|  0  4   1  3  0
|  0  4  10  9  0
|  0  8   6  6  0
|  0  0   0  0  0
`----

-- 
Ángel de Vicente
http://www.iac.es/galeria/angelv/          

Reply via email to