From 7d716c0be7c6728494722b9f603720474d44d9b2 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Tue, 6 Apr 2021 08:38:56 +0200 Subject: [PATCH] Fix conversion warnings --- .../include/CGAL/PCA_util_Eigen.h | 96 +++++++++---------- .../linear_least_squares_fitting_circles_2.h | 12 +-- ...inear_least_squares_fitting_rectangles_2.h | 6 +- .../linear_least_squares_fitting_segments_2.h | 8 +- ...linear_least_squares_fitting_triangles_2.h | 6 +- 5 files changed, 64 insertions(+), 64 deletions(-) diff --git a/Principal_component_analysis/include/CGAL/PCA_util_Eigen.h b/Principal_component_analysis/include/CGAL/PCA_util_Eigen.h index 5cd1dbbd7d8..e7fd18b8842 100644 --- a/Principal_component_analysis/include/CGAL/PCA_util_Eigen.h +++ b/Principal_component_analysis/include/CGAL/PCA_util_Eigen.h @@ -56,9 +56,9 @@ assemble_covariance_matrix_3(InputIterator first, // assemble 2nd order moment about the origin. Matrix moment; - moment << 1.0/12.0, 1.0/24.0, 1.0/24.0, - 1.0/24.0, 1.0/12.0, 1.0/24.0, - 1.0/24.0, 1.0/24.0, 1.0/12.0; + moment << FT(1.0/12.0), FT(1.0/24.0), FT(1.0/24.0), + FT(1.0/24.0), FT(1.0/12.0), FT(1.0/24.0), + FT(1.0/24.0), FT(1.0/24.0), FT(1.0/12.0); for(InputIterator it = first; it != beyond; @@ -100,12 +100,12 @@ assemble_covariance_matrix_3(InputIterator first, // Translate the 2nd order moment calculated about the origin to // the center of mass to get the covariance. - covariance[0] += mass * (-1.0 * c.x() * c.x()); - covariance[1] += mass * (-1.0 * c.x() * c.y()); - covariance[2] += mass * (-1.0 * c.z() * c.x()); - covariance[3] += mass * (-1.0 * c.y() * c.y()); - covariance[4] += mass * (-1.0 * c.z() * c.y()); - covariance[5] += mass * (-1.0 * c.z() * c.z()); + covariance[0] += -mass * (c.x() * c.x()); + covariance[1] += -mass * (c.x() * c.y()); + covariance[2] += -mass * (c.z() * c.x()); + covariance[3] += -mass * (c.y() * c.y()); + covariance[4] += -mass * (c.z() * c.y()); + covariance[5] += -mass * (c.z() * c.z()); } @@ -176,9 +176,9 @@ assemble_covariance_matrix_3(InputIterator first, transformation = volume * transformation * moment * transformation.transpose(); // Translate the 2nd order moment to the minimum corner (x0,y0,z0) of the cuboid. - FT xav0 = (x1 - x0) / (2.0); - FT yav0 = (y1 - y0) / (2.0); - FT zav0 = (z1 - z0) / (2.0); + FT xav0 = (x1 - x0) / FT(2.0); + FT yav0 = (y1 - y0) / FT(2.0); + FT zav0 = (z1 - z0) / FT(2.0); // and add to covariance matrix covariance[0] += transformation(0,0) + volume * (2*x0*xav0 + x0*x0); @@ -314,12 +314,12 @@ assemble_covariance_matrix_3(InputIterator first, // Translate the 2nd order moment calculated about the origin to // the center of mass to get the covariance. - covariance[0] += mass * (-1.0 * c.x() * c.x()); - covariance[1] += mass * (-1.0 * c.x() * c.y()); - covariance[2] += mass * (-1.0 * c.z() * c.x()); - covariance[3] += mass * (-1.0 * c.y() * c.y()); - covariance[4] += mass * (-1.0 * c.z() * c.y()); - covariance[5] += mass * (-1.0 * c.z() * c.z()); + covariance[0] += -mass * (c.x() * c.x()); + covariance[1] += -mass * (c.x() * c.y()); + covariance[2] += -mass * (c.z() * c.x()); + covariance[3] += -mass * (c.y() * c.y()); + covariance[4] += -mass * (c.z() * c.y()); + covariance[5] += -mass * (c.z() * c.z()); #endif } @@ -350,9 +350,9 @@ assemble_covariance_matrix_3(InputIterator first, // assemble 2nd order moment about the origin. Matrix moment; - moment << 4.0/15.0, 0.0, 0.0, - 0.0, 4.0/15.0, 0.0, - 0.0, 0.0, 4.0/15.0; + moment << FT(4.0/15.0), FT(0.0), FT(0.0), + FT(0.0), FT(4.0/15.0), FT(0.0), + FT(0.0), FT(0.0), FT(4.0/15.0); for(InputIterator it = first; it != beyond; @@ -399,12 +399,12 @@ assemble_covariance_matrix_3(InputIterator first, // Translate the 2nd order moment calculated about the origin to // the center of mass to get the covariance. - covariance[0] += mass * (-1.0 * c.x() * c.x()); - covariance[1] += mass * (-1.0 * c.x() * c.y()); - covariance[2] += mass * (-1.0 * c.z() * c.x()); - covariance[3] += mass * (-1.0 * c.y() * c.y()); - covariance[4] += mass * (-1.0 * c.z() * c.y()); - covariance[5] += mass * (-1.0 * c.z() * c.z()); + covariance[0] += -mass * (c.x() * c.x()); + covariance[1] += -mass * (c.x() * c.y()); + covariance[2] += -mass * (c.z() * c.x()); + covariance[3] += -mass * (c.y() * c.y()); + covariance[4] += -mass * (c.z() * c.y()); + covariance[5] += -mass * (c.z() * c.z()); } // assemble covariance matrix from a sphere set @@ -434,9 +434,9 @@ assemble_covariance_matrix_3(InputIterator first, // assemble 2nd order moment about the origin. Matrix moment; - moment << 4.0/3.0, 0.0, 0.0, - 0.0, 4.0/3.0, 0.0, - 0.0, 0.0, 4.0/3.0; + moment << FT(4.0/3.0), FT(0.0), FT(0.0), + FT(0.0), FT(4.0/3.0), FT(0.0), + FT(0.0), FT(0.0), FT(4.0/3.0); for(InputIterator it = first; it != beyond; @@ -484,12 +484,12 @@ assemble_covariance_matrix_3(InputIterator first, // Translate the 2nd order moment calculated about the origin to // the center of mass to get the covariance. - covariance[0] += mass * (-1.0 * c.x() * c.x()); - covariance[1] += mass * (-1.0 * c.x() * c.y()); - covariance[2] += mass * (-1.0 * c.z() * c.x()); - covariance[3] += mass * (-1.0 * c.y() * c.y()); - covariance[4] += mass * (-1.0 * c.z() * c.y()); - covariance[5] += mass * (-1.0 * c.z() * c.z()); + covariance[0] += -mass * (c.x() * c.x()); + covariance[1] += -mass * (c.x() * c.y()); + covariance[2] += -mass * (c.z() * c.x()); + covariance[3] += -mass * (c.y() * c.y()); + covariance[4] += -mass * (c.z() * c.y()); + covariance[5] += -mass * (c.z() * c.z()); } @@ -520,9 +520,9 @@ assemble_covariance_matrix_3(InputIterator first, // 5 // assemble 2nd order moment about the origin. Matrix moment; - moment << 1.0/60.0, 1.0/120.0, 1.0/120.0, - 1.0/120.0, 1.0/60.0, 1.0/120.0, - 1.0/120.0, 1.0/120.0, 1.0/60.0; + moment << FT(1.0/60.0), FT(1.0/120.0), FT(1.0/120.0), + FT(1.0/120.0), FT(1.0/60.0), FT(1.0/120.0), + FT(1.0/120.0), FT(1.0/120.0), FT(1.0/60.0); Matrix accum; // zero by default accum << 0, 0, 0, 0, 0, 0, 0, 0, 0; @@ -597,9 +597,9 @@ assemble_covariance_matrix_3(InputIterator first, // assemble 2nd order moment about the origin. Matrix moment; - moment << 1.0/3.0, 0.5/3.0, 0.0, - 0.5/3.0, 1.0/3.0, 0.0, - 0.0, 0.0, 0.0; + moment << FT(1.0/3.0), FT(0.5/3.0), FT(0.0), + FT(0.5/3.0), FT(1.0/3.0), FT(0.0), + FT(0.0), FT(0.0), FT(0.0); for(InputIterator it = first; it != beyond; @@ -641,12 +641,12 @@ assemble_covariance_matrix_3(InputIterator first, // Translate the 2nd order moment calculated about the origin to // the center of mass to get the covariance. - covariance[0] += mass * (-1.0 * c.x() * c.x()); - covariance[1] += mass * (-1.0 * c.x() * c.y()); - covariance[2] += mass * (-1.0 * c.z() * c.x()); - covariance[3] += mass * (-1.0 * c.y() * c.y()); - covariance[4] += mass * (-1.0 * c.z() * c.y()); - covariance[5] += mass * (-1.0 * c.z() * c.z()); + covariance[0] += -mass * (c.x() * c.x()); + covariance[1] += -mass * (c.x() * c.y()); + covariance[2] += -mass * (c.z() * c.x()); + covariance[3] += -mass * (c.y() * c.y()); + covariance[4] += -mass * (c.z() * c.y()); + covariance[5] += -mass * (c.z() * c.z()); } diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_circles_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_circles_2.h index 3b4f679ce3b..715f76cd0d0 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_circles_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_circles_2.h @@ -111,9 +111,9 @@ linear_least_squares_fitting_2(InputIterator first, // Translate the 2nd order moment calculated about the origin to // the center of mass to get the covariance. - covariance[0] += mass * (-1.0 * c.x() * c.x()); - covariance[1] += mass * (-1.0 * c.x() * c.y()); - covariance[2] += mass * (-1.0 * c.y() * c.y()); + covariance[0] += -mass * (c.x() * c.x()); + covariance[1] += -mass * (c.x() * c.y()); + covariance[2] += -mass * (c.y() * c.y()); // solve for eigenvalues and eigenvectors. // eigen values are sorted in ascending order, @@ -217,9 +217,9 @@ linear_least_squares_fitting_2(InputIterator first, // Translate the 2nd order moment calculated about the origin to // the center of mass to get the covariance. - covariance[0] += mass * (-1.0 * c.x() * c.x()); - covariance[1] += mass * (-1.0 * c.x() * c.y()); - covariance[2] += mass * (-1.0 * c.y() * c.y()); + covariance[0] += -mass * (c.x() * c.x()); + covariance[1] += -mass * (c.x() * c.y()); + covariance[2] += -mass * (c.y() * c.y()); // solve for eigenvalues and eigenvectors. // eigen values are sorted in ascending order, diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h index 34a00b79519..c3d8c2602f7 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h @@ -115,9 +115,9 @@ linear_least_squares_fitting_2(InputIterator first, // Translate the 2nd order moment calculated about the origin to // the center of mass to get the covariance. - covariance[0] += mass * (-1.0 * c.x() * c.x()); - covariance[1] += mass * (-1.0 * c.x() * c.y()); - covariance[2] += mass * (-1.0 * c.y() * c.y()); + covariance[0] += -mass * (c.x() * c.x()); + covariance[1] += -mass * (c.x() * c.y()); + covariance[2] += -mass * (c.y() * c.y()); // solve for eigenvalues and eigenvectors. // eigen values are sorted in ascending order, diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h index 5407c3fe497..a6d581d97df 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h @@ -104,9 +104,9 @@ linear_least_squares_fitting_2(InputIterator first, // Translate the 2nd order moment calculated about the origin to // the center of mass to get the covariance. - covariance[0] += mass * (-1.0 * c.x() * c.x()); - covariance[1] += mass * (-1.0 * c.x() * c.y()); - covariance[2] += mass * (-1.0 * c.y() * c.y()); + covariance[0] += -mass * ( c.x() * c.x()); + covariance[1] += -mass * (c.x() * c.y()); + covariance[2] += -mass * (c.y() * c.y()); // solve for eigenvalues and eigenvectors. // eigen values are sorted in ascending order, @@ -128,7 +128,7 @@ linear_least_squares_fitting_2(InputIterator first, // isotropic case (infinite number of directions) // by default: assemble a line that goes through // the centroid and with a default horizontal vector. - line = Line(c, Vector(1.0, 0.0)); + line = Line(c, Vector(FT(1), FT(0))); return (FT)0.0; } } // end linear_least_squares_fitting_2 for segment set with 1D tag diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h index 91c5d2b6449..15843aa40fb 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h @@ -112,9 +112,9 @@ linear_least_squares_fitting_2(InputIterator first, // Translate the 2nd order moment calculated about the origin to // the center of mass to get the covariance. - covariance[0] += mass * (-1.0 * c.x() * c.x()); - covariance[1] += mass * (-1.0 * c.x() * c.y()); - covariance[2] += mass * (-1.0 * c.y() * c.y()); + covariance[0] += -mass * (c.x() * c.x()); + covariance[1] += -mass * (c.x() * c.y()); + covariance[2] += -mass * (c.y() * c.y()); // std::cout<<"cov: "<