Python| numpy matrix.getA()
在Numpy matrix.getA()
方法的帮助下,我们可以获得与给定矩阵相同大小的ndarray 。
Syntax : matrix.getA()
Return : Return ndarray of same size as given matrix
示例 #1:
在这个例子中,我们可以看到我们能够在方法matrix.getA()
的帮助下获得 numpy 数组。
# import the important module in python
import numpy as np
# make matrix with numpy
gfg = np.matrix('[6; 2; 3]')
# applying matrix.getA() method
geeks = gfg.getA()
print(geeks)
输出:
[[6]
[2]
[3]]
示例 #2:
# import the important module in python
import numpy as np
# make a matrix with numpy
gfg = np.matrix('[1, 2, 3; 4, 5, 6; 7, 8, 9]')
# applying matrix.getA() method
geeks = gfg.getA()
print(geeks)
输出:
[[1 2 3]
[4 5 6]
[7 8 9]]