Add imaginary part of spherical harmonics
Framework for numerical computations, data analysis and visualisation
Brought to you by:
numere
For reasons of completeness, NumeRe should also know the imaginary part of the spherical harmonics, e.g. through imY(l,m,theta,phi).
Analysis:
The following function has to be implemented with sin(m*phi)
value_type parser_SphericalHarmonics(value_type vl, value_type vm, value_type theta, value_type phi)
{
if (isinf(vl) || isnan(vl)
|| isinf(vm) || isnan(vm)
|| isinf(theta) || isnan(theta)
|| isinf(phi) || isnan(phi))
return NAN;
int l = (int)fabs(vl);
int m = (int)vm;
if (abs(m) > l)
{
return NAN;
}
else
{
return sqrt((double)(2.0*l+1.0) * parser_Faculty(l-m) / (4.0 * M_PI * parser_Faculty(l+m)))*parser_AssociatedLegendrePolynomial(l,m,cos(theta))*cos(m*phi);
}
return 0.0;
}
Implementation:
Implementation was done as proposed by the analysis.
Documentation:
Function was added to the documentation.
Tests:
Not needed as direct derivation from tested function, where only one standard function was changed.
Anonymous
Diff:
Diff:
Diff:
Diff:
Diff: