Re: [Numpy-discussion] fortran array storage question

2007-10-26 Thread Anne Archibald
On 26/10/2007, Travis E. Oliphant <[EMAIL PROTECTED]> wrote: > There is an optimization where-in the inner-loops are done over the > dimension with the smallest stride. > > What other cache-coherent optimizations do you recommend? That sounds like a very good first step. I'm far from an expert on

Re: [Numpy-discussion] fortran array storage question

2007-10-26 Thread Travis E. Oliphant
Anne Archibald wrote: > On 26/10/2007, Georg Holzmann <[EMAIL PROTECTED]> wrote: > > >> if in that example I also change the strides: >> >>int s = tmp->strides[1]; >>tmp->strides[0] = s; >>tmp->strides[1] = s * dim0[0]; >> >> Then I get in python the fortran-style array in right orde

Re: [Numpy-discussion] fortran array storage question

2007-10-26 Thread Anne Archibald
On 26/10/2007, Georg Holzmann <[EMAIL PROTECTED]> wrote: > if in that example I also change the strides: > >int s = tmp->strides[1]; >tmp->strides[0] = s; >tmp->strides[1] = s * dim0[0]; > > Then I get in python the fortran-style array in right order. This is the usual way. More or le

Re: [Numpy-discussion] fortran array storage question

2007-10-26 Thread Georg Holzmann
Hallo! > This depends on what you are trying to do, but generally, I find that if > you can afford it memory-wise, it is much faster to just get a C > contiguous array if you treat your C array element per element. If you Yes, but the problem is that this data is very big (up to my memory lim

Re: [Numpy-discussion] fortran array storage question

2007-10-26 Thread David Cournapeau
Georg Holzmann wrote: > Hallo! > > I found now a way to get the data: > > >> Therefore I do the following (2D example): >> >>obj = PyArray_FromDimsAndData(2, dim0, PyArray_DOUBLE, (char*)data); >>PyArrayObject *tmp = (PyArrayObject*)obj; >>tmp->flags = NPY_FARRAY; >> > > if in t

Re: [Numpy-discussion] fortran array storage question

2007-10-26 Thread Georg Holzmann
Hallo! I found now a way to get the data: > Therefore I do the following (2D example): > >obj = PyArray_FromDimsAndData(2, dim0, PyArray_DOUBLE, (char*)data); >PyArrayObject *tmp = (PyArrayObject*)obj; >tmp->flags = NPY_FARRAY; if in that example I also change the strides: int s

[Numpy-discussion] fortran array storage question

2007-10-25 Thread Georg Holzmann
Hallo! I have the following problem: I get a data array in column major storage order and want to use it as numpy array without copying data. Therefore I do the following (2D example): obj = PyArray_FromDimsAndData(2, dim0, PyArray_DOUBLE, (char*)data); PyArrayObject *tmp = (PyArrayObject