python 生成对称矩阵_对称矩阵| 使用Python的线性代数
生活随笔
收集整理的這篇文章主要介紹了
python 生成对称矩阵_对称矩阵| 使用Python的线性代数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
python 生成對稱矩陣
Prerequisites:
先決條件:
Defining a matrix
定義矩陣
Identity matrix
身份矩陣
Transpose matrix
轉置矩陣
In linear algebra, if the matrix and its transpose are equal, then the matrix is symmetric (MT = M).
在線性代數中,如果矩陣及其轉置相等,則矩陣是對稱的(MT = M) 。
In terms of elements of matrices: M(i, j) = M(j, i)
根據矩陣的元素: M(i,j)= M(j,i)
Following is a python code for demonstrating how to check for Symmetric Matrix.
以下是用于演示如何檢查對稱矩陣的python代碼。
Method:
方法:
Syntax:M = numpy.array( )transpose_M = M.Tif transpose_M == M:Transpose = True Return:MT對稱矩陣的Python代碼 (Python code for symmetric matrices)
# Linear Algebra Learning Sequence # Transpose using different Methodimport numpy as npM = np.array([[2,3,4], [3,45,8], [4,8,78]]) print("---Matrix M---\n", M)# Transposing the Matrix M print('\n\nTranspose as M.T----\n', M.T)if M.T.all() == M.all():print("--------> Transpose is eqaul to M")M = np.array([[2,3,4], [3,45,8]]) print("\n\n---Matrix B---\n", M)# Transposing the Matrix M print('\n\nTranspose as B.T----\n', M.T)if M.T.all() == M.all() and np.shape(M) == np.shape(M.T):print("---------> Transpose is eqaul to B")else:print("---------> Not Transpose!!")Output:
輸出:
---Matrix M---[[ 2 3 4][ 3 45 8][ 4 8 78]]Transpose as M.T----[[ 2 3 4][ 3 45 8][ 4 8 78]] --------> Transpose is eqaul to M---Matrix B---[[ 2 3 4][ 3 45 8]]Transpose as B.T----[[ 2 3][ 3 45][ 4 8]] ---------> Not Transpose!!翻譯自: https://www.includehelp.com/python/symmetric-matrices.aspx
python 生成對稱矩陣
總結
以上是生活随笔為你收集整理的python 生成对称矩阵_对称矩阵| 使用Python的线性代数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: vector clone_Java Ve
- 下一篇: go newscanner判断文件读取结