1.矩陣的初始化
(1).建立全X的矩陣
(2)随機矩陣
(3) 機關陣
(4)矩陣運算
加減乘直接“+” “ -” “*”
(5)矩陣元素和
mymatrix = mat([[1,2,3],[4,5,6],[7,8,9]])
print (sum(mymatrix))
(6) 矩陣元素積
multiply
(7)N次幂
from numpy import *
a = mat ( [ [1,2,3],[4,5,6],[7,8,9] ] )
print (power(a,2))
(8)矩陣轉置
from numpy import *
a = mat ( [ [1,2,3],[4,5,6],[7,8,9] ] )
print (a.T)
(9)其他操作
from numpy import *
a = mat ( [ [1,2,3],[4,5,6],[7,8,9] ] )
[c,d] = shape(a)
print ("矩陣行列數:",c,d)
e = a [0] #按行切片
f = a.T[0] #按列切片
g = a.copy() #複制
#比較直接“<” “>” "=" 傳回的是bool型