One can use rank 0 arrays instead of scalars to automatically promote
type of scalar-array
operations:
>>> from numarray import *
>>> a = arange(10, type=Int16)
>>> a * 10
array([ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90], type=Int16) # same type
>>> a * array(10, type=Int32)
array([ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90]) # Type
promoted to Int32
Is there any way to economically set the type of the operation result?
something like:
multiply(a,b, type=xxx) # Doesn't work
instead of:
(a*b).astype(xxx)
Nadav.
|