[Numpy-discussion] tril, triu, document/ implementation conflict

eat e.antero.tammi at gmail.com
Wed Jan 26 07:22:09 EST 2011


Hi,

I just noticed a document/ implementation conflict with tril and triu.
According tril documentation it should return of same shape and data-type as

called. But this is not the case at least with dtype bool.

The input shape is referred as (M, N) in tril and triu, but as (N, M) in
tri.
Inconsistent?

Also I'm not very happy with the performance, at least dtype bool can be
accelerated as follows.

In []: M= ones((2000, 3000), dtype= bool)
In []: timeit triu(M)
10 loops, best of 3: 173 ms per loop
In []: timeit triu_(M)
10 loops, best of 3: 107 ms per loop

In []: M= asarray(M, dtype= int)
In []: timeit triu(M)
10 loops, best of 3: 160 ms per loop
In []: timeit triu_(M)
10 loops, best of 3: 163 ms per loop

In []: M= asarray(M, dtype= float)
In []: timeit triu(M)
10 loops, best of 3: 195 ms per loop
In []: timeit triu_(M)
10 loops, best of 3: 157 ms per loop

I have attached a crude 'fix' incase someone is interested.
Regards,
eat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110126/331d6723/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: twodim_base_fix.py
Type: application/octet-stream
Size: 3886 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110126/331d6723/attachment.obj>


More information about the NumPy-Discussion mailing list