help-gsl
[Top][All Lists]
Advanced

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

Re: [Help-gsl] segmentation error while using gsl_rng_alloc(gsl_rng_mt19


From: Ralph Silva
Subject: Re: [Help-gsl] segmentation error while using gsl_rng_alloc(gsl_rng_mt19937)
Date: Wed, 17 Oct 2007 11:03:00 -0300

Hi Xavier,

I do not know C++ very well but I compiled your program (see below) using
Cygwin  and g++ with

g++ -W -Wall -o test test.cpp -I/usr/include -L/usr/lib -lgsl -lm

and it worked fine. It also worked fine on Debian Etch Gnu/Linux 64bit with
g++.

Please, check where your library is installed and if you can compiled any
other program which make uses of GSL. It is always a good idea to use "-W
-Wall" for all warnings and error messages.
I hope that helps you.

Best,
Ralph.


#include <stdlib.h>
#include <ctime>
#include <iostream>
#include <time.h>
#include <gsl/gsl_randist.h>
#include <gsl/gsl_rng.h>

using std::cout;
using std::endl;

int main(void) {
 gsl_rng *r = r;

 r = gsl_rng_alloc(gsl_rng_mt19937);

 gsl_rng_set(r, time(NULL));

 double sigma = 1;

 cout << "Loi de Gauss avec sigma= " << sigma << endl;
 for(int i = 0; i < 20; i++)
   cout << i << " : " << gsl_ran_gaussian(r, sigma) << endl;
 gsl_rng_free(r);

 return 0;
 }


On 10/16/07, Xavier Faure-Miller <address@hidden> wrote:
>
>
> Hi everybody
>
> I use Dev-C++ and have installed GSL with a DevPak.
> I have copied the headers and libraries and made links with Dev-C++.
>
> I would like to generate random numbers (gaussian law)
>
> I use this code:
> ------------------------------------------
> #include <stdlib.h>
> #include <ctime>
> #include <iostream>
> #include <time.h>
> #include <gsl/gsl_randist.h>
> #include <gsl/gsl_rng.h>
>
> using std::cout;
> using std::endl;
>
> int main(int argc, char *argv[]) {
>   gsl_rng *r = r;
>
>   r = gsl_rng_alloc(gsl_rng_mt19937);
>
>   gsl_rng_set(r, time(NULL));
>
>   double sigma = 1;
>
>   cout << "Loi de Gauss avec sigma= " << sigma << endl;
>   for(int i = 0; i < 20; i++)
>     cout << i << " : " << gsl_ran_gaussian(r, sigma) << endl;
>   gsl_rng_free(r);
> ------------------------------------------
>
> The code seams to compile correctly but when I execute the *.exe, I got a
> segmentation error.
> I have searched where the program stops and it seams that the error
> appears
> while executing
>
> r = gsl_rng_alloc(gsl_rng_mt19937);
>
> Do you know how to solve my mysterioux problem?
>
> Thank you very much
>
> xavier
>
>
>
>
> _______________________________________________
> Help-gsl mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-gsl
>


reply via email to

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