12#ifndef FUNCTIONS_RANDOM_ORTHOGONAL_MATRIX_H_
13#define FUNCTIONS_RANDOM_ORTHOGONAL_MATRIX_H_
19#include <Eigen/Sparse>
22#include <CGAL/Epick_d.h>
23#include <CGAL/point_generators_d.h>
24#include <CGAL/Random.h>
26#include <boost/math/constants/constants.hpp>
30namespace coxeter_triangulation {
42Eigen::MatrixXd random_orthogonal_matrix(std::size_t d) {
43 typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> Kernel;
44 typedef typename Kernel::Point_d Point_d;
45 if (d == 1)
return Eigen::VectorXd::Constant(1, 1.0);
48 CGAL::Random& rng = CGAL::get_default_random();
49 double alpha = rng.get_double(0., 2 * boost::math::constants::pi<double>());
52 rot << std::cos(alpha), -std::sin(alpha), std::sin(alpha), cos(alpha);
55 Eigen::MatrixXd low_dim_rot = random_orthogonal_matrix(d - 1);
56 Eigen::MatrixXd rot(d, d);
57 Point_d v = *CGAL::Random_points_on_sphere_d<Point_d>(d, 1);
58 for (std::size_t i = 0; i < d; ++i) rot(i, 0) = v[i];
59 for (std::size_t i = 0; i < d - 1; ++i)
60 for (std::size_t j = 1; j < d - 1; ++j) rot(i, j) = low_dim_rot(i, j - 1);
61 for (std::size_t j = 1; j < d; ++j) rot(d - 1, j) = 0;
62 rot = rot.householderQr()
Gudhi namespace.
Definition SimplicialComplexForAlpha.h:14