-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMD_Dfunction.hpp
111 lines (99 loc) · 3.11 KB
/
MD_Dfunction.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef UNOMOL_MD_DFUNCTION_HPP
#define UNOMOL_MD_DFUNCTION_HPP
#include <iostream>
#include <cmath>
#include "Util.hpp"
using namespace std;
namespace unomol {
class MD_Dfunction {
private:
int asize1;
double*** dtx;
public:
MD_Dfunction(int lmax) {
asize1=lmax+1;
int asize2=2*lmax+1;
dtx=new_tensor3< double >(asize1,asize1,asize2);
}
~MD_Dfunction() {
delete_tensor3<double>(dtx,asize1,asize1);
}
constexpr const double* getRow(int i,int j) const noexcept {
return dtx[i][j];
}
constexpr double getValue(int i,int j,int k) const noexcept {
return dtx[i][j][k];
}
constexpr const double * operator()(int i,int j) const noexcept { return dtx[i][j];}
constexpr double operator()(int i,int j,int k) const noexcept { return dtx[i][j][k];}
constexpr void eval(double abi,double ax,double bx,int l1,int l2) noexcept {
int ltot=l1+l2;
if (ltot==0) {
dtx[0][0][0]=1.0;
return;
}
for (int i=0; i<=l1; i++) {
for (int j=0; j<=l2; j++) {
for (int k=0; k<=ltot; k++) dtx[i][j][k]=0.0;
}
}
dtx[0][0][0]=1.0;
for (int i=1; i<=l2; i++) {
int im1=i-1;
dtx[0][i][0]=bx*dtx[0][im1][0]+dtx[0][im1][1];
for (int n=1; n<i; n++) {
dtx[0][i][n]=abi*dtx[0][im1][n-1]+bx*dtx[0][im1][n]+
(n+1)*dtx[0][im1][n+1];
}
dtx[0][i][i]=abi*dtx[0][im1][im1];
}
for (int j=1; j<=l1; j++) {
for (int i=0; i<=l2; i++) {
int jm1=j-1;
int ipj=i+j;
dtx[j][i][0]=ax*dtx[jm1][i][0]+dtx[jm1][i][1];
for (int n=1; n<ipj; n++) {
dtx[j][i][n]=abi*dtx[jm1][i][n-1]+ax*dtx[jm1][i][n]+
(n+1)*dtx[jm1][i][n+1];
}
dtx[j][i][ipj]=abi*dtx[jm1][i][ipj-1];
}
}
}
constexpr void eval_one_cen(double abi,int l1,int l2) noexcept {
int ltot=l1+l2;
if (ltot==0) {
dtx[0][0][0]=1.0;
return;
}
for (int i=0; i<=l1; i++) {
for (int j=0; j<=l2; j++) {
for (int k=0; k<=ltot; k++) dtx[i][j][k]=0.0;
}
}
dtx[0][0][0]=1.0;
for (int i=1; i<=l2; i++) {
int im1=i-1;
dtx[0][i][0]=dtx[0][im1][1];
for (int n=1; n<i; n++) {
dtx[0][i][n]=abi*dtx[0][im1][n-1]+
(n+1)*dtx[0][im1][n+1];
}
dtx[0][i][i]=abi*dtx[0][im1][im1];
}
for (int j=1; j<=l1; j++) {
for (int i=0; i<=l2; i++) {
int jm1=j-1;
int ipj=i+j;
dtx[j][i][0]=dtx[jm1][i][1];
for (int n=1; n<ipj; n++) {
dtx[j][i][n]=abi*dtx[jm1][i][n-1]+
(n+1)*dtx[jm1][i][n+1];
}
dtx[j][i][ipj]=abi*dtx[jm1][i][ipj-1];
}
}
}
};
}
#endif