使用numpy.eye()函数打印身份矩阵| 使用Python的线性代数

Prerequisite:

先决条件:

In linear algebra, the identity matrix, of size n is the n × n square matrix with ones on the main diagonal and zeros elsewhere. It is denoted by I. Also known as the unit matrix because its determinant value is 1 irrespective of size. This is the key feature of an identity matrix and it plays an important role in Linear Algebra.

在线性代数中,大小为n恒等矩阵n×n方阵,主对角线上为1,其他地方为零。 用I表示。 也称为单位矩阵,因为其行列式值为1 ,与大小无关。 这是单位矩阵的关键特征,并且在线性代数中起重要作用。

Python Identity Matrix

Syntax:

句法:

    identity_matrix = eye(n)

Input parameter(s):

输入参数:

  • n – size of the identity matrix.

    n –单位矩阵的大小。

Return value:

返回值:

A square matrix with 1 at its diagonal and rest is zero.

对角线为1且其余为零的方阵。

Applications:

应用范围:

  1. Machine Learning

    机器学习

  2. Neural Network

    神经网络

  3. Linear Algebra - Gauss Jordan Elimination

    线性代数-高斯约旦消除

使用numpy.eye()函数打印身份矩阵的Python代码 (Python code to print the identity matrix using numpy.eye() function)

# Linear Algebra Learning Sequence
# Identity matrix using numpy.eye() function

import numpy as np
   
# Using power function
print("\n---I(4x4)---\n", np.eye(4))
print("\n---I(6x6)---\n", np.eye(6))

Output:

输出:

---I(4x4)---
 [[1. 0. 0. 0.]
 [0. 1. 0. 0.]
 [0. 0. 1. 0.]
 [0. 0. 0. 1.]]

---I(6x6)---
 [[1. 0. 0. 0. 0. 0.]
 [0. 1. 0. 0. 0. 0.]
 [0. 0. 1. 0. 0. 0.]
 [0. 0. 0. 1. 0. 0.]
 [0. 0. 0. 0. 1. 0.]
 [0. 0. 0. 0. 0. 1.]]


翻译自: https://www.includehelp.com/python/print-the-identity-matrix-using-numpy-eye-function.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值