Skip to content

Commit c41f1ce

Browse files
author
Matthias Koeppe
committed
sage.groups.perm_gps.partn_ref*: Remove dependency of everything on GAP
1 parent b9fd252 commit c41f1ce

File tree

4 files changed

+44
-7
lines changed

4 files changed

+44
-7
lines changed

src/sage/groups/perm_gps/partn_ref/data_structures.pxd

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ from sage.data_structures.bitset_base cimport *
1313
from libc.string cimport memcpy
1414
from libc.stdlib cimport rand
1515
from sage.libs.gmp.mpz cimport *
16-
from sage.groups.perm_gps.partn_ref2.refinement_generic cimport PartitionRefinement_generic
1716

1817

1918
cdef enum:
@@ -260,8 +259,7 @@ cdef PS_print(PartitionStack *PS)
260259

261260
cdef void PS_unit_partition(PartitionStack *PS)
262261

263-
cdef int PS_first_smallest(PartitionStack *PS, bitset_t b, int *second_pos=?,
264-
PartitionRefinement_generic partn_ref_alg=?)
262+
cdef int PS_first_smallest(PartitionStack *PS, bitset_t b, int *second_pos=?)
265263

266264
cdef PartitionStack *PS_from_list(list L)
267265

src/sage/groups/perm_gps/partn_ref/data_structures.pyx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,7 @@ cdef PS_print_partition(PartitionStack *PS, int k):
284284
s = s[:-1] + ')'
285285
print(s)
286286

287-
cdef int PS_first_smallest(PartitionStack *PS, bitset_t b, int *second_pos=NULL,
288-
PartitionRefinement_generic partn_ref_alg=None):
287+
cdef int PS_first_smallest(PartitionStack *PS, bitset_t b, int *second_pos=NULL):
289288
"""
290289
Find the first occurrence of the smallest cell of size greater than one,
291290
which is admissible (checked by the function ``test_allowance``).
@@ -295,8 +294,7 @@ cdef int PS_first_smallest(PartitionStack *PS, bitset_t b, int *second_pos=NULL,
295294
bitset_zero(b)
296295
while 1:
297296
if PS.levels[i] <= PS.depth:
298-
if i != j and n > i - j + 1 and (partn_ref_alg is None or
299-
partn_ref_alg._minimization_allowed_on_col(PS.entries[j])):
297+
if i != j and n > i - j + 1:
300298
n = i - j + 1
301299
location = j
302300
j = i + 1

src/sage/groups/perm_gps/partn_ref2/refinement_generic.pxd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,7 @@ cdef class PartitionRefinement_generic:
8282
bint* inner_group_changed, bint* changed_partition,
8383
str refine_name)
8484
cdef int len(self)
85+
86+
87+
cdef int PS_first_smallest_PR(PartitionStack *PS, bitset_t b, int *second_pos=?,
88+
PartitionRefinement_generic partn_ref_alg=?)

src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,3 +941,40 @@ cdef class PartitionRefinement_generic:
941941
"""
942942
if BACKTRACK_WITHLATEX_DEBUG:
943943
self._latex_debug_string += "]\n"
944+
945+
946+
cdef int PS_first_smallest_PR(PartitionStack *PS, bitset_t b, int *second_pos=NULL,
947+
PartitionRefinement_generic partn_ref_alg=None):
948+
"""
949+
Find the first occurrence of the smallest cell of size greater than one,
950+
which is admissible (checked by the function ``test_allowance``).
951+
Its entries are stored to b and its minimum element is returned.
952+
953+
This generalizes :func:`sage.groups.perm_gps.partn_ref.data_structures.PS_first_smallest`.
954+
"""
955+
cdef int i = 0, j = 0, location = 0, n = PS.degree
956+
bitset_zero(b)
957+
while 1:
958+
if PS.levels[i] <= PS.depth:
959+
if i != j and n > i - j + 1 and (partn_ref_alg is None or
960+
partn_ref_alg._minimization_allowed_on_col(PS.entries[j])):
961+
n = i - j + 1
962+
location = j
963+
j = i + 1
964+
if PS.levels[i] == -1: break
965+
i += 1
966+
# location now points to the beginning of the first, smallest,
967+
# nontrivial cell
968+
i = location
969+
while 1:
970+
bitset_flip(b, PS.entries[i])
971+
if PS.levels[i] <= PS.depth: break
972+
i += 1
973+
974+
if second_pos != NULL:
975+
if n==2:
976+
second_pos[0] = PS.entries[location+1]
977+
else:
978+
second_pos[0] = -1
979+
980+
return PS.entries[location]

0 commit comments

Comments
 (0)