@@ -322,6 +322,51 @@ cdef class OneSumNode(SumNode):
322
322
"""
323
323
return Matrix_cmr_chr_sparse.one_sum(* self .summand_matrices())
324
324
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
+
325
370
326
371
cdef class TwoSumNode(SumNode):
327
372
r """
0 commit comments