Skip to content

Commit a08c3e4

Browse files
author
Matthias Koeppe
committedFeb 16, 2024·
src/sage/matrix/seymour_decomposition.pyx: Add OneSumNode.check
1 parent 85c9e28 commit a08c3e4

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed
 

‎.vscode/settings.json

+21-1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,25 @@
3636
"Cython"
3737
],
3838
"editor.formatOnType": true,
39-
"esbonio.sphinx.confDir": ""
39+
"esbonio.sphinx.confDir": "",
40+
"workbench.colorCustomizations": {
41+
"activityBar.activeBackground": "#5ac88b",
42+
"activityBar.background": "#5ac88b",
43+
"activityBar.foreground": "#15202b",
44+
"activityBar.inactiveForeground": "#15202b99",
45+
"activityBarBadge.background": "#8958c7",
46+
"activityBarBadge.foreground": "#e7e7e7",
47+
"commandCenter.border": "#15202b99",
48+
"sash.hoverBorder": "#5ac88b",
49+
"statusBar.background": "#3cb371",
50+
"statusBar.foreground": "#15202b",
51+
"statusBarItem.hoverBackground": "#2f8d59",
52+
"statusBarItem.remoteBackground": "#3cb371",
53+
"statusBarItem.remoteForeground": "#15202b",
54+
"titleBar.activeBackground": "#3cb371",
55+
"titleBar.activeForeground": "#15202b",
56+
"titleBar.inactiveBackground": "#3cb37199",
57+
"titleBar.inactiveForeground": "#15202b99"
58+
},
59+
"peacock.color": "mediumseagreen"
4060
}

‎src/sage/matrix/seymour_decomposition.pyx

+45
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,51 @@ cdef class OneSumNode(SumNode):
322322
"""
323323
return Matrix_cmr_chr_sparse.one_sum(*self.summand_matrices())
324324

325+
@staticmethod
326+
def check(result_matrix, summand_matrices, summand_parent_rows_and_columns):
327+
r"""
328+
Check that ``result_matrix`` is a 1-sum of ``summand_matrices``.
329+
330+
EXAMPLES::
331+
332+
sage: from sage.matrix.matrix_cmr_sparse import Matrix_cmr_chr_sparse
333+
sage: from sage.matrix.seymour_decomposition import OneSumNode
334+
335+
sage: M2 = Matrix_cmr_chr_sparse.one_sum([[1, 0], [-1, 1]],
336+
....: [[1, 1], [-1, 0]])
337+
sage: result, certificate = M2.is_totally_unimodular(certificate=True); certificate
338+
OneSumNode (4×4) with 2 children
339+
sage: OneSumNode.check(M2,
340+
....: certificate.summand_matrices(),
341+
....: [summand.parent_rows_and_columns()
342+
....: for summand in certificate.summands()])
343+
344+
Symbolic identities::
345+
346+
sage: from sage.matrix.seymour_decomposition import OneSumNode
347+
sage: R.<x,y> = QQ[]
348+
sage: A = matrix([[x, 0], [-x, 1]])
349+
sage: B = matrix([[x, y], [-x, 0]])
350+
sage: A1B = block_diagonal_matrix([A, B])
351+
sage: OneSumNode.check(A1B, [A, B], [([0, 1], [0, 1]),
352+
....: ([2, 3], [2, 3])])
353+
354+
Using program analysis::
355+
356+
sage: # optional - cutgeneratingfunctionology
357+
sage: R.<x,y,z> = ParametricRealField({x: 1}, {y: -1}, {z: 0}) # true example
358+
sage: A = matrix([[x, 0], [-x, 1]])
359+
sage: B = matrix([[x, y], [-x, 0]])
360+
sage: A1B = matrix([[z, 0, 0, 0], [-x, z, 0, 0], [], []])
361+
sage: OneSumNode.check(A1B, [A, B], [([0, 1], [0, 1]),
362+
....: ([2, 3], [2, 3])])
363+
sage: # side-effect: R stores polynomial identities
364+
"""
365+
# TODO: Check that summand_parent_rows_and_columns form partitions of rows and columns
366+
for matrix, rows_and_columns in zip(summand_matrices, summand_parent_rows_and_columns):
367+
assert result_matrix.matrix_from_rows_and_columns(*rows_and_columns) == matrix
368+
# TODO: Check zero blocks
369+
325370

326371
cdef class TwoSumNode(SumNode):
327372
r"""

0 commit comments

Comments
 (0)