matrix pow python

Solutions on MaxInterview for matrix pow python by the best coders in the world

showing results for - "matrix pow python"
Vihan
04 Feb 2016
1>>> from numpy.linalg import matrix_power
2>>> i = np.array([[0, 1], [-1, 0]]) # matrix equiv. of the imaginary unit
3>>> matrix_power(i, 3) # should = -i
4array([[ 0, -1],
5       [ 1,  0]])
6>>> matrix_power(i, 0)
7array([[1, 0],
8       [0, 1]])
9>>> matrix_power(i, -3) # should = 1/(-i) = i, but w/ f.p. elements
10array([[ 0.,  1.],
11       [-1.,  0.]])
12