diff options
author | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2020-09-22 18:12:31 +0200 |
---|---|---|
committer | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2020-09-22 18:12:31 +0200 |
commit | be7555abfb97f02c37de96736f7a0993d4d47f03 (patch) | |
tree | 180f618a1db3a8b866f43f66210ac38c028d74dd /src/Coxeter_triangulation/include/gudhi/Functions/Cartesian_product.h | |
parent | e0041b766b647f3906b52f861e97edba1f089312 (diff) |
clang-format files
Diffstat (limited to 'src/Coxeter_triangulation/include/gudhi/Functions/Cartesian_product.h')
-rw-r--r-- | src/Coxeter_triangulation/include/gudhi/Functions/Cartesian_product.h | 82 |
1 files changed, 36 insertions, 46 deletions
diff --git a/src/Coxeter_triangulation/include/gudhi/Functions/Cartesian_product.h b/src/Coxeter_triangulation/include/gudhi/Functions/Cartesian_product.h index 0a6f264d..c0d6aec4 100644 --- a/src/Coxeter_triangulation/include/gudhi/Functions/Cartesian_product.h +++ b/src/Coxeter_triangulation/include/gudhi/Functions/Cartesian_product.h @@ -14,7 +14,7 @@ #include <cstdlib> #include <tuple> #include <type_traits> // for std::enable_if -#include <cstdlib> // for std::size_t +#include <cstdlib> // for std::size_t #include <gudhi/Functions/Function.h> @@ -27,86 +27,79 @@ namespace coxeter_triangulation { /* Get the domain dimension of the tuple of functions. */ template <std::size_t I = 0, typename... T> -inline typename std::enable_if<I == sizeof... (T), std::size_t>::type -get_amb_d (const std::tuple<T...>& tuple) { +inline typename std::enable_if<I == sizeof...(T), std::size_t>::type get_amb_d(const std::tuple<T...>& tuple) { return 0; } template <std::size_t I = 0, typename... T> -inline typename std::enable_if<I != sizeof... (T), std::size_t>::type -get_amb_d (const std::tuple<T...>& tuple) { - return std::get<I>(tuple).amb_d() + get_amb_d<I+1, T...>(tuple); +inline typename std::enable_if<I != sizeof...(T), std::size_t>::type get_amb_d(const std::tuple<T...>& tuple) { + return std::get<I>(tuple).amb_d() + get_amb_d<I + 1, T...>(tuple); } /* Get the codomain dimension of the tuple of functions. */ template <std::size_t I = 0, typename... T> -inline typename std::enable_if<I == sizeof... (T), std::size_t>::type -get_cod_d (const std::tuple<T...>& tuple) { +inline typename std::enable_if<I == sizeof...(T), std::size_t>::type get_cod_d(const std::tuple<T...>& tuple) { return 0; } template <std::size_t I = 0, typename... T> -inline typename std::enable_if<I != sizeof... (T), std::size_t>::type -get_cod_d (const std::tuple<T...>& tuple) { - return std::get<I>(tuple).cod_d() + get_cod_d<I+1, T...>(tuple); +inline typename std::enable_if<I != sizeof...(T), std::size_t>::type get_cod_d(const std::tuple<T...>& tuple) { + return std::get<I>(tuple).cod_d() + get_cod_d<I + 1, T...>(tuple); } /* Get the seed of the tuple of functions. */ template <std::size_t I = 0, typename... T> -inline typename std::enable_if<I == sizeof... (T), void>::type -get_seed (const std::tuple<T...>& tuple, Eigen::VectorXd& point, std::size_t i = 0) { -} +inline typename std::enable_if<I == sizeof...(T), void>::type get_seed(const std::tuple<T...>& tuple, + Eigen::VectorXd& point, std::size_t i = 0) {} template <std::size_t I = 0, typename... T> -inline typename std::enable_if<I != sizeof... (T), void>::type -get_seed (const std::tuple<T...>& tuple, Eigen::VectorXd& point, std::size_t i = 0) { +inline typename std::enable_if<I != sizeof...(T), void>::type get_seed(const std::tuple<T...>& tuple, + Eigen::VectorXd& point, std::size_t i = 0) { const auto& f = std::get<I>(tuple); std::size_t n = f.amb_d(); Eigen::VectorXd seed = f.seed(); - for (std::size_t j = 0; j < n; ++j) - point(i+j) = seed(j); - get_seed<I+1, T...>(tuple, point, i+n); + for (std::size_t j = 0; j < n; ++j) point(i + j) = seed(j); + get_seed<I + 1, T...>(tuple, point, i + n); } /* Get the seed of the tuple of functions. */ template <std::size_t I = 0, typename... T> -inline typename std::enable_if<I == sizeof... (T), void>::type -get_value (const std::tuple<T...>& tuple, const Eigen::VectorXd& x, Eigen::VectorXd& point, std::size_t i = 0, std::size_t j = 0) { -} +inline typename std::enable_if<I == sizeof...(T), void>::type get_value(const std::tuple<T...>& tuple, + const Eigen::VectorXd& x, + Eigen::VectorXd& point, std::size_t i = 0, + std::size_t j = 0) {} template <std::size_t I = 0, typename... T> -inline typename std::enable_if<I != sizeof... (T), void>::type -get_value (const std::tuple<T...>& tuple, const Eigen::VectorXd& x, Eigen::VectorXd& point, std::size_t i = 0, std::size_t j = 0) { +inline typename std::enable_if<I != sizeof...(T), void>::type get_value(const std::tuple<T...>& tuple, + const Eigen::VectorXd& x, + Eigen::VectorXd& point, std::size_t i = 0, + std::size_t j = 0) { const auto& f = std::get<I>(tuple); std::size_t n = f.amb_d(); std::size_t k = f.cod_d(); Eigen::VectorXd x_i(n); - for (std::size_t l = 0; l < n; ++l) - x_i(l) = x(i+l); + for (std::size_t l = 0; l < n; ++l) x_i(l) = x(i + l); Eigen::VectorXd res = f(x_i); - for (std::size_t l = 0; l < k; ++l) - point(j+l) = res(l); - get_value<I+1, T...>(tuple, x, point, i+n, j+k); + for (std::size_t l = 0; l < k; ++l) point(j + l) = res(l); + get_value<I + 1, T...>(tuple, x, point, i + n, j + k); } - -/** +/** * \class Cartesian_product * \brief Constructs the function the zero-set of which is the Cartesian product * of the zero-sets of some given functions. * - * \tparam Functions A pack template parameter for functions. All functions should be models of + * \tparam Functions A pack template parameter for functions. All functions should be models of * the concept FunctionForImplicitManifold. * * \ingroup coxeter_triangulation */ template <class... Functions> struct Cartesian_product : public Function { - - /** + /** * \brief Value of the function at a specified point. * @param[in] p The input point. The dimension needs to coincide with the ambient dimension. */ @@ -117,10 +110,10 @@ struct Cartesian_product : public Function { } /** \brief Returns the domain (ambient) dimension. */ - virtual std::size_t amb_d() const override {return amb_d_;} + virtual std::size_t amb_d() const override { return amb_d_; } /** \brief Returns the codomain dimension. */ - virtual std::size_t cod_d() const override {return cod_d_;} + virtual std::size_t cod_d() const override { return cod_d_; } /** \brief Returns a point on the zero-set. */ virtual Eigen::VectorXd seed() const override { @@ -128,15 +121,14 @@ struct Cartesian_product : public Function { get_seed(function_tuple_, result, 0); return result; } - - /** + + /** * \brief Constructor of the Cartesian product function. * * @param[in] functions The functions the zero-sets of which are factors in the * Cartesian product of the resulting function. */ - Cartesian_product(const Functions&... functions) - : function_tuple_(std::make_tuple(functions...)) { + Cartesian_product(const Functions&... functions) : function_tuple_(std::make_tuple(functions...)) { amb_d_ = get_amb_d(function_tuple_); cod_d_ = get_cod_d(function_tuple_); } @@ -146,14 +138,13 @@ struct Cartesian_product : public Function { std::size_t amb_d_, cod_d_; }; - -/** +/** * \brief Static constructor of a Cartesian product function. * * @param[in] functions The functions the zero-sets of which are factors in the * Cartesian product of the resulting function. * - * \tparam Functions A pack template parameter for functions. All functions should be models of + * \tparam Functions A pack template parameter for functions. All functions should be models of * the concept FunctionForImplicitManifold. * * \ingroup coxeter_triangulation @@ -163,9 +154,8 @@ Cartesian_product<Functions...> make_product_function(const Functions&... functi return Cartesian_product<Functions...>(functions...); } +} // namespace coxeter_triangulation -} // namespace coxeter_triangulation - -} // namespace Gudhi +} // namespace Gudhi #endif |