Converting Vector<Int> to Vector<TropicalNumber<Max> >

Questions and problems about using polymake go here.
ren
Posts: 38
Joined: 03 May 2011, 15:21

Converting Vector<Int> to Vector<TropicalNumber<Max> >

Postby ren » 13 Dec 2016, 12:58

What is the proper way to convert a Vector<Int> to Vector<TropicalNumber<Max> >? I am currently admiring polymake's features for tropical geometry and trying to construct a curve from a subdivision of the Newton polygon:

Code: Select all

$points = new Matrix<Int>( [[1,0,0], [1,1,0], [1,2,0], [1,3,0], [1,4,0], [1,0,1], [1,1,1], [1,2,1], [1,3,1], [1,0,2], [1,1,2], [1,2,2], [1,0,3], [1,1,3], [1,0,4]]); $v00 = 0; $v10 = 1; $v20 = 2; $v30 = 3; $v40 = 4; $v01 = 5; $v11 = 6; $v21 = 7; $v31 = 8; $v02 = 9; $v12 = 10; $v22 = 11; $v03 = 12; $v13 = 13; $v04 = 14; $cells = new Array<Set<Int>>( [[$v00,$v11,$v02], [$v00,$v10,$v11], [$v10,$v22,$v11], [$v10,$v21,$v22], [$v10,$v20,$v21], [$v20,$v30,$v21], [$v30,$v31,$v21], [$v30,$v40,$v31], [$v11,$v12,$v02], [$v11,$v22,$v12], [$v21,$v31,$v22], [$v02,$v12,$v03], [$v12,$v13,$v03], [$v12,$v22,$v13], [$v03,$v13,$v04]] ); $pc = new fan::PolyhedralComplex(POINTS=>$points, INPUT_POLYTOPES=>$cells); $pc->VISUAL; print is_regular($points, $cells);
I obtain the following lift, which I multiply with the common denominator to make the entries integral:

Code: Select all

$w = new Vector<Int>([0,1/12,2/3,4/3,13/6,1/12,0,3/8,9/8,0,1/24,1/4,1/8,1/4,5/12]); $w = $w*24;
But plugging this vector as COEFFICIENTS into TropicalHypersurface does not work:

Code: Select all

$Tg = new Hypersurface<Max>(MONOMIALS=>$points,COEFFICIENTS=>$w);
So how do I convert $w into a Vector<TropicalNumber<Max> >? The following conversion failed:

Code: Select all

$ww = new Vector<TropicalNumber<Max> >($w);

User avatar
hampe
Developer
Posts: 48
Joined: 29 Apr 2011, 10:42

Re: Converting Vector<Int> to Vector<TropicalNumber<Max> >

Postby hampe » 13 Dec 2016, 13:28

Your example fails earlier on my computer

Code: Select all

polytope > $w = new Vector<Int>([0,1/12,2/3,4/3,13/6,1/12,0,3/8,9/8,0,1/24,1/4,1/8,1/4,5/12]); polymake: ERROR: non-integral number at input line 1.
Which makes sense, as 1/12 is not integer.
Also, doing

Code: Select all

$v = new Vector<Int>(1,2,3); $w = new Vector<TropicalNumber<Max >>($v);
works fine for me. I remember that we had some issues with converting to tropical numbers in older versions. What polymake version are you using?

You could try using Vector<Rational> instead of Vector<Int>. If that doesn't help, you could either upgrade to the new snapshot version or try the following tedious workaround:

Code: Select all

$w = new Vector<TropicalNumber<Max>>(map {new TropicalNumber<Max>($_)} @{$v});

ren
Posts: 38
Joined: 03 May 2011, 15:21

Re: Converting Vector<Int> to Vector<TropicalNumber<Max> >

Postby ren » 13 Dec 2016, 14:10

Ah sorry, the code I meant to post was
$wRat = new Vector<Rational>([0,1/12,2/3,4/3,13/6,1/12,0,3/8,9/8,0,1/24,1/4,1/8,1/4,5/12]);
$wRat = $w*24;
$wInt = new Vector<Int>($wRat);
$wTrop = new Vector<TropicalNumber<Max> >($wInt);
The last line causes an error in my polymake, which is version 3.0.

I'll try to update my polymake to the newest snapshot asap, in the meantime I will use your workaround, thanks!


Return to “Helpdesk”