Wrapping up this, for the record, from a couple of weeks back:

On Jun 29, 2007, at 12:48 AM, Robert Bradshaw wrote:

> As other people have mentioned, there's a factor of 2 overhead in the
> first loop. I'm not sure why you're indexing from 1 either.

Thanks for the comments...

Indeed, I managed to inflict a 'typo' while fiddling with various
implementations and systems, so I was indeed incurring a *2 factor in
time.  That's fixed.

> As for writing fast pyrex matrix code, M[i,j] is really slow. Here's
> what happens:

Thanks for the details; I went with your version of the code, and  
sent William a patch (Trac #400)...

> You will still have the same overhead from object creation for each
> entry (in the integer case), but this would be mitigated by the
> integer pool and should be much faster.


Thanks particularly for Robert's comments on pyrex trickery.  Using
Robert's version, it looks like this (now on an Intel Core 2 Duo):

                M1        M2        M3
is_symmetric   1.05 s    1.74 s    1.76 s
issym          1.53 s    2.22 s    2.24 s
is_sym3        1.15 s    1.75 s    1.77 s
is_sym4        0.50 s    1.16 s    1.18 s

'is_symmetric' is my original code (with the 'ncols' typo fixed), and
i and j cdef'd (not sure if this was previously the case).

'issym' is "purely pythonic", using xrange().

'is_sym3' is 'issym' in pyrex.

'is_sym4' is Robert's version (this is the version, renamed  
is_symmetric, in the patch).

Again, the matrices are symmetric 200x200 matrices with random
elements (so the timings are worst-case :-}).

The limits for the random entries are:
M1: (1,300000)
M2: (1,20000000000000000)
M3: (1,2000000000000000000000000000000000000000000000000000000000000000)

Justin

--
Justin C. Walker, Curmudgeon-At-Large
Institute for the Absorption of Federal Funds
--------
Men are from Earth.
Women are from Earth.
    Deal with it.
--------




--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to