[Numpy-discussion] improvement request to np.dot(a, b) - extended precision summation

Pauli Virtanen pav@iki...
Fri Feb 13 15:21:14 CST 2009

Fri, 13 Feb 2009 12:04:12 -0800, David Henderson wrote:
> I'd like accumulate the summation in extended precision, "double" sum
> for float  inputs, "long double" sum for "double" inputs.
> A way of doing this is to add an optional third argument to dot - to
> specify the summation type.

`dot` does matrix-matrix, matrix-vector, or vector-vector products. These 
are usually implemented via calling the BLAS linear algebra library, and 
AFAIK BLAS only has routines for type-homogenous arguments. So I doubt 
this can be implemented for `dot` in any way.

On the other hand, `numpy.sum` already has a `dtype` argument that 
specifies the accumulator data type. Maybe you can use that?

Pauli Virtanen

More information about the Numpy-discussion mailing list