From 49b8f1f7fbe73d32ae2da5bd381a77fa38edfd91 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 23 Mar 2023 14:41:46 +0100 Subject: [PATCH 1/7] Add partial specializations of boost::multiprecision::is_byte_container --- Installation/include/CGAL/config.h | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h index 22fe30a1823..2149ea244cd 100644 --- a/Installation/include/CGAL/config.h +++ b/Installation/include/CGAL/config.h @@ -597,4 +597,40 @@ inline std::string data_file_path(const std::string& filename) } // end namespace CGAL + +// Workaround for an accidental enable if of Eigen::Matrix in the +// boost::multiprecision::cpp_int constructor for some versions of +// boost + +namespace Eigen{ + template + class Matrix; + template + class Ref; + +} + +namespace boost { + namespace multiprecision { + namespace detail { + template + struct is_byte_container; + + + template + struct is_byte_container< Eigen::Matrix> + { + static const bool value = false; + }; + + template + struct is_byte_container< Eigen::Ref> + { + static const bool value = false; + }; + + } + } +} + #endif // CGAL_CONFIG_H From a9cf79e512c65664663080892ae65be33e4c105d Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Apr 2023 10:21:00 +0100 Subject: [PATCH 2/7] Add more partial specializations --- Installation/include/CGAL/config.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h index 2149ea244cd..2396191a639 100644 --- a/Installation/include/CGAL/config.h +++ b/Installation/include/CGAL/config.h @@ -608,6 +608,11 @@ namespace Eigen{ template class Ref; + template + class Product; + + template class CwiseBinaryOp; + } namespace boost { @@ -629,6 +634,18 @@ namespace boost { static const bool value = false; }; + template + struct is_byte_container< Eigen::Product> + { + static const bool value = false; + }; + + template + struct is_byte_container< Eigen::CwiseBinaryOp> + { + static const bool value = false; + }; + } } } From 3d9e5898538d4b3fc27b42858271716405c54bb8 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Apr 2023 10:42:17 +0100 Subject: [PATCH 3/7] Remove default value --- Installation/include/CGAL/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h index 2396191a639..422c4600825 100644 --- a/Installation/include/CGAL/config.h +++ b/Installation/include/CGAL/config.h @@ -608,7 +608,7 @@ namespace Eigen{ template class Ref; - template + template class Product; template class CwiseBinaryOp; From be85b37b374aa67394c6f5f3e9654dc9514d4ec5 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Apr 2023 10:42:43 +0100 Subject: [PATCH 4/7] Simplify expressions --- .../include/CGAL/PCA_util_Eigen.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Principal_component_analysis/include/CGAL/PCA_util_Eigen.h b/Principal_component_analysis/include/CGAL/PCA_util_Eigen.h index e7fd18b8842..f4a8fc09f80 100644 --- a/Principal_component_analysis/include/CGAL/PCA_util_Eigen.h +++ b/Principal_component_analysis/include/CGAL/PCA_util_Eigen.h @@ -368,7 +368,7 @@ assemble_covariance_matrix_3(InputIterator first, transformation << radius, 0.0, 0.0, 0.0, radius, 0.0, 0.0, 0.0, radius; - FT volume = (FT)(4.0/3.0) * radius * t.squared_radius(); + FT volume = radius * t.squared_radius(); // skip zero measure primitives if(volume == (FT)0.0) @@ -377,8 +377,9 @@ assemble_covariance_matrix_3(InputIterator first, // Find the 2nd order moment for the sphere wrt to the origin by an affine transformation. // Transform the standard 2nd order moment using the transformation matrix - transformation = (3.0/4.0) * volume * transformation * moment * transformation.transpose(); + transformation = volume * transformation * moment * transformation.transpose(); + volume *= FT(4.0 / 3.0); // Translate the 2nd order moment to the center of the sphere. FT x0 = t.center().x(); FT y0 = t.center().y(); @@ -453,7 +454,7 @@ assemble_covariance_matrix_3(InputIterator first, transformation << radius, 0.0, 0.0, 0.0, radius, 0.0, 0.0, 0.0, radius; - FT area = (FT)4.0 * t.squared_radius(); + FT area = t.squared_radius(); // skip zero measure primitives if(area == (FT)0.0) @@ -462,8 +463,9 @@ assemble_covariance_matrix_3(InputIterator first, // Find the 2nd order moment for the sphere wrt to the origin by an affine transformation. // Transform the standard 2nd order moment using the transformation matrix - transformation = (1.0/4.0) * area * transformation * moment * transformation.transpose(); + transformation = area * transformation * moment * transformation.transpose(); + area *= FT(4.0); // Translate the 2nd order moment to the center of the sphere. FT x0 = t.center().x(); FT y0 = t.center().y(); From b5f44bdac113c22a9c7b363b53bac25b2276f3c2 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Apr 2023 10:55:31 +0100 Subject: [PATCH 5/7] Activate workaround only for boost < 1.79 --- Installation/include/CGAL/config.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h index 422c4600825..38e6788a438 100644 --- a/Installation/include/CGAL/config.h +++ b/Installation/include/CGAL/config.h @@ -598,6 +598,8 @@ inline std::string data_file_path(const std::string& filename) } // end namespace CGAL +#if BOOST_VERSION < 107900 + // Workaround for an accidental enable if of Eigen::Matrix in the // boost::multiprecision::cpp_int constructor for some versions of // boost @@ -650,4 +652,6 @@ namespace boost { } } +#endif + #endif // CGAL_CONFIG_H From 246cc9ba0b90797bd16d42e059a042ec284df9d1 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Apr 2023 11:16:52 +0100 Subject: [PATCH 6/7] Simplify expressions --- Principal_component_analysis/include/CGAL/PCA_util.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Principal_component_analysis/include/CGAL/PCA_util.h b/Principal_component_analysis/include/CGAL/PCA_util.h index 9e3508a68a6..d3f7215d801 100644 --- a/Principal_component_analysis/include/CGAL/PCA_util.h +++ b/Principal_component_analysis/include/CGAL/PCA_util.h @@ -391,7 +391,7 @@ assemble_covariance_matrix_3(InputIterator first, 0.0, radius, 0.0, 0.0, 0.0, radius}; Matrix transformation = init_matrix(3,delta); - FT volume = (FT)(4.0/3.0) * radius * t.squared_radius(); + FT volume = radius * t.squared_radius(); // skip zero measure primitives if(volume == (FT)0.0) @@ -400,8 +400,9 @@ assemble_covariance_matrix_3(InputIterator first, // Find the 2nd order moment for the sphere wrt to the origin by an affine transformation. // Transform the standard 2nd order moment using the transformation matrix - transformation = (3.0/4.0) * volume * transformation * moment * LA::transpose(transformation); + transformation = volume * transformation * moment * LA::transpose(transformation); + volume *= FT(4.0/3.0); // Translate the 2nd order moment to the center of the sphere. FT x0 = t.center().x(); FT y0 = t.center().y(); @@ -476,7 +477,7 @@ assemble_covariance_matrix_3(InputIterator first, 0.0, radius, 0.0, 0.0, 0.0, radius}; Matrix transformation = init_matrix(3,delta); - FT area = (FT)4.0 * t.squared_radius(); + FT area = t.squared_radius(); // skip zero measure primitives if(area == (FT)0.0) @@ -485,8 +486,9 @@ assemble_covariance_matrix_3(InputIterator first, // Find the 2nd order moment for the sphere wrt to the origin by an affine transformation. // Transform the standard 2nd order moment using the transformation matrix - transformation = (1.0/4.0) * area * transformation * moment * LA::transpose(transformation); + transformation = area * transformation * moment * LA::transpose(transformation); + area *= FT(4.0); // Translate the 2nd order moment to the center of the sphere. FT x0 = t.center().x(); FT y0 = t.center().y(); From df17ad5e245c2189dbb5d29d21da49342a4479f9 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 6 Apr 2023 12:47:07 +0200 Subject: [PATCH 7/7] Add a comment to the closing #endif --- Installation/include/CGAL/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h index 38e6788a438..d492dafc046 100644 --- a/Installation/include/CGAL/config.h +++ b/Installation/include/CGAL/config.h @@ -652,6 +652,6 @@ namespace boost { } } -#endif +#endif // BOOST_VERSION < 107900 #endif // CGAL_CONFIG_H