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

Just GaussianNoise adding part perl script emitter

parent 7f650ca3
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;
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.
#//
#//
#//
#// \n
$printed = 0;
$init_code_printed = 0;
1;
sub partType {
return GaussianNoise;
}
# Print Epics communication structure into a header file
# Current part number is passed as first argument
sub printHeaderStruct {
my ($i) = @_;
}
# Print Epics variable definitions
# Current part number is passed as first argument
sub printEpics {
my ($i) = @_;
}
# Print variable declarations int front-end file
# Current part number is passed as first argument
sub printFrontEndVars {
my ($i) = @_;
print ::OUT "static double \L$::xpartName[$i];\n";
if ($printed) { return; }
print ::OUT << "END";
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);
}
END
$printed = 1;
}
# Check inputs are connected
sub checkInputConnect {
my ($i) = @_;
return "";
}
# Figure out part input code
# Argument 1 is the part number
# Argument 2 is the input number
# Returns calculated input code
sub fromExp {
my ($i, $j) = @_;
my $from = $::partInNum[$i][$j];
return "\L$::xpartName[$from]";
}
# Return front end initialization code
# Argument 1 is the part number
# Returns calculated code string
sub frontEndInitCode {
my ($i) = @_;
if ($init_code_printed) { return ""; }
my $calcExp = "\L$::xpartName[$i] = 0;\n";
$init_code_printed = 1;
return $calcExp;
}
# Return front end code
# Argument 1 is the part number
# Returns calculated code string
sub frontEndCode {
my ($i) = @_;
my $calcExp = "// GaussiaNoise\n";
$calcExp .= "\L$::xpartName[$i] = gaussianRandomDouble(" . . ", " . . ");\n";
}
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