Skip to content

Commit

Permalink
lib/cdhc/as177.c: rewrite Cdhc_alnfac function according to original …
Browse files Browse the repository at this point in the history
…Fortran code
  • Loading branch information
lbartoletti committed Jun 18, 2024
1 parent dfeda0b commit e888726
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/cdhc/as177.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,20 @@ void init(double work[])
*/
static double Cdhc_alnfac(int j)
{
static const double r[7] = {0.0, 1.0, 0.69314718056,
static const double r[7] = {0.0, 0.0, 0.69314718056,
1.79175946923, 3.17805383035, 4.78749174278,
6.57925121101};
double w, z;

if (j >= 0 && j < 7)
if (j < 0)
return 1.0;
if (j < 7)
return r[j];

w = (double)j + 1;
z = 1.0 / (w * w);

return (w - 0.5) * log(w) - w + 0.918938522305 +
return (w - 0.5) * log(w) - w + 0.918938533205 +
(((4.0 - 3.0 * z) * z - 14.0) * z + 420.0) / (5040.0 * w);
}

Expand Down

0 comments on commit e888726

Please sign in to comment.