Python 矩阵Numpy

import numpy as np

a = np.array([(1,2),(-1,2)])
b = np.array([(2,3),(-1,2)])
#c = np.ones((2,2))
print(a)
print(b)
print('\n\n')

#9-1
print(a + a)
print(a * a.T)
print(a.T * a)
print(a * b)
p = 1
x = np.array([(p,p),(p,p)])
print(a * (b - x))

#9-2
b0 = np.zeros(2)
print(b0)
print('\n\n')
print(np.linalg.solve(b,b0))

#9-3
print(np.linalg.norm(a))
print(np.linalg.norm(b,ord=np.inf))
print(np.linalg.svd(b))#9-4x = np.diag((1,2,3)) i,j = np.linalg.eig(x)print(i)print(j)#9-5print(np.linalg.norm(a))#9-6print(np.minimum(a, 255))
G:\>python Num.py
[[ 1  2]
 [-1  2]]
[[ 2  3]
 [-1  2]]



[[ 2  4]
 [-2  4]]
[[ 1 -2]
 [-2  4]]
[[ 1 -2]
 [-2  4]]
[[2 6]
 [1 4]]
[[1 4]
 [2 2]]
[0. 0.]



[0. 0.]
3.1622776601683795
5.0
(array([[ 0.92387953,  0.38268343],
       [ 0.38268343, -0.92387953]]), array([3.82842712, 1.82842712]), array([[ 0.38268343,  0.92387953],
       [ 0.92387953, -0.38268343]]))
[1. 2. 3.]
[[1. 0. 0.]
 [0. 1. 0.]
 [0. 0. 1.]]
3.1622776601683795
[[ 1  2]
 [-1  2]]

print(np.linalg.svd(b))#9-4x = np.diag((1,2,3)) i,j = np.linalg.eig(x)print(i)print(j)#9-5print(np.linalg.norm(a))#9-6print(np.minimum(a, 255))

结果



你可能感兴趣的:(Python 矩阵Numpy)