QMCPACK
test_math.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2019 QMCPACK developers.
6 //
7 // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
8 //
9 // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "catch.hpp"
14 
15 #include <memory>
16 #include <vector>
17 #include <iostream>
19 
20 namespace qmcplusplus
21 {
22 TEST_CASE("OMPmath", "[OMP]")
23 {
24  using vec_t = std::vector<double, OMPallocator<double>>;
25  vec_t A(3);
26 
27  // iterator
28  vec_t::iterator ia = A.begin();
29  for (; ia != A.end(); ia++)
30  {
31  *ia = 3.1;
32  }
33 
34  auto* A_ptr = A.data();
35  PRAGMA_OFFLOAD("omp target teams distribute map(always, tofrom:A_ptr[0:2])")
36  for (int i = 0; i < 2; i++)
37  {
38  float s, c, v = 1.2;
39  s = std::sin(i * v);
40  c = std::cos(i * v);
41  //sincos(i*v, &s, &c);
42  A_ptr[i] += s + c;
43  }
44 
45  CHECK(A[0] == Approx(4.1));
46  CHECK(A[1] == Approx(4.3943968404));
47 }
48 
49 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
TEST_CASE("complex_helper", "[type_traits]")
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))