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
|
/* 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.
--------------------------------------------------------------------------------
*/
#pragma once
#include "polymake/linalg.h"
#include "polymake/Vector.h"
#include "polymake/Matrix.h"
#include "polymake/Rational.h"
#include "polymake/hash_map"
#include "polymake/polytope/canonicalize.h"
#include "polymake/polytope/convex_hull.h"
namespace polymake { namespace fan {
namespace {
template <typename Scalar, typename TMatrix>
Set<Int>
indices_of(const GenericMatrix<TMatrix, Scalar>& rays,
hash_map<Vector<Scalar>, Int>& index_of,
Int& i)
{
Set<Int> indices_of;
for (auto rit = entire(rows(rays)); !rit.at_end(); ++rit) {
Vector<Scalar> v(*rit);
polytope::canonicalize_oriented(entire(v));
if (!index_of.exists(v)) {
index_of[v] = i++;
}
indices_of += index_of[v];
}
return indices_of;
}
} // end anonymous namespace
template <typename Scalar, typename TMatrix>
Matrix<Scalar>
rays_of_intersection(const GenericMatrix<TMatrix,Scalar>& V,
const Matrix<Scalar>& intersection_lineality,
const Matrix<Scalar>& H)
{
BigObject C("Cone", mlist<Scalar>(), "INPUT_RAYS", Matrix<Scalar>(V), "INPUT_LINEALITY", intersection_lineality);
const Matrix<Scalar> facets = C.give("FACETS");
BigObject D("Cone", mlist<Scalar>(), "INEQUALITIES", facets, "EQUATIONS", H);
Matrix<Scalar> rays = D.give("RAYS");
project_to_orthogonal_complement(rays, intersection_lineality);
for (auto rit = entire(rows(rays)); !rit.at_end(); ++rit)
polytope::canonicalize_oriented(entire(*rit));
return rays;
}
#if 0
template<typename TMatrix>
Matrix<Rational>
rays_of_intersection(const GenericMatrix<TMatrix, Rational>& V,
const Matrix<Rational>& intersection_lineality,
const Matrix<Rational>& H)
{
const bool is_cone = true;
const Matrix<Rational> facets = polytope::enumerate_facets(V, intersection_lineality, is_cone).first;
Matrix<Rational> rays = polytope::enumerate_vertices(facets, H, is_cone).first;
project_to_orthogonal_complement(rays, intersection_lineality);
for (auto rit = entire(rows(rays)); !rit.at_end(); ++rit)
polytope::canonicalize_oriented(entire(*rit));
return rays;
}
#endif
} }
// Local Variables:
// mode:C++
// c-basic-offset:3
// indent-tabs-mode:nil
// End:
|