Ticket #3676: trac3676-cleanup.patch

File trac3676-cleanup.patch, 3.4 KB (added by rlm, 13 years ago)
  • sage/groups/perm_gps/partn_ref/tree_traversal.pyx

    # HG changeset patch
    # User Robert L. Miller <rlm@rlmiller.org>
    # Date 1218044187 25200
    # Node ID b1de815b82dd2e5fc79e9ef0cf70700d2cb5957c
    # Parent  a5e2fd3928b58fe2de1878ca0dba06b7bf1c9a75
    A few missing details in tree_traversal.pyx
    
    diff -r a5e2fd3928b5 -r b1de815b82dd sage/groups/perm_gps/partn_ref/tree_traversal.pyx
    a b cdef inline PartitionStack *PS_from_list 
    281281    cdef int cell, i, num_cells = len(L), cur_start = 0, cur_len, n = 0
    282282    for cell from 0 <= cell < num_cells:
    283283        n += len(L[cell])
    284     cdef PartitionStack *PS = PS_new(n, False)
     284    cdef PartitionStack *PS = PS_new(n, 0)
    285285    cell = 0
    286286    if PS is NULL:
    287287        return PS
    cdef inline int PS_print(PartitionStack  
    312312    cdef int i
    313313    for i from 0 <= i < PS.depth + 1:
    314314        PS_print_partition(PS, i)
     315    print
    315316
    316317cdef inline int PS_print_partition(PartitionStack *PS, int k):
    317318    """
    def PS_represent(partition=[[6],[3,4,8,7 
    509510    cdef int i, n = sum([len(cell) for cell in partition]), *gamma
    510511    cdef bitset_t b
    511512    print "Allocating PartitionStack..."
    512     cdef PartitionStack *PS = PS_new(n, True), *PS2
     513    cdef PartitionStack *PS = PS_new(n, 1), *PS2
    513514    if PS is NULL:
    514515        print "Allocation failed!"
    515516        return
    cdef traverse_return *traverse_tree(obje 
    759760    output.num_gens = 0
    760761    if base:
    761762        output.base = <int *> sage_malloc( n * sizeof(int) )
     763        output.base_size = 0
    762764   
    763765    current_indicators = <int *> sage_malloc( n * sizeof(int) )
    764766    first_indicators = <int *> sage_malloc( n * sizeof(int) )
    cdef traverse_return *traverse_tree(obje 
    776778    cells_to_refine_by = <int *> sage_malloc( n * sizeof(int) )
    777779    vertices_determining_current_stack = <int *> sage_malloc( n * sizeof(int) )
    778780   
    779     current_ps = PS_new(n, False)
     781    current_ps = PS_new(n, 0)
    780782    orbits_of_subgroup = OP_new(n)
    781783   
    782784    # Check for allocation failures:
    cdef traverse_return *traverse_tree(obje 
    951953            label_indicators[i] = current_indicators[i]
    952954        if base:
    953955            output.base[i] = vertices_determining_current_stack[i]
     956            output.base_size += 1
    954957
    955958    first_meets_current = current_ps.depth
    956959    first_kids_are_same = current_ps.depth
    cdef traverse_return *traverse_tree(obje 
    971974            label_meets_current = current_ps.depth
    972975
    973976        # I. Search for a new vertex to split, and update subgroup information
    974 
    975977        new_vertex = 0
    976978        if current_ps.depth > first_meets_current:
    977979            # If we are not at a node of the first stack, reduce size of
    cdef traverse_return *traverse_tree(obje 
    11111113                    elif i < 0:
    11121114                        backtrack = 1
    11131115                    else:
     1116                        PS_get_perm_from(current_ps, label_ps, permutation)
    11141117                        automorphism = 1
    11151118                if update_label:
    11161119                    PS_copy_from_to(current_ps, label_ps)
    cdef traverse_return *traverse_tree(obje 
    12191222        if canonical_label:
    12201223            sage_free(output.relabeling)
    12211224        sage_free(output)
     1225        output = NULL
     1226        raise MemoryError
    12221227
    12231228
    12241229
    cdef traverse_return *traverse_tree(obje 
    12331238
    12341239
    12351240
    1236