日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

矩阵形状| 使用Python的线性代数

發布時間:2023/12/1 python 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 矩阵形状| 使用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的线性代数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。