Prerequisite: Linear Algebra | Defining a Matrix

先决条件: 线性代数| 定义矩阵

In the python code, we will add two Matrices. We can add two Matrices only and only if both the matrices have the same dimensions. Therefore, knowing the dimensions of the matrices turns out to be one of the major steps in Linear Algebra. The following code shows how an inbuilt function can be used to achieve our goal of the shape of a Matrix.

在python代码中,我们将添加两个矩阵。 仅当两个矩阵的维数相同时,我们才可以添加两个矩阵。 因此,了解矩阵的维数成为线性代数的主要步骤之一。 以下代码展示了如何使用内置函数来实现矩阵形状的目标。

查找矩阵形状的Python代码 (Python code for fidning Shape of Matrix)

# Linear Algebra Learning Sequence
# Shape of Matrix
import numpy as np
#Use of np.array() to define a matrix
V1 = np.array([[1,2,3],[2,3,5],[3,6,8],[323,623,823]])
V2 = np.array([[965,2413,78,44],[223,356,500,44],[312,66,78,44],[42,42,42,44],[44,44,44,44]])
print("--The Matrixa A-- \n",V1)
print("\n--The Matrix B-- \n",V2)
print("\n\n Shape of the matrix A: ", V1.shape)
print(" Shape of the matrix B: ", V2.shape)

Output:

输出:

--The Matrixa A--
[[  1   2   3]
[  2   3   5]
[  3   6   8]
[323 623 823]]
--The Matrix B--
[[ 965 2413   78   44]
[ 223  356  500   44]
[ 312   66   78   44]
[  42   42   42   44]
[  44   44   44   44]]
Shape of the matrix A:  (4, 3)
Shape of the matrix B:  (5, 4)

翻译自: https://www.includehelp.com/python/shape-of-matrix.aspx

矩阵形状| 使用Python的线性代数相关推荐

  1. 线性代数分块矩阵求逆矩阵_单位矩阵属性(AI = A)| 使用Python的线性代数

    线性代数分块矩阵求逆矩阵 Prerequisites: 先决条件: Defining Matrix 定义矩阵 Identity matrix 身份矩阵 numpy.matmul( ) matrix m ...

  2. 线性代数矩阵行列式_非平方矩阵的行列式| 使用Python的线性代数

    线性代数矩阵行列式 Prerequisites: 先决条件: Defining a Matrix 定义矩阵 Determinant of a Matrix 矩阵的行列式 Note: Determina ...

  3. 单位矩阵属性(I ^ k = I)| 使用Python的线性代数

    Prerequisites: 先决条件: numpy.matmul( ) matrix multiplication numpy.matmul()矩阵乘法 Identity matrix 身份矩阵 I ...

  4. matlab 定义矩阵_MATLAB与Python,Mathematica由高维转化一维矩阵的方式的不同

    在进行数据处理的时候,我比较喜欢的数据存储方式是所有的数据都保存成MATLAB的".mat"文件,这种格式Python,Mathematica,MATLAB都会支持.不过在转化的时 ...

  5. 使用python学线性代数_最简单的神经网络简介| 使用Python的线性代数

    使用python学线性代数 A neural network is a powerful tool often utilized in Machine Learning because neural ...

  6. 使用python学线性代数_二项式过程| 使用Python的线性代数

    使用python学线性代数 When we flip a coin, there are two possible outcomes as head or tail. Each outcome has ...

  7. matlab 调整矩阵形状,matlab对矩阵/向量的常用操作(拼接矩阵、向量逆序、改变矩阵形状、求行阶梯形矩阵、提取矩阵的一部分等)...

    几乎所有变量在matlab中都可以视为矩阵(1 x 1元素,1 x n向量,m x n矩阵等),matlab中对矩阵/向量的操作非常多,个人认为对矩阵的操作是体现matlab功底的地方:灵活搭配使用这 ...

  8. 线性代数矩阵行列式_矩阵的行列式 使用Python的线性代数

    线性代数矩阵行列式 In linear algebra, the determinant is a scalar value that can be computed for a square mat ...

  9. 向量余弦值python_向量/矩阵的余弦值打印(元素明智的操作) 使用Python的线性代数

    向量余弦值python Prerequisite: 先决条件: Defining a Vector 定义向量 Defining a Matrix 定义矩阵 Numpy is the library o ...

最新文章

  1. 你哪来这么多事(六):职工信息查找
  2. 看清头秃元凶,腾讯AI首度揭示真相
  3. Lync Server 2013与OWA的集成
  4. Intellij Idea 从 Svn 检出 Maven 项目、部署 Tomcat 运行
  5. [转载]我的博后申请经历从陶瓷到Offer过程
  6. 列举mysql的所有触发器以及删除触发器
  7. python中字典的find_python中的字典
  8. 华为Mate 50系列明年亮相:或首发高通骁龙898 4G芯片
  9. Google 中国版搜索引擎项目凉了!
  10. python类与对象的内置函数大全(BIF)
  11. Lotus Traveler 8.5.1的安装及配置
  12. oracle11g rman实例,oracle11g rman备份与恢复详细实例
  13. ubuntu 22.04 安装网易云音乐
  14. 分类模型的评价指标--混淆矩阵,ROC,AUC,KS,Lift,Gain
  15. 基于Qt的上古神器-Qt Cryptographic Architecture (QCA)加密库介绍
  16. 软件测试职业规划(转)
  17. 机器学习-泛化能力笔记
  18. Scratch简单实现大鱼吃小鱼
  19. 宽带连接错误691,623,678......
  20. pip,pip安装源

热门文章

  1. function——函数声明头的提升和预解析
  2. HTML中直接写js 函数
  3. 前端生态混乱,AMPMIP在努力做标准化工作
  4. 基于canvas的骨骼动画
  5. Linux中文档去掉windows文本的多余的回车符(^M)
  6. 日期处理一之NSLalendar的使用
  7. (转)求单链表是否有环,环入口和环长
  8. 原生js封装table表格操作,获取任意行列td,任意单行单列方法
  9. WebApp 里Meta标签大全
  10. Flash中的SLC/MLC/MLC--基础