56 float w, coeff1, coeff2, tri_coeff, sum_s, x_t;
59 if (abs(m1)>abs(j1) || abs(m2)>abs(j2) || abs(m3)>abs(j3))
61 else if (m1+m2+m3 !=0)
63 else if ( j3<abs(j1-j2) || j3>(j1+j2) )
70 N_t = j1+m1 > N_t ? j1+m1 : N_t;
71 N_t = j1-m1 > N_t ? j1-m1 : N_t;
72 N_t = j2+m2 > N_t ? j2+m2 : N_t;
73 N_t = j2-m2 > N_t ? j2-m2 : N_t;
74 N_t = j3+m3 > N_t ? j3+m3 : N_t;
75 N_t = j3-m3 > N_t ? j3-m3 : N_t;
76 N_t = j1+j2-j3 > N_t ? j1+j2-j3 : N_t;
77 N_t = j2+j3-j1 > N_t ? j2+j3-j1 : N_t;
78 N_t = j3+j1-j2 > N_t ? j3+j1-j2 : N_t;
81 coeff1 = powf(-1.0f,(
float)(j1-j2-m3));
87 for (t = 0; t<=N_t; t++){
90 if (j3-j2+t+m1 >= 0 && j3-j1+t-m2 >=0 && j1+j2-j3-t >= 0 && j1-t-m1 >=0 && j2-t+m2 >= 0){
92 sum_s += powf(-1.0f, (
float)t)/x_t;
95 w = coeff1*sqrtf(coeff2*tri_coeff)*sum_s;
108 int n, m, q, n1, m1, q1, n2, m2, q2, D1, D2, D3;
109 float wigner3jm, wigner3j0;
114 memset(A, 0, D1*D2*D3*
sizeof(
float));
115 for (n = 0; n<=N; n++){
116 for (m = -n; m<=n; m++){
119 for (n1 = 0; n1<=N1; n1++){
120 for (m1 = -n1; m1<=n1; m1++){
123 for (n2 = 0; n2<=N2; n2++){
124 for (m2 = -n2; m2<=n2; m2++){
127 if (n<abs(n1-n2) || n>n1+n2)
128 A[q1*D2*D3 + q2*D3 + q] = 0.0f;
130 wigner3jm =
wigner_3j(n1, n2, n, m1, m2, -m);
131 wigner3j0 =
wigner_3j(n1, n2, n, 0, 0, 0);
132 A[q1*D2*D3 + q2*D3 + q] = powf(-1.0f,(
float)m) *
133 sqrtf((2.0f*(
float)n1+1.0f)*(2.0f*(
float)n2+1.0f)*(2.0f*(
float)n+1.0f)/(4.0f*
SAF_PI)) *
134 wigner3jm * wigner3j0;
162 float ret, ri1, rim1, ri0;
169 ret = ri1 * R_lm1[(a+l-1)*M+0] + rim1 * R_lm1[(a+l-1)*M+(2*l-2)];
172 ret = ri1*R_lm1[(a+l-1)*M+(2*l-2)] - rim1 * R_lm1[(a+l-1)*M];
174 ret = ri0 * R_lm1[(a+l-1)*M+(b+l-1)];
192 return getP(M, 0, l, m, n, R_1, R_lm1);
211 p0 =
getP(M, 1, l, 1, n, R_1, R_lm1);
212 p1 =
getP(M, -1, l, -1, n, R_1, R_lm1);
218 p0 =
getP(M, 1, l, m - 1, n, R_1, R_lm1);
219 p1 =
getP(M, -1, l, -m + 1, n, R_1, R_lm1);
220 ret = p0*sqrtf(1.0f + d) - p1*(1.0f - d);
224 p0 =
getP(M, 1, l, m + 1, n, R_1, R_lm1);
225 p1 =
getP(M, -1, l, -m - 1, n, R_1, R_lm1);
226 ret = p0*(1.0f - (float)d) + p1*sqrtf(1.0f + (
float)d);
250 p0 =
getP(M, 1, l, m + 1, n, R_1, R_lm1);
251 p1 =
getP(M, -1, l, -m - 1, n, R_1, R_lm1);
255 p0 =
getP(M, 1, l, m - 1, n, R_1, R_lm1);
256 p1 =
getP(M, -1, l, -m + 1, n, R_1, R_lm1);
277 int i, n, n2_1, ind, len;
278 double* nm, *nimu, *w_nimu;
281 nm =
malloc1d(len*2*
sizeof(
double));
282 nimu =
malloc1d(len*2*
sizeof(
double));
283 w_nimu =
malloc1d(len*
sizeof(
double));
285 for(n=0; n<=order-1; n++){
287 for(i=0; i<n2_1; i++, ind++){
288 nm[ind*2] = (double)n;
289 nm[ind*2+1] = -(double)n+(
double)i;
293 for(i=0; i<len; i++){
294 nimu[i*2] = nm[i*2]+(double)ni;
295 nimu[i*2+1] = nm[i*2+1]+(double)mu;
299 for(i=0; i<len; i++){
300 nimu[i*2] = nm[i*2]+(double)ni;
301 nimu[i*2+1] = -nm[i*2+1]+(double)mu;
305 w_nimu[i] = sqrt( (nimu[i*2]-nimu[i*2+1]-1.0)*(nimu[i*2]-nimu[i*2+1])/((2.0*nimu[i*2]-1.0)*(2.0*nimu[i*2]+1.0)) );
306 memset(Wnimu, 0, len*len*
sizeof(
double));
308 Wnimu[i*len+i] = w_nimu[i];
323 int i, n, n2_1, ind, len;
324 double* nm, *nimu, *v_nimu;
327 nm =
malloc1d(len*2*
sizeof(
double));
328 nimu =
malloc1d(len*2*
sizeof(
double));
329 v_nimu =
malloc1d(len*
sizeof(
double));
331 for(n=0; n<=order-1; n++){
333 for(i=0; i<n2_1; i++, ind++){
334 nm[ind*2] = (double)n;
335 nm[ind*2+1] = -(double)n+(
double)i;
338 for(i=0; i<len; i++){
339 nimu[i*2] = nm[i*2]+(double)ni;
340 nimu[i*2+1] = nm[i*2+1]+(double)mu;
343 v_nimu[i] = sqrt( (nimu[i*2]-nimu[i*2+1])*(nimu[i*2]+nimu[i*2+1])/((2.0*nimu[i*2]-1.0)*(2.0*nimu[i*2]+1.0)) );
344 memset(Vnimu, 0, len*len*
sizeof(
double));
346 Vnimu[i*len+i] = v_nimu[i];
362 int i, n, n2_1, ind, len;
363 int* nm, *nimu, *qnm, *qnimu;
371 for(n=0; n<=order-1; n++){
373 for(i=0; i<n2_1; i++, ind++){
378 for(i=0; i<len; i++){
379 nimu[i*2] = nm[i*2]+ni;
380 nimu[i*2+1] = nm[i*2+1]+mu;
381 qnm[i] = nm[i*2]*nm[i*2]+nm[i*2]+nm[i*2+1];
382 qnimu[i] = nimu[i*2]*nimu[i*2]+nimu[i*2]+nimu[i*2+1];
384 for(i=0, ind=0; i<len; i++){
385 if(abs(nimu[i*2+1])<=nimu[i*2]){
386 idx_nm[ind] = qnimu[i];
387 idx_nimu[ind] = qnm[i];
#define SAF_PI
pi constant (single precision)
long double factorial(int n)
Factorial, accurate up to n<=25.
void * malloc1d(size_t dim1_data_size)
1-D malloc (same as malloc, but with error checking)
Main header for the Spherical Harmonic Transform and Spherical Array Processing module (SAF_SH_MODULE...
void getVnimu(int order, int ni, int mu, double *Vnimu)
Helper function for sphESPRIT_create()
float getV(int M, int l, int m, int n, float R_1[3][3], float *R_lm1)
Helper function for getSHrotMtxReal()
void gaunt_mtx(int N1, int N2, int N, float *A)
Constructs a matrix of Guant coefficients.
float getU(int M, int l, int m, int n, float R_1[3][3], float *R_lm1)
Helper function for getSHrotMtxReal()
float getP(int M, int i, int l, int a, int b, float R_1[3][3], float *R_lm1)
Helper function for getSHrotMtxReal()
float getW(int M, int l, int m, int n, float R_1[3][3], float *R_lm1)
Helper function for getSHrotMtxReal()
void getWnimu(int order, int mm, int ni, int mu, double *Wnimu)
Helper function for sphESPRIT_create()
void muni2q(int order, int ni, int mu, int *idx_nimu, int *idx_nm)
Helper function for sphESPRIT_create()
float wigner_3j(int j1, int j2, int j3, int m1, int m2, int m3)
Computes the Wigner 3j symbol through the Racah formula found in http://mathworld....
Internal header for the Spherical Harmonic Transform and Spherical Array Processing module (SAF_SH_MO...