;### CONSTRUCTING A POLYTOPE $orig_points=new Matrix([[1,2,0],[0,1,2],[2,0,1],[1,1,1],[1,0,2],[2,1,0],[0,2,1]]); ;### Loading data from file? -> see tutorial "Save and load data in polymake" ;### homogenization: prepend ones-vector $fst_col=ones_vector($orig_points->rows); print $fst_col; $homog_points=$fst_col|$orig_points; print $homog_points; $p=new Polytope(POINTS=>$homog_points); print $p->VERTICES; print "Number of points: ".$p->N_POINTS.", number of vertices: ".$p->N_VERTICES; $p->VISUAL; $p->VISUAL(VertexThickness=>3,VertexColor=>"green",FacetColor=>"blue"); ;### more information about visualization: tutorial VIS and wiki page print "Ambient dimension: ".$p->AMBIENT_DIM.", dimension of the polytope: ".$p->DIM; $p_proj=projection_full($p); print $p_proj->VERTICES; ; ;### CONVEX HULL COMPUTATIONS $pyr=pyramid(n_gon); print $pyr->list_properties; print join(", ", $pyr->list_properties); $schedule=$pyr->get_schedule("FACETS"); print join("\n", $schedule->list); prefer "lrs"; $schedule=$pyr->get_schedule("FACETS"); print join("\n", $schedule->list); print $p->FACETS; ; ;### COMPUTING LATTICE POINTS $schedule=$pyr->get_schedule("LATTICE_POINTS"); print join("\n", $schedule->list); print $pyr->LATTICE_POINTS; $pyr->VISUAL->LATTICE; ; ;### PERL SYNTAX FOR POLYMAKE ;### STANDARD DATA STRUCTURES i=5; $i=5; @array=("a","b","c"); print scalar(@array); push(@array,"d"); print "@array"; $first_entry=$array[0]; print $first_entry; print join("\n",@array); @array2=(3,1,4,2); print sort(@array2); %hash=(); $hash{"zero"}=0; $hash{"four"}=4; print keys %hash; print join(", ",keys %hash); print join(", ",values %hash); %hash=("one",1,"two",2); %hash=("one"=>1,"two"=>2); ; ;### "SMALL OBJECTS": DATA STRUCTURES INHERITED FROM C++ ;### ARRAY $arr1=new Array(\@array); print $arr1; $arr2=new Array([3,2,5]); print $arr2; $arr3=new Array(0,1,2,3); print $arr3; $arr4=new Array(0..4); print $arr4; @arr4=@{$arr4}; print @arr4; ;### SET $set=new Set(3,2,5); print $set; ;### MATRIX $mat=new Matrix([[2,1,4,0,0,1],[3,1,5,2,1,2],[1,0,4,0,6,0]]); print $mat; $mat->row(1)->[1]=7; print $mat; $mat->(1,2)=8; print $mat; print 4*unit_matrix(6); $scaled_unitmat=new Matrix(4*unit_matrix(6)); print $scaled_unitmat; $append=$mat/$scaled_unitmat; print $append; $z_vec=zero_vector($append->rows); $extend=($z_vec|$append); print $extend; print $set; $cols235=$extend->minor(All,$set); print $cols235; ;### TEMPLATES $template_Ex=new Array>((new Set(5,2,6)),$set); print $template_Ex; ; ;### "BIG OBJECTS": OBJECTS WITH PROPERTIES $p=new Polytope(POINTS=>cube(4)->VERTICES); $lp=new LinearProgram(LINEAR_OBJECTIVE=>[0,1,1,1,1]); $p->LP=$lp; print $p->LP->MAXIMAL_VALUE; ;