@@ -623,7 +623,47 @@ cdef class ThreeSumNode(SumNode):
623
623
sage: C1. parent_rows_and_columns( )
624
624
(( 0, 1, a, 3) , ( b, c, d, e, + 3+ e))
625
625
sage: C2. parent_rows_and_columns( )
626
- (( 0, 2, 3, 5) , ( + b+ 0, d, 4, e, f))
626
+ (( 0, 2, 3, 5) , ( + d+ 0, d, 4, e, f))
627
+
628
+ sage: from sage. matrix. matrix_cmr_sparse import Matrix_cmr_chr_sparse
629
+ sage: R12_large = Matrix_cmr_chr_sparse( MatrixSpace( ZZ, 9, 12, sparse=True) ,
630
+ .... : [[1, -1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1 ],
631
+ .... : [0, 0, 0, 1, -1, 0, 0, 0, 1 , 1, 1, 1 ],
632
+ .... : [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1 ],
633
+ .... : [ 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0 ],
634
+ .... : [ 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, -1, -1 ],
635
+ .... : [ 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0 ],
636
+ .... : [ 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, -1, -1 ],
637
+ .... : [ 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0 ],
638
+ .... : [ 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1 ]])
639
+ sage: result, certificate = R12_large. is_totally_unimodular( certificate=True,
640
+ .... : three_sum_strategy="Wide_Wide",
641
+ .... : row_keys=range( 9) ,
642
+ .... : column_keys='abcdefghijkl')
643
+ sage: C = certificate. _children( ) [0 ]; C
644
+ ThreeSumNode ( 9×12) with 2 children
645
+ sage: C1, C2 = C. _children( )
646
+ sage: C1. matrix( )
647
+ [ 0 0 1 1 1 1 1 ]
648
+ [ 1 1 0 0 0 -1 -1 ]
649
+ [ 1 0 -1 0 -1 -1 -1 ]
650
+ [ 0 1 1 0 1 0 0 ]
651
+ [ 0 0 0 -1 -1 0 -1 ]
652
+ sage: C2. matrix( )
653
+ [ 1 0 0 0 0 1 -1 0 -1 ]
654
+ [ 0 0 1 -1 0 -1 1 0 1 ]
655
+ [-1 -1 1 0 1 -1 1 0 1 ]
656
+ [-1 -1 0 1 1 0 0 0 0 ]
657
+ [-1 -1 0 0 0 0 1 1 1 ]
658
+ [-1 -1 0 0 0 0 1 1 0 ]
659
+ sage: C. row_keys( )
660
+ ( 0, i, 2, 3, 4, 5, 6, 7, 8)
661
+ sage: C. column_keys( )
662
+ ( a, b, c, d, e, f, g, h, 1, j, k, l)
663
+ sage: C1. parent_rows_and_columns( )
664
+ (( i, 2, 7, 8, 3) , ( g, h, j, k, l, d, -3+ d))
665
+ sage: C2. parent_rows_and_columns( )
666
+ (( i, 0, 3, 4, 5, 6) , ( + i+ k, k, a, b, c, d, e, f, 1))
627
667
628
668
sage: result, certificate = R12. is_totally_unimodular( certificate=True,
629
669
.... : three_sum_strategy="Mixed_Mixed",
@@ -642,9 +682,9 @@ cdef class ThreeSumNode(SumNode):
642
682
[ 1 0 1 0 ]
643
683
[ 0 -1 0 1 ]
644
684
sage: C1. parent_rows_and_columns( )
645
- (( 0, 1, 2, 3) , ( a, b, c, d, + 2 + 3 ))
685
+ (( 0, 1, 2, 3) , ( a, b, c, d, + 3 + 2 ))
646
686
sage: C2. parent_rows_and_columns( )
647
- (( + a+ b , 2, 3, 4, 5) , ( a, d, e, f))
687
+ (( + a+ d , 2, 3, 4, 5) , ( a, d, e, f))
648
688
"""
649
689
if self .nchildren() != 2 :
650
690
raise ValueError (" ThreeSumNode has exactly two children" )
@@ -686,7 +726,7 @@ cdef class ThreeSumNode(SumNode):
686
726
else :
687
727
epsilon2 = Integer(mat1.entryValues[index2])
688
728
689
- child1_column_keys += (ElementKey((epsilon1, row_keys [child1_nrows- 2 ], epsilon2, row_keys [child1_nrows- 1 ]), composition = True ),)
729
+ child1_column_keys += (ElementKey((epsilon1, child1_row_keys [child1_nrows- 2 ], epsilon2, child1_row_keys [child1_nrows- 1 ]), composition = True ),)
690
730
else : # Wide_Wide
691
731
child1_row_keys = tuple (self ._CMRelement_to_key(parent_rows1[i])
692
732
for i in range (child1_nrows))
@@ -699,8 +739,8 @@ cdef class ThreeSumNode(SumNode):
699
739
else :
700
740
epsilon1 = Integer(mat1.entryValues[index1])
701
741
702
- child1_column_keys += (ElementKey((1 , column_keys [child1_ncols- 1 ], epsilon1,
703
- row_keys [child1_nrows- 1 ]), composition = True ),)
742
+ child1_column_keys += (ElementKey((1 , child1_column_keys [child1_ncols- 2 ], epsilon1,
743
+ child1_row_keys [child1_nrows- 1 ]), composition = True ),)
704
744
705
745
child1 = create_DecompositionNode(child1_dec, root = self ._root or self ,
706
746
row_keys = child1_row_keys,
@@ -712,6 +752,8 @@ cdef class ThreeSumNode(SumNode):
712
752
if self .is_concentrated_rank(): # Mixed_Mixed
713
753
child2_row_keys = tuple (self ._CMRelement_to_key(parent_rows2[i])
714
754
for i in range (1 , child2_nrows))
755
+ child2_column_keys = tuple (self ._CMRelement_to_key(parent_columns2[i])
756
+ for i in range (child2_ncols))
715
757
716
758
CMR_CALL(CMRchrmatFindEntry(mat2, 0 , 0 , & index1))
717
759
if index1 == SIZE_MAX:
@@ -725,9 +767,7 @@ cdef class ThreeSumNode(SumNode):
725
767
else :
726
768
epsilon2 = Integer(mat1.entryValues[index2])
727
769
728
- child2_row_keys = (ElementKey((epsilon1, column_keys[0 ], epsilon2, column_keys[1 ]), composition = True ), ) + child2_row_keys
729
- child2_column_keys = tuple (self ._CMRelement_to_key(parent_columns2[i])
730
- for i in range (child2_ncols))
770
+ child2_row_keys = (ElementKey((epsilon1, child2_column_keys[0 ], epsilon2, child2_column_keys[1 ]), composition = True ), ) + child2_row_keys
731
771
else : # Wide_Wide
732
772
child2_row_keys = tuple (self ._CMRelement_to_key(parent_rows2[i])
733
773
for i in range (child2_nrows))
@@ -740,7 +780,7 @@ cdef class ThreeSumNode(SumNode):
740
780
741
781
child2_column_keys = tuple (self ._CMRelement_to_key(parent_columns2[i])
742
782
for i in range (1 , child2_ncols))
743
- child2_column_keys = (ElementKey((1 , column_keys[ 1 ], epsilon1, row_keys [0 ]), composition = True ),) + child2_column_keys
783
+ child2_column_keys = (ElementKey((1 , child2_column_keys[ 0 ], epsilon1, child2_row_keys [0 ]), composition = True ),) + child2_column_keys
744
784
745
785
child2 = create_DecompositionNode(child2_dec, root = self ._root or self ,
746
786
row_keys = child2_row_keys,
0 commit comments