Matrix SageMath的深度复制

时间:2016-12-25 15:25:54

标签: python python-2.7 matrix deep-copy sage

我正在SageMath中创建Matrix的深度复制。

import copy
A = Matrix([[1,2],[3,4]]).augment(Matrix.identity(2), subdivide=True)
B = copy.deepcopy(A)
print A
print B

给我:

[1 2|1 0]
[3 4|0 1]

[1 2 1 0]
[3 4 0 1]

使用细分深度检查矩阵的正确方法是什么?我必须使用:

B.subdivide(*A.subdivisions())

SageMath版本7.2,发布日期:2016-05-15

1 个答案:

答案 0 :(得分:0)

回答tmonteil在https://ask.sagemath.org/question/36134/deepcopy-of-a-matrix-sagemath/?answer=36137#post-id-36137

似乎sage有一个自定义方法

....feature_extraction(20News).py", line 31, in <module>
    score = gini_index.gini_index(X_train, y_train)
  File "C:\Python27\lib\site-packages\skfeature\function\statistical_based\gini_index.py", line 31, in gini_index
    left_y = y[X[:, i] <= v[j]]
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

但不是自定义方法

__copy__