In [6]:
from pylab import *

In [7]:
A=matrix([ [9,8,6],[1,2,7],[4,9,2],[6,0,5] ])

In [8]:
A


Out[8]:
matrix([[9, 8, 6],
        [1, 2, 7],
        [4, 9, 2],
        [6, 0, 5]])

In [9]:
A.T


Out[9]:
matrix([[9, 1, 4, 6],
        [8, 2, 9, 0],
        [6, 7, 2, 5]])

In [10]:
A*A


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-10-efb08c3213b7> in <module>()
----> 1 A*A

/Users/bblais/anaconda/lib/python2.7/site-packages/numpy/matrixlib/defmatrix.pyc in __mul__(self, other)
    339         if isinstance(other, (N.ndarray, list, tuple)) :
    340             # This promotes 1-D vectors to row vectors
--> 341             return N.dot(self, asmatrix(other))
    342         if isscalar(other) or not hasattr(other, '__rmul__') :
    343             return N.dot(self, other)

ValueError: shapes (4,3) and (4,3) not aligned: 3 (dim 1) != 4 (dim 0)

In [11]:
A*A.T


Out[11]:
matrix([[181,  67, 120,  84],
        [ 67,  54,  36,  41],
        [120,  36, 101,  34],
        [ 84,  41,  34,  61]])

In [12]:
A=matrix([ 1,3,1,0,1,2 ])
print(A)


[[1 3 1 0 1 2]]

In [13]:
A.shape=(3,2)

In [14]:
A


Out[14]:
matrix([[1, 3],
        [1, 0],
        [1, 2]])

In [15]:
B=matrix([0,0,7,5,2,1])
B.shape=(3,2)

In [16]:
B


Out[16]:
matrix([[0, 0],
        [7, 5],
        [2, 1]])

In [17]:
A+B


Out[17]:
matrix([[1, 3],
        [8, 5],
        [3, 3]])

In [18]:
A-B


Out[18]:
matrix([[ 1,  3],
        [-6, -5],
        [-1,  1]])

In [19]:
A*B.T


Out[19]:
matrix([[ 0, 22,  5],
        [ 0,  7,  2],
        [ 0, 17,  4]])

In [20]:
A.T*B


Out[20]:
matrix([[9, 6],
        [4, 2]])

In [21]:
x=matrix([20,50])
wA=matrix([.3,.2])
wB=matrix([-.75,.3])

In [22]:
x*wA.T


Out[22]:
matrix([[ 16.]])

In [ ]: