Re: [Numpy-discussion] Faster np.triu_indices

2013-09-02 Thread Stéfan van der Walt
On Mon, Sep 2, 2013 at 12:38 AM, Daniel Smith malor...@me.com wrote: This is just a first run at the function, and unfortunately does not work for k0. However, it does return the correct results for k=0 and is between 2-8 faster on my machine then `np.triu_indices`. Any thoughts on this?

[Numpy-discussion] Faster np.triu_indices

2013-09-01 Thread Daniel Smith
Hello all, I was noticing that `np.triu_indices` took quite awhile and discovered it creates an upper triu array and then uses `np.where`. This seems quite inefficient and I was curious if something like the following would be better: def fast_triu_indices(dim,k=0): tmp_range =