#  Copyright (c) 1997-2015
#  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.
#-------------------------------------------------------------------------------


object VectorConfiguration {

#property GROUP : group::GroupOfCone : multiple;

}

object PointConfiguration {

# @category Combinatorics
# The equivalence classes of maximal-dimensional simplices under a symmetry group 
rule GROUP.REPRESENTATIVE_SIMPLICES : VECTOR_DIM, POINTS, GROUP.GENERATORS {
    $this->GROUP->REPRESENTATIVE_SIMPLICES = representative_simplices($this->VECTOR_DIM-1, $this->POINTS, $this->GROUP->GENERATORS);
}

# @category Combinatorics
# The number of equivalence classes of maximal-dimensional simplices under a symmetry group 
rule GROUP.N_REPRESENTATIVE_SIMPLICES : GROUP.REPRESENTATIVE_SIMPLICES {
    my $cds = $this->GROUP->REPRESENTATIVE_SIMPLICES;
    my @n_vector = map { $cds->[$_]->size } (0..$cds->size-1);
    $this->GROUP->N_REPRESENTATIVE_SIMPLICES = \@n_vector;
}

# @category Combinatorics
# The equivalence classes of maximal-dimensional simplices in the interior and boundary under a symmetry group 
rule GROUP.REPRESENTATIVE_INTERIOR_RIDGE_SIMPLICES, GROUP.REPRESENTATIVE_MAX_BOUNDARY_SIMPLICES : VECTOR_DIM, CONVEX_HULL.VERTICES_IN_FACETS, CONVEX_HULL.VERTICES, GROUP.GENERATORS {
    my $pair = representative_interior_and_boundary_ridges($this);
    $this->GROUP->REPRESENTATIVE_INTERIOR_RIDGE_SIMPLICES = $pair->first;
    $this->GROUP->REPRESENTATIVE_MAX_BOUNDARY_SIMPLICES = $pair->second;
}


# @category Combinatorics
# The symmetrized version of the cocircuit equations, where equivalent simplices have been merged into the same variable
rule GROUP.SYMMETRIZED_COCIRCUIT_EQUATIONS : GROUP.REPRESENTATIVE_SIMPLICES, GROUP.DOMAIN, VECTOR_DIM, POINTS, CONVEX_HULL.VERTICES_IN_FACETS, GROUP.GENERATORS {
    my $group_on_vertices = group_acting_on_vertices($this, "GROUP");
    my $rs = representative_simplices($this->VECTOR_DIM-1, $this->POINTS, $group_on_vertices->GENERATORS);
    my $cceqs = symmetrized_cocircuit_equations($this->VECTOR_DIM-1, $this->POINTS, $this->CONVEX_HULL->VERTICES_IN_FACETS, $group_on_vertices->GENERATORS, $rs);
    $this->GROUP->SYMMETRIZED_COCIRCUIT_EQUATIONS = $cceqs;
}

# @category Combinatorics
# The symmetrized version of SIMPLEXITY_LOWER_BOUND
rule GROUP.SIMPLEXITY_LOWER_BOUND : CONVEX_HULL.VOLUME, GROUP.REPRESENTATIVE_MAX_INTERIOR_SIMPLICES, VECTOR_DIM, POINTS, GROUP.SYMMETRIZED_COCIRCUIT_EQUATIONS {
   my $d = $this->VECTOR_DIM-1;
   $this->GROUP->SIMPLEXITY_LOWER_BOUND = simplexity_lower_bound($this->VECTOR_DIM-1, $this->POINTS, $this->GROUP->REPRESENTATIVE_MAX_INTERIOR_SIMPLICES, $this->CONVEX_HULL->VOLUME, $this->GROUP->SYMMETRIZED_COCIRCUIT_EQUATIONS);
}


}


# @category Triangulations, subdivisions and volume
# Calculate the universal polytope of a point configuration
# @param PointConfiguration<Scalar> PC the point configuration
# @return Polytope
user_function universal_polytope<Scalar>(PointConfiguration<Scalar>) {
    my $p = shift;
    return universal_polytope_impl($p->VECTOR_DIM-1, $p->POINTS, $p->MAX_INTERIOR_SIMPLICES, $p->CONVEX_HULL->VOLUME, $p->COCIRCUIT_EQUATIONS);
}                      


# @category Triangulations, subdivisions and volume
# Find a set of representative simplices of the cone or polytope, up to its symmetry group in GROUP.
# The return value is an array whose //k//-th entry is the set of //k//-dimensional representatives.
# @param Cone P the input cone or polytope
# @option group_name the symmetry group to use; default is GROUP
# @return Array<Set<Set<Int>>>
#user_function representative_simplices<Scalar>(PointConfiguration<Scalar> { group_name=>'GROUP' }) {
#    representative_simplices_impl<Scalar>(@_);
#}


# @category Matroid properties
# Find projections of the representatives for the cocircuit equations of a PointConfiguration, up to symmetry
# @param PointConfiguration P the input point configuration
# @return SparseMatrix
#user_function symmetrized_cocircuit_equations<Scalar>(PointConfiguration<Scalar> { filename=>'', reduce_rows=>1 }) {
#    symmetrized_cocircuit_equations_impl<Scalar>(@_);
#}


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