Re: [Numpy-discussion] ***[Possible UCE]*** user-d efined type example

2006-10-08 Thread Alan G Isaac
On Sun, 8 Oct 2006, Matt Knox apparently wrote: > I have a custom Date class which allows creation of > different frequency Dates (annual, monthly, etc..). Two > dates of the same frequency can be subtracted, and > integers can be added to a Date, with the obvious results > in each case. I st

Re: [Numpy-discussion] can this be made faster?

2006-10-08 Thread Greg Willden
On 10/8/06, Daniel Mahler <[EMAIL PROTECTED]> wrote: >>> aarray([0, 0])>>> barray([0, 1, 0, 1, 0])>>> carray([1, 1, 1, 1, 1])Well for this particular example you could doa=array([len(b)-sum(b), sum(b)]) Since you are just counting the ones and zeros. This next one is a little closer for the case wh

Re: [Numpy-discussion] can this be made faster?

2006-10-08 Thread Robert Kern
Bill Baxter wrote: > Yes, that'd be >a[b] += c No, I'm afraid that fancy indexing does not do the loop that you are thinking it would (and for reasons that we've discussed previously on this list, *can't* do that loop). That statement reduces to something like the following: tmp = a[b]

Re: [Numpy-discussion] can this be made faster?

2006-10-08 Thread Bill Baxter
So what's the answer then?  Can it be made faster?--bbOn 10/9/06, Robert Kern <[EMAIL PROTECTED]> wrote: Bill Baxter wrote:> Yes, that'd be>a[b] += cNo, I'm afraid that fancy indexing does not do the loop that you are thinking it would (and for reasons that we've discussed previously on this li

Re: [Numpy-discussion] can this be made faster?

2006-10-08 Thread A. M. Archibald
On 08/10/06, Robert Kern <[EMAIL PROTECTED]> wrote: > Bill Baxter wrote: > > Yes, that'd be > >a[b] += c > > No, I'm afraid that fancy indexing does not do the loop that you are thinking > it > would (and for reasons that we've discussed previously on this list, *can't* > do > that loop). Tha

Re: [Numpy-discussion] tensor product

2006-10-08 Thread Charles R Harris
Hi Nadav,On 10/8/06, Nadav Horesh <[EMAIL PROTECTED]> wrote: There is a "tensortdot" function in numpy1.0rc1 The tensordot is not the same thing as a tensor product. What I want is the following: def tensor(a, b) :     """Tensor product of a and b         """     a = asarray(a)     b = asarray(b)

Re: [Numpy-discussion] can this be made faster?

2006-10-08 Thread Daniel Mahler
On 10/8/06, Greg Willden <[EMAIL PROTECTED]> wrote: > On 10/8/06, Daniel Mahler <[EMAIL PROTECTED]> wrote: > > > > >>> a > > array([0, 0]) > > >>> b > > array([0, 1, 0, 1, 0]) > > >>> c > > array([1, 1, 1, 1, 1]) > > > > > Well for this particular example you could do > a=array([len(b)-sum(b), sum(

Re: [Numpy-discussion] can this be made faster?

2006-10-08 Thread Robert Kern
Daniel Mahler wrote: > On 10/8/06, Greg Willden <[EMAIL PROTECTED]> wrote: >> This next one is a little closer for the case when c is not just a bunch of >> 1's but you still have to know how the highest number in b. >> a=array([sum(c[b==0]), sum(c[b==1]), ... sum(c[b==N]) ] ) >> >> So it sort of