You can protect yourself against unexpected behavior with
    @assert pointer(A) == pointer(B)
This should never fail if you're using plain Arrays.

--Tim

On Thursday, January 29, 2015 05:55:43 PM Kevin Squire wrote:
> Not answering the question, but any array can be treated as a 1D array by
> simply using a single index, without any shaping.
> 
> Cheers,
>  Kevin
> 
> On Thursday, January 29, 2015, Kirill Ignatiev <[email protected]>
> 
> wrote:
> > On Thursday, 29 January 2015 04:10:40 UTC-5, Milan Bouchet-Valat wrote:
> >> Though if you only work with the standard `Array` type, it's fine to
> >> rely on the fact that the data is not copied. You could then restrict
> >> the signature of your function to only accept `Array`, not any
> >> `AbstractArray`, at least until more consistency is attained.
> > 
> > But does it guarantee that for a plain array the data is not copied? I
> > would like to avoid that class of bugs if I can.
> > 
> > That's what I don't understand, I have a completely plain Array, with size
> > (2, n), and I need its data as a 1d array of size 2*n. Basically, I need
> > to
> > work with a 1d array, but when the array is created it is convenient to
> > think of it as a 2d array.
> > 
> > I can use reinterpret(eltype(array), array, (2*n, )). But is reshape, for
> > a plain array, guaranteed to share the data, or not?

Reply via email to