# Copyright (c) 1997-2004 # Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany) # http://www.math.tu-berlin.de/polymake, mailto:polymake@math.tu-berlin.de # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2, or (at your option) any # later version: http://www.gnu.org/licenses/gpl.txt. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. #----------------------------------------------------------------------------- # $Project: polymake $$Id: polytope_completeness 5639 2004-12-17 21:36:25Z gawrilow $ sub complete($) { my ($pq)=@_; # maybe only a partial polytope my $d=$pq->DIM; # impossible to detect completeness without the dimension my $crosscut=new Apps::topaz::SimplicialComplex(); Modules::client("crosscut_complex", $crosscut, $pq, "-noc"); # reads VERTICES_IN_FACETS return ${$crosscut->HOMOLOGY}[$d-1] eq "({} 1)\n"; } sub verify_poly($) { my ($pq)=@_; eval { Modules::client("check_inc", $pq, "VERTICES", "FACETS", "0+", "-q") }; return $@==0 ? complete($pq) : undef; } sub main($$) { my ($p,$q)=@_; die "only works if first polytope is full-dimensional" if ($p->AMBIENT_DIM!=$p->DIM); my $same=($p->AMBIENT_DIM == $q->AMBIENT_DIM); if ($same) { # what follows is a severe abuse of polymake semantics my $pq=new Apps::polytope::RationalPolytope(VERTICES => $p->VERTICES, FACETS => $q->FACETS, DIM => $p->DIM); $same=verify_poly($pq); } if ($same) { print "the two polytopes agree\n"; } else { print "the two polytopes do not agree\n"; } } 1 # Local Variables: # mode: perl # c-basic-offset:3 # End: