[Numpy-discussion] Regarding Matrices

Torgil Svensson torgil.svensson at gmail.com
Mon Aug 14 16:03:04 CDT 2006


>>> import numpy
>>> numpy.__version__
'1.0b1'
>>> from numpy import *
>>> A = [1,2,3,4,5,6,7,8,9]
>>> B = asmatrix(reshape(A,(3,3)))
>>> B
matrix([[1, 2, 3],
        [4, 5, 6],
        [7, 8, 9]])
>>> B**0
matrix([[ 1.,  0.,  0.],
        [ 0.,  1.,  0.],
        [ 0.,  0.,  1.]])
>>> power(B,0)
matrix([[1, 1, 1],
        [1, 1, 1],
        [1, 1, 1]])

Shouldn't power() and the ** operator return the same result for matrixes?

//Torgil




More information about the Numpy-discussion mailing list