@@ -28,6 +28,10 @@ namespace boost { namespace geometry
28
28
namespace detail { namespace generic_robust_predicates
29
29
{
30
30
31
+ // The templates in this file are meant to be used for the evaluation of
32
+ // expressions with floating-point precision and floating-point rounding.
33
+ // The most important template in this file is approximate_interim.
34
+
31
35
template
32
36
<
33
37
typename Node,
@@ -37,7 +41,7 @@ template
37
41
>
38
42
struct get_nth_real_impl
39
43
{
40
- static inline Real apply (const InputArr& input)
44
+ static inline Real apply (InputArr const & input)
41
45
{
42
46
return input[N - 1 ];
43
47
}
@@ -51,7 +55,7 @@ template
51
55
>
52
56
struct get_nth_real_impl <Node, 0 , Real, InputArr>
53
57
{
54
- static inline Real apply (const InputArr&)
58
+ static inline Real apply (InputArr const &)
55
59
{
56
60
return Node::value;
57
61
}
@@ -64,7 +68,7 @@ template
64
68
typename Real,
65
69
typename InputArr
66
70
>
67
- inline Real get_nth_real (const InputArr& input)
71
+ inline Real get_nth_real (InputArr const & input)
68
72
{
69
73
return get_nth_real_impl<Node, Node::argn, Real, InputArr>::apply (input);
70
74
}
@@ -80,7 +84,7 @@ template
80
84
>
81
85
struct get_approx_impl
82
86
{
83
- static inline Real apply (Arr& interim_results, const InputArr& input )
87
+ static inline Real apply (Arr& interim_results, InputArr const & )
84
88
{
85
89
return interim_results[boost::mp11::mp_find<All, Node>::value];
86
90
}
@@ -96,7 +100,7 @@ template
96
100
>
97
101
struct get_approx_impl <All, Node, Real, Arr, true , InputArr>
98
102
{
99
- static inline Real apply (Arr& interim_results, const InputArr& input)
103
+ static inline Real apply (Arr&, InputArr const & input)
100
104
{
101
105
return get_nth_real<Node, Node::argn, Real, InputArr>(input);
102
106
}
@@ -110,7 +114,7 @@ template
110
114
typename Arr,
111
115
typename InputArr
112
116
>
113
- inline Real get_approx (Arr& interim_results, const InputArr& input)
117
+ inline Real get_approx (Arr& interim_results, InputArr const & input)
114
118
{
115
119
return get_approx_impl
116
120
<
@@ -145,7 +149,7 @@ template
145
149
>
146
150
struct approximate_remainder_impl
147
151
{
148
- static inline void apply (Arr& interim_results, const InputArr& input)
152
+ static inline void apply (Arr& interim_results, InputArr const & input)
149
153
{
150
154
using node = boost::mp11::mp_front<Remaining>;
151
155
approximate_interim_impl
@@ -178,7 +182,7 @@ struct approximate_remainder_impl
178
182
InputArr
179
183
>
180
184
{
181
- static inline void apply (Arr& interim_results, const InputArr& input ) {}
185
+ static inline void apply (Arr&, InputArr const & ) {}
182
186
};
183
187
184
188
template
@@ -189,7 +193,7 @@ template
189
193
typename Arr,
190
194
typename InputArr
191
195
>
192
- inline void approximate_remainder (Arr& interim_results, const InputArr& input)
196
+ inline void approximate_remainder (Arr& interim_results, InputArr const & input)
193
197
{
194
198
approximate_remainder_impl
195
199
<
@@ -220,7 +224,7 @@ struct approximate_interim_impl
220
224
InputArr
221
225
>
222
226
{
223
- static inline void apply (Arr& interim_results, const InputArr& input)
227
+ static inline void apply (Arr& interim_results, InputArr const & input)
224
228
{
225
229
using node = boost::mp11::mp_front<Remaining>;
226
230
interim_results[boost::mp11::mp_find<All, node>::value] =
@@ -255,7 +259,7 @@ struct approximate_interim_impl
255
259
InputArr
256
260
>
257
261
{
258
- static inline void apply (Arr& interim_results, const InputArr& input)
262
+ static inline void apply (Arr& interim_results, InputArr const & input)
259
263
{
260
264
using node = boost::mp11::mp_front<Remaining>;
261
265
interim_results[boost::mp11::mp_find<All, node>::value] = std::max (
@@ -290,7 +294,7 @@ struct approximate_interim_impl
290
294
InputArr
291
295
>
292
296
{
293
- static inline void apply (Arr& interim_results, const InputArr& input)
297
+ static inline void apply (Arr& interim_results, InputArr const & input)
294
298
{
295
299
using node = boost::mp11::mp_front<Remaining>;
296
300
interim_results[boost::mp11::mp_find<All, node>::value] = std::min (
@@ -325,7 +329,7 @@ struct approximate_interim_impl
325
329
InputArr
326
330
>
327
331
{
328
- static inline void apply (Arr& interim_results, const InputArr& input)
332
+ static inline void apply (Arr& interim_results, InputArr const & input)
329
333
{
330
334
using node = boost::mp11::mp_front<Remaining>;
331
335
interim_results[boost::mp11::mp_find<All, node>::value] =
@@ -360,7 +364,7 @@ struct approximate_interim_impl
360
364
InputArr
361
365
>
362
366
{
363
- static inline void apply (Arr& interim_results, const InputArr& input)
367
+ static inline void apply (Arr& interim_results, InputArr const & input)
364
368
{
365
369
using node = boost::mp11::mp_front<Remaining>;
366
370
interim_results[boost::mp11::mp_find<All, node>::value] =
@@ -395,7 +399,7 @@ struct approximate_interim_impl
395
399
InputArr
396
400
>
397
401
{
398
- static inline void apply (Arr& interim_results, const InputArr& input)
402
+ static inline void apply (Arr& interim_results, InputArr const & input)
399
403
{
400
404
using node = boost::mp11::mp_front<Remaining>;
401
405
interim_results[boost::mp11::mp_find<All, node>::value] =
@@ -432,7 +436,7 @@ struct approximate_interim_impl
432
436
InputArr
433
437
>
434
438
{
435
- static inline void apply (Arr& interim_results, const InputArr& input)
439
+ static inline void apply (Arr& interim_results, InputArr const & input)
436
440
{
437
441
approximate_remainder
438
442
<
@@ -443,6 +447,13 @@ struct approximate_interim_impl
443
447
}
444
448
};
445
449
450
+ // All expects an boost::mp11::mp_list of all expressions that need to be
451
+ // evaluated. Remaining expects an boost::mp11::mp_list of the expressions
452
+ // that are left to be evaluated. In the first call it is expected to be
453
+ // equal to All and it serves as an anchor for template recursion. Real is a
454
+ // floating-point type. The remaining template arguments are deduced from
455
+ // parameters.
456
+
446
457
template
447
458
<
448
459
typename All,
@@ -451,7 +462,7 @@ template
451
462
typename Arr,
452
463
typename InputArr
453
464
>
454
- inline void approximate_interim (Arr& interim_results, const InputArr& input)
465
+ inline void approximate_interim (Arr& interim_results, InputArr const & input)
455
466
{
456
467
approximate_remainder
457
468
<
@@ -462,7 +473,7 @@ inline void approximate_interim(Arr& interim_results, const InputArr& input)
462
473
}
463
474
464
475
template <typename Expression, typename Real, typename InputArr>
465
- inline Real approximate_value (const InputArr& input)
476
+ inline Real approximate_value (InputArr const & input)
466
477
{
467
478
using stack = typename boost::mp11::mp_unique<post_order<Expression>>;
468
479
using evals = typename boost::mp11::mp_remove_if<stack, is_leaf>;
0 commit comments