;### 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++ $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 $arr2; $set=new Set(3,2,5); print $set; $mat=new Matrix([[2,1,4,0,0],[3,1,5,2,1],[1,0,4,0,6]]); print $mat; $mat->row(1)->[1]=7; print $mat; $mat->(1,2)=8; print $mat; print 4*unit_matrix(3); $m_rat=new Matrix(3/5*unit_matrix(5)); print $m_rat; $m2=$mat/$m_rat; print $m2; $m_int=new Matrix(unit_matrix(5)); print $m_int; $m3=$m_rat/$m_int; $m3=$m_rat/(convert_to($m_int)); print $m3; $z_vec=zero_vector($m_int->rows); $extended_matrix=($z_vec|$m_int); print $extended_matrix; $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; ; ;### WORKING WITH PERL IN POLYMAKE open(INPUT, "< /home/katrin/polymake/demo/Workshop2011/points.demo"); $matrix=new Matrix(); close(INPUT); print $matrix; $p=new Polytope(POINTS=>$matrix); print $p->FACETS; print $p->DIM; print $p->VERTEX_SIZES; ;### choose "simple" vertices for(my $i=0;$iVERTEX_SIZES});$i++){ if($p->VERTEX_SIZES->[$i]==$p->DIM){ print $i.": ".$p->VERTICES->row($i)."\n"; } } $s=new Set(); for(my $i=0;$iVERTEX_SIZES});$i++){ if($p->VERTEX_SIZES->[$i]==$p->DIM){ $s+=$i; } } $special_points=$p->VERTICES->minor($s,All); print $special_points; ; foreach(@{$s}){ print $p->VERTICES->row($_)."\n"; } foreach my $index(@{$s}){ print $p->VERTICES->row($index)."\n"; } ; ;### SCRIPTS