[MRG] SGD Cython improvements

Here are some safe bits from #2419, which can be pulled without waiting for my threading experiments.

* nogil declarations where possible (but no with nogil blocks, since the performance benefit of those is not clear)
* use BLAS where appropriate
* replaced DOUBLE by double, INTEGER and int32 by int/np.intc, since that's the type used by scipy.sparse
* explicit checks that dataset dims don't exceed INT_MAX
* replaced an np.all by an explicit loop (npymath library for C99 isfinite)

I also cleaned up the code a little bit (e.g. `min` and `max` no longer need to be defined for current Cython).