Skip to content

Commit c72b067

Browse files
committed
add examples over the rationals and number fields
1 parent 74480a8 commit c72b067

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/sage/matrix/matrix_polynomial_dense.pyx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4362,6 +4362,44 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense):
43624362
[ 0 1 0 0]
43634363
[ 0 0 x + 3 0]
43644364
4365+
Here are a few more examples, similar to the above but over fields
4366+
other than ``GF(7)``::
4367+
4368+
sage: ring.<x> = QQ[]
4369+
sage: mat = matrix([[x*(x-1)*(x-2), (x-2)*(x-3)*(x-4), (x-4)*(x-5)*(x-6)]])
4370+
sage: mat
4371+
[ x^3 - 3*x^2 + 2*x x^3 - 9*x^2 + 26*x - 24 x^3 - 15*x^2 + 74*x - 120]
4372+
sage: rcomp = mat.basis_completion(algorithm="smith"); rcomp
4373+
[ -1/12*x - 1/12 -1/12*x + 5/12 0]
4374+
[ 1/12 1/12 1/24*x^2 - 13/24*x + 2]
4375+
sage: mat.stack(rcomp).determinant()
4376+
1
4377+
4378+
sage: mat = matrix([[x*(x-1), x*(x-2)], \
4379+
[x*(x-2), x*(x-3)], \
4380+
[(x-1)*(x-2), (x-1)*(x-3)]])
4381+
sage: mat.smith_form(transformation=False)
4382+
[1 0]
4383+
[0 x]
4384+
[0 0]
4385+
sage: ccomp = mat.basis_completion(row_wise=False, algorithm="smith")
4386+
sage: ccomp
4387+
[1/2*x - 1/2]
4388+
[ 1/2*x - 1]
4389+
[1/2*x - 3/2]
4390+
sage: ccomp.augment(mat).smith_form(transformation=False)
4391+
[ 1 0 0]
4392+
[ 0 1 0]
4393+
[ 0 0 1/2*x]
4394+
4395+
sage: ring.<y> = NumberField(x**2 - 2, "a")[]
4396+
sage: a = ring.base_ring().gen()
4397+
sage: mat = matrix([[3*a*y - 1, (-8*a - 1)*y - 2*a + 1]])
4398+
sage: rcomp = mat.basis_completion(algorithm="smith"); rcomp
4399+
[ 39/119*a - 30/119 -99/119*a + 67/119]
4400+
sage: mat.stack(rcomp).determinant()
4401+
1
4402+
43654403
TESTS:
43664404
43674405
Corner cases are handled correctly::

0 commit comments

Comments
 (0)