Issue 1:
Original ticket http://projects.scipy.org/scipy/ticket/706 on 2008-07-23 by trac user rjansen, assigned to @wnbell.

Hi,

I'm trying to compile scipy on Solaris 10:

After, what seems to be a succesfull LAPACK and ATLAS build with the GNU compiler 4.0.2 (switched to sunfreeware python,w hich is build with GNU compilers

and installing NumPy with same compiler, I'm bumped into the following error below when trying to compile SciPy.

This same error shows also when using the Sun Studio 12 compiler chain. (everything rebuild with Sun compilers, due to the python used from the blastwave.org packages)

The SciPy build stage seems to switch/default to Sun Studio compiler again

scipy/optimize/minpack2/dcstep.f:

dcstep:

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2602: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2603: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2604: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2605: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2606: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2607: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2608: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2609: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2610: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2611: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2612: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2614: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools.h", line 409: Error: multiplies is not a member of std.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 15087: Where: While instantiating "csr_elmul_csr<int, int>(const int, const int, const int_, const int_, const int_, const int_, const int_, const int_, std::vector, std::vector, std::vector)".

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 15087: Where: Instantiated from non-template code.

"scipy/sparse/sparsetools/sparsetools.h", line 409: Error: Unexpected type name "T" encountered.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 15087: Where: While instantiating "csr_elmul_csr<int, int>(const int, const int, const int, const int_, const int_, const int_, const int_, const int_, std::vector, std::vector, std::vector)".

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 15087: Where: Instantiated from non-template code.

"scipy/sparse/sparsetools/sparsetools.h", line 409: Error: Operand expected instead of ")".

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 15087: Where: While instantiating "csr_elmul_csr<int, int>(const int, const int, const int, const int_, const int_, const int_, const int_, const int_, std::vector, std::vector, std::vector)".

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 15087: Where: Instantiated from non-template code.

3 Error(s) and 12 Warning(s) detected.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2602: Warning: String literal converted to char in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2603: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2604: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2605: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2606: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2607: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2608: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2609: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2610: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2611: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2612: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 2614: Warning: String literal converted to char* in initialization.

"scipy/sparse/sparsetools/sparsetools.h", line 409: Error: multiplies is not a member of std.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 15087: Where: While instantiating "csr_elmul_csr<int, int>(const int, const int, const int_, const int_, const int_, const int_, const int_, const int_, std::vector, std::vector, std::vector)".

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 15087: Where: Instantiated from non-template code.

"scipy/sparse/sparsetools/sparsetools.h", line 409: Error: Unexpected type name "T" encountered.

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 15087: Where: While instantiating "csr_elmul_csr<int, int>(const int, const int, const int, const int_, const int_, const int_, const int_, const int_, std::vector, std::vector, std::vector)".

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 15087: Where: Instantiated from non-template code.

"scipy/sparse/sparsetools/sparsetools.h", line 409: Error: Operand expected instead of ")".

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 15087: Where: While instantiating "csr_elmul_csr<int, int>(const int, const int, const int, const int_, const int_, const int_, const int_, const int_, std::vector, std::vector, std::vector*)".

"scipy/sparse/sparsetools/sparsetools_wrap.cxx", line 15087: Where: Instantiated from non-template code.

3 Error(s) and 12 Warning(s) detected.

error: Setup script exited with error: Command "CC -DNDEBUG -xO3 -xtarget=ultra -xarch=v8 -Iscipy/sparse/sparsetools -I/opt/csw/lib/python/site-packages/numpy-1.1.0-py2.5-solaris-2.10-sun4u.egg/numpy/core/include -I/opt/csw/include/python2.5 -c scipy/sparse/sparsetools/sparsetools_wrap.cxx -o build/temp.solaris-2.10-sun4u-2.5/scipy/sparse/sparsetools/sparsetools_wrap.o" failed with exit status 3

Issue 2:
This started out as a hack on stack overflow to speed up construction of csr matrices.

As in some cases savings are considerable (several-fold reduction in time needed), it was suggested to me to offer this for inclusion in scipy.

I'm on Python 3.6, numpy 1.11.3, scipy 0.18.1

The speedup is achieved by

using int32 and viewcasting this to int64 in the indirect sort of indices

using quicksort instead of mergesort since duplicate indices are fused anyway (is there any deeper reason lexsort doesn't let you pick the sort algo?)

using argsort instead of lexsort

I attach a proof-of-concept version lacking checks for endianness and index size.

Nico Schlömer has offered to add some timings.

fast_tocsr.py.txt