#  Copyright (c) 1997-2016
#  Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
#  http://www.polymake.org
#
#  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.
#-------------------------------------------------------------------------------

# A rational cone in Q^d.
object Cone<Rational> {

# cdd conversion primal <-> dual
# FIXME maybe combine into one client
rule cdd.convex_hull.primal: FACETS, LINEAR_SPAN : RAYS | INPUT_RAYS {
   cdd_ch_primal($this);
}
weight 4.10;
precondition : N_RAYS | N_INPUT_RAYS;
incurs FacetPerm;

rule cdd.convex_hull.dual: RAYS, LINEALITY_SPACE, POINTED, LINEALITY_DIM : FACETS | INEQUALITIES {
    cdd_ch_dual($this);
}
weight 4.10;
incurs VertexPerm;

# cdd redundancy checks
rule cdd.convex_hull.canon: POINTED, RAYS, LINEALITY_SPACE : INPUT_RAYS {
   cdd_canonicalize($this,0);
}
weight 3.10;
incurs VertexPerm;

rule cdd.convex_hull.lineality: LINEALITY_SPACE, POINTED : INPUT_RAYS {
   cdd_canonicalize_lineality($this,0);
}
weight 3.10;

rule cdd.convex_hull.redund: RAYS, RAY_SEPARATORS, LINEALITY_SPACE : INPUT_RAYS {
   cdd_eliminate_redundant_points($this);
}
weight 3.20;
precondition : POINTED;
incurs VertexPerm;

rule cdd.convex_hull.separators: RAY_SEPARATORS : RAYS {
   cdd_vertex_normals($this);
}
weight 3.20;
incurs VertexPerm;

rule cdd.convex_hull.canon : FACETS, LINEAR_SPAN : INEQUALITIES { 
  cdd_canonicalize($this,1)
}
weight 3.20;
incurs FacetPerm;

rule cdd.convex_hull.linear_span : LINEAR_SPAN : INEQUALITIES {     
   cdd_canonicalize_lineality($this,1);
}
precondition : INEQUALITIES | EQUATIONS {
  ($this->INEQUALITIES | EQUATIONS)->rows;
}
weight 3.10;

# FIXME potential new rules for symmetry with dual case
# clients would need bool primal as parameter
#
# rule cdd.convex_hull.redund: FACETS, FACET_CERTIFICATES : INEQUALITIES {   # lookup EQUATIONS
#   cdd_eliminate_redundant_points($this);
#}
#weight 3.20;
#precondition : FULL_DIM;
#incurs FacetPerm;

# rule cdd.convex_hull.facet_certificates: FACET_CERTIFICATES : FACETS { 
#   cdd_vertex_normals($this);
#}
#weight 3.20;

}


INCLUDE
   lp_rational.rules

# Local Variables:
# cperl-indent-level:3
# mode: perl
# End:
