OpenFPM_data  0.1.0
Project that contain the implementation and interfaces for basic structure like vectors, grids, graph ... .
 All Data Structures Namespaces Functions Variables Typedefs Friends
Point_unit_test.hpp
1 /*
2  * Point_unit_test.hpp
3  *
4  * Created on: Aug 11, 2015
5  * Author: i-bird
6  */
7 
8 #ifndef SRC_SPACE_SHAPE_POINT_UNIT_TEST_HPP_
9 #define SRC_SPACE_SHAPE_POINT_UNIT_TEST_HPP_
10 
11 #include <iostream>
12 #include "Space/Shape/Point.hpp"
13 #include "Grid/comb.hpp"
14 #include "util/convert.hpp"
15 
16 BOOST_AUTO_TEST_SUITE( Point_test_suite )
17 
18 BOOST_AUTO_TEST_CASE( Point_use )
19 {
20  std::cout << "Point unit test start" << "\n";
21 
23 
25 
26  p.get(0) = 1.0;
27  p.get(1) = 2.0;
28  p.get(2) = 3.0;
29 
30  p = p*p + p;
31 
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);
35 
36  // Combination 3D
37  comb<3> c;
38  c.c[0] = 1;
39  c.c[1] = 1;
40  c.c[2] = 1;
42 
43  Point<3,float> one;
44  // fill the point with one
45  one.one();
46  Point<3,float> middle = p / 2;
47 
48  // middle * (one + comb_p) = 0
49  p = p + middle * (one + pc);
50 
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);
54 
56 
58 
59  Point<3,float> pn({1.0,1.0,1.0});
60 
61  BOOST_REQUIRE_CLOSE(pn.norm(),1.732050,0.0001);
62 
64 
65  std::cout << "Point unit test stop" << "\n";
66 }
67 
68 BOOST_AUTO_TEST_SUITE_END()
69 
70 
71 
72 
73 #endif /* SRC_SPACE_SHAPE_POINT_UNIT_TEST_HPP_ */
Position of the element of dimension d in the hyper-cube of dimension dim.
Definition: comb.hpp:34
static Point< dim, St > convert(const comb< dim > &c)
Return the combination converted to point.
Definition: convert.hpp:25
This class implement the point shape in an N-dimensional space.
Definition: Point.hpp:20
T get(int i) const
Get coordinate.
Definition: Point.hpp:42
void one()
Set to one the point coordinate.
Definition: Point.hpp:252
char c[dim]
Array that store the combination.
Definition: comb.hpp:37