QMCPACK
contraction_helper.hpp
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 #ifndef QMCPLUSPLUS_CONTRACTION_HELPER_HPP
14 #define QMCPLUSPLUS_CONTRACTION_HELPER_HPP
15 
16 namespace qmcplusplus
17 {
19 {
20  VAL = 0,
32 };
33 
34 /** compute Trace(H*G)
35  *
36  * gg is symmetrized as
37  * gg[0]=GG(0,0)
38  * gg[1]=GG(0,1)+GG(1,0)
39  * gg[2]=GG(0,2)+GG(2,0)
40  * gg[3]=GG(1,1)
41  * gg[4]=GG(1,2)+GG(2,1)
42  * gg[5]=GG(2,2)
43  */
44 template<typename T>
45 inline T SymTrace(T h00, T h01, T h02, T h11, T h12, T h22, const T gg[6])
46 {
47  return h00 * gg[0] + h01 * gg[1] + h02 * gg[2] + h11 * gg[3] + h12 * gg[4] + h22 * gg[5];
48 }
49 
50 /** compute vector[3]^T x matrix[3][3] x vector[3]
51  *
52  */
53 template<typename T>
54 T v_m_v(T h00, T h01, T h02, T h11, T h12, T h22, T g1x, T g1y, T g1z, T g2x, T g2y, T g2z)
55 {
56  return g1x * g2x * h00 + g1x * g2y * h01 + g1x * g2z * h02 + g1y * g2x * h01 + g1y * g2y * h11 + g1y * g2z * h12 +
57  g1z * g2x * h02 + g1z * g2y * h12 + g1z * g2z * h22;
58 }
59 /** Coordinate transform for a 3rd rank symmetric tensor representing coordinate derivatives
60  * (hence t3_contract, for contraction with vectors).
61  *
62  * hijk are the symmetry inequivalent tensor elements, i,j,k range from 0 to 2 for x to z.
63  * (gix,giy,giz) are vectors, labelled 1, 2 and 3. g1 is contracted with the first tensor index,
64  * g2 with the second, g3 with the third.
65  *
66  * This would be easier with a for loop, but I'm sticking with the convention in this section.
67  */
68 template<typename T>
69 T t3_contract(T h000,
70  T h001,
71  T h002,
72  T h011,
73  T h012,
74  T h022,
75  T h111,
76  T h112,
77  T h122,
78  T h222,
79  T g1x,
80  T g1y,
81  T g1z,
82  T g2x,
83  T g2y,
84  T g2z,
85  T g3x,
86  T g3y,
87  T g3z)
88 {
89  return h000 * (g1x * g2x * g3x) + h001 * (g1x * g2x * g3y + g1x * g2y * g3x + g1y * g2x * g3x) +
90  h002 * (g1x * g2x * g3z + g1x * g2z * g3x + g1z * g2x * g3x) +
91  h011 * (g1x * g2y * g3y + g1y * g2x * g3y + g1y * g2y * g3x) +
92  h012 *
93  (g1x * g2y * g3z + g1x * g2z * g3y + g1y * g2x * g3z + g1y * g2z * g3x + g1z * g2x * g3y + g1z * g2y * g3x) +
94  h022 * (g1x * g2z * g3z + g1z * g2x * g3z + g1z * g2z * g3x) + h111 * (g1y * g2y * g3y) +
95  h112 * (g1y * g2y * g3z + g1y * g2z * g3y + g1z * g2y * g3y) +
96  h122 * (g1y * g2z * g3z + g1z * g2y * g3z + g1z * g2z * g3y) + h222 * (g1z * g2z * g3z);
97 }
98 
99 } // namespace qmcplusplus
100 
101 #endif
T SymTrace(T h00, T h01, T h02, T h11, T h12, T h22, const T gg[6])
compute Trace(H*G)
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
T v_m_v(T h00, T h01, T h02, T h11, T h12, T h22, T g1x, T g1y, T g1z, T g2x, T g2y, T g2z)
compute vector[3]^T x matrix[3][3] x vector[3]
T t3_contract(T h000, T h001, T h002, T h011, T h012, T h022, T h111, T h112, T h122, T h222, T g1x, T g1y, T g1z, T g2x, T g2y, T g2z, T g3x, T g3y, T g3z)
Coordinate transform for a 3rd rank symmetric tensor representing coordinate derivatives (hence t3_co...