ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/math/SphericalHarmonic.cpp
(Generate patch)

Comparing branches/development/src/math/SphericalHarmonic.cpp (file contents):
Revision 1874 by gezelter, Wed Feb 20 15:39:39 2013 UTC vs.
Revision 1875 by gezelter, Fri May 17 14:41:42 2013 UTC

# Line 68 | Line 68 | RealType SphericalHarmonic::LegendreP(int l,int m, Rea
68   //
69   RealType SphericalHarmonic::LegendreP(int l,int m, RealType x) {
70  
71 <  RealType temp1, temp2, temp3, temp4, result;
72 <  RealType temp5;
73 <  int i, ll;
71 >  RealType result;
72    
73    if (fabs(x) > 1.0) {
74      printf("LegendreP: x out of range: l = %d\tm = %d\tx = %lf\n", l, m, x);
# Line 86 | Line 84 | RealType SphericalHarmonic::LegendreP(int l,int m, Rea
84      printf("LegendreP: m < 0: l = %d\tm = %d\tx = %lf\n", l, m, x);
85      return std::numeric_limits <RealType>:: quiet_NaN();
86    } else {
87 +    RealType temp1, temp2, temp3, temp4, temp5;
88      temp3=1.0;
89      
90      if (m>0) {
91        temp1=sqrt(1.0-pow(x,2));
92        temp5 = 1.0;
93 <      for (i=1;i<=m;++i) {
93 >      for (int i=1;i<=m;++i) {
94          temp3 *= -temp5*temp1;
95          temp5 += 2.0;
96        }
# Line 103 | Line 102 | RealType SphericalHarmonic::LegendreP(int l,int m, Rea
102        if (l==(m+1)) {
103          result = temp4;
104        } else {
105 <        for (ll=(m+2);ll<=l;++ll) {
105 >        for (int ll=(m+2);ll<=l;++ll) {
106            temp2 = (x*(2.*ll-1.)*temp4-(ll+m-1.)*temp3)/(RealType)(ll-m);
107            temp3=temp4;
108            temp4=temp2;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines