Skip to content

Commit 9d8454a

Browse files
committed
Ensure _charpoly_df is interruptible
1 parent 7d83063 commit 9d8454a

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/sage/matrix/matrix2.pyx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3291,6 +3291,16 @@ cdef class Matrix(Matrix1):
32913291
sage: A._charpoly_df()
32923292
x^3 + 8*x^2 + 10*x + 1
32933293

3294+
.. NOTE::
3295+
3296+
The key feature of this implementation is that it is division-free.
3297+
This means that it can be used as a generic implementation for any
3298+
ring (commutative and with multiplicative identity). The algorithm
3299+
is described in full detail as Algorithm 3.1 in [Sei2002]_.
3300+
3301+
Note that there is a missing minus sign in front of the last term in
3302+
the penultimate line of Algorithm 3.1.
3303+
32943304
TESTS::
32953305

32963306
sage: A = matrix(ZZ, 0, 0)
@@ -3309,15 +3319,11 @@ cdef class Matrix(Matrix1):
33093319
sage: matrix(4, 4, lambda i, j: R.an_element())._charpoly_df() # needs sage.combinat
33103320
B[1]*x^4 - 4*B[u]*x^3
33113321

3312-
.. NOTE::
3322+
Test that the function is interruptible::
33133323

3314-
The key feature of this implementation is that it is division-free.
3315-
This means that it can be used as a generic implementation for any
3316-
ring (commutative and with multiplicative identity). The algorithm
3317-
is described in full detail as Algorithm 3.1 in [Sei2002]_.
3318-
3319-
Note that there is a missing minus sign in front of the last term in
3320-
the penultimate line of Algorithm 3.1.
3324+
sage: m = matrix.random(RR, 128)
3325+
sage: from sage.doctest.util import ensure_interruptible_after
3326+
sage: with ensure_interruptible_after(1): m.charpoly()
33213327
"""
33223328

33233329
# Validate assertions
@@ -3374,6 +3380,7 @@ cdef class Matrix(Matrix1):
33743380
for j in range(t+1):
33753381
s = s + M.get_unsafe(i, j) * a.get_unsafe(p-1, j)
33763382
a.set_unsafe(p, i, s)
3383+
sig_check()
33773384

33783385
# Set A[p, t] to be the (t)th entry in a[p, t]
33793386
A[p] = a.get_unsafe(p, t)

0 commit comments

Comments
 (0)