tutorial:perl_continued

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revisionBoth sides next revision
tutorial:perl_continued [2017/07/11 08:56] – removed typos oroehrigtutorial:perl_continued [2017/07/11 09:04] oroehrig
Line 110: Line 110:
  
 ==="Big Objects": Objects with properties=== ==="Big Objects": Objects with properties===
 +A big object is an instance of a data type which represents a mathematical concept with clear semantics. They may have template parameters. Big objects have properties which come with a type, which is either built-in or a small object type or a big object type, and which can be accessed using the ''->'' operator. 
 <code> <code>
 > $p=new Polytope<Rational>(POINTS=>cube(4)->VERTICES); > $p=new Polytope<Rational>(POINTS=>cube(4)->VERTICES);
 > $lp=new LinearProgram<Rational>(LINEAR_OBJECTIVE=>[0,1,1,1,1]); > $lp=new LinearProgram<Rational>(LINEAR_OBJECTIVE=>[0,1,1,1,1]);
 +> # access the property named ''LP'':
 > $p->LP=$lp; > $p->LP=$lp;
 +> # properties can have properties themselves.
 > print $p->LP->MAXIMAL_VALUE; > print $p->LP->MAXIMAL_VALUE;
 </code> </code>
Line 119: Line 122:
 {{:points.demo|}} {{:points.demo|}}
 <code> <code>
-open(INPUT, "< $HOME/polymake/demo/Workshop2011/points.demo"); +open(INPUT, "< $HOME/polymake/demo/Workshop2011/points.demo"); 
-$matrix=new Matrix<Rational>(<INPUT>); +$matrix=new Matrix<Rational>(<INPUT>); 
-close(INPUT); +close(INPUT); 
-print $matrix; +print $matrix; 
- + 
-$p=new Polytope<Rational>(POINTS=>$matrix); +$p=new Polytope<Rational>(POINTS=>$matrix); 
-print $p->FACETS; +print $p->FACETS; 
-print $p->DIM; +print $p->DIM; 
-print $p->VERTEX_SIZES; +print $p->VERTEX_SIZES; 
-### choose "simple" vertices +### choose "simple" vertices 
-for(my $i=0;$i<scalar(@{$p->VERTEX_SIZES});$i++){ +for(my $i=0;$i<scalar(@{$p->VERTEX_SIZES});$i++){ 
->     if($p->VERTEX_SIZES->[$i]==$p->DIM){ +    if($p->VERTEX_SIZES->[$i]==$p->DIM){ 
-> print $i.": ".$p->VERTICES->row($i)."\n"; + print $i.": ".$p->VERTICES->row($i)."\n"; 
->     +    
-+
-$s=new Set<Int>(); +$s=new Set<Int>(); 
-for(my $i=0;$i<scalar(@{$p->VERTEX_SIZES});$i++){ +for(my $i=0;$i<scalar(@{$p->VERTEX_SIZES});$i++){ 
->     if($p->VERTEX_SIZES->[$i]==$p->DIM){ +    if($p->VERTEX_SIZES->[$i]==$p->DIM){ 
-> $s+=$i; + $s+=$i; 
->     +    
-+
-$special_points=$p->VERTICES->minor($s,All); print $special_points; +$special_points=$p->VERTICES->minor($s,All); print $special_points; 
- + 
-foreach(@{$s}){ +foreach(@{$s}){ 
->     print $p->VERTICES->row($_)."\n"; +    print $p->VERTICES->row($_)."\n"; 
-+
-foreach my $index(@{$s}){ +foreach my $index(@{$s}){ 
->     print $p->VERTICES->row($index)."\n"; +    print $p->VERTICES->row($index)."\n"; 
-}+}
 </code> </code>
  
-===Scripts=== +===Scripts===
 [[scripting:start|Scripting]] [[scripting:start|Scripting]]