首页 > 解决方案 > 在python中获取矩阵的形容词

问题描述

我在解决通过给定辅因子矩阵的公式找到矩阵的佐词时遇到了一些问题

c[i][j] = (-1)**(i+j)*m[i][j] 

其中 m 代表矩阵的行列式。

x = np.array([[1,3,5],[-2,-4,-5],[3,6,1]] , dtype = 'int')

我只能做到这一点,不知道如何继续,请帮助

找到辅因子我有这个提示 def COF(C) 创建一个空矩阵 CO

 for row
     for col
         sel_rows = all rows except current row 
         sel_columns = all cols except current col
         MATij = [selected rows and selected columns]
         compute COij
 return CO

标签: pythonnumpy

解决方案


import numpy as np
x = np.array([[1,3,5],[-2,-4,-5],[3,6,1]] , dtype = 'int')
m = np.linalg.det(x)
c =[[i for i in range(3)] for j in range(3)]
for i in range(3):
    for j in range(3):
        c[i][j] = (-1)*(i+j)*m

推荐阅读