一个使用numpy.ones()的矩阵| 使用Python的线性代数
Ones Matrix - When all the entries of a matrix are one, then it is called as ones matrix. It may be of any dimension (MxN).
一個矩陣 -當矩陣的所有條目均為1時,則稱為一個矩陣。 它可以是任何尺寸( MxN )。
Properties:
特性:
The determinant of the matrix is 1 (when the number of columns and rows are 1, i.e. there is only one element in the matrix) or 0 otherwise.
矩陣的行列式為1(當行數為1時,即矩陣中只有一個元素),否則為0。
The Rank of any Ones Matrix is 1.
任何人矩陣的等級是1。
In python, we have an inbuilt function (defined in numpy library) numpy.ones() to define the ones matrix. Here is the code with examples.
在python中,我們有一個內置函數(在numpy庫中定義) numpy.ones()來定義一個矩陣。 這是帶有示例的代碼。
使用numpy.ones()實現矩陣矩陣的Python代碼 (Python code for ones matrix using numpy.ones())
# Linear Algebra Learning Sequence # Ones matrix using numpy.ones() import numpy as npa = np.ones([3,5]) b = np.ones([6,6]) c = np.ones([9,5])#printing the matrices print("\n----Ones Matrix (3x5)----\n",a) print("\n----Ones Matrix (6x6)----\n",b) print("\n----Ones Matrix (9x5)----\n",c)Output:
輸出:
----Ones Matrix (3x5)----[[1. 1. 1. 1. 1.][1. 1. 1. 1. 1.][1. 1. 1. 1. 1.]]----Ones Matrix (6x6)----[[1. 1. 1. 1. 1. 1.][1. 1. 1. 1. 1. 1.][1. 1. 1. 1. 1. 1.][1. 1. 1. 1. 1. 1.][1. 1. 1. 1. 1. 1.][1. 1. 1. 1. 1. 1.]]----Ones Matrix (9x5)----[[1. 1. 1. 1. 1.][1. 1. 1. 1. 1.][1. 1. 1. 1. 1.][1. 1. 1. 1. 1.][1. 1. 1. 1. 1.][1. 1. 1. 1. 1.][1. 1. 1. 1. 1.][1. 1. 1. 1. 1.][1. 1. 1. 1. 1.]]翻譯自: https://www.includehelp.com/python/ones-matrix-using-numpy-ones.aspx
總結
以上是生活随笔為你收集整理的一个使用numpy.ones()的矩阵| 使用Python的线性代数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: “洁诚洗志期暮年”上一句是什么
- 下一篇: 虎牙挖掘机多少钱一个啊?