Page 1 of 1

Create a PolyhedralFan from maximal cones

Posted: 02 Apr 2012, 10:33
by simon
Hi everyone,

just a little question on Fans:
I have a rather big list of all maximal cones of a pointed fan given as a list of Cones and I want to create a PolyhedralFan out of them.
Right now, I do the following: I create the large stackmatrix $R of all "->RAYS"-matrices (of course this is highly redundant) and then store the corresponding index-ranges for each cone in @Ind. Then the fan is

Code: Select all

$F = new PolyhedralFan(INPUT_RAYS=>$R, INPUT_CONES=>[@Ind]);
However, this is quite cumbersome. Is there another way to do this?

Re: Create a PolyhedralFan from maximal cones

Posted: 02 Apr 2012, 11:30
by gawrilow
At the risk of telling a complete nonsense... if you really know that your cones are the maximal ones and their list is complete, you can pass your data to the constructor as RAYS and MAXIMAL_CONES right away. You should only take care of duplicate rays. To this end, you can maintain a HashMap<Vector, Int> and renumber the elements in MAXIMAL_CONES input. On larger dimensions and with fewer cones Map might happen to be more efficient than HashMap.

Re: Create a PolyhedralFan from maximal cones

Posted: 02 Apr 2012, 21:31
by simon
Thanks for the quick reply.
This is embarrassing, but how do I use HashMap<Vector, Int>?
(I tried to use it like a usual perl hash, put this did not work.)

Could you post some small example?
Thanks in advance!

Re: Create a PolyhedralFan from maximal cones

Posted: 02 Apr 2012, 23:33
by gawrilow
It indeed works like a usual perl hash map, but requires a little adornment: the return value of the constructor

Code: Select all

$h=new HashMap<Vector, Int>;
is a reference, hence all operations must be accompanied with a dereferencing:

Code: Select all

if (defined $h->{$v}) { ... } $h->{$v}=$i; delete $h->{$v}; foreach my $k (keys %$h) { ... } while (my ($k, $v)=each %$h) { ... }