1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
# Copyright (c) 1997-2024
# Ewgenij Gawrilow, Michael Joswig, and the polymake team
# Technische Universität Berlin, Germany
# https://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.
#-------------------------------------------------------------------------------
# @category Other
# Returns a Wronski polynomial of a [[topaz::FOLDABLE]] triangulation of a lattice polytope
# @param Matrix<Int> M points (in homogeneous coordinates); affinely span the space
# @param Vector<Int> lambda height function on lattice points
# @param Array<Rational> coeff coefficients
# @param Rational s additional Parameter in the polynomial
# @option topaz::SimplicialComplex triangulation The triangulation of the pointset corresponding to the lifting function
user_function wronski_polynomial(Matrix, Vector, Array<Rational>, $; {triangulation => undef}) {
my ($M, $lambda, $coeffs, $s, $options) = @_;
my ($n, $d) = ($M->rows(), $M->cols()-1);
my $T = $options->{"triangulation"};
if (!defined($options->{"triangulation"})) {
$T=new topaz::SimplicialComplex(FACETS=>polytope::regular_subdivision($M,$lambda));
}
die "wronski_polynomial: triangulation not foldable" unless $T->FOLDABLE;
die "wronski_polynomial: dimension mismatch" unless $coeffs->size() == $d+1;
my $i = 0;
my $m = new Map<Int, Int>;
map { $m->{$_}= $i++ } @{$T->FACETS->[0]};
my $full_coeffs = new Vector<Rational>(map { $s**(convert_to<Int>($lambda->[$_]))*$coeffs->[$m->{$T->PROJ_DICTIONARY->[$_]}] } 0..($n-1));
return new Polynomial($full_coeffs, convert_to<Int>($M->minor(All,~[0])));
}
# @category Other
# Returns a Wronski system of a [[topaz::FOLDABLE]] triangulation of a lattice polytope
# @param Matrix<Int> M points (in homogeneous coordinates); affinely span the space
# @param Vector<Int> lambda height function on lattice points
# @param Array<Array<Rational>> coeff_array coefficients
# @param Rational s additional Parameter in the polynomial
# @option topaz::SimplicialComplex triangulation The triangulation of the pointset corresponding to the lifting function
user_function wronski_system(Matrix, Vector, Array<Array<Rational> >, $; {triangulation => undef}) {
my ($M, $lambda, $coeffs_array, $s, $options) = @_;
my ($n, $d) = ($M->rows(), $M->cols()-1);
my $T = $options->{"triangulation"};
if (!defined($options->{"triangulation"})) {
$T=new topaz::SimplicialComplex(FACETS=>polytope::regular_subdivision($M,$lambda));
}
die "wronski_system: triangulation not foldable" unless $T->FOLDABLE;
die "wronski_system: dimension mismatch" unless $coeffs_array->size() == $d;
my @wSystem = ();
map { push @wSystem, wronski_polynomial($M,$lambda,$coeffs_array->[$_],$s, triangulation=>$T) } (0..$d-1);
return new ideal::Ideal(GENERATORS=>\@wSystem);
}
# @category Other
# Returns a system of polynomials which is
# necessary to check if degeneration avoids center of projection:
# compute eliminant e(s); this must not have a zero in (0,1)
# @param Matrix<Int> L lattice points
# @param Vector<Int> lambda height function on lattice points
user_function wronski_center_ideal(Matrix, Vector; {triangulation => undef}) {
my ($L, $lambda, $options) = @_;
my $d=$L->cols()-1; # ambient dimension
my $N=$L->rows(); # number of lattice points
# usually one wants to get the triangulation before since otherwise it is impossible
# to predict which coefficient is assigned to which monomial;
# however, e.g., for random constructions the line below might be convenient
my $T = $options->{"triangulation"};
if (!defined($options->{"triangulation"})) {
$T=new topaz::SimplicialComplex(FACETS=>polytope::regular_subdivision($L,$lambda));
}
die "subdivision not a triangulation\n" unless $T->DIM==$d;
die "triangulation induced by lifting not foldable\n" unless $T->FOLDABLE;
# group the lattice points according to color
my %c=();
map { $c{$T->PROJ_ORBITS->[$_]->[0]}=$_ } (0..$d);
my @points_by_color=(); foreach (0..$d) { push @points_by_color, [] }
for (my $pt=0; $pt<$N; ++$pt) {
my $pt_color=$c{$T->PROJ_DICTIONARY->[$pt]};
push @{$points_by_color[$pt_color]}, $pt;
}
my $monomials=new Matrix<Int>($L->minor(All,~[0])|$lambda);
my @eqs=();
for (my $col=0; $col<=$d; ++$col) {
my $points_of_this_color=$points_by_color[$col];
my $sz=scalar(@$points_of_this_color);
my $eq=new Polynomial(ones_vector<Rational>($sz), $monomials->minor($points_of_this_color,All));
push @eqs, $eq;
}
return new ideal::Ideal(GENERATORS=>\@eqs);
}
# Local Variables:
# mode: perl
# cperl-indent-level:4
# indent-tabs-mode:nil
# End:
|