NumPy 中 Sage .right_array() 的等价物是什么?

时间:2021-05-08 15:56:51

标签: python numpy matrix kernel sage

我有这个数组,后来被转换成一个“矩阵”数组 56x54,我如何计算这个数组的内核? 理想情况下,我如何修改它以便它可以在 Sage 中作为矩阵进行操作?我想在 Sage 中使用 .right_kernel() 函数。

import numpy

m = numpy.zeros(shape=(56,54), dtype=int)

eqns = [[0,1,2,3,4,5]
    ,[0,1,2,6,7,8]
    ,[0,1,2,0,3,6]
    ,[0,1,2,1,4,7]
    ,[0,1,2,2,5,8]
    ,[0,1,2,3,4,5]
    ,[0,1,2,12,13,14]
    ,[0,1,2,15,16,17]
    ,[0,1,2,9,12,15]
    ,[0,1,2,10,13,16]
    ,[0,1,2,11,14,17]
    ,[0,1,2,21,22,23]
    ,[0,1,2,24,25,26]
    ,[0,1,2,18,21,24]
    ,[0,1,2,19,22,25]
    ,[0,1,2,20,23,26]
    ,[0,1,2,30,31,32]
    ,[0,1,2,33,34,35]
    ,[0,1,2,27,30,33]
    ,[0,1,2,28,31,34]
    ,[0,1,2,29,32,35]
    ,[0,1,2,39,40,41]
    ,[0,1,2,42,43,44]
    ,[0,1,2,36,39,42]
    ,[0,1,2,37,40,43]
    ,[0,1,2,38,41,44]
    ,[0,1,2,48,49,50]
    ,[0,1,2,51,52,53]
    ,[0,1,2,45,48,51]
    ,[0,1,2,46,49,52]
    ,[0,1,2,47,50,53]

    #now the diagonals
    ,[0,1,2,0,4,8]
    ,[0,1,2,2,4,6]
    ,[0,1,2,9,13,17]
    ,[0,1,2,11,13,15]
    ,[0,1,2,18,22,26]
    ,[0,1,2,20,22,24]
    ,[0,1,2,27,31,35]
    ,[0,1,2,29,31,33]
    ,[0,1,2,36,40,44]
    ,[0,1,2,38,40,42]
    ,[0,1,2,45,49,53]
    ,[0,1,2,47,49,51]
    
    #the connnecting corners with the "standard" being a+c3+i4
    ,[0,1,2,2,38,9]
    ,[0,1,2,6,35,47]
    ,[0,1,2,8,15,53]
    ,[0,1,2,18,36,11]
    ,[0,1,2,20,27,42]
    ,[0,1,2,24,42,26]
    ,[0,1,2,26,33,45]
    ,[0,1,2,9,10,11]
    ,[0,1,2,18,19,20]
    ,[0,1,2,27,28,29]
    ,[0,1,2,36,37,38]
    ,[0,1,2,45,46,47]
    ,[0,1,2,0,29,44]]

for i in range(len(eqns)):
    for j in range(len(eqns[i])):
        if j<=2:
            m[i,eqns[i][j]] += 1
        if j>2:
            m[i,eqns[i][j]] += -1
b = numpy.matrix(numpy.array(m))

我使用 numpy,因为我无法更改 sage 中空的 56x54 矩阵的值

0 个答案:

没有答案
相关问题