Matrice Multiplication Problem

mclaugb mclaugb at nospm.yahoo.com
Thu Aug 24 12:54:11 EDT 2006


I want to multiply two arrays:  a matrice and the conjugate of its 
transpose.  Then i wish to invert the resulting matrix.

In Matlab, the statement is :  Z= inv(M .' * M)

To implement in python, I simply cannot get this to work.  Here is my code:

from numpy import *
import scipy as Sci
from scipy.linalg import lu
m=array([[4,6+7j],[3+3j,7],[2+2j,4-7j]])
z=m.conj().transpose()
q=z*m


Traceback (most recent call last):
  File "C:\Program Files\ActiveState Komodo 
3.5\lib\support\dbgp\pythonlib\dbgp\client.py", line 3241, in runcode
    locals = self.frame.f_locals)
  File "C:\Program Files\ActiveState Komodo 
3.5\lib\support\dbgp\pythonlib\dbgp\client.py", line 1583, in runcode
    h_exec(code, globals=globals, locals=locals, module=module)
  File "C:\Program Files\ActiveState Komodo 
3.5\lib\support\dbgp\pythonlib\dbgp\client.py", line 520, in __init__
    exec code in globals, locals
  File "<console>", line 0, in __main__
ValueError: index objects are not broadcastable to a single shape





More information about the Python-list mailing list