[GAP Forum] Counting occurrences of double cosets, or changing values in dictionaries

Erick Matsen matsen at fredhutch.org
Mon Mar 9 21:27:33 GMT 2015


Hello everyone—

I have a random process that generates double cosets of the symmetric
group. I would like to keep track of how often I have seen the various
double cosets.

In hunting around, it seemed initially that dictionaries would be the
perfect solution. I was able to use double cosets as keys, and checked in a
few examples that it was doing the right thing. However, I have not been
able to change the value of dictionaries, which is the way I was thinking
about counting them.

The documentation <http://www.gap-system.org/Manuals/doc/ref/chap28.html>
says

We hash by keys and also store a value. Keys cannot be removed from the
> table, but the corresponding value can be changed. Fast access to last hash
> index allows you to efficiently store more than one array of values –this
> facility should be used with care.

How does one change these values? I can’t find how to do that.

If it matters, double cosets do not have an order in GAP4 and thus the
Dictionary storage happens as a ListLookupDictionary, for which the Add
method looks like:

#############################################################################
##
#M  AddDictionary(<dict>,<obj>,<val>)
##
InstallOtherMethod(AddDictionary,"for lookup list dictionaries",true,
  [IsListLookupDictionary and IsMutable,IsObject,IsObject],0,
function(d, x, val)
  x:=[Immutable(x),val];
  #  MakeImmutable(x); # to be able to store sortedness
  # We don't actually need to do that and we don't want to modify val
  #
  Add(d!.entries,x);
end);

Thank you!

Erick
​
-- 
Frederick "Erick" Matsen, Assistant Member
Fred Hutchinson Cancer Research Center
http://matsen.fredhutch.org/


More information about the Forum mailing list