summaryrefslogtreecommitdiff
path: root/src/Coxeter_triangulation/include/gudhi/Freudenthal_triangulation.h
diff options
context:
space:
mode:
authorROUVREAU Vincent <vincent.rouvreau@inria.fr>2020-09-22 18:12:31 +0200
committerROUVREAU Vincent <vincent.rouvreau@inria.fr>2020-09-22 18:12:31 +0200
commitbe7555abfb97f02c37de96736f7a0993d4d47f03 (patch)
tree180f618a1db3a8b866f43f66210ac38c028d74dd /src/Coxeter_triangulation/include/gudhi/Freudenthal_triangulation.h
parente0041b766b647f3906b52f861e97edba1f089312 (diff)
clang-format files
Diffstat (limited to 'src/Coxeter_triangulation/include/gudhi/Freudenthal_triangulation.h')
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Freudenthal_triangulation.h129
1 files changed, 56 insertions, 73 deletions
diff --git a/src/Coxeter_triangulation/include/gudhi/Freudenthal_triangulation.h b/src/Coxeter_triangulation/include/gudhi/Freudenthal_triangulation.h
index 6b33a00c..43b33d1f 100644
--- a/src/Coxeter_triangulation/include/gudhi/Freudenthal_triangulation.h
+++ b/src/Coxeter_triangulation/include/gudhi/Freudenthal_triangulation.h
@@ -13,9 +13,9 @@
#include <vector>
#include <algorithm> // for std::sort
-#include <cmath> // for std::floor
-#include <numeric> // for std::iota
-#include <cstdlib> // for std::size_t
+#include <cmath> // for std::floor
+#include <numeric> // for std::iota
+#include <cstdlib> // for std::size_t
#include <Eigen/Eigenvalues>
#include <Eigen/Sparse>
@@ -27,7 +27,7 @@ namespace Gudhi {
namespace coxeter_triangulation {
-/**
+/**
* \class Freudenthal_triangulation
* \brief A class that stores any affine transformation of the Freudenthal-Kuhn
* triangulation.
@@ -41,32 +41,30 @@ namespace coxeter_triangulation {
* \tparam Permutahedral_representation_ Type of a simplex given by a permutahedral representation.
* Needs to be a model of SimplexInCoxeterTriangulation.
*/
-template <class Permutahedral_representation_
- = Permutahedral_representation<std::vector<int>, std::vector<std::vector<std::size_t> > > >
+template <class Permutahedral_representation_ =
+ Permutahedral_representation<std::vector<int>, std::vector<std::vector<std::size_t> > > >
class Freudenthal_triangulation {
using Matrix = Eigen::MatrixXd;
using Vector = Eigen::VectorXd;
using SparseMatrix = Eigen::SparseMatrix<double>;
using Triplet = Eigen::Triplet<double>;
-
+
public:
/** \brief Type of the simplices in the triangulation. */
using Simplex_handle = Permutahedral_representation_;
/** \brief Type of the vertices in the triangulation. */
using Vertex_handle = typename Permutahedral_representation_::Vertex;
-
-
- /** \brief Constructor of the Freudenthal-Kuhn triangulation of a given dimension.
+
+ /** \brief Constructor of the Freudenthal-Kuhn triangulation of a given dimension.
* @param[in] dimension The dimension of the triangulation.
*/
Freudenthal_triangulation(std::size_t dimension)
- : dimension_(dimension),
- matrix_(Matrix::Identity(dimension, dimension)),
- offset_(Vector::Zero(dimension)),
- colpivhouseholderqr_(matrix_.colPivHouseholderQr()),
- is_freudenthal(true) {
- }
+ : dimension_(dimension),
+ matrix_(Matrix::Identity(dimension, dimension)),
+ offset_(Vector::Zero(dimension)),
+ colpivhouseholderqr_(matrix_.colPivHouseholderQr()),
+ is_freudenthal(true) {}
/** \brief Constructor of the Freudenthal-Kuhn triangulation of a given dimension under
* a linear transformation by a given matrix.
@@ -75,12 +73,11 @@ class Freudenthal_triangulation {
* Needs to be invertible.
*/
Freudenthal_triangulation(std::size_t dimension, const Matrix& matrix)
- : dimension_(dimension),
- matrix_(matrix),
- offset_(Vector::Zero(dimension)),
- colpivhouseholderqr_(matrix_.colPivHouseholderQr()),
- is_freudenthal(false) {
- }
+ : dimension_(dimension),
+ matrix_(matrix),
+ offset_(Vector::Zero(dimension)),
+ colpivhouseholderqr_(matrix_.colPivHouseholderQr()),
+ is_freudenthal(false) {}
/** \brief Constructor of the Freudenthal-Kuhn triangulation of a given dimension under
* an affine transformation by a given matrix and a translation vector.
@@ -90,64 +87,56 @@ class Freudenthal_triangulation {
* @param[in] offset The offset vector.
*/
Freudenthal_triangulation(unsigned dimension, const Matrix& matrix, const Vector& offset)
- : dimension_(dimension),
- matrix_(matrix),
- offset_(offset),
- colpivhouseholderqr_(matrix_.colPivHouseholderQr()),
- is_freudenthal(false) {
- }
-
+ : dimension_(dimension),
+ matrix_(matrix),
+ offset_(offset),
+ colpivhouseholderqr_(matrix_.colPivHouseholderQr()),
+ is_freudenthal(false) {}
/** \brief Dimension of the triangulation. */
- unsigned dimension() const {
- return dimension_;
- }
+ unsigned dimension() const { return dimension_; }
/** \brief Matrix that defines the linear transformation of the triangulation. */
- const Matrix& matrix() const {
- return matrix_;
- }
+ const Matrix& matrix() const { return matrix_; }
/** \brief Vector that defines the offset of the triangulation. */
- const Vector& offset() const {
- return offset_;
- }
+ const Vector& offset() const { return offset_; }
- /** \brief Change the linear transformation matrix to a given value.
+ /** \brief Change the linear transformation matrix to a given value.
* @param[in] matrix New value of the linear transformation matrix.
*/
void change_matrix(const Eigen::MatrixXd& matrix) {
matrix_ = matrix;
colpivhouseholderqr_ = matrix.colPivHouseholderQr();
is_freudenthal = false;
- }
+ }
- /** \brief Change the offset vector to a given value.
+ /** \brief Change the offset vector to a given value.
* @param[in] offset New value of the offset vector.
*/
void change_offset(const Eigen::VectorXd& offset) {
offset_ = offset;
is_freudenthal = false;
}
-
+
/** \brief Returns the permutahedral representation of the simplex in the
* triangulation that contains a given query point.
- * \details Using the additional parameter scale, the search can be done in a
+ * \details Using the additional parameter scale, the search can be done in a
* triangulation that shares the origin, but is scaled by a given factor.
* This parameter can be useful to simulate the point location in a subdivided
* triangulation.
* The returned simplex is always minimal by inclusion.
- *
+ *
* \tparam Point_d A class that represents a point in d-dimensional Euclidean space.
* The coordinates should be random-accessible. Needs to provide the method size().
*
* @param[in] point The query point.
- * @param[in] scale The scale of the triangulation.
+ * @param[in] scale The scale of the triangulation.
*/
template <class Point_d>
- Simplex_handle locate_point(const Point_d& point, double scale=1) const {
- using Ordered_set_partition = typename Simplex_handle::OrderedSetPartition;
- using Part = typename Ordered_set_partition::value_type;
+ Simplex_handle locate_point(const Point_d& point, double scale = 1) const {
+ using Ordered_set_partition = typename Simplex_handle::OrderedSetPartition;
+ using Part = typename Ordered_set_partition::value_type;
unsigned d = point.size();
assert(d == dimension_);
double error = 1e-9;
@@ -160,11 +149,9 @@ class Freudenthal_triangulation {
output.vertex().push_back(y_i);
z.push_back(x_i - y_i);
}
- }
- else {
+ } else {
Eigen::VectorXd p_vect(d);
- for (std::size_t i = 0; i < d; i++)
- p_vect(i) = point[i];
+ for (std::size_t i = 0; i < d; i++) p_vect(i) = point[i];
Eigen::VectorXd x_vect = colpivhouseholderqr_.solve(p_vect - offset_);
for (std::size_t i = 0; i < d; i++) {
double x_i = scale * x_vect(i);
@@ -174,15 +161,13 @@ class Freudenthal_triangulation {
}
}
z.push_back(0);
- Part indices(d+1);
+ Part indices(d + 1);
std::iota(indices.begin(), indices.end(), 0);
- std::sort(indices.begin(),
- indices.end(),
- [&z](std::size_t i1, std::size_t i2) {return z[i1] > z[i2];});
+ std::sort(indices.begin(), indices.end(), [&z](std::size_t i1, std::size_t i2) { return z[i1] > z[i2]; });
output.partition().push_back(Part(1, indices[0]));
for (std::size_t i = 1; i <= d; ++i)
- if (z[indices[i-1]] > z[indices[i]] + error)
+ if (z[indices[i - 1]] > z[indices[i]] + error)
output.partition().push_back(Part(1, indices[i]));
else
output.partition().back().push_back(indices[i]);
@@ -190,39 +175,37 @@ class Freudenthal_triangulation {
}
/** \brief Returns the Cartesian coordinates of the given vertex.
- * \details Using the additional parameter scale, the search can be done in a
+ * \details Using the additional parameter scale, the search can be done in a
* triangulation that shares the origin, but is scaled by a given factor.
- * This parameter can be useful to simulate the computation of Cartesian coordinates
+ * This parameter can be useful to simulate the computation of Cartesian coordinates
* of a vertex in a subdivided triangulation.
* @param[in] vertex The query vertex.
- * @param[in] scale The scale of the triangulation.
+ * @param[in] scale The scale of the triangulation.
*/
Eigen::VectorXd cartesian_coordinates(const Vertex_handle& vertex, double scale = 1) const {
Eigen::VectorXd v_vect(dimension_);
- for (std::size_t j = 0; j < dimension_; j++)
- v_vect(j) = vertex[j] / scale;
+ for (std::size_t j = 0; j < dimension_; j++) v_vect(j) = vertex[j] / scale;
return matrix_ * v_vect + offset_;
}
/** \brief Returns the Cartesian coordinates of the barycenter of a given simplex.
- * \details Using the additional parameter scale, the search can be done in a
+ * \details Using the additional parameter scale, the search can be done in a
* triangulation that shares the origin, but is scaled by a given factor.
- * This parameter can be useful to simulate the computation of Cartesian coordinates
+ * This parameter can be useful to simulate the computation of Cartesian coordinates
* of the barycenter of a simplex in a subdivided triangulation.
* @param[in] simplex The query simplex.
- * @param[in] scale The scale of the triangulation.
+ * @param[in] scale The scale of the triangulation.
*/
Eigen::VectorXd barycenter(const Simplex_handle& simplex, double scale = 1) const {
Eigen::VectorXd res_vector(dimension_);
- for (size_t i = 0; i < dimension_; ++i)
- res_vector(i) = 0;
- for (auto v: simplex.vertex_range()) {
+ for (size_t i = 0; i < dimension_; ++i) res_vector(i) = 0;
+ for (auto v : simplex.vertex_range()) {
res_vector += cartesian_coordinates(v, scale);
}
- return (1./(simplex.dimension()+1)) * res_vector;
+ return (1. / (simplex.dimension() + 1)) * res_vector;
}
-
-protected:
+
+ protected:
unsigned dimension_;
Matrix matrix_;
Vector offset_;
@@ -230,8 +213,8 @@ protected:
bool is_freudenthal;
};
-} // namespace coxeter_triangulation
+} // namespace coxeter_triangulation
-} // namespace Gudhi
+} // namespace Gudhi
#endif