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

Attachment: twodim_base_fix.py
Description: Binary data

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to