This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

A problem wit tgamma function


For the sake of completeness I want to flag this.

A recent failure of GFortran tests, regarding the usage of GAMMA
functions, results in the following problem with 'tgamma' on Cygwin
(gcc-3.4.4-3):

=============================================================
/*
  gcc --std=c99 test_tgamma.c -lm && ./a.out
*/
#include <math.h>
#include <stdio.h>

#define N_MAX 34
#undef M_PI
#define M_PI 3.14159265358979323846

int main()
{
  float c[N_MAX+1];
  float xs, ts;
  float diff;
  int i;

  c[0] = 1.;
  for (i=1; i<=N_MAX; i++)
    c[i] = (2*i-1)*c[i-1]*0.5;

  for (i=1; i<=N_MAX; i++)
    {
      xs = i + 0.5f;  /* argument to the gamma function */
      ts = c[i] * sqrtf(M_PI);
      diff = fabsf(tgammaf(xs)-ts)/ts;
      if (diff > 1e-6)
        printf("Arg: %g, Exact: %12.8g, tgamma: %12.8g, diff: %12.8g\n",
              xs, ts, tgammaf(xs), diff);
    }
  return 0;
}
=============================================================

$ ./a.exe
Segmentation fault (core dumped)



Cheers,

   Angelo.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]