8#ifndef OPENFPM_NUMERICS_SRC_VECTOR_VECTOR_UNIT_TESTS_HPP_
9#define OPENFPM_NUMERICS_SRC_VECTOR_VECTOR_UNIT_TESTS_HPP_
11#define BOOST_TEST_DYN_LINK
12#include <boost/test/unit_test.hpp>
13#include <VCluster/VCluster.hpp>
16#include "Vector/Vector.hpp"
18BOOST_AUTO_TEST_SUITE( vector_test_suite )
22BOOST_AUTO_TEST_CASE(vector_eigen_parallel)
66 BOOST_REQUIRE_EQUAL(v(0),0);
67 BOOST_REQUIRE_EQUAL(v(1),1);
68 BOOST_REQUIRE_EQUAL(v(2),2);
70 BOOST_REQUIRE_EQUAL(v(3),3);
71 BOOST_REQUIRE_EQUAL(v(4),4);
72 BOOST_REQUIRE_EQUAL(v(5),5);
74 BOOST_REQUIRE_EQUAL(v(6),6);
75 BOOST_REQUIRE_EQUAL(v(7),7);
76 BOOST_REQUIRE_EQUAL(v(8),8);
97 BOOST_REQUIRE_EQUAL(v(0),8);
98 BOOST_REQUIRE_EQUAL(v(1),7);
99 BOOST_REQUIRE_EQUAL(v(2),6);
101 BOOST_REQUIRE_EQUAL(v2(0),0);
102 BOOST_REQUIRE_EQUAL(v2(1),1);
103 BOOST_REQUIRE_EQUAL(v2(2),2);
105 BOOST_REQUIRE_EQUAL(v3(0),0);
106 BOOST_REQUIRE_EQUAL(v3(1),1);
107 BOOST_REQUIRE_EQUAL(v3(2),2);
111 BOOST_REQUIRE_EQUAL(v(3),5);
112 BOOST_REQUIRE_EQUAL(v(4),4);
113 BOOST_REQUIRE_EQUAL(v(5),3);
115 BOOST_REQUIRE_EQUAL(v2(3),3);
116 BOOST_REQUIRE_EQUAL(v2(4),4);
117 BOOST_REQUIRE_EQUAL(v2(5),5);
119 BOOST_REQUIRE_EQUAL(v3(3),3);
120 BOOST_REQUIRE_EQUAL(v3(4),4);
121 BOOST_REQUIRE_EQUAL(v3(5),5);
125 BOOST_REQUIRE_EQUAL(v(6),2);
126 BOOST_REQUIRE_EQUAL(v(7),1);
127 BOOST_REQUIRE_EQUAL(v(8),0);
129 BOOST_REQUIRE_EQUAL(v2(6),6);
130 BOOST_REQUIRE_EQUAL(v2(7),7);
131 BOOST_REQUIRE_EQUAL(v2(8),8);
133 BOOST_REQUIRE_EQUAL(v3(6),6);
134 BOOST_REQUIRE_EQUAL(v3(7),7);
135 BOOST_REQUIRE_EQUAL(v3(8),8);
143BOOST_AUTO_TEST_CASE(vector_petsc_parallel)
201 BOOST_REQUIRE_EQUAL(v(0),8);
202 BOOST_REQUIRE_EQUAL(v(1),7);
203 BOOST_REQUIRE_EQUAL(v(2),6);
205 BOOST_REQUIRE_EQUAL(v3(0),0);
206 BOOST_REQUIRE_EQUAL(v3(1),1);
207 BOOST_REQUIRE_EQUAL(v3(2),2);
211 BOOST_REQUIRE_EQUAL(v(3),5);
212 BOOST_REQUIRE_EQUAL(v(4),4);
213 BOOST_REQUIRE_EQUAL(v(5),3);
215 BOOST_REQUIRE_EQUAL(v3(3),3);
216 BOOST_REQUIRE_EQUAL(v3(4),4);
217 BOOST_REQUIRE_EQUAL(v3(5),5);
221 BOOST_REQUIRE_EQUAL(v(6),2);
222 BOOST_REQUIRE_EQUAL(v(7),1);
223 BOOST_REQUIRE_EQUAL(v(8),0);
225 BOOST_REQUIRE_EQUAL(v3(6),6);
226 BOOST_REQUIRE_EQUAL(v3(7),7);
227 BOOST_REQUIRE_EQUAL(v3(8),8);
231 auto & vp = v.getVec();
237 PetscInt ix[] = {0,1,2};
240 VecGetValues(vp,3,ix,y);
242 BOOST_REQUIRE_EQUAL(y[0],8);
243 BOOST_REQUIRE_EQUAL(y[1],7);
244 BOOST_REQUIRE_EQUAL(y[2],6);
248 PetscInt ix[] = {3,4,5};
251 VecGetValues(vp,3,ix,y);
253 BOOST_REQUIRE_EQUAL(y[0],5);
254 BOOST_REQUIRE_EQUAL(y[1],4);
255 BOOST_REQUIRE_EQUAL(y[2],3);
259 PetscInt ix[] = {6,7,8};
262 VecGetValues(vp,3,ix,y);
264 BOOST_REQUIRE_EQUAL(y[0],2);
265 BOOST_REQUIRE_EQUAL(y[1],1);
266 BOOST_REQUIRE_EQUAL(y[2],0);
273BOOST_AUTO_TEST_SUITE_END()
size_t getProcessUnitID()
Get the process unit id.
size_t getProcessingUnits()
Get the total number of processors.
Implementation of VCluster class.
Sparse Matrix implementation stub object when OpenFPM is compiled with no linear algebra support.