vendredi 14 juillet 2017

gsl_rng_uniform(rr) causing segmentation fault

I'm using a random number generator to create an array of random numbers. The values in the array that the pointer *rand_vec points to is then used in other parts of the code. This however leads to a segmentation fault error. The included files in the header file are:

#include <complex>
#include <vector>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <iostream>
#include <gsl/gsl_rng.h>

The relevant part of the file is:

#include "random.h"

using namespace std;
extern const gsl_rng_type * TT;
extern gsl_rng * rr;

double ranVector[10001];

void randnums(int rand_dim, double *rand_vec){
    for (int i = 0; i < rand_dim; ++i){
        rand_vec[i] = gsl_rng_uniform (rr);
    }
}

ranVector is the array where the random numbers are stored and called from. Thanks




Aucun commentaire:

Enregistrer un commentaire