Created
March 17, 2016 10:18
-
-
Save dboyliao/e8fef3f604ba3900549b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import numpy as np | |
m = np.array([[1, 2], [3, 4]]) | |
print("m**2: ") | |
print(m**2) | |
print("matrix_power:") | |
print(np.linalg.matrix_power(m, 2)) | |
# you can apply ** operation on a non-square matrix, which is impossible for a non-square matrix to do | |
# so if ** is to raise a matrix to upper power. | |
m = np.array([[1, 2, 3], [4, 5, 6]]) | |
print("m**2 (non-square):") | |
print(m**2) | |
# np.linalg.matrix_power(m, 2) # ValueError |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment