[Numpy-discussion] type of matrixmultiply result

Curzio Basso curzio.basso at unibas.ch
Thu Jun 24 03:15:00 CDT 2004


Hi.

I noticed that when multiplying two matrices of type Float32, the result 
is Float64:

-----------------------------------------
In [103]: a=NA.ones((2,2), NA.Float32)

In [104]: b=NA.ones((2,2), NA.Float32)

In [105]: c=NA.matrixmultiply(a,b)

In [106]: c.type()
Out[106]: Float64
-----------------------------------------

Since the matrix I'm going to multiply in practice are quite big, I'd 
like to do the operation in Float32. Otherwise this is what I get:

Traceback (most recent call last):
   File "/home/basso/work/python/port/apps/pca-heads.py", line 141, in ?
     pc = NA.array(NA.matrixmultiply(cent, c), NA.Float32)
   File "/home/basso/usr//lib/python/numarray/numarraycore.py", line 
1150, in dot    return ufunc.innerproduct(array1, _gen.swapaxes(array2, 
-1, -2))
   File "/home/basso/usr//lib/python/numarray/ufunc.py", line 2047, in 
innerproduct
     r = a.__class__(shape=adots+bdots, type=rtype)
MemoryError

Any suggestion (apart from doing the operation one column at a time)?

thanks




More information about the Numpy-discussion mailing list