Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lex Least Dyclet #270

Merged
merged 10 commits into from
Sep 9, 2024
62 changes: 62 additions & 0 deletions gap/utilities.g
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,65 @@
);



#############################################################################
##
#F LexicographicallyLeastDyclet . . . . . . . lexicographically least dyclet
##
## A dyclet represents the orbit of a list under the diherdral group of the
## list. Find the lexicographically least representative of the dyclet.
##

# called for lists of sets
BindGlobal( "__SIMPLICIAL_LexicographicallyLeastDyclet",
function(dyclet)

local n, min_dyclet, k, perm, mirror_dyclet;

if (Filtered(dyclet,i-> not IsInt(i))<>[]) or (Length(dyclet)=0) then
Error("Dyclet must be a list of integers");
return fail;
fi;
n := Size(dyclet);

Check warning on line 68 in gap/utilities.g

View check run for this annotation

Codecov / codecov/patch

gap/utilities.g#L64-L68

Added lines #L64 - L68 were not covered by tests
# current candidate for minimal dyclet
min_dyclet := ShallowCopy(dyclet);
perm := Reversed(dyclet);
if perm < min_dyclet then min_dyclet := perm; fi;

Check warning on line 72 in gap/utilities.g

View check run for this annotation

Codecov / codecov/patch

gap/utilities.g#L70-L72

Added lines #L70 - L72 were not covered by tests

# Generate all cyclic permutations and their mirror images
for k in [1..n-1] do
perm := Concatenation(dyclet{[1+k..n]}, dyclet{[1..k]});
mirror_dyclet := Reversed(perm);

Check warning on line 77 in gap/utilities.g

View check run for this annotation

Codecov / codecov/patch

gap/utilities.g#L75-L77

Added lines #L75 - L77 were not covered by tests

if perm < min_dyclet then
min_dyclet := perm;
fi;

Check warning on line 81 in gap/utilities.g

View check run for this annotation

Codecov / codecov/patch

gap/utilities.g#L79-L81

Added lines #L79 - L81 were not covered by tests

if mirror_dyclet < min_dyclet then
min_dyclet := mirror_dyclet;
fi;
od;

Check warning on line 86 in gap/utilities.g

View check run for this annotation

Codecov / codecov/patch

gap/utilities.g#L83-L86

Added lines #L83 - L86 were not covered by tests

return min_dyclet;

Check warning on line 88 in gap/utilities.g

View check run for this annotation

Codecov / codecov/patch

gap/utilities.g#L88

Added line #L88 was not covered by tests
end
);


#############################################################################
##
#F LtDyclet . . . . . . . . . . . . less than comparisons of dyclets
##
BindGlobal( "__SIMPLICIAL_LtDyclet",
function( dyc1, dyc2 )

if __SIMPLICIAL_LexicographicallyLeastDyclet(dyc1)
< __SIMPLICIAL_LexicographicallyLeastDyclet(dyc2) then return true;
fi;

Check warning on line 102 in gap/utilities.g

View check run for this annotation

Codecov / codecov/patch

gap/utilities.g#L100-L102

Added lines #L100 - L102 were not covered by tests

return false;

Check warning on line 104 in gap/utilities.g

View check run for this annotation

Codecov / codecov/patch

gap/utilities.g#L104

Added line #L104 was not covered by tests

end
);



Loading