@@ -39,7 +39,7 @@ cdef class DecompositionNode(SageObject):
39
39
if self ._root is None or self ._root is self :
40
40
if self ._dec != NULL :
41
41
# We own it, so we have to free it.
42
- CMR_CALL(CMRmatroiddecFree (cmr, & self ._dec))
42
+ CMR_CALL(CMRmatroiddecRelease (cmr, & self ._dec))
43
43
self ._dec = dec
44
44
self ._root = root
45
45
@@ -193,26 +193,7 @@ cdef class DecompositionNode(SageObject):
193
193
sage: C. parent_rows_and_columns( )
194
194
(( r1, i, r3, r4, r5, r6, r7, r8, r9) , ( a, b, c, d, e, f, g, h, r2, j, k, l))
195
195
"""
196
- cdef CMR_ELEMENT * parent_rows = CMRmatroiddecRowsParent(self ._dec)
197
- cdef CMR_ELEMENT * parent_columns = CMRmatroiddecColumnsParent(self ._dec)
198
- if parent_rows == NULL or all (parent_rows[i] == 0 for i in range (self .nrows())):
199
- parent_rows_tuple = None
200
- else :
201
- if self .row_keys() is not None :
202
- parent_rows_tuple = tuple (self .row_keys())
203
- else :
204
- parent_rows_tuple = tuple (CMRelementToRowIndex(parent_rows[i])
205
- for i in range (self .nrows()))
206
- if parent_columns == NULL or all (parent_columns[i] == 0 for i in range (self .ncols())):
207
- parent_columns_tuple = None
208
- else :
209
- if self .column_keys() is not None :
210
- parent_columns_tuple = tuple (self .column_keys())
211
- else :
212
- parent_columns_tuple = tuple (CMRelementToColumnIndex(parent_columns[i])
213
- for i in range (self .ncols()))
214
-
215
- return parent_rows_tuple, parent_columns_tuple
196
+ return self .row_keys(), self .column_keys()
216
197
217
198
def as_ordered_tree (self ):
218
199
r """
@@ -283,19 +264,33 @@ cdef class DecompositionNode(SageObject):
283
264
row_keys = self .row_keys()
284
265
column_keys = self .column_keys()
285
266
cdef CMR_MATROID_DEC * child_dec = CMRmatroiddecChild(self ._dec, index)
286
- cdef CMR_ELEMENT * parent_rows = CMRmatroiddecRowsParent(child_dec)
287
- cdef CMR_ELEMENT * parent_columns = CMRmatroiddecColumnsParent(child_dec)
267
+ cdef CMR_ELEMENT * parent_rows = CMRmatroiddecChildRowsToParent(self ._dec, index)
268
+ cdef CMR_ELEMENT * parent_columns = CMRmatroiddecChildColumnsToParent(self ._dec, index)
269
+ child_nrows = CMRmatroiddecNumRows(child_dec)
270
+ child_ncols = CMRmatroiddecNumColumns(child_dec)
288
271
289
272
if row_keys is not None and column_keys is not None :
290
273
child_row_keys = tuple (self ._CMRelement_to_key(parent_rows[i])
291
- for i in range (CMRmatroiddecNumRows(child_dec) ))
274
+ for i in range (child_nrows ))
292
275
child_column_keys = tuple (self ._CMRelement_to_key(parent_columns[i])
293
- for i in range (CMRmatroiddecNumColumns(child_dec) ))
276
+ for i in range (child_ncols ))
294
277
child = create_DecompositionNode(child_dec, root = self ._root or self ,
295
278
row_keys = child_row_keys,
296
279
column_keys = child_column_keys)
297
280
else :
298
- child = create_DecompositionNode(child_dec, root = self ._root or self )
281
+ if parent_rows == NULL or all (parent_rows[i] == 0 for i in range (child_nrows)):
282
+ parent_rows_tuple = None
283
+ else :
284
+ parent_rows_tuple = tuple (CMRelementToRowIndex(parent_rows[i])
285
+ for i in range (child_nrows))
286
+ if parent_columns == NULL or all (parent_columns[i] == 0 for i in range (child_ncols)):
287
+ parent_columns_tuple = None
288
+ else :
289
+ parent_columns_tuple = tuple (CMRelementToColumnIndex(parent_columns[i])
290
+ for i in range (child_ncols))
291
+ child = create_DecompositionNode(child_dec, root = self ._root or self ,
292
+ row_keys = parent_rows_tuple,
293
+ column_keys = parent_columns_tuple)
299
294
return child
300
295
301
296
@cached_method
@@ -655,13 +650,13 @@ cdef class ThreeSumNode(SumNode):
655
650
raise ValueError (" ThreeSumNode has exactly two children" )
656
651
657
652
cdef CMR_MATROID_DEC * child1_dec = CMRmatroiddecChild(self ._dec, 0 )
658
- cdef CMR_ELEMENT * parent_rows1 = CMRmatroiddecRowsParent(child1_dec )
659
- cdef CMR_ELEMENT * parent_columns1 = CMRmatroiddecColumnsParent(child1_dec )
653
+ cdef CMR_ELEMENT * parent_rows1 = CMRmatroiddecChildRowsToParent( self ._dec, 0 )
654
+ cdef CMR_ELEMENT * parent_columns1 = CMRmatroiddecChildColumnsToParent( self ._dec, 0 )
660
655
cdef CMR_CHRMAT * mat1 = CMRmatroiddecGetMatrix(child1_dec)
661
656
662
657
cdef CMR_MATROID_DEC * child2_dec = CMRmatroiddecChild(self ._dec, 1 )
663
- cdef CMR_ELEMENT * parent_rows2 = CMRmatroiddecRowsParent(child2_dec )
664
- cdef CMR_ELEMENT * parent_columns2 = CMRmatroiddecColumnsParent(child2_dec )
658
+ cdef CMR_ELEMENT * parent_rows2 = CMRmatroiddecChildRowsToParent( self ._dec, 1 )
659
+ cdef CMR_ELEMENT * parent_columns2 = CMRmatroiddecChildColumnsToParent( self ._dec, 1 )
665
660
cdef CMR_CHRMAT * mat2 = CMRmatroiddecGetMatrix(child2_dec)
666
661
667
662
cdef size_t index1, index2
0 commit comments