Changeset 2880


Ignore:
Timestamp:
12/13/13 19:00:06 (10 years ago)
Author:
WataruKawasaki
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s): sd

Description: modify algorithm to calculate Chebyshev polynomials with better accuracy.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Scantable.cpp

    r2869 r2880  
    33653365    return x;
    33663366  } else {
    3367     double res = 0.0;
    3368     for (int m = 0; m <= n/2; ++m) {
    3369       double c = 1.0;
    3370       if (m > 0) {
    3371         for (int i = 1; i <= m; ++i) {
    3372           c *= (double)(n-2*m+i)/(double)i;
    3373         }
    3374       }
    3375       res += (m%2 == 0 ? 1.0 : -1.0)*(double)n/(double)(n-m)*pow(2.0*x, (double)(n-2*m))/2.0*c;
    3376     }
    3377     return res;
     3367    double res[n+1];
     3368    for (int i = 0; i < n+1; ++i) {
     3369      double res0 = 0.0;
     3370      if (i == 0) {
     3371        res0 = 1.0;
     3372      } else if (i == 1) {
     3373        res0 = x;
     3374      } else {
     3375        res0 = 2.0 * x * res[i-1] - res[i-2];
     3376      }
     3377      res[i] = res0;
     3378    }
     3379    return res[n];
    33783380  }
    33793381}
Note: See TracChangeset for help on using the changeset viewer.