Hello all

> <snip>
> Python 2.3b1+ (#2, Jun 10 2003, 20:53:51)
> [GCC 3.0.2 20010905 (Red Hat Linux 7.1 3.0.1-3)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> import Numeric
>  >>> a=Numeric.arange(20)
>  >>> b=a[::2]
>  >>> c=a[1::2]
>  >>> a
> array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
> 16, 17, 18,
>              19])
>  >>> b
> array([ 0,  2,  4,  6,  8, 10, 12, 14, 16, 18])
>  >>> c
> array([ 1,  3,  5,  7,  9, 11, 13, 15, 17, 19])
>  >>> b[0]=99
>  >>> c[0]=99
>  >>> a
> array([99, 99,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
> 16, 17, 18,
>              19])
> 
> 
> Do "b" and "c" share a copy of the same data? None of the values in
> either array is visible in the other, but both share data with "a"!

I think we might be talking about two related but different concepts. One is
sharing of data between arrays, the other is whether the data overlaps.

Let's assume we can get at the starting address of the array in memory via
the array interface or whatever, and the length of the array in bytes.

To determine whether two arrays overlap, find the smallest data address of
the two arrays. If the data address of the other array is smaller than the
sum of the smallest data address and its corresponding length, you have
overlap.

I'm not quite sure how to check whether two arrays share the same underlying
data buffer. Flags don't tell the whole story here.

Regards,

Albert


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to