diff --git a/Generator/include/CGAL/random_convex_hull_in_disc_2.h b/Generator/include/CGAL/random_convex_hull_in_disc_2.h index 0315a7108e4..0bac0f466e3 100644 --- a/Generator/include/CGAL/random_convex_hull_in_disc_2.h +++ b/Generator/include/CGAL/random_convex_hull_in_disc_2.h @@ -21,6 +21,7 @@ #include #include #include +#include #include namespace CGAL { @@ -192,7 +193,7 @@ void random_convex_hull_in_disc_2(std::size_t n, double radius, std::list(std::floor(n / std::pow(std::log(static_cast(n)), 2))); + if (!fast) T = static_cast(std::floor(n / CGAL::square(std::log(static_cast(n))))); while (simulated_points < n) { // l is a list coming from a convex hull operation. we are moving the diff --git a/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h index b15b9dc45e3..65bd536cf71 100644 --- a/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h +++ b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h @@ -90,7 +90,7 @@ compute_denoise_projection( Vector normal_sum = CGAL::NULL_VECTOR; FT cos_sigma = cos(sharpness_angle * CGAL_PI / 180.0); - FT sharpness_bandwidth = std::pow((CGAL::max)(1e-8, 1 - cos_sigma), 2); + FT sharpness_bandwidth = CGAL::square((CGAL::max)(1e-8, 1 - cos_sigma)); for (typename PointRange::iterator it : neighbor_pwns) { @@ -101,7 +101,7 @@ compute_denoise_projection( if (dist2 < radius2) { FT theta = std::exp(dist2 * iradius16); - FT psi = std::exp(-std::pow(1 - get(normal_map, vt) * nn, 2) + FT psi = std::exp(-CGAL::square(1 - get(normal_map, vt) * nn) / sharpness_bandwidth); weight = theta * psi; diff --git a/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h b/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h index 153159fffd8..0a6445492ad 100644 --- a/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h +++ b/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h @@ -212,7 +212,7 @@ update_new_point( for (unsigned int j = 0; j < candidate_num; j++) { - FT psi = std::exp(-std::pow(FT(1) - normal_cadidate[j] * t.normal, FT(2)) + FT psi = std::exp(-CGAL::square(FT(1) - normal_cadidate[j] * t.normal) / sharpness_bandwidth); FT project_diff_t_v = (t.pt - new_v.pt) * t.normal; FT weight = psi * theta; @@ -435,7 +435,7 @@ edge_aware_upsample_point_set( // FT cos_sigma = static_cast(std::cos(FT(CGAL::to_double(sharpness_angle)) / FT(180) * FT(CGAL_PI))); - FT sharpness_bandwidth = std::pow((CGAL::max)((FT)1e-8, (FT)1.0 - cos_sigma), 2); + FT sharpness_bandwidth = CGAL::square((CGAL::max)((FT)1e-8, (FT)1.0 - cos_sigma)); FT sum_density = 0.0; unsigned int count_density = 1; diff --git a/Point_set_processing_3/include/CGAL/wlop_simplify_and_regularize_point_set.h b/Point_set_processing_3/include/CGAL/wlop_simplify_and_regularize_point_set.h index 0f30fed84ac..5f2ae9bd610 100644 --- a/Point_set_processing_3/include/CGAL/wlop_simplify_and_regularize_point_set.h +++ b/Point_set_processing_3/include/CGAL/wlop_simplify_and_regularize_point_set.h @@ -185,7 +185,7 @@ compute_update_sample_point( if (dist2 < 1e-10) continue; FT dist = std::sqrt(dist2); - weight = std::exp(dist2 * iradius16) * std::pow(FT(1.0) / dist, 2); // L1 + weight = std::exp(dist2 * iradius16) * CGAL::square(FT(1.0) / dist); // L1 if (!is_sample_densities_empty) { diff --git a/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Efficient_RANSAC.h b/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Efficient_RANSAC.h index 820eee71576..e2e7bb38107 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Efficient_RANSAC.h +++ b/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Efficient_RANSAC.h @@ -1030,7 +1030,7 @@ namespace CGAL { } inline FT stop_probability(std::size_t largest_candidate, std::size_t num_pts, std::size_t num_candidates, std::size_t octree_depth) const { - return (std::min)(std::pow(FT(1) - FT(largest_candidate) + return (std::min)((FT)std::pow(FT(1) - FT(largest_candidate) / (FT(num_pts) * FT(octree_depth+1) * FT(1 << (m_required_samples - 1))), int(num_candidates)), FT(1)); diff --git a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Disk_samplers.h b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Disk_samplers.h index cd8917ed12b..aca2e52cef4 100644 --- a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Disk_samplers.h +++ b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Disk_samplers.h @@ -88,7 +88,7 @@ public: for(std::size_t i = 0; i < number_of_points; ++i) { double Q = i * golden_ratio * CGAL_PI; double R = std::sqrt(static_cast(i) / number_of_points); - double weight = exp(-0.5 * (std::pow(R / CGAL_ANGLE_ST_DEV_DIVIDER, 2))); + double weight = exp(-0.5 * (CGAL::square(R / CGAL_ANGLE_ST_DEV_DIVIDER))); *out_it++ = Tuple(R * cos(Q), R * sin(Q), weight); } } else { diff --git a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Expectation_maximization.h b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Expectation_maximization.h index 0982f5eea0a..67dbfac4878 100644 --- a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Expectation_maximization.h +++ b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Expectation_maximization.h @@ -75,7 +75,7 @@ private: return x == mean ? 1.0 : 0.0; } - double e_over = -0.5 * std::pow((x - mean) / deviation, 2); + double e_over = -0.5 * CGAL::square((x - mean) / deviation); return exp(e_over) / deviation; } /** @@ -289,7 +289,7 @@ private: double new_deviation = 0.0; for(std::size_t point_i = 0; point_i < points.size(); ++point_i) { double membership = responsibility_matrix[center_i][point_i]; - new_deviation += membership * std::pow(points[point_i] - new_mean, 2); + new_deviation += membership * CGAL::square(points[point_i] - new_mean); } new_deviation = std::sqrt(new_deviation/total_membership); diff --git a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Filters.h b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Filters.h index 6c6e231a604..f1733ef2ac4 100644 --- a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Filters.h +++ b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Filters.h @@ -30,6 +30,8 @@ #include #include +#include +#include namespace CGAL { @@ -92,7 +94,7 @@ public: double deviation = 0.0; for(typename std::map::iterator it = neighbors.begin(); it != neighbors.end(); ++it) { - deviation += std::pow(get(values, it->first) - current_sdf_value, 2); + deviation += CGAL::square(get(values, it->first) - current_sdf_value); } deviation = std::sqrt(deviation / neighbors.size()); if(deviation == 0.0) { @@ -133,7 +135,7 @@ public: private: /** Gaussian function for weighting. */ double gaussian_function(double value, double deviation) const { - return exp(-0.5 * (std::pow(value / deviation, 2))); + return exp(-0.5 * (CGAL::square(value / deviation))); } }; diff --git a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/K_means_clustering.h b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/K_means_clustering.h index c35b6301648..9ca194cac17 100644 --- a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/K_means_clustering.h +++ b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/K_means_clustering.h @@ -123,7 +123,7 @@ public: double cumulative_distance_square = 0.0; // distance_square holds closest distance that points have, so just test new coming center (i.e. centers.back()) for(std::size_t j = 0; j < points.size(); ++j) { - double new_distance = std::pow(centers.back() - points[j], 2); + double new_distance = CGAL::square(centers.back() - points[j]); if(new_distance < distance_square[j]) { distance_square[j] = new_distance; } @@ -422,7 +422,7 @@ private: double sum = 0.0; for(std::vector::const_iterator point_it = points.begin(); point_it != points.end(); ++point_it) { - sum += std::pow(centers[point_it->center_id].mean - point_it->data, 2); + sum += CGAL::square(centers[point_it->center_id].mean - point_it->data); } return sum; }