天天看點

python numpy 矩陣

python numpy 矩陣

from numpy import *;
import numpy as np;


randomMat1=np.matrix([0.26358242,0.35134772,0.43263799,2.87872261]);
mul1 = np.matrix([100,15,100,15]);
T1 = np.matrix([[316.22776602,0.,0.,0.],[0.,3.16227766,0.,0.],[0.,0.,316.22776602,0.],[0.,0.,0.,3.16227766]]);

print("randomMat1 shape:",shape(randomMat1));
print("mul1 shape:",shape(mul1));
print("T1 shape:",shape(T1));


T2 = randomMat1*T1;
print("T2:",T2);
print("T2 shape:",shape(T2));      
(wind_2021) F:\PythonProject\ckf>
(wind_2021) F:\PythonProject\ckf>python mat1.py
randomMat1 shape: (1, 4)
mul1 shape: (1, 4)
T1 shape: (4, 4)
T2: [[ 83.35207984   1.11105905 136.81214507   9.1033202 ]]
T2 shape: (1, 4)

(wind_2021) F:\PythonProject\ckf>
(wind_2021) F:\PythonProject\ckf>