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 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC vs.
Revision 1875 by gezelter, Fri May 17 14:41:42 2013 UTC

# Line 35 | Line 35
35   *                                                                      
36   * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37   * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 < * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
38 > * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).          
39   * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40   * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42 <
42 >
43 > #include "config.h"
44   #include <stdio.h>
45   #include <cmath>
46   #include <limits>
# Line 67 | 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;
71 <  RealType temp5;
72 <  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 85 | 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 102 | 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