8#ifndef SRC_SPACE_SHAPE_POINT_UNIT_TEST_HPP_
9#define SRC_SPACE_SHAPE_POINT_UNIT_TEST_HPP_
12#include "Space/Shape/Point.hpp"
13#include "Grid/comb.hpp"
14#include "util/convert.hpp"
16BOOST_AUTO_TEST_SUITE( Point_test_suite )
18BOOST_AUTO_TEST_CASE( Point_use )
20 std::cout <<
"Point unit test start" <<
"\n";
32 BOOST_REQUIRE_EQUAL(p.
get(0),2.0);
33 BOOST_REQUIRE_EQUAL(p.
get(1),6.0);
34 BOOST_REQUIRE_EQUAL(p.
get(2),12.0);
49 p = p + pmul(middle,(one + pc));
51 BOOST_REQUIRE_EQUAL(p.
get(0),4.0);
52 BOOST_REQUIRE_EQUAL(p.
get(1),12.0);
53 BOOST_REQUIRE_EQUAL(p.
get(2),24.0);
61 BOOST_REQUIRE_CLOSE(pn.norm(),1.732050,0.0001);
70 BOOST_REQUIRE_EQUAL(p1.distance(p2),p2.distance(p1));
71 BOOST_REQUIRE_CLOSE(p1.distance(p2),3.74165738677,0.0001);
73 BOOST_REQUIRE_EQUAL(p1.distance2(p2),p2.distance2(p1));
74 BOOST_REQUIRE_CLOSE(p1.distance2(p2),14.0,0.0001);
76 std::cout <<
"Point unit test stop" <<
"\n";
80 BOOST_REQUIRE( p1 != p2 );
81 BOOST_REQUIRE( p1 == p1 );
88 BOOST_REQUIRE_CLOSE(p2.get(0),1.0,0.001);
89 BOOST_REQUIRE_CLOSE(p2.get(1),1.5,0.001);
90 BOOST_REQUIRE_CLOSE(p2.get(2),2.0,0.001);
92 BOOST_REQUIRE_CLOSE(p1.get(0),2.0,0.001);
93 BOOST_REQUIRE_CLOSE(p1.get(1),2.0,0.001);
94 BOOST_REQUIRE_CLOSE(p1.get(2),2.0,0.001);
100BOOST_AUTO_TEST_CASE( Point_expression_usage )
109 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),p1.get(i) + 2.0);}
111 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),2.0 + p2.get(i));}
113 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),p2.get(i) + p1.get(i));}
116 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),p1.get(i) - 2.0);}
118 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),2.0 - p2.get(i));}
120 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),p2.get(i) - p1.get(i));}
123 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),p1.get(i) * 2.0);}
125 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),2.0 * p2.get(i));}
127 for (
size_t i = 0 ; i < 3 ; i++) {scal += p1.
get(i) * p2.get(i);}
128 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),scal);}
131 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),p1.get(i) / 2.0);}
133 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),(
float)2.0 / p2.get(i));}
135 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),p2.get(i) / p1.get(i));}
140 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),p1.get(i) + (p2.get(i) + p1.get(i))) ;}
142 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),(p1.get(i) + p2.get(i)) + p2.get(i)) ;}
143 p3 = (p1 + p2) + (p1 + p2);
144 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),(p1.get(i) + p2.get(i)) + (p2.get(i) + p1.get(i))) ;}
147 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),p2.get(i) - (p1.get(i) + p2.get(i))) ;}
149 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),(p1.get(i) + p2.get(i)) - p2.get(i)) ;}
150 p3 = (p1 + p2) - (p1 + p2);
151 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),(p1.get(i) + p2.get(i)) - (p1.get(i) + p2.get(i))) ;}
155 for (
size_t i = 0 ; i < 3 ; i++) {scal += p2.
get(i) * (p2.get(i) + p1.get(i));}
156 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),scal) ;}
159 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),scal) ;}
161 p3 = (p1 + p2) * (p1 + p2);
162 for (
size_t i = 0 ; i < 3 ; i++) {scal += (p2.get(i) + p1.get(i)) * (p2.get(i) + p1.get(i));}
163 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),scal) ;}
167 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),p1.get(i) / p1.norm()) ;}
169 float dist = norm(p1 - p2);
171 for (
size_t i = 0 ; i < 3 ; i++) {dist2 += (p1.get(i) - p2.get(i)) * (p1.get(i) - p2.get(i));}
173 BOOST_REQUIRE_EQUAL(dist,dist2);
174 float dist3 = distance(p1,p2);
175 BOOST_REQUIRE_EQUAL(dist,dist3);
178 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),p2.get(i) / (p2.get(i) + p1.get(i))) ;}
180 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),(p2.get(i) + p1.get(i)) / p2.get(i) ) ;}
181 p3 = (p1 + p2) / (p1 + p2);
182 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),(p2.get(i) + p1.get(i)) / (p2.get(i) + p1.get(i)) ) ;}
188 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::abs(p1.get(i) + p2.get(i))) ;}
190 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::exp(p1.get(i) - p2.get(i))) ;}
192 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::exp2(p1.get(i) + p2.get(i))) ;}
194 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::expm1(p1.get(i) + p2.get(i))) ;}
196 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::log(p1.get(i) + p2.get(i))) ;}
198 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::log10(p1.get(i) + p2.get(i))) ;}
200 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::log2(p1.get(i) + p2.get(i))) ;}
202 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::log1p(p1.get(i) + p2.get(i))) ;}
204 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::sqrt(p1.get(i) + p2.get(i))) ;}
206 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::cbrt(p1.get(i) + p2.get(i))) ;}
208 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::sin(p1.get(i) + p2.get(i))) ;}
210 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::cos(p1.get(i) + p2.get(i))) ;}
212 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::tan(p1.get(i) + p2.get(i))) ;}
214 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::atan(p1.get(i) + p2.get(i))) ;}
215 p3 = asin(p1/5.0f + p2/6.0f);
216 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::asin(p1.get(i)/5.0f + p2.get(i)/6.0f)) ;}
217 p3 = acos(p1/5.0f + p2/6.0f);
218 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::acos(p1.get(i)/5.0f + p2.get(i)/6.0f)) ;}
220 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::sinh(p1.get(i) + p2.get(i))) ;}
222 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::cosh(p1.get(i) + p2.get(i))) ;}
224 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::tanh(p1.get(i) + p2.get(i))) ;}
225 p3 = atanh(p1/5.0f + p2/6.0f);
226 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::atanh(p1.get(i)/5.0f + p2.get(i)/6.0f)) ;}
228 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::asinh(p1.get(i) + p2.get(i))) ;}
230 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::acosh(p1.get(i) + p2.get(i))) ;}
232 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::erf(p1.get(i) + p2.get(i))) ;}
234 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::erfc(p1.get(i) + p2.get(i))) ;}
235 p3 = tgamma(p1 + p2);
236 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::tgamma(p1.get(i) + p2.get(i))) ;}
237 p3 = lgamma(p1 + p2);
238 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::lgamma(p1.get(i) + p2.get(i))) ;}
240 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::ceil(p1.get(i) + p2.get(i))) ;}
242 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::floor(p1.get(i) + p2.get(i))) ;}
244 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::trunc(p1.get(i) + p2.get(i))) ;}
246 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::round(p1.get(i) + p2.get(i))) ;}
247 p3 = nearbyint(p1 + p2);
248 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::nearbyint(p1.get(i) + p2.get(i))) ;}
250 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),std::rint(p1.get(i) + p2.get(i))) ;}
253 double tmp = 5.0 + (p1 * p2);
254 BOOST_REQUIRE_EQUAL(tmp,14.0);
255 p3 = 5.0 + (p1 * p2);
256 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),14.0) ;}
257 tmp = 5.0 - (p1 * p2);
258 BOOST_REQUIRE_EQUAL(tmp,-4.0);
259 p3 = 5.0 - (p1 * p2);
260 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),-4.0) ;}
261 tmp = 5.0 * (p1 * p2);
262 BOOST_REQUIRE_EQUAL(tmp,45.0);
263 p3 = 5.0 * (p1 * p2);
264 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),45.0) ;}
265 tmp = 5.0f / (p1 * p2);
266 BOOST_REQUIRE_EQUAL(tmp,5.0f/9.0f);
267 p3 = 5.0f / (p1 * p2);
268 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),5.0f/9.0f) ;}
270 float p[3] = {1.0,2.0,3.0};
271 auto p_e = getExprR(p);
274 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),p[i]-p1.get(i)) ;}
276 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),p[i]+p1.get(i)) ;}
279 BOOST_REQUIRE_EQUAL(tmp,sqrtf(14.0));
284 BOOST_REQUIRE_EQUAL(p4.
get(0),3.0);
285 BOOST_REQUIRE_EQUAL(p4.
get(1),5.0);
286 BOOST_REQUIRE_EQUAL(p4.
get(2),7.0);
293 BOOST_REQUIRE_EQUAL(p4.
get(0),4.0);
294 BOOST_REQUIRE_EQUAL(p4.
get(1),6.0);
295 BOOST_REQUIRE_EQUAL(p4.
get(2),8.0);
299 BOOST_REQUIRE_EQUAL(s,4.0);
307 BOOST_REQUIRE_EQUAL(p4.
get(0),9.0);
308 BOOST_REQUIRE_EQUAL(p4.
get(1),18.0);
309 BOOST_REQUIRE_EQUAL(p4.
get(2),27.0);
313 BOOST_REQUIRE_EQUAL(p4.
get(0),9.0);
314 BOOST_REQUIRE_EQUAL(p4.
get(1),18.0);
315 BOOST_REQUIRE_EQUAL(p4.
get(2),27.0);
320 BOOST_REQUIRE_EQUAL(p4.
get(0),18.0);
321 BOOST_REQUIRE_EQUAL(p4.
get(1),27.0);
322 BOOST_REQUIRE_EQUAL(p4.
get(2),36.0);
326 BOOST_REQUIRE_EQUAL(p4.
get(0),18.0);
327 BOOST_REQUIRE_EQUAL(p4.
get(1),27.0);
328 BOOST_REQUIRE_EQUAL(p4.
get(2),36.0);
330 p4 = (p1*p2) * (p2*p1);
332 BOOST_REQUIRE_EQUAL(p4.
get(0),81.0);
333 BOOST_REQUIRE_EQUAL(p4.
get(1),81.0);
334 BOOST_REQUIRE_EQUAL(p4.
get(2),81.0);
338BOOST_AUTO_TEST_CASE( Point_expression_usage_with_array )
342 float p1_p[] = {1.0,1.0,1.0};
343 float p2_p[] = {2.0,3.0,4.0};
344 float p3_p[] = {6.0,7.0,9.0};
350 auto p1 = getExprR(p1_p);
351 auto p2 = getExprR(p2_p);
353 auto p3L = getExprL(p3_p);
356 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],p1_p[i] + 2.0);}
358 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],2.0 + p2_p[i]);}
360 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],p2_p[i] + p1_p[i]);}
363 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],p1_p[i] - 2.0);}
365 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],2.0 - p2_p[i]);}
367 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],p2_p[i] - p1_p[i]);}
370 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],p1_p[i] * 2.0);}
372 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],2.0 * p2_p[i]);}
374 for (
size_t i = 0 ; i < 3 ; i++) {scal += p1_p[i] * p2_p[i];}
375 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],scal);}
378 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],p1_p[i] / 2.0);}
380 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],(
float)2.0 / p2_p[i]);}
382 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],p2_p[i] / p1_p[i]);}
387 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],p1_p[i] + p2_p[i]);}
389 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],p1_p[i] + pp2.get(i));}
391 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],pp2.get(i) + p1_p[i]);}
395 p3L = p1 + (p2 + p1);
396 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],p1_p[i] + (p2_p[i] + p1_p[i])) ;}
397 p3L = (p1 + p2) + p2;
398 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],(p1_p[i] + p2_p[i]) + p2_p[i]) ;}
399 p3L = (p1 + p2) + (p1 + p2);
400 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],(p1_p[i] + p2_p[i]) + (p2_p[i] + p1_p[i])) ;}
402 p3L = p2 - (p1 + p2);
403 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],p2_p[i] - (p1_p[i] + p2_p[i])) ;}
404 p3L = (p1 + p2) - p2;
405 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],(p1_p[i] + p2_p[i]) - p2_p[i]) ;}
406 p3L = (p1 + p2) - (p1 + p2);
407 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],(p1_p[i] + p2_p[i]) - (p1_p[i] + p2_p[i])) ;}
410 p3L = p2 * (p1 + p2);
411 for (
size_t i = 0 ; i < 3 ; i++) {scal += p2_p[i] * (p2_p[i] + p1_p[i]);}
412 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],scal) ;}
413 p3L = (p1 + p2) * p2;
414 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],scal) ;}
416 p3L = (p1 + p2) * (p1 + p2);
417 for (
size_t i = 0 ; i < 3 ; i++) {scal += (p2_p[i] + p1_p[i]) * (p2_p[i] + p1_p[i]);}
418 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],scal) ;}
422 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],p1_p[i] / sqrtf(3.0)) ;}
424 float dist = norm(p1 - p2);
426 for (
size_t i = 0 ; i < 3 ; i++) {dist2 += (p1_p[i] - p2_p[i]) * (p1_p[i] - p2_p[i]);}
428 BOOST_REQUIRE_EQUAL(dist,dist2);
429 float dist3 = distance(p1,p2);
430 BOOST_REQUIRE_EQUAL(dist,dist3);
432 p3L = p2 / (p1 + p2);
433 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],p2_p[i] / (p2_p[i] + p1_p[i])) ;}
434 p3L = (p1 + p2) / p2;
435 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],(p2_p[i] + p1_p[i]) / p2_p[i] ) ;}
436 p3L = (p1 + p2) / (p1 + p2);
437 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],(p2_p[i] + p1_p[i]) / (p2_p[i] + p1_p[i]) ) ;}
443 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::abs(p1_p[i] + p2_p[i])) ;}
445 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::exp(p1_p[i] - p2_p[i])) ;}
447 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::exp2(p1_p[i] + p2_p[i])) ;}
448 p3L = expm1(p1 + p2);
449 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::expm1(p1_p[i] + p2_p[i])) ;}
451 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::log(p1_p[i] + p2_p[i])) ;}
452 p3L = log10(p1 + p2);
453 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::log10(p1_p[i] + p2_p[i])) ;}
455 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::log2(p1_p[i] + p2_p[i])) ;}
456 p3L = log1p(p1 + p2);
457 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::log1p(p1_p[i] + p2_p[i])) ;}
459 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::sqrt(p1_p[i] + p2_p[i])) ;}
461 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::cbrt(p1_p[i] + p2_p[i])) ;}
463 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::sin(p1_p[i] + p2_p[i])) ;}
465 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::cos(p1_p[i] + p2_p[i])) ;}
467 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::tan(p1_p[i] + p2_p[i])) ;}
469 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::atan(p1_p[i] + p2_p[i])) ;}
470 p3L = asin(p1/5.0f + p2/6.0f);
471 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_CLOSE(p3_p[i],std::asin(p1_p[i]/5.0f + p2_p[i]/6.0f),0.1) ;}
472 p3L = acos(p1/5.0f + p2/6.0f);
473 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::acos(p1_p[i]/5.0f + p2_p[i]/6.0f)) ;}
475 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::sinh(p1_p[i] + p2_p[i])) ;}
477 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::cosh(p1_p[i] + p2_p[i])) ;}
479 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::tanh(p1_p[i] + p2_p[i])) ;}
480 p3L = atanh(p1/5.0f + p2/6.0f);
481 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::atanh(p1_p[i]/5.0f + p2_p[i]/6.0f)) ;}
482 p3L = acosh(p1 + p2);
483 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::acosh(p1_p[i] + p2_p[i])) ;}
485 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::erf(p1_p[i] + p2_p[i])) ;}
487 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::erfc(p1_p[i] + p2_p[i])) ;}
488 p3L = tgamma(p1 + p2);
489 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::tgamma(p1_p[i] + p2_p[i])) ;}
490 p3L = lgamma(p1 + p2);
491 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::lgamma(p1_p[i] + p2_p[i])) ;}
493 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::ceil(p1_p[i] + p2_p[i])) ;}
494 p3L = floor(p1 + p2);
495 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::floor(p1_p[i] + p2_p[i])) ;}
496 p3L = trunc(p1 + p2);
497 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::trunc(p1_p[i] + p2_p[i])) ;}
498 p3L = round(p1 + p2);
499 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::round(p1_p[i] + p2_p[i])) ;}
500 p3L = nearbyint(p1 + p2);
501 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::nearbyint(p1_p[i] + p2_p[i])) ;}
503 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::rint(p1_p[i] + p2_p[i])) ;}
506 double tmp = 5.0 + (p1 * p2);
507 BOOST_REQUIRE_EQUAL(tmp,14.0);
508 p3L = 5.0 + (p1 * p2);
509 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],14.0) ;}
510 tmp = 5.0 - (p1 * p2);
511 BOOST_REQUIRE_EQUAL(tmp,-4.0);
512 p3L = 5.0 - (p1 * p2);
513 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],-4.0) ;}
514 tmp = 5.0 * (p1 * p2);
515 BOOST_REQUIRE_EQUAL(tmp,45.0);
516 p3L = 5.0 * (p1 * p2);
517 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],45.0) ;}
518 tmp = 5.0f / (p1 * p2);
519 BOOST_REQUIRE_EQUAL(tmp,5.0f/9.0f);
520 p3L = 5.0f / (p1 * p2);
521 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],5.0f/9.0f) ;}
524BOOST_AUTO_TEST_CASE( Point_expression_usage_with_conversion )
533 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),p1.get(i) + 2);}
535 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),2 + p2.get(i));}
538 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),p1.get(i) - 2);}
540 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),2 - p2.get(i));}
543 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),p1.get(i) * 2);}
545 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),2 * p2.get(i));}
548 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),p1.get(i) / 2.0);}
550 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),(
float)2 / p2.get(i));}
554 double tmp = 5 + (p1 * p2);
555 double check = 5 + p1.get(0)*p2.get(0) + p1.get(1)*p2.get(1) + p1.get(2)*p2.get(2);
556 BOOST_REQUIRE_EQUAL(tmp,check);
557 p3 = 5.0 + (p1 * p2);
558 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),check) ;}
560 check = 5 - p1.get(0)*p2.get(0) - p1.get(1)*p2.get(1) - p1.get(2)*p2.get(2);
561 BOOST_REQUIRE_EQUAL(tmp,check);
563 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),check) ;}
565 check = 5*(p1.get(0)*p2.get(0) + p1.get(1)*p2.get(1) + p1.get(2)*p2.get(2));
566 BOOST_REQUIRE_EQUAL(tmp,check);
568 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),check) ;}
570 check = 5/(p1.get(0)*p2.get(0) + p1.get(1)*p2.get(1) + p1.get(2)*p2.get(2));
571 BOOST_REQUIRE_EQUAL(tmp,check);
573 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3.
get(i),check) ;}
576 for (
size_t i = 0 ; i < 3 ; i++)
578 check = 2*(p1.get(0)*p2.get(0) + p1.get(1)*p2.get(1) + p1.get(2)*p2.get(2))*p1.get(i);
579 BOOST_REQUIRE_EQUAL(p3[i],check) ;
582 for (
size_t i = 0 ; i < 3 ; i++)
584 check = 2*(p1.get(0)*p2.get(0) + p1.get(1)*p2.get(1) + p1.get(2)*p2.get(2))*p1.get(i);
585 BOOST_REQUIRE_EQUAL(p3[i],check) ;
588 for (
size_t i = 0 ; i < 3 ; i++)
590 check = 2*(p1.get(0)*p2.get(0) + p1.get(1)*p2.get(1) + p1.get(2)*p2.get(2))*p1.get(i);
591 BOOST_REQUIRE_EQUAL(p3[i],check) ;
596BOOST_AUTO_TEST_CASE( Point_expression_usage_with_conversion_array )
600 float p1_p[] = {0.1,0.1,0.1};
601 float p2_p[] = {0.2,0.3,0.4};
602 float p3_p[] = {0.6,0.7,0.9};
608 auto p1 = getExprR(p1_p);
609 auto p2 = getExprR(p2_p);
611 auto p3L = getExprL(p3_p);
614 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],p1_p[i] + 2);}
616 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],2 + p2_p[i]);}
619 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],p1_p[i] - 2);}
621 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],2 - p2_p[i]);}
624 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],p1_p[i] * 2);}
626 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],2 * p2_p[i]);}
629 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],p1_p[i] / 2);}
631 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],2 / p2_p[i]);}
635 p3L = asin(p1/5 + p2/6);
636 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_CLOSE(p3_p[i],std::asin(p1_p[i]/5 + p2_p[i]/6),0.1) ;}
637 p3L = acos(p1/5 + p2/6);
638 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],std::acos(p1_p[i]/5 + p2_p[i]/6)) ;}
641 double tmp = 5 + (p1 * p2);
642 double check = 5 + pp1.get(0)*pp2.get(0) + pp1.get(1)*pp2.get(1) + pp1.get(2)*pp2.get(2);
643 BOOST_REQUIRE_EQUAL(tmp,check);
645 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],check) ;}
647 check = 5 - pp1.get(0)*pp2.get(0) - pp1.get(1)*pp2.get(1) - pp1.get(2)*pp2.get(2);
648 BOOST_REQUIRE_EQUAL(tmp,check);
650 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],check) ;}
652 check = 5*(pp1.get(0)*pp2.get(0) + pp1.get(1)*pp2.get(1) + pp1.get(2)*pp2.get(2));
653 BOOST_REQUIRE_EQUAL(tmp,check);
655 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],check) ;}
657 check = 5/(pp1.get(0)*pp2.get(0) + pp1.get(1)*pp2.get(1) + pp1.get(2)*pp2.get(2));
658 BOOST_REQUIRE_EQUAL(tmp,check);
660 for (
size_t i = 0 ; i < 3 ; i++)
662 check = 2*(pp1.get(0)*pp2.get(0) + pp1.get(1)*pp2.get(1) + pp1.get(2)*pp2.get(2))*pp1.get(i);
663 BOOST_REQUIRE_EQUAL(p3_p[i],check) ;
666 for (
size_t i = 0 ; i < 3 ; i++)
668 check = 2*(pp1.get(0)*pp2.get(0) + pp1.get(1)*pp2.get(1) + pp1.get(2)*pp2.get(2))*pp1.get(i);
669 BOOST_REQUIRE_EQUAL(p3_p[i],check) ;
672 for (
size_t i = 0 ; i < 3 ; i++)
674 check = 2*(pp1.get(0)*pp2.get(0) + pp1.get(1)*pp2.get(1) + pp1.get(2)*pp2.get(2))*pp1.get(i);
675 BOOST_REQUIRE_EQUAL(p3_p[i],check) ;
678 check = 5/(pp1.get(0)*pp2.get(0) + pp1.get(1)*pp2.get(1) + pp1.get(2)*pp2.get(2));
679 for (
size_t i = 0 ; i < 3 ; i++) {BOOST_REQUIRE_EQUAL(p3_p[i],check) ;}
682BOOST_AUTO_TEST_SUITE_END()
This class implement the point shape in an N-dimensional space.
void one()
Set to one the point coordinate.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
static Point< dim, St > convert(const comb< dim > &c)
Return the combination converted to point.
Position of the element of dimension d in the hyper-cube of dimension dim.
signed char c[dim]
Array that store the combination.