>>> import numpy as np >>> np.mat(((1,0),(0,1)))**2 matrix([[1, 0], [0, 1]])
>>> np.array([[1, 0], [0, 1]])**2 array([[1, 0], [0, 1]])
>>> np.array([[1, 2], [3, 4]])**2 array([[ 1, 4], [ 9, 16]]) >>> np.mat([[1, 2], [3, 4]])**2 matrix([[ 7, 10], [15, 22]])
np.array("asdgh")**2
Matrix vs. array squaring has other issues too, as matrix squaring only works with square matrices:
>>> np.mat([1, 2])**2 [...] LinAlgError: Last 2 dimensions of the array must be square >>> np.array([1, 2])**2 array([1, 4])
Matrix vs. array squaring has other issues too, as matrix squaring only works with square matrices: