Skip to content

Commit 32ec9ef

Browse files
committed
fix bug on h2test
1 parent 7d305b1 commit 32ec9ef

File tree

1 file changed

+8
-31
lines changed

1 file changed

+8
-31
lines changed

tests/h2.h

+8-31
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class H2Test: public CxxTest::TestSuite {
6060
ABORIA_VARIABLE(target_h2,double,"target h2");
6161

6262
public:
63+
#ifdef HAVE_EIGEN
6364
template <unsigned int N, typename ParticlesType, typename KernelFunction>
6465
void helper_fast_methods_calculate(ParticlesType& particles, const KernelFunction& kernel, const double scale) {
6566
typedef typename ParticlesType::position position;
@@ -105,13 +106,9 @@ class H2Test: public CxxTest::TestSuite {
105106
typedef Eigen::Map<Eigen::Matrix<double,Eigen::Dynamic,1>> map_type;
106107
map_type target_eigen(get<target_h2>(particles).data(),particles.size());
107108
map_type source_eigen(get<source>(particles).data(),particles.size());
108-
typedef Eigen::Matrix<double,Eigen::Dynamic,1> vector_type;
109-
vector_type target_eigen_v(particles.size());
110-
vector_type source_eigen_v(particles.size());
111-
source_eigen_v = source_eigen;
112109

113110
t0 = Clock::now();
114-
target_eigen_v = h2_eigen*source_eigen_v;
111+
target_eigen = h2_eigen*source_eigen;
115112
t1 = Clock::now();
116113
time_h2_eval = t1 - t0;
117114

@@ -124,7 +121,7 @@ class H2Test: public CxxTest::TestSuite {
124121
);
125122

126123
std::cout << "for h2 operator:" <<std::endl;
127-
std::cout << "dimension = "<<dimension<<". N = "<<N<<". L2_h2 error = "<<L2_h2<<". L2_fmm relative error is "<<std::sqrt(L2_h2/scale)<<". time_h2_setup = "<<time_h2_setup.count()<<". time_h2_eval = "<<time_h2_eval.count()<<std::endl;
124+
std::cout << "dimension = "<<dimension<<". N = "<<N<<". L2_h2 error = "<<L2_h2<<". L2_h2 relative error is "<<std::sqrt(L2_h2/scale)<<". time_h2_setup = "<<time_h2_setup.count()<<". time_h2_eval = "<<time_h2_eval.count()<<std::endl;
128125

129126
if (N == 3) {
130127
TS_ASSERT_LESS_THAN(L2_h2/scale,1e-2);
@@ -134,7 +131,6 @@ class H2Test: public CxxTest::TestSuite {
134131

135132
template<unsigned int D, template <typename,typename> class StorageVector,template <typename> class SearchMethod>
136133
void helper_fast_methods(size_t N) {
137-
#ifdef HAVE_EIGEN
138134
typedef Vector<double,D> double_d;
139135
typedef Vector<int,D> int_d;
140136
typedef Vector<bool,D> bool_d;
@@ -207,12 +203,10 @@ class H2Test: public CxxTest::TestSuite {
207203
helper_fast_methods_calculate<1>(particles,kernel,scale);
208204
helper_fast_methods_calculate<2>(particles,kernel,scale);
209205
helper_fast_methods_calculate<3>(particles,kernel,scale);
210-
#endif
211206
}
212207

213208
template <typename Expansions>
214209
void helper_fmm_matrix_operators(Expansions& expansions) {
215-
#ifdef HAVE_EIGEN
216210
const unsigned int D = Expansions::dimension;
217211
typedef Vector<double,D> double_d;
218212
typedef Vector<int,D> int_d;
@@ -359,8 +353,8 @@ class H2Test: public CxxTest::TestSuite {
359353
scale += std::pow(field_all_leaf1[i],2);
360354
}
361355
TS_ASSERT_LESS_THAN(std::sqrt(L2/scale),1e-4);
362-
#endif
363356
}
357+
#endif
364358

365359
void test_fmm_matrix_operators() {
366360
#ifdef HAVE_EIGEN
@@ -376,67 +370,50 @@ class H2Test: public CxxTest::TestSuite {
376370

377371

378372
void test_fast_methods_bucket_search_serial(void) {
373+
#ifdef HAVE_EIGEN
379374
const size_t N = 10000;
380-
#ifdef HAVE_GPERFTOOLS
381-
ProfilerStart("h2_bucket_search_serial");
382-
#endif
383375
std::cout << "BUCKET_SEARCH_SERIAL: testing 1D..." << std::endl;
384376
helper_fast_methods<1,std::vector,bucket_search_serial>(N);
385377
std::cout << "BUCKET_SEARCH_SERIAL: testing 2D..." << std::endl;
386378
helper_fast_methods<2,std::vector,bucket_search_serial>(N);
387379
std::cout << "BUCKET_SEARCH_SERIAL: testing 3D..." << std::endl;
388380
helper_fast_methods<3,std::vector,bucket_search_serial>(N);
389-
#ifdef HAVE_GPERFTOOLS
390-
ProfilerStop();
391381
#endif
392-
393382
}
394383

395384
void test_fast_methods_bucket_search_parallel(void) {
385+
#ifdef HAVE_EIGEN
396386
const size_t N = 10000;
397-
#ifdef HAVE_GPERFTOOLS
398-
ProfilerStart("h2_bucket_search_parallel");
399-
#endif
400387
std::cout << "BUCKET_SEARCH_PARALLEL: testing 1D..." << std::endl;
401388
helper_fast_methods<1,std::vector,bucket_search_parallel>(N);
402389
std::cout << "BUCKET_SEARCH_PARALLEL: testing 2D..." << std::endl;
403390
helper_fast_methods<2,std::vector,bucket_search_parallel>(N);
404391
std::cout << "BUCKET_SEARCH_PARALLEL: testing 3D..." << std::endl;
405392
helper_fast_methods<3,std::vector,bucket_search_parallel>(N);
406-
#ifdef HAVE_GPERFTOOLS
407-
ProfilerStop();
408393
#endif
409394
}
410395

411396
void test_fast_methods_kd_tree(void) {
397+
#ifdef HAVE_EIGEN
412398
const size_t N = 10000;
413-
#ifdef HAVE_GPERFTOOLS
414-
ProfilerStart("h2_kd_tree");
415-
#endif
416399
std::cout << "KD_TREE: testing 1D..." << std::endl;
417400
helper_fast_methods<1,std::vector,nanoflann_adaptor>(N);
418401
std::cout << "KD_TREE: testing 2D..." << std::endl;
419402
helper_fast_methods<2,std::vector,nanoflann_adaptor>(N);
420403
std::cout << "KD_TREE: testing 3D..." << std::endl;
421404
helper_fast_methods<3,std::vector,nanoflann_adaptor>(N);
422-
#ifdef HAVE_GPERFTOOLS
423-
ProfilerStop();
424405
#endif
425406
}
426407

427408
void test_fast_methods_octtree(void) {
409+
#ifdef HAVE_EIGEN
428410
const size_t N = 10000;
429-
#ifdef HAVE_GPERFTOOLS
430-
ProfilerStart("h2_octtree");
431-
#endif
432411
std::cout << "OCTTREE: testing 1D..." << std::endl;
433412
helper_fast_methods<1,std::vector,octtree>(N);
434413
std::cout << "OCTTREE: testing 2D..." << std::endl;
435414
helper_fast_methods<2,std::vector,octtree>(N);
436415
std::cout << "OCTTREE: testing 3D..." << std::endl;
437416
helper_fast_methods<3,std::vector,octtree>(N);
438-
#ifdef HAVE_GPERFTOOLS
439-
ProfilerStop();
440417
#endif
441418
}
442419

0 commit comments

Comments
 (0)