QMCPACK
test_RotationMatrix3D.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) 2022 QMCPACK developers.
6 //
7 // File developed by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory
8 //
9 //////////////////////////////////////////////////////////////////////////////////////
10 
11 #include "catch.hpp"
12 
14 #include <string>
15 #include <vector>
16 
17 namespace qmcplusplus
18 {
19 
20 TEMPLATE_TEST_CASE("RandomRotationMatrix", "[numerics]", float, double)
21 {
22  // TestType is defined by Catch
23  using TensorType = Tensor<TestType, 3>;
24 
25  TensorType rmat = generateRotationMatrix<TestType>(0.0, 0.0, 0.0);
26 
27  // Default rotation matrix should be the identity
28  for (int i = 0; i < 3; i++)
29  for (int j = 0; j < 3; j++)
30  if (i == j)
31  CHECK(rmat(i, j) == Approx(1.0));
32  else
33  CHECK(rmat(i, j) == Approx(0.0));
34 
35 
36  TensorType rmat2 = generateRotationMatrix<TestType>(0.1, 0.2, 0.3);
37 
38  CHECK(rmat2(0, 0) == Approx(-0.459016994374947));
39  CHECK(rmat2(0, 1) == Approx(0.842075137094350));
40  CHECK(rmat2(0, 2) == Approx(-0.283218753550188));
41  CHECK(rmat2(1, 0) == Approx(-0.489403985718866));
42  CHECK(rmat2(1, 1) == Approx(0.0263932022500210));
43  CHECK(rmat2(1, 2) == Approx(0.871657695220709));
44  CHECK(rmat2(2, 0) == Approx(0.741476323045772));
45  CHECK(rmat2(2, 1) == Approx(0.538714082201795));
46  CHECK(rmat2(2, 2) == Approx(0.400000000000000));
47 
48 
49  TensorType rmat3 = generateRotationMatrix<TestType>(0.9, 0.5, 0.8);
50 
51  CHECK(rmat3(0, 0) == Approx(0.485410196624969));
52  CHECK(rmat3(0, 1) == Approx(-0.352671151375484));
53  CHECK(rmat3(0, 2) == Approx(0.800000000000000));
54  CHECK(rmat3(1, 0) == Approx(-0.587785252292473));
55  CHECK(rmat3(1, 1) == Approx(-0.809016994374947));
56  CHECK(rmat3(1, 2) == Approx(9.79717439317882e-17));
57  CHECK(rmat3(2, 0) == Approx(0.647213595499958));
58  CHECK(rmat3(2, 1) == Approx(-0.470228201833979));
59  CHECK(rmat3(2, 2) == Approx(-0.600000000000000));
60 }
61 
62 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
Tensor<T,D> class for D by D tensor.
Definition: OhmmsTinyMeta.h:32
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
TEMPLATE_TEST_CASE("RandomRotationMatrix", "[numerics]", float, double)