[Numpy-discussion] type of matrixmultiply result

Todd Miller jmiller at stsci.edu
Thu Jun 24 08:34:08 CDT 2004


On Thu, 2004-06-24 at 10:30, Rick White wrote:
> On 24 Jun 2004, Todd Miller wrote:
> 
> > On Thu, 2004-06-24 at 06:14, Curzio Basso wrote:
> >
> > > I noticed that when multiplying two matrices of type Float32, the result
> > > is Float64:
> >
> > I modified dot() and innerproduct() this morning to return Float32 and
> > Complex32 for like inputs.
> 
> I wonder whether it would be worth providing an option to accumulate
> the sums using Float64 and to convert to Float32 before storing them in
> an array.  I suspect that one reason this returned Float64 is that it
> is very easy to run into precision/roundoff problems in
> single-precision matrix multiplies.  You could avoid that by using
> doubles for the sum while still returning the result as a single.
> 				Rick

OK.  I implemented intermediate sums using Float64 and Complex64 but
single precision inputs will still result in single precision outputs.

Todd





More information about the Numpy-discussion mailing list