sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.44k stars 480 forks source link

Implement insert_row for general matrices #15965

Open b48024d7-8558-4864-b0aa-be1c697148a6 opened 10 years ago

b48024d7-8558-4864-b0aa-be1c697148a6 commented 10 years ago

Matrices over the integers have an insert_row method:

sage: A = matrix([[1, 2], [3, 4]])
sage: A.insert_row(A.nrows(), [6, 7])
[1 2]
[3 4]
[6 7]

Matrices over fields seem to lack such a method:

sage: B = A.change_ring(QQ)
sage: C = A.change_ring(GF(11))

Matrices B and C have no insert_row method, contrary to A.

Neither of A, B, C have an insert_column method.

CC: @pjbruin @slel

Component: linear algebra

Keywords: matrix, insert_row

Issue created by migration from https://trac.sagemath.org/ticket/15965

slel commented 2 years ago

Description changed:

--- 
+++ 
@@ -1,10 +1,19 @@
+Matrices over the integers have an `insert_row` method:

-sage: A = matrix([[1,2],[3,4]]) -sage: A.insert_row(A.nrows(),[6,7]) -[1 2]
-[3 4]
-[6 7]
-sage: V = matrix(GF(3), [[1,2,3],[4,5,6]]) +sage: A = matrix([[1, 2], [3, 4]]) +sage: A.insert_row(A.nrows(), [6, 7]) +[1 2] +[3 4] +[6 7]

-V does not have the function .insert_row(). Also, it would be nice to have insert_column().
+Matrices over fields seem to lack such a method:
+
+```
+sage: B = A.change_ring(QQ)
+sage: C = A.change_ring(GF(11))
+```
+Matrices `B` and `C` have no `insert_row` method,
+contrary to `A`.
+
+Neither of `A`, `B`, `C` have an `insert_column` method.
slel commented 2 years ago
comment:3

Requested at