Re: [Numpy-discussion] repeat an array without allocation

2014-05-05 Thread Jaime Fernández del Río
On Sun, May 4, 2014 at 9:34 PM, srean srean.l...@gmail.com wrote: Hi all, is there an efficient way to do the following without allocating A where A = np.repeat(x, [4, 2, 1, 3], axis=0) c = A.dot(b)# b.shape If x is a 2D array you can call repeat **after** dot, not before, which

Re: [Numpy-discussion] repeat an array without allocation

2014-05-05 Thread srean
Great ! thanks. I should have seen that. Is there any way array multiplication (as opposed to matrix multiplication) can be sped up without forming A and (A * b) explicitly. A = np.repeat(x, [4, 2, 1, 3], axis = 0)# A.shape == 10,10 c = sum(b * A, axis = 1)# b.shape

Re: [Numpy-discussion] repeat an array without allocation

2014-05-05 Thread Eelco Hoogendoorn
If b is indeed big I don't see a problem with the python loop, elegance aside; but Cython will not beat it on that front. On Mon, May 5, 2014 at 9:34 AM, srean srean.l...@gmail.com wrote: Great ! thanks. I should have seen that. Is there any way array multiplication (as opposed to matrix

[Numpy-discussion] repeat an array without allocation

2014-05-04 Thread srean
Hi all, is there an efficient way to do the following without allocating A where A = np.repeat(x, [4, 2, 1, 3], axis=0) c = A.dot(b)# b.shape thanks -- srean ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org

Re: [Numpy-discussion] repeat an array without allocation

2014-05-04 Thread Eelco Hoogendoorn
nope; its impossible to express A as a strided view on x, for the repeats you have. even if you had uniform repeats, it still would not work. that would make it easy to add an extra axis to x without a new allocation; but reshaping/merging that axis with axis=0 would again trigger a copy, as it