https://doi.org/10.5201/ipol.2012.llm-ksvd
Raw File
Tip revision: c78cdcf65f9f2fd89008647de7d7776cb2454f08 authored by Software Heritage on 01 January 2011, 00:00:00 UTC
ipol: Deposit 1191 in collection ipol
Tip revision: c78cdcf
addnoise_function.cpp
#include "mt19937ar.h"
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <math.h>

void fiAddNoise(float *u, double *v, double std, long int randinit, unsigned size)
{
	mt_init_genrand((unsigned long int) time (NULL) + (unsigned long int) getpid()  + (unsigned long int) randinit);

    for (unsigned i = 0; i < size; i++)
    {
        double a = mt_genrand_res53();
        double b = mt_genrand_res53();
        double z = (double)(std) * sqrtl(-2.0 * log(a)) * cos(2.0 * M_PI * b);

        v[i] =  (double) u[i] + z;
    }
}

back to top