矩阵形状| 使用Python的线性代数
生活随笔
收集整理的這篇文章主要介紹了
矩阵形状| 使用Python的线性代数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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的线性代数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 凯立德导航多少钱啊?
- 下一篇: 超时空男臣剧情介绍