bug-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gsl] bug in gsl_sf_choose ?


From: Patrick Alken
Subject: Re: [Bug-gsl] bug in gsl_sf_choose ?
Date: Tue, 2 Aug 2016 09:13:46 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0

Its happening when you case gsl_sf_choose() to (int). Try this instead:

int nchoosetwo_gsl = (int) round(gsl_sf_choose(n,2))

On 08/02/2016 06:34 AM, Eldon, Bjarki wrote:
Dear GSL,

I'm using GSL  version 1.16-5.1.3 on  openSUSE-13.2-Oss  on x86_64 arch.


the C code  below  returns a lot of 1s; is there a bug in gsl_sf_choose or am I 
doing something wrong?

best regards
bjarki


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_sf_elementary.h>
#include <gsl/gsl_sf_gamma.h>
#include <gsl/gsl_sf_exp.h>



int main()
{
   unsigned int n ;
   int nchoosetwo ;

   for( n = 2 ; n <= 102 ; n++){
     nchoosetwo = (int) ( ( (double)( n*(n-1)) )/2. ) ;

     printf( "%d:  %d\n", n, (nchoosetwo != (int)gsl_sf_choose( n,2)) ? 1 : 0 
); }

   return GSL_SUCCESS;

}







reply via email to

[Prev in Thread] Current Thread [Next in Thread]