[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-gsl] segmentation error while using gsl_rng_alloc(gsl_rng_mt19937)
From: |
Xavier Faure-Miller |
Subject: |
[Help-gsl] segmentation error while using gsl_rng_alloc(gsl_rng_mt19937) |
Date: |
Tue, 16 Oct 2007 15:57:19 +0200 |
User-agent: |
Internet Messaging Program (IMP) 3.2.5 |
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] segmentation error while using gsl_rng_alloc(gsl_rng_mt19937),
Xavier Faure-Miller <=