Page 1 of 1

The root_system function

Posted: 21 Mar 2019, 23:00
by mjs
I am writing a script which involves constructing the vectors e_i-e_j for certain values of i and j. My current code involves a lot of looping and takes a long time, and I am sure that there must be a better way. I saw in the polymake documentation that there is a function called root_system which returns a vector configuration. I think that this could be useful to me, but I cannot figure out how to use it. I cannot find any examples online of code where it is used, and when I try to call it in the polymake shell, I get the following error:

Code: Select all

polymake > $r = root_system('A3'); polymake: ERROR: Undefined subroutine &Polymake ::User::root_system called at input line 1.
Can you help me with this function and/or direct me to someplace where I can find information about it? Alternatively, is there a different method that you would recommend for constructing standard basis vectors or vectors of the form e_i-e_j?

Re: The root_system function

Posted: 21 Mar 2019, 23:46
by gawrilow
root_system is defined in application "polytope", so you can call it by qualified name "polytope::root_system(...)". Namespace prefix can be omitted when your current application is "polytope" or "fan".

In your post, the shell prompt says "polymake" which looks suspicious - there is no such application.

Re: The root_system function

Posted: 22 Mar 2019, 07:39
by mjs
Thanks for the response! In my original post I was transcribing and I made an error -- I was actually in the polytope application. So this does not seem to explain my problem.

Re: The root_system function

Posted: 22 Mar 2019, 12:02
by joswig
Please tell us which polymake version your are using on which operating system. Did you compile from source code (then, please, send your file build/config.ninja), or did you use some precompiled version from some package manager (which?).

Re: The root_system function

Posted: 26 Mar 2019, 10:20
by mjs
I am using Polymake version 3.0 on the Ubuntu Linux subsystem for Windows 10. I installed polymake through the Ubuntu package manager.

Re: The root_system function

Posted: 26 Mar 2019, 10:40
by gawrilow
Sorry, your version is too old. root_system was introduced in 3.1 .

Re: The root_system function

Posted: 26 Mar 2019, 10:57
by mjs
Ah, I see. Here is the embarrassingly slow code that I came up with to construct the vector e_l-e_{l+i} for a given l and i:

Code: Select all

my $neweq = new Vector([0]); for(my $j=0;$j<$n;$j++){ if($j==$l){ $neweq = $neweq|new Vector([1]); } elsif($j==$l+$i){ $neweq = $neweq|new Vector([-1]); } else { $neweq = $neweq|new Vector([0]); } }
Is there a simple method that you would recommend for constructing certain standard basis vectors or vectors of the form e_i-e_j, without using root_system?

Re: The root_system function

Posted: 26 Mar 2019, 13:51
by gawrilow
Vectors offer random access to their elements, so simply do this:

Code: Select all

my $neweq = new Vector($n + 1); # automatically fills with zeroes $neweq->[$l + 1] = 1; $neweq->[$l + $i + 1] = -1;

Re: The root_system function

Posted: 26 Mar 2019, 14:14
by mjs
Great, thank you for your help!