-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add a kernel that stores objects twice: with Intervals and Gmpq #4495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add a kernel that stores objects twice: with Intervals and Gmpq #4495
Conversation
Ah, yes, that's a good idea, I did think about it when I noticed how much time a filtered rational kernel spends converting the same rational to an interval again and again. |
TODO: Once all tests pass, add specialization of the construction wrapper to use approx input when possible (to avoid non needed conversion to interval). |
After the exact construction we create the approximation. However, we have "constructions" such as |
…lt_of types Also get rid of operator() that takes an int overload, it's useless as variadic parameter do the job.
2490190 and feae9aa need reviewing. Former is to get Latter is because |
6c41cc0
to
655ae08
Compare
I have removed the hack from T3 which travis was complaining about, but it's inconsequential to what you're trying to do so nothing will change. Even when FRK is lazy (which you have to enable with the macro Adding --- a/Filtered_kernel/include/CGAL/Filtered_rational_kernel.h
+++ b/Filtered_kernel/include/CGAL/Filtered_rational_kernel.h
@@ -18,6 +18,7 @@
#include <CGAL/Filtered_rational.h>
#include <CGAL/Cartesian_converter.h>
+#include <CGAL/Compact_container.h>
#include <CGAL/Filtered_kernel/Cartesian_coordinate_iterator_2.h>
#include <CGAL/Filtered_kernel/Cartesian_coordinate_iterator_3.h>
#include <CGAL/intersections.h>
Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? y
@@ -57,7 +58,7 @@ struct Infimum_to_double
template <typename T1, typename T2>
struct Approximate_exact_pair
- : public std::pair<T1, T2>
+ : public std::pair<T1, T2>, public CGAL::Compact_container_base
{
typedef Approximate_exact_pair<T1, T2> Self;
typedef std::pair<T1, T2> Base;
but I don't know if it's the best way to go at it as I am not super familiar with the compact container inner workings. |
Thanks @MaelRL , will try. |
First preliminary tests with my program that computes arrangement of segments, on two datasets: File1: EPECK: 9.61331 seconds second step: File2: EPECK: 53.8384 seconds second step: My algorithm has 3 steps. In this test, I only parallelized the second step. It works with FRK while I have a core dump with EPECK in the destructor (corrupted double-linked list). I can try more tests if you want; and I can try to re-add the parallel version for my second step if you think it is interesting. Note that cgal arrangement does not compile with this kernel, nor my basic viewer. Hope this help. |
FRK might have such a bad runtime because of |
I mainly use the following predicates:
|
Couldn't that return a proxy instead of the heavy object? But in any case, FRK is supposed to be significantly slower than Epeck, that was the whole point of the lazy kernel...
If we start adding various things in Compact containers, I guess an FRK segment should look for a pointer in the FRK point, which should look in the exact point, which should look in its first coordinate, which should look in its numerator, etc, stopping whenever there is already a pointer available (and avoiding shared objects?). |
I don't really see how I could return a proxy. With the current definition,
I see, thanks. |
You could return an object that contains just pointers to the approximate and exact numbers, and has a conversion operator to a true FT. If this object provides exact, to_interval, etc, in some cases you may avoid the conversion to FT (in less lucky cases you may end up converting several times to FT...). It depends how the result of Compute_x_3 is used. |
I thought about this, but then you need a mechanism to know whether your pointers are still valid because you could have a function that constructs a point and returns its |
Same for kernels where x() returns a reference? |
Sure, if that function returns a reference; but if you return a copy, you are still going to have a pair with a pointer to a deleted object whereas it is safe for other kernels. |
So the case that works with references but not this shallow pair is auto x = get_temporary_point().x(); If I write FT instead of auto, it is safe. If I write auto const& the reference case is broken as well. |
My point was something like:
If you have a shallow pair, your FT will be pointing to a deleted object, even with the return by copy. |
Since the return type is explicitly FT, which is a heavy pair, the shallow pair returned by p.x() gets immediately converted to a heavy pair. It doesn't save anything, but it seems safe to me. The issue would be if the function returned auto (or decltype(auto)). |
Summary of Changes
Add a kernel and a numbertype that stores interval approximations for Gmqs.
TODO:
Release Management.
Kernel_23