[NumPy-Tickets] [NumPy] #1723: Mainly performance improvement in tri and related functions
NumPy Trac
numpy-tickets@scipy....
Wed Jan 26 11:14:04 CST 2011
#1723: Mainly performance improvement in tri and related functions
----------------------------------------------+-----------------------------
Reporter: eat | Owner: somebody
Type: enhancement | Status: new
Priority: normal | Milestone: 1.5.2
Component: Other | Version: 1.5.0
Keywords: tri*, tri*_indices, mask_indices |
----------------------------------------------+-----------------------------
First of all this is enhancement request for functions: tri, tril, triu
and mask_indices. If these are implemented as demonstrated in the attached
code, more than 1.5 speedup (old exec time/ new exec time) may be achieved
(and as far I'm aware the speedup is always >1). Thus this is observed on
np.__version__== '1.5.1' and sys.version '2.7.1 (r271:86832, Nov 27 2010,
18:30:46) [MSC v.1500 32 bit (Intel)]'.
The speedup is achieved by avoiding unnecessary copying of arrays in tri
and changing the default dtype (when tri is called) from int to bool in
tril, triu and mask_indices.
Secondly the documentation of tril states that it will return "of same
shape and data-type" as input. This is not the case with current
implementation (at least with dtype bool). My proposal fixes this
trivially.
Thirdly, naming of rows and cols. In tri (N, M) while in rest related (M,
N). I propose consistency with (M, N) as fixed in attachment.
My attachment is based on version 1.5.1 twodim_base.py. Basically just
replace "_f" with "" and remove rows after and including "if __name__ ..."
should give you a working version.
Additionally all related *_indices functions in twodim_base will gain
performance.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1723>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list