3
#include <libmints/wavefunction.h>
5
#include <libmints/basisset.h>
6
#include <libmints/onebody.h>
7
#include <libmints/integral.h>
15
#define parity(m) ((m)%2 ? -1 : 1) // returns (-1)^m
16
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
17
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
19
double xyz2lm_coeff(int l, int m, int lx, int ly, int lz)
21
static int use_cca_integrals_standard = (PSI_INTEGRALS_STANDARD == 1);
26
double pfac, pfac1, sum, sum1;
29
if ((lx + ly - abs(m))%2)
32
j = (lx + ly - abs(m))/2;
37
comp = (m >= 0) ? 1 : -1;
39
if (comp != parity(i))
42
pfac = sqrt(fac[2*lx]*fac[2*ly]*fac[2*lz]*fac[l-abs_m]/(fac[2*l]*fac[l]
43
*fac[lx]*fac[ly]*fac[lz]*fac[l+abs_m]));
47
pfac *= parity((i-1)/2);
53
for (i=0; i<=i_max; i++) {
54
pfac1 = bc[l][i]*bc[i][j];
58
pfac1 *= (parity(i)*fac[2*(l-i)]/fac[l-abs_m-2*i]);
60
k_min = MAX((lx-abs_m)/2,0);
62
for (k=k_min; k<=k_max; k++)
63
sum1 += bc[j][k]*bc[abs_m][lx-2*k]*parity(k);
67
if (use_cca_integrals_standard)
68
sum *= sqrt(df[2*l]/(df[2*lx]*df[2*ly]*df[2*lz]));
73
return M_SQRT2*pfac*sum;
76
void SphericalTransformComponent::init(int a, int b, int c, double coef, int cartindex, int pureindex)
78
// printf("a = %d, b = %d, c = %d, coef = %f, cartindex = %d, pureindex = %d\n", a, b, c, coef, cartindex, pureindex);
83
cartindex_ = cartindex;
84
pureindex_ = pureindex;
87
SphericalTransform::SphericalTransform(int l)
94
// Go through all the spherical harmonic possibilities
95
for (int m = -l_; m <= l_; ++m) {
96
// Generate all the possible cartesian functions
98
for(int ii = 0; ii <= l_; ii++) {
100
for(int jj = 0; jj <= ii; jj++) {
104
// Compute the coefficient needed to convert from cartesian to spherical
105
double coef = xyz2lm_coeff(l, m, l1, m1, n1);
107
// Save the information if it is nonzero
108
if (fabs(coef) > 1.0e-16) {
109
SphericalTransformComponent component;
110
component.init(l1, m1, n1, coef, cartindex, pureindex);
111
components_.push_back(component);