You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.0 KiB
C
44 lines
1.0 KiB
C
#include <stdlib.h>
|
|
#include <math.h>
|
|
#include "geostat.h"
|
|
|
|
|
|
/* GENERATION OF A GAUSSIAN WHITE NOISE VECTOR */
|
|
/*input: */
|
|
/* seed: seed */
|
|
/* n: number of components in the vector */
|
|
/*output: */
|
|
/* realization: structure defining the realization*/
|
|
|
|
void generate(long *seed, int n, struct realization_mod *realization)
|
|
{
|
|
int i;
|
|
long idum2 = 123456789,iy = 0;
|
|
long *iv;
|
|
int iset =0;
|
|
|
|
iv = (long *) malloc(NTAB * sizeof(long));
|
|
|
|
/*negative seed*/
|
|
if (*seed > 0.0)
|
|
*seed = -(*seed);
|
|
|
|
/*realization definition*/
|
|
(*realization).n = n;
|
|
(*realization).code = 0;
|
|
(*realization).vector = (double *) malloc(n * sizeof(double));
|
|
if ((*realization).vector == NULL) {
|
|
printf("No memory available in generate");
|
|
exit;
|
|
}
|
|
|
|
/*Gaussian white noise generation*/
|
|
for (i=0; i < n; i++)
|
|
(*realization).vector[i] = gasdev(seed,&idum2,&iy,iv,&iset);
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
|