Python Numpy matrix.getA()
在Numpy matrix.getA()方法的帮助下,我们可以得到与给定矩阵大小相同的ndarray。
语法: matrix.getA()
返回:返回与给定矩阵相同大小的ndarray。
例子#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]]