# HG changeset patch
# User Robert L. Miller <rlm@rlmiller.org>
# Date 1218045593 25200
# Node ID a3565e4f0f9ba13547775e64edaa16dbf441bd0d
# Parent b1de815b82dd2e5fc79e9ef0cf70700d2cb5957c
a few optimizations/fixes
diff -r b1de815b82dd -r a3565e4f0f9b sage/groups/perm_gps/partn_ref/refinement_graphs.pxd
|
a
|
b
|
|
| 24 | 24 | cdef int refine_by_degree(PartitionStack *, object, int *, int) |
| 25 | 25 | cdef int compare_graphs(int *, int *, object) |
| 26 | 26 | cdef bint all_children_are_equivalent(PartitionStack *, object) |
| 27 | | cdef int degree(PartitionStack *, CGraph, int, int, bint) |
| 28 | | cdef int sort_by_function(PartitionStack *, int, int *) |
| | 27 | cdef inline int degree(PartitionStack *, CGraph, int, int, bint) |
| | 28 | cdef inline int sort_by_function(PartitionStack *, int, int *) |
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | |
diff -r b1de815b82dd -r a3565e4f0f9b sage/groups/perm_gps/partn_ref/refinement_graphs.pyx
|
a
|
b
|
|
| 239 | 239 | for i from 0 <= i < len(partition): |
| 240 | 240 | part[i] = <int *> sage_malloc((len(partition[i])+1) * sizeof(int)) |
| 241 | 241 | if part[i] is NULL: |
| | 242 | for j from 0 <= j < i: |
| | 243 | sage_free(part[j]) |
| | 244 | sage_free(part) |
| 242 | 245 | raise MemoryError |
| 243 | 246 | for j from 0 <= j < len(partition[i]): |
| 244 | 247 | part[i][j] = partition[i][j] |
| … |
… |
|
| 251 | 254 | GS.use_indicator = 1 if use_indicator_function else 0 |
| 252 | 255 | GS.scratch = <int *> sage_malloc( (3*G.num_verts + 1) * sizeof(int) ) |
| 253 | 256 | if GS.scratch is NULL: |
| | 257 | for j from 0 <= j < len(partition): |
| | 258 | sage_free(part[j]) |
| | 259 | sage_free(part) |
| 254 | 260 | raise MemoryError |
| 255 | 261 | |
| 256 | 262 | output = traverse_tree(GS, part, G.num_verts, &all_children_are_equivalent, &refine_by_degree, &compare_graphs, lab, base, order) |
| … |
… |
|
| 360 | 366 | cells_to_refine_by[against_index] = first_largest_subcell |
| 361 | 367 | break |
| 362 | 368 | against_index += 1 |
| 363 | | against_index = ctrb_len |
| 364 | 369 | r = current_cell |
| 365 | 370 | while 1: |
| 366 | 371 | if r == current_cell or PS.levels[r-1] == PS.depth: |
| 367 | 372 | if r != first_largest_subcell: |
| 368 | | cells_to_refine_by[against_index] = r |
| 369 | | against_index += 1 |
| | 373 | cells_to_refine_by[ctrb_len] = r |
| 370 | 374 | ctrb_len += 1 |
| 371 | 375 | r += 1 |
| 372 | 376 | if r >= i: |
| … |
… |
|
| 473 | 477 | return 1 |
| 474 | 478 | return 0 |
| 475 | 479 | |
| 476 | | cdef int degree(PartitionStack *PS, CGraph G, int entry, int cell_index, bint reverse): |
| | 480 | cdef inline int degree(PartitionStack *PS, CGraph G, int entry, int cell_index, bint reverse): |
| 477 | 481 | """ |
| 478 | 482 | Returns the number of edges from the vertex corresponding to entry to |
| 479 | 483 | vertices in the cell corresponding to cell_index. |
| … |
… |
|
| 506 | 510 | break |
| 507 | 511 | return num_arcs |
| 508 | 512 | |
| 509 | | cdef int sort_by_function(PartitionStack *PS, int start, int *degrees): |
| | 513 | cdef inline int sort_by_function(PartitionStack *PS, int start, int *degrees): |
| 510 | 514 | """ |
| 511 | 515 | A simple counting sort, given the degrees of vertices to a certain cell. |
| 512 | 516 | |
| … |
… |
|
| 517 | 521 | |
| 518 | 522 | """ |
| 519 | 523 | cdef int n = PS.degree |
| 520 | | cdef int i, j, m = 2*n, max, max_location |
| | 524 | cdef int i, j, max, max_location |
| 521 | 525 | cdef int *counts = degrees + n, *output = degrees + 2*n + 1 |
| 522 | 526 | for i from 0 <= i <= n: |
| 523 | 527 | counts[i] = 0 |