一个使用的矩阵| 使用Python的线性代数

时间:2024-11-18 08:11:08

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 ())

  1. # Linear Algebra Learning Sequence
  2. # Ones matrix using ()
  3. import numpy as np
  4. a = ([3,5])
  5. b = ([6,6])
  6. c = ([9,5])
  7. #printing the matrices
  8. print("\n----Ones Matrix (3x5)----\n",a)
  9. print("\n----Ones Matrix (6x6)----\n",b)
  10. print("\n----Ones Matrix (9x5)----\n",c)

Output:

输出:

  1. ----Ones Matrix (3x5)----
  2. [[1. 1. 1. 1. 1.]
  3. [1. 1. 1. 1. 1.]
  4. [1. 1. 1. 1. 1.]]
  5. ----Ones Matrix (6x6)----
  6. [[1. 1. 1. 1. 1. 1.]
  7. [1. 1. 1. 1. 1. 1.]
  8. [1. 1. 1. 1. 1. 1.]
  9. [1. 1. 1. 1. 1. 1.]
  10. [1. 1. 1. 1. 1. 1.]
  11. [1. 1. 1. 1. 1. 1.]]
  12. ----Ones Matrix (9x5)----
  13. [[1. 1. 1. 1. 1.]
  14. [1. 1. 1. 1. 1.]
  15. [1. 1. 1. 1. 1.]
  16. [1. 1. 1. 1. 1.]
  17. [1. 1. 1. 1. 1.]
  18. [1. 1. 1. 1. 1.]
  19. [1. 1. 1. 1. 1.]
  20. [1. 1. 1. 1. 1.]
  21. [1. 1. 1. 1. 1.]]

翻译自: /python/