[SciPy-user] Numpy matrix and blitz Matrix

Paolo Tenconi ptenconi at eco.uninsubria.it
Thu Nov 22 09:24:42 EST 2007


Hi Everyone,

*) numpy arrays are automatically converted to blitz arrays. That's fine.

*) I need to work with blitz Matrix objects, but I noticed that
    numpy matrix objects are not converted to them and I get a
    compilation error too

3) Does someone on the list succeeded doing that?
    Or is there a workaround to create quickly a blitz matrix object
    from a numpy 2D array or numpy-matrix without wasting time
    in casting operations?

It would be nice having an automatic translation of numpy.matrix to
blitz Matrix as matrices are used frequently in scientific computing.

Any suggestion or help would be very glad.
Paolo


#------------------  EXAMPLE CODE -----------------------------------

import numpy
import scipy

#Dot product with arrays (it works)
x=numpy.array([[1,2,],[3,4]])
y=numpy.zeros((2,2))
scipy.weave.inline("""y=x*x;""",['x','y'],type_converters=scipy.weave.converters.blitz,compiler='gcc',force=1)

#Matrix multiplication with matrix (gives compilation error)
X=numpy.matlib.mat('1 2; 3 4')
Y=numpy.matlib.zeros((2,2))
scipy.weave.inline("""Y=X*X;""",['X','Y'],type_converters=scipy.weave.converters.blitz,compiler='gcc')

#--------------------------------------------------------------------



More information about the SciPy-User mailing list