wulpuqu
1
Hello,
I was reading the definition of AbstractArray
in Base
and I was searching for concrete cases of memory aliasing with two AbstractArrays
.
A simple case with SubArrays.
julia> A=randn(10)
julia> Base.mightalias(A,view(A,1:5))
true
Do you know other examples in Base
without using SubArrays ?
rdeits
2
Two examples that come to mind are reshaping and transposing:
julia> A = rand(3, 3);
julia> Base.mightalias(A, vec(A))
true
julia> Base.mightalias(A, reshape(A, :))
true
julia> Base.mightalias(A, transpose(A))
true
wulpuqu
3
Nice ! I forgot that reshaping was actually not allocating a new chunk of memory !