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
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.
As for writing fast pyrex matrix code, M[i,j] is really slow. Here's
what happens:
- A new (len 2) tuple is allocated
- i and j are converted into Python ints (in
On 6/28/07, Justin C. Walker <[EMAIL PROTECTED]> wrote:
> def is_symmetric(self):
> [...]
> for i from 1 <= i < self._nrows:
> for j from 0 <= j < self._ncols:
> [ DO SOMETHING ]
> def is_sym3(self):
> [...]
> for i in xrange(1,self._nrow
"Justin C. Walker" <[EMAIL PROTECTED]> writes:
> if self[i,j] != self[j,i]: return False
One more thought: this could be creating Python ints for i and j each
repetition; optimized indexing might avoid that.
Nick
--~--~-~--~~~---~--~~
To post to
In the first one, you're checking all entries, not just upper-triangular ones.
That'd account for a factor of 2 pretty well.
On Thu, 28 Jun 2007, Justin C. Walker wrote:
>
> Hi,
>
> I tried the following, added to the Matrix class definition in matrix/
> matrix0.pyx:
>
> def is_symmetric(
Two comments, without a great deal of thought or justification.
> if self[i,j] != self[j,i]: return False
This could be getting compiled to a default Python object indexing,
which is slow like molasses. You might want to check the generated C
code and change it to use faster in