QMCPACK
test_multi_dirac_determinant.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: Peter Doak, doakpw@ornl.gov, Oak Ridge National Laboratory
8 //
9 // File created by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "catch.hpp"
14 
15 #include "OhmmsPETE/OhmmsMatrix.h"
17 
18 //#include <stdio.h>
19 #include <string>
20 
21 using std::string;
22 
23 
24 namespace qmcplusplus
25 {
26 template<class T>
28 {
29  template<typename DT>
31 
34  std::vector<int> it_things;
35 
36 public:
37  void build_interal_data(int dim_size)
38  {
39  MDDC.resize(dim_size);
40  dots.resize(dim_size, dim_size);
41  it_things.resize(2 * dim_size);
42 
43  double n = 0.0;
44  int i = 0;
45  //Just making some non trivial data
46  for (auto& m : dots)
47  {
48  if (++i % 2 != 0)
49  m = -n / (T)dim_size;
50  else
51  m = n / (T)dim_size;
52  if (n > (T)dim_size - 0.5)
53  n = 0.0;
54  else
55  n += 1.0;
56  }
57 
58  for (size_t i = 0; i < dim_size; i++)
59  it_things[i] = it_things[i + dim_size] = i;
60  }
61 
62  T generic_evaluate(int dim_size)
63  {
64  build_interal_data(dim_size);
65  return MDDC.evaluate(dots, it_things.data(), dim_size);
66  }
67 
68  template<unsigned EXT_LEVEL>
70  {
71  build_interal_data(EXT_LEVEL);
72  return calcSmallDeterminant(EXT_LEVEL, dots.data(), it_things.data(),dots.cols());
73  }
74 };
75 
76 /** Simple synthetic test case will trip on changes in this method.
77  */
78 TEST_CASE("SmallMatrixDetCalculator::evaluate-Small", "[wavefunction][fermion][multidet]")
79 {
81  CHECK(double_test.generic_evaluate(1) == Approx(0.0));
82  CHECK(double_test.generic_evaluate(2) == Approx(0.5));
83  CHECK(double_test.generic_evaluate(3) == Approx(-0.7407407407));
84  CHECK(double_test.generic_evaluate(4) == Approx(-0.87890625));
85  CHECK(double_test.generic_evaluate(5) == Approx(-0.96768));
86 
87  CHECK(double_test.customized_evaluate<1>() == Approx(0.0));
88  CHECK(double_test.customized_evaluate<2>() == Approx(0.5));
89  CHECK(double_test.customized_evaluate<3>() == Approx(-0.7407407407));
90  CHECK(double_test.customized_evaluate<4>() == Approx(-0.87890625));
91  CHECK(double_test.customized_evaluate<5>() == Approx(-0.96768));
92 
93  CHECK(double_test.generic_evaluate(1<<3) == Approx(-1.1086723208));
94  CHECK(double_test.generic_evaluate(1<<7) == Approx(-1.3432116824));
95  CHECK(double_test.generic_evaluate(1<<12) == Approx(-1.3586431786));
96 }
97 
98 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
TEST_CASE("complex_helper", "[type_traits]")
VALUE calcSmallDeterminant(size_t n, const VALUE *table_matrix, const int *it, const size_t nb_cols)
static T evaluate(T a11, T a12, T a21, T a22)
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))