gsl_sf_legendre.pd (PDL-2.077) | : | gsl_sf_legendre.pd (PDL-2.078) | ||
---|---|---|---|---|
skipping to change at line 87 | skipping to change at line 87 | |||
if (defined($v) && version->parse($v)>=version->parse(2.0)){ | if (defined($v) && version->parse($v)>=version->parse(2.0)){ | |||
pp_def('gsl_sf_legendre_array', | pp_def('gsl_sf_legendre_array', | |||
GenericTypes => ['D'], | GenericTypes => ['D'], | |||
OtherPars => 'char norm; int lmax; int csphase', | OtherPars => 'char norm; int lmax; int csphase', | |||
Pars => 'double x(); double [o]y(n); double [t]work(wn)', | Pars => 'double x(); double [o]y(n); double [t]work(wn)', | |||
RedoDimsCode => ' | RedoDimsCode => ' | |||
$SIZE(wn)=gsl_sf_legendre_array_n($COMP(lmax)); | $SIZE(wn)=gsl_sf_legendre_array_n($COMP(lmax)); | |||
$SIZE(n)=$COMP(lmax)*($COMP(lmax)+1)/2+$COMP(lmax)+1; | $SIZE(n)=$COMP(lmax)*($COMP(lmax)+1)/2+$COMP(lmax)+1; | |||
', | ', | |||
Code => <<'EOC', | ||||
int i; | ||||
if($x()<-1||$x()>1) $CROAK("The input to gsl_sf_legendre_array must b | ||||
e abs(x)<=1, and you input %f. Try normalizing your input.",$x()); | ||||
switch ($COMP(norm)){ | ||||
case 'P' : | ||||
GSLERR(gsl_sf_legendre_array_e,(GSL_SF_LEGENDRE_NONE, $COMP(lm | ||||
ax), $x(), $COMP(csphase), $P(work))); | ||||
break; | ||||
case 'S' : | ||||
GSLERR(gsl_sf_legendre_array_e,(GSL_SF_LEGENDRE_SCHMIDT, $COMP | ||||
(lmax), $x(), $COMP(csphase), $P(work))); | ||||
break; | ||||
case 'Y' : | ||||
GSLERR(gsl_sf_legendre_array_e,(GSL_SF_LEGENDRE_SPHARM, $COMP( | ||||
lmax), $x(), $COMP(csphase), $P(work))); | ||||
break; | ||||
case 'N' : | ||||
GSLERR(gsl_sf_legendre_array_e,(GSL_SF_LEGENDRE_FULL, $COMP(lm | ||||
ax), $x(), $COMP(csphase), $P(work))); | ||||
break; | ||||
default : | ||||
; | ||||
} | ||||
for(i=0; i<$SIZE(n); i++) { | ||||
$y(n=>i) = $work(wn=>i); | ||||
} | ||||
EOC | ||||
HandleBad => 1, | HandleBad => 1, | |||
BadCode => <<'EOBC', | Code => <<'EOBC', | |||
int i; | PDL_IF_BAD(if ( $ISBAD( x() ) ) { | |||
if ( $ISBAD( x() ) ) { | ||||
loop(n) %{ $SETBAD ( y() ); %} | loop(n) %{ $SETBAD ( y() ); %} | |||
} else { | } else,) { | |||
if($x()<-1||$x()>1) $CROAK("The input to gsl_sf_legendre_array must be abs(x)<=1, and you input %f",$x()); | if($x()<-1||$x()>1) $CROAK("The input to gsl_sf_legendre_array must be abs(x)<=1, and you input %f",$x()); | |||
gsl_sf_legendre_t norm; | ||||
switch ($COMP(norm)) { | switch ($COMP(norm)) { | |||
case 'P' : | case 'S': norm = GSL_SF_LEGENDRE_SCHMIDT; break; | |||
GSLERR(gsl_sf_legendre_array_e,(GSL_SF_LEGENDRE_NONE, $COM | case 'Y': norm = GSL_SF_LEGENDRE_SPHARM; break; | |||
P(lmax), $x(), $COMP(csphase), $P(work))); | case 'N': norm = GSL_SF_LEGENDRE_FULL; break; | |||
break; | default: norm = GSL_SF_LEGENDRE_NONE; break; | |||
case 'S' : | } | |||
GSLERR(gsl_sf_legendre_array_e,(GSL_SF_LEGENDRE_SCHMIDT, $ | GSLERR(gsl_sf_legendre_array_e,(norm, $COMP(lmax), $x(), $COMP(cspha | |||
COMP(lmax), $x(), $COMP(csphase), $P(work))); | se), $P(work))); | |||
break; | loop(n) %{ $y() = $work(wn=>n); %} | |||
case 'Y' : | ||||
GSLERR(gsl_sf_legendre_array_e,(GSL_SF_LEGENDRE_SPHARM, $C | ||||
OMP(lmax), $x(), $COMP(csphase), $P(work))); | ||||
break; | ||||
case 'N' : | ||||
GSLERR(gsl_sf_legendre_array_e,(GSL_SF_LEGENDRE_FULL, $COM | ||||
P(lmax), $x(), $COMP(csphase), $P(work))); | ||||
break; | ||||
default : | ||||
; | ||||
} | ||||
for(i=0; i<$SIZE(n); i++) { | ||||
$y(n=>i) = $work(wn=>i); | ||||
} | ||||
} | } | |||
EOBC | EOBC | |||
Doc => <<'EOD', | Doc => <<'EOD', | |||
=for ref | =for ref | |||
Calculate all normalized associated Legendre polynomials. | Calculate all normalized associated Legendre polynomials. | |||
=for usage | =for usage | |||
$Plm = gsl_sf_legendre_array($x,'P',4,-1); | $Plm = gsl_sf_legendre_array($x,'P',4,-1); | |||
The calculation is done for degree 0 <= l <= lmax and order 0 <= m <= l on the r ange abs(x)<=1. | The calculation is done for degree 0 <= l <= lmax and order 0 <= m <= l on the r ange abs(x)<=1. | |||
The parameter norm should be: | The parameter norm should be: | |||
=over 3 | =over 3 | |||
=item 'P' for unnormalized associated Legendre polynomials P_l^m(x), | ||||
=item 'S' for Schmidt semi-normalized associated Legendre polynomials S_l^m(x), | =item 'S' for Schmidt semi-normalized associated Legendre polynomials S_l^m(x), | |||
=item 'Y' for spherical harmonic associated Legendre polynomials Y_l^m(x), or | =item 'Y' for spherical harmonic associated Legendre polynomials Y_l^m(x), or | |||
=item 'N' for fully normalized associated Legendre polynomials N_l^m(x). | =item 'N' for fully normalized associated Legendre polynomials N_l^m(x). | |||
=item 'P' (or any other) for unnormalized associated Legendre polynomials P_l^m( | ||||
x), | ||||
=back | =back | |||
lmax is the maximum degree l. | lmax is the maximum degree l. | |||
csphase should be (-1) to INCLUDE the Condon-Shortley phase factor (-1)^m, or (+ 1) to EXCLUDE it. | csphase should be (-1) to INCLUDE the Condon-Shortley phase factor (-1)^m, or (+ 1) to EXCLUDE it. | |||
See L</gsl_sf_legendre_array_index> to get the value of C<l> and C<m> in the ret urned vector. | See L</gsl_sf_legendre_array_index> to get the value of C<l> and C<m> in the ret urned vector. | |||
EOD | EOD | |||
); | ); | |||
pp_def('gsl_sf_legendre_array_index', | pp_def('gsl_sf_legendre_array_index', | |||
OtherPars => 'int lmax', | OtherPars => 'int lmax', | |||
Pars => 'int [o]l(n); int [o]m(n)', | Pars => 'int [o]l(n); int [o]m(n)', | |||
RedoDimsCode => '$SIZE(n)=$COMP(lmax)*($COMP(lmax)+1)/2+$COMP(lmax)+1; ', | RedoDimsCode => '$SIZE(n)=$COMP(lmax)*($COMP(lmax)+1)/2+$COMP(lmax)+1; ', | |||
Code => q/ | Code => q/ | |||
int ell, em, index; | int ell, em, index; | |||
for (ell=0; ell<=$COMP(lmax); ell++){ | for (ell=0; ell<=$COMP(lmax); ell++){ | |||
for (em=0; em<=ell; em++){ | for (em=0; em<=ell; em++){ | |||
End of changes. 11 change blocks. | ||||
62 lines changed or deleted | 15 lines changed or added |