Hi,

I'm trying to figure out how to use arrays with custom indices, and I've
read http://docs.julialang.org/en/release-0.5/devdocs/offset-arrays/,
but I don't seem to see how I could actually access array positions
using arbitrary indices.

A basic example of what I'd like to do would be something like:
,----
| m = rand(1:10,(3,3))
| mg = zeros(Int,(0:4,0:4))
| mg[1:3,1:3]=m
`----

so that mg would be a copy of m but with a buffer zone around it, and
when I need to access any value in mg, I can use the same indexing as
for m (the buffer zone would represent ghost cells for PDEs).

But I don't seem to get very far, as the creation of mg already is
giving me troubles:
,----
| julia> mg = zeros(Int,(0:4,0:4))
| ERROR: MethodError: Cannot `convert` an object of type 
Tuple{UnitRange{Int64},UnitRange{Int64}} to an object of type 
| Array{Int64,N}                                                                
                                      
| This may have arisen from a call to the constructor Array{Int64,N}(...),
| since type constructors fall back to convert methods.
|  in Array{Int64,N}(::Tuple{UnitRange{Int64},UnitRange{Int64}}) at 
./sysimg.jl:53
|  in zeros(::Type{T}, ::Tuple{UnitRange{Int64},UnitRange{Int64}}, 
::Vararg{Tuple{UnitRange{Int64},UnitRange{Int64}},N}
| ) at ./array.jl:169                                                           
                                      
`----

I had a tough night, so perhaps the answer is clear from
http://docs.julialang.org/en/release-0.5/devdocs/offset-arrays/, but I
can't see whether what I'm trying to do is doable and if so, how. Any
help appreciated.

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

Reply via email to