numpy/numpy — pull request #3916 by larsmans (2013-10-14 20:02:29+00:00)
Title: 64-bit safe _dotblas

Here are two patches to make the vector dot products `_dotblas` module 64-bit-safe even with 32-bit BLAS, and clean it up in the meantime. The first simply backs off to the naive dot implementation for very large arrays (and also for strides of 0).

The second patch calls BLAS's dot functions even for very large input arrays, in the real case. Since I have no use for complex arrays, I leave their optimization to someone else.

Performance doesn't suffer. NumPy 1.7.1 w/ ATLAS:

```
>>> rng = np.random.RandomState(42)
>>> x = np.random.randn(10000)
>>> y = np.random.randn(10000)
>>> %timeit np.dot(x,y)
100000 loops, best of 3: 4.66 us per loop
```

New `_dotblas` w/ ATLAS:

```
>>> %timeit np.dot(x,y)
100000 loops, best of 3: 4.53 us per loop
```

There's no unit test for very large arrays, since I don't see how to reliably write such a test. The new code can be tested, though, by manually setting a very low `CHUNKSIZE` in `_dotblas.c`. On my Linux/x86-64 box, it works just fine with a chunksize of 100 and two size-10000 arrays.