Skip to content

Difference between Array reshaping and MArray/SizedArray reshaping #836

Open
@mateuszbaran

Description

@mateuszbaran

Modifying a reshaped array modifies the original array as well but it doesn't do that with MArray or SizedArray (a copy is created instead):

julia> vm = @MVector ones(4);

julia> vmr = reshape(vm, Size(2,2))
2×2 MArray{Tuple{2,2},Float64,2,4} with indices SOneTo(2)×SOneTo(2):
 1.0  1.0
 1.0  1.0

julia> vmr[1] = 12
12

julia> vm
4-element MArray{Tuple{4},Float64,1,4} with indices SOneTo(4):
 1.0
 1.0
 1.0
 1.0

Since we now have SizedArray that can wrap any AbstractArray, this could be fixed relatively easily. Is this something worth fixing before the 1.0 release?

Metadata

Metadata

Assignees

No one assigned

    Labels

    arraysAbstractArray interface and array operationsbug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions