使用numpy.zeros,numpy.ones,numpy.eye等方法可以构造特定的矩阵

 1 >>>from numpy import *
 2 >>> a=zeros((3,4))
 3 >>> a
 4 array([[ 0.,  0.,  0.,  0.],
 5        [ 0.,  0.,  0.,  0.],
 6        [ 0.,  0.,  0.,  0.]])
 7 
 8 >>> from numpy import *
 9 >>> a=ones((3,4))
10 >>> a
11 array([[ 1.,  1.,  1.,  1.],
12        [ 1.,  1.,  1.,  1.],
13        [ 1.,  1.,  1.,  1.]])
14 
15 >>> from numpy import *
16 >>> a=eye(3)
17 >>> a
18 array([[ 1.,  0.,  0.],
19        [ 0.,  1.,  0.],
20        [ 0.,  0.,  1.]])

 

使用numpy.zeros,numpy.ones,numpy.eye等方法可以构造特定的矩阵

 1 >>>from numpy import *
 2 >>> a=zeros((3,4))
 3 >>> a
 4 array([[ 0.,  0.,  0.,  0.],
 5        [ 0.,  0.,  0.,  0.],
 6        [ 0.,  0.,  0.,  0.]])
 7 
 8 >>> from numpy import *
 9 >>> a=ones((3,4))
10 >>> a
11 array([[ 1.,  1.,  1.,  1.],
12        [ 1.,  1.,  1.,  1.],
13        [ 1.,  1.,  1.,  1.]])
14 
15 >>> from numpy import *
16 >>> a=eye(3)
17 >>> a
18 array([[ 1.,  0.,  0.],
19        [ 0.,  1.,  0.],
20        [ 0.,  0.,  1.]])

 

相关文章:

  • 2021-12-03
  • 2021-09-29
  • 2021-11-17
  • 2021-07-05
  • 2021-08-13
  • 2021-10-08
猜你喜欢
  • 2021-05-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
  • 2022-01-06
  • 2021-09-22
相关资源
相似解决方案