36 if( !( ( m1 + m2 + m3 ).toIndex() == 0 ) )
42 if( !( ( J ).Denom() == 1 ) )
45 if( !(
abs( m1 ) <= j1 &&
abs( m2 ) <= j2 &&
abs( m3 ) <= j3 ) )
50 if( !( (( J ).toIndex() % 2) == 0 ) )
54 return ((((J/2)%2)==0)?(1.):(-1.)) * sqrt(
factorials(
66 (J/2-j3).toIndex())));
76 (+j1-j2+j3).toIndex(),
77 (-j1+j2+j3).toIndex(),
89 while( (j1+j2-j3-s).toIndex() >= 0 &&
90 (j1-m1-s).toIndex() >= 0 &&
91 (j2+m2-s).toIndex() >= 0 )
93 if( (j3-j2+m1+s).toIndex() >= 0 &&
94 (j3-j1-m2+s).toIndex() >= 0 )
99 (j1+j2-j3-s).toIndex(),
102 (j3-j2+m1+s).toIndex(),
103 (j3-j1-m2+s).toIndex()));
139 return 2 * ((((j1+j2+j3+1).toIndex()%2)==0)?(1.):(-1.)) *
146 while( (j1+j2+J1+J2-s).toIndex() >= 0 &&
147 (j2+j3+J2+J3-s).toIndex() >= 0 &&
148 (j3+j1+J3+J1-s).toIndex() >= 0 )
150 if( (s-j1-j2-j3).toIndex() >= 0 &&
151 (s-j1-J2-J3).toIndex() >= 0 &&
152 (s-J1-j2-J3).toIndex() >= 0 &&
153 (s-J1-J2-j3).toIndex() >= 0 )
158 (s-j1-J2-J3).toIndex(),
159 (s-J1-j2-J3).toIndex(),
160 (s-J1-J2-j3).toIndex(),
161 (j1+j2+J1+J2-s).toIndex(),
162 (j2+j3+J2+J3-s).toIndex(),
163 (j3+j1+J3+J1-s).toIndex()));
182 Numeric wigner9j(){
return NAN;}
214 Rational nom1=(a+b-c), nom2=(a-b+c), nom3=(-a+b+c), denom1=(a+b+c+1);
248 for(
Index jj=0;jj<JJ;jj++)
251 if((ii%output[jj])==0)
260 output.push_back(ii);
275 output.resize(numbers);
277 for(
Index ii=0;ii<numbers;ii++)
281 while( input/num != 0 )
283 output[ii] += input/num;
294 Index max_nom_ind, max_denom_ind;
297 std::ostringstream os;
298 Index test_if_input_is_crazy = 0;
302 max_nom_ind =
max(NomFac);
305 test_if_input_is_crazy++;
306 os <<
"Negative values in the factorial nominator.\n This is: " << NomFac << std::endl;
311 if(DenomFac.
nelem()>0)
313 max_denom_ind =
max(DenomFac);
314 if(
min(DenomFac)<0 )
316 test_if_input_is_crazy++;
317 os <<
"Negative values in the factorial denominator.\n This is: " << DenomFac << std::endl;
322 if(test_if_input_is_crazy>0)
323 throw std::runtime_error(os.str());
326 const Index max_ind = (max_denom_ind<max_nom_ind) ? max_nom_ind : max_denom_ind;
330 primes(all_primes, max_ind);
331 all_powers.resize(all_primes.
nelem());
334 for(
Index jj = 0; jj < NomFac.
nelem(); jj++ )
338 for(
Index ii = 0; ii <
temp.nelem(); ii++ )
339 all_powers[ii] +=
temp[ii];
343 for(
Index jj = 0; jj < DenomFac.
nelem(); jj++ )
347 for(
Index ii = 0; ii <
temp.nelem(); ii++ )
348 all_powers[ii] -=
temp[ii];
352 bool still_possible=
true;
Index num=all_primes.
nelem();
357 while( still_possible )
360 for(
Index jj = 0 ; jj < num; jj++)
364 if(total > 1e20 &&
min(all_powers)<0)
366 total *= (
Numeric) all_primes[jj];
369 else if(all_powers[jj]<0)
371 if(total < 1e-20 &&
max(all_powers)>0)
373 total /= (
Numeric) all_primes[jj];
382 still_possible=
false;