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, . 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) () to define the ones matrix. Here is the code with examples.
在python中,我们有一个内置函数(在numpy库中定义) ()来定义一个矩阵。 这是带有示例的代码。
使用()实现矩阵矩阵的Python代码 (Python code for ones matrix using ())
-
# Linear Algebra Learning Sequence
-
# Ones matrix using ()
-
-
import numpy as np
-
-
a = ([3,5])
-
b = ([6,6])
-
c = ([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.]]
翻译自: /python/