Changeset 7183 in ntrip for trunk/BNC/src/bncutils.cpp


Ignore:
Timestamp:
Aug 14, 2015, 4:56:19 PM (9 years ago)
Author:
stuerze
Message:

methods are added for the determination of the factorial and the assosiated Legendre functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/bncutils.cpp

    r7053 r7183  
    415415}
    416416
    417 // 
     417//
    418418////////////////////////////////////////////////////////////////////////////
    419419double Modulo (double x, double y) {
     
    426426  return ((val < 0.0) ? -floor(fabs(val)+0.5) : floor(val+0.5));
    427427}
     428
     429//
     430////////////////////////////////////////////////////////////////////////////
     431int factorial(int n) {
     432  if (n == 0) {
     433    return 1;
     434  }
     435  else {
     436    return (n * factorial(n - 1));
     437  }
     438}
     439
     440//
     441////////////////////////////////////////////////////////////////////////////
     442double associatedLegendreFunction(int n, int m, double t) {
     443  double sum = 0.0;
     444  int    r   = (int) floor((n - m) / 2);
     445  for (int k = 0; k <= r; k++) {
     446      sum += (pow(-1.0, (double)k) * factorial(2*n - 2*k)
     447              / (factorial(k) * factorial(n-k) * factorial(n-m-2*k))
     448              * pow(t, (double)n-m-2*k));
     449  }
     450  double fac = pow(2.0,(double) -n) * pow((1 - t*t), (double)m/2);
     451  return sum *= fac;
     452}
     453
    428454
    429455// Jacobian XYZ --> NEU
Note: See TracChangeset for help on using the changeset viewer.