Create a PolyhedralFan from maximal cones

Questions and problems about using polymake go here.
simon
Posts: 13
Joined: 18 Mar 2012, 19:47

Create a PolyhedralFan from maximal cones

Postby simon » 02 Apr 2012, 10:33

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?

User avatar
gawrilow
Main Author
Posts: 423
Joined: 25 Dec 2010, 17:40

Re: Create a PolyhedralFan from maximal cones

Postby gawrilow » 02 Apr 2012, 11:30

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.

simon
Posts: 13
Joined: 18 Mar 2012, 19:47

Re: Create a PolyhedralFan from maximal cones

Postby simon » 02 Apr 2012, 21:31

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!

User avatar
gawrilow
Main Author
Posts: 423
Joined: 25 Dec 2010, 17:40

Re: Create a PolyhedralFan from maximal cones

Postby gawrilow » 02 Apr 2012, 23:33

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) { ... }


Return to “Helpdesk”