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

Fix AsPartialPerm method for transformations #1036

Merged
merged 1 commit into from
Jan 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions doc/ref/pperm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,6 @@ gap> AsPartialPerm(f, [ 1, 2, 3 ] );
set of positive integer"/>
<Meth Name="AsPartialPerm" Arg="f, n" Label="for a transformation and a
positive integer"/>
<Meth Name="AsPartialPerm" Arg="f" Label="for a transformation"/>
<Returns>A partial permutation or <K>fail</K>.</Returns>
<Description>
A transformation <A>f</A> defines a partial permutation when it is
Expand All @@ -1095,33 +1094,19 @@ gap> AsPartialPerm(f, [ 1, 2, 3 ] );
integer and this set satisfies the
conditions given above.
</Item>
<Mark>for a transformation</Mark>
<Item>
Let <C>n</C> denote the degree of <A>f</A>. If
<C>n^<A>f</A>=n</C> and <A>f</A> is injective on those <C>i</C> such
that <C>i^<A>f</A>&lt;>n</C>, then <C>AsPartialPerm</C> returns
the partial permutation obtained by restricting <A>f</A> to those
<C>i</C> such that <C>i^<A>f</A>&lt;>n</C>.
</Item>
</List>

<C>AsPartialPerm</C> returns <K>fail</K> if the arguments do not describe a
partial permutation.<P/>

The operation <Ref Oper="PartialPermOp"/> can also be used to convert
transformations into partial permutations.

<Example>
gap> f:=Transformation( [ 8, 3, 5, 9, 6, 2, 9, 7, 9 ] );;
gap> AsPartialPerm(f);
[1,8,7](2,3,5,6)
gap> AsPartialPerm(f, [1, 2, 3, 5, 8]);
[1,8,7][2,3,5,6]
gap> AsPartialPerm(f, 3);
[1,8][2,3,5]
gap> AsPartialPerm(f, [ 2 .. 4 ] );
[2,3,5][4,9]
gap> f:=Transformation( [ 2, 10, 2, 4, 4, 7, 6, 9, 10, 1 ] );;
gap> AsPartialPerm(f);
fail</Example>
[2,3,5][4,9]</Example>
</Description>
</ManSection>
</Section>
Expand Down
33 changes: 5 additions & 28 deletions lib/pperm.gi
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,12 @@ InstallMethod(AsPartialPerm, "for a transformation and list",
[IsTransformation, IsList],
function(f, list)

if not IsSSortedList(list) or not ForAll(list, IsPosInt)
or not ForAll(list, i-> i<=DegreeOfTransformation(f)) then
Error("usage: the second argument must be a set of positive integers ",
"not greater than the degree of the first argument,");
return;
if not IsSSortedList(list) or not ForAll(list, IsPosInt) then
ErrorNoReturn("usage: the second argument must be a set of positive ",
"integers,");
elif not IsInjectiveListTrans(list, f) then
Error("usage: the first argument must be injective on the second,");
return fail;
ErrorNoReturn("usage: the first argument must be injective on the ",
"second,");
fi;
return PartialPermNC(list, OnTuples(list, f));
end);
Expand All @@ -249,27 +247,6 @@ function(f, n)
return AsPartialPerm(f, [1..n]);
end);

# c method? JDM

InstallMethod(AsPartialPerm, "for a transformation",
[IsTransformation],
function(f)
local img, n;
n:=DegreeOfTransformation(f);
if not n^f=n then
return fail;
fi;
return PartialPerm(List([1..n], function(i)
local j;
j:=i^f;
if j=n then
return 0;
else
return j;
fi;
end));
end);

# n is image of undefined points
InstallMethod(AsTransformation, "for a partial perm and positive integer",
[IsPartialPerm, IsPosInt],
Expand Down
4 changes: 0 additions & 4 deletions tst/testinstall/pperm.tst
Original file line number Diff line number Diff line change
Expand Up @@ -2286,17 +2286,13 @@ gap> AsTransformation(f);
<transformation: 6,2,5,10,4,7,8,9,10>
gap> AsTransformation(f, 12);
<transformation: 6,2,5,12,4,7,8,9,12,10,12>
gap> AsPartialPerm(last);
[1,6,7,8,9][3,5,4](2)(10)
gap> f;
[1,6,7,8,9][3,5,4](2)(10)
gap> f:=PartialPermNC([ 1, 3, 4, 5, 6, 9 ], [ 9, 10, 5, 7, 2, 8 ]);;
gap> AsTransformation(f);
<transformation: 9,11,10,5,7,2,11,11,8,11>
gap> AsTransformation(f);
<transformation: 9,11,10,5,7,2,11,11,8,11>
gap> AsPartialPerm(last)=f;
true
gap> OnTuples([1..DegreeOfPartialPerm(f)], f);
[ 9, 10, 5, 7, 2, 8 ]
gap> g:=PartialPermNC([ 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 19 ],
Expand Down