#  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 Cone {

    property GROUP {

        # @category Symmetry
        # One representative for each orbit of interior ridge simplices
        property REPRESENTATIVE_INTERIOR_RIDGE_SIMPLICES : Array<Bitset>;

        # @category Symmetry
        # One representative for each orbit of boundary ridge simplices
        property REPRESENTATIVE_BOUNDARY_RIDGE_SIMPLICES : Array<Bitset>;

        # @category Symmetry
        # One representative for each orbit of maximal-dimensional interior simplices
        property REPRESENTATIVE_MAX_INTERIOR_SIMPLICES : Array<Bitset>;
    }

    # @category Symmetry
    # The equivalence classes of maximal-dimensional simplices in the interior and boundary under a symmetry group 
    rule GROUP.REPRESENTATIVE_INTERIOR_RIDGE_SIMPLICES, GROUP.REPRESENTATIVE_BOUNDARY_RIDGE_SIMPLICES : COMBINATORIAL_DIM, RAYS_IN_FACETS, RAYS, GROUP.RAYS_ACTION.GENERATORS {
        my $pair = representative_interior_and_boundary_ridges($this);
        $this->GROUP->REPRESENTATIVE_INTERIOR_RIDGE_SIMPLICES = $pair->first;
        $this->GROUP->REPRESENTATIVE_BOUNDARY_RIDGE_SIMPLICES = $pair->second;
    }

    # @category Symmetry
    # The equivalence classes of maximal-dimensional simplices in the boundary under a symmetry group 
    rule GROUP.REPRESENTATIVE_MAX_INTERIOR_SIMPLICES : COMBINATORIAL_DIM, RAYS, GROUP.RAYS_ACTION.GENERATORS {
        $this->GROUP->REPRESENTATIVE_MAX_INTERIOR_SIMPLICES = representative_max_interior_simplices($this->COMBINATORIAL_DIM, $this->RAYS, $this->GROUP->RAYS_ACTION->GENERATORS);
    }

}

sub symmetrized_cocircuit_equations;

# @category Symmetry
# calculate the projection of the cocircuit equations to a direct sum of isotypic components
# @param Cone P
# @param group::PermutationActionOnSets action
# @param Set<Int> irrep the list of indices of the isotypic components to project to; default {0}, which
# amounts to summing all cocircuit equations corresponding to the orbit of each ridge.
# @option Bool reduce_rows Should we return only linearly independent equations? default: true
user_function symmetrized_cocircuit_equations<Scalar>(Cone<Scalar> group::PermutationActionOnSets; Set<Int>=(new Set<Int>([0])) { "reduce_rows" => 1 }) {
    my ($p, $rep, $irrep_array, $options) = @_;
    my @total_basis;
    my $irreps = new Set<Int>($irrep_array);
    foreach my $i (@{$irreps}) {
        my $isotypic_component = $rep->give("ISOTYPIC_COMPONENT", IRREP=>$i);
        foreach (@{$isotypic_component->SPARSE_BASIS}) {
            push @total_basis, $_;
        }
    }
    return symmetrized_cocircuit_equations($p->RAYS, $p->GROUP->REPRESENTATIVE_INTERIOR_RIDGE_SIMPLICES, $irreps, $rep->GROUP->CHARACTER_TABLE, $rep->GROUP->CONJUGACY_CLASSES, (new Array<HashMap<Bitset,Rational>>(\@total_basis)), $options->{"reduce_rows"});
}


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