Skip to content
Snippets Groups Projects
Commit 79bcc8f5 authored by Ezekiel Dohmen's avatar Ezekiel Dohmen
Browse files

Adding perl logic for GaussianNoiseGenerator

parent a573a51d
No related branches found
No related tags found
4 merge requests!439RCG 5.0 release fro deb 10,!366Merge with branch 4.2,!365Merge branch 'branch-4.2' into master-branch-4.2-merge,!354Adding gaussian noise part
package CDS::GaussianNoise;
package CDS::GaussianNoiseGenerator;
use Exporter;
@ISA = ('Exporter');
#// \page GaussianNoise Noise.pm
#// Documentation for GaussianNoise.pm
#// This GaussianNoise part generates gaussian random noise around
#// the given mean with the given standard deviation.
#// \page GaussianNoiseGenerator Noise.pm
#// Documentation for GaussianNoiseGenerator.pm
#// This GaussianNoiseGenerator part generates gaussian
#// random noise with 0 mean and 1 standard deviation.
#//
#//
#//
......@@ -17,7 +17,7 @@ $init_code_printed = 0;
1;
sub partType {
return GaussianNoise;
return GaussianNoiseGenerator;
}
# Print Epics communication structure into a header file
......@@ -46,7 +46,7 @@ static inline double gaussianRandomDouble( void )
{
uint64_t gaussRandomUint;
ligo_get_random_bytes(&gaussRandomUint, sizeof(gaussRandomUint));
return qnorm5( ((double)gaussRandomUint/0xFFFFFFFFFFFFFFFF), 0 /*mean*/, 1/*standard deviation*/, 1, 0);
return qnorm5_s( ((double)gaussRandomUint/0xFFFFFFFFFFFFFFFF), 1, 0);
}
END
......@@ -87,6 +87,6 @@ sub frontEndInitCode {
# Returns calculated code string
sub frontEndCode {
my ($i) = @_;
my $calcExp = "// GaussiaNoise\n";
$calcExp .= "\L$::xpartName[$i] = gaussianRandomDouble(" . . ", " . . ");\n";
my $calcExp = "// GaussiaNoiseGenerator\n";
$calcExp .= "\L$::xpartName[$i] " . "= gaussianRandomDouble();\n";
}
#ifndef LIGO_RAMDOM_BYTES_H
#define LIGO_RAMDOM_BYTES_H
#ifdef __KERNEL__
#include <linux/random.h>
#define ligo_get_random_bytes get_random_bytes
static inline void ligo_get_random_bytes(void *buf, int nbytes)
{
return get_random_bytes(buf, nbytes);
}
#else
#include <sys/random.h>
static inline void ligo_get_random_bytes(void *buf, int nbytes)
{
getrandom(buf, nbytes, GRND_NONBLOCK);
//This can fail if the urandom source has not yet been initialized
return;
}
#endif
#endif //LIGO_RAMDOM_BYTES_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment