/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. * Author(s): Siargey Kachanovich * * Copyright (C) 2019 Inria * * Modification(s): * - YYYY/MM Author: Description of the modification */ #ifndef COXETER_TRIANGULATION_H_ #define COXETER_TRIANGULATION_H_ #include #include // for std::sqrt #include #include #include #include #include #include #include #include namespace Gudhi { namespace coxeter_triangulation { /** * \class Coxeter_triangulation * \brief A class that stores Coxeter triangulation of type \f$\tilde{A}_d\f$. * This triangulation has the greatest simplex quality out of all linear transformations * of the Freudenthal-Kuhn triangulation. * * \ingroup coxeter_triangulation * * \tparam Permutahedral_representation_ Type of a simplex given by a permutahedral representation. * Needs to be a model of SimplexInCoxeterTriangulation. */ template , std::vector > > > class Coxeter_triangulation : public Freudenthal_triangulation { using Matrix = Eigen::MatrixXd; Matrix root_matrix(unsigned d) { Matrix cartan(Matrix::Identity(d, d)); for (unsigned i = 1; i < d; i++) { cartan(i - 1, i) = -0.5; cartan(i, i - 1) = -0.5; } Eigen::SelfAdjointEigenSolver saes(cartan); Eigen::VectorXd sqrt_diag(d); for (unsigned i = 0; i < d; ++i) sqrt_diag(i) = std::sqrt(saes.eigenvalues()[i]); Matrix lower(Matrix::Ones(d, d)); lower = lower.triangularView(); Matrix result = (lower * saes.eigenvectors() * sqrt_diag.asDiagonal()).inverse(); return result; } public: /** \brief Constructor of Coxeter triangulation of a given dimension. * @param[in] dimension The dimension of the triangulation. */ Coxeter_triangulation(std::size_t dimension) : Freudenthal_triangulation(dimension, root_matrix(dimension)) {} }; } // namespace coxeter_triangulation } // namespace Gudhi #endif