Skip to content
Snippets Groups Projects
Commit d52a08c1 authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

fix output formatting.

parent 316ea992
Branches
Tags
1 merge request!866New random_unit_interval implementation
...@@ -150,6 +150,9 @@ int main(int argc, char* argv[]) { ...@@ -150,6 +150,9 @@ int main(int argc, char* argv[]) {
const double r = const double r =
random_unit_interval(id, ti_current, random_number_star_formation); random_unit_interval(id, ti_current, random_number_star_formation);
if (r < 0.0 || r >= 1.0) {
error("Generated random vlaue %f is not in [0, 1).", r);
}
total += r; total += r;
total2 += r * r; total2 += r * r;
...@@ -163,6 +166,9 @@ int main(int argc, char* argv[]) { ...@@ -163,6 +166,9 @@ int main(int argc, char* argv[]) {
/* Calculate if there is a correlation between different ids */ /* Calculate if there is a correlation between different ids */
const double r_2ndid = random_unit_interval(idoffset, ti_current, const double r_2ndid = random_unit_interval(idoffset, ti_current,
random_number_star_formation); random_number_star_formation);
if (r_2ndid < 0.0 || r_2ndid >= 1.0) {
error("Generated random vlaue %f is not in [0, 1).", r_2ndid);
}
/* Pearson correlation for small different IDs */ /* Pearson correlation for small different IDs */
pearsonIDs += r * r_2ndid; pearsonIDs += r * r_2ndid;
...@@ -174,12 +180,21 @@ int main(int argc, char* argv[]) { ...@@ -174,12 +180,21 @@ int main(int argc, char* argv[]) {
const double r_sf = const double r_sf =
random_unit_interval(id, ti_current, random_number_stellar_feedback); random_unit_interval(id, ti_current, random_number_stellar_feedback);
if (r_sf < 0.0 || r_sf >= 1.0) {
error("Generated random vlaue %f is not in [0, 1).", r_sf);
}
const double r_se = random_unit_interval( const double r_se = random_unit_interval(
id, ti_current, random_number_stellar_enrichment); id, ti_current, random_number_stellar_enrichment);
if (r_se < 0.0 || r_se >= 1.0) {
error("Generated random vlaue %f is not in [0, 1).", r_se);
}
const double r_bh = const double r_bh =
random_unit_interval(id, ti_current, random_number_BH_feedback); random_unit_interval(id, ti_current, random_number_BH_feedback);
if (r_bh < 0.0 || r_bh >= 1.0) {
error("Generated random vlaue %f is not in [0, 1).", r_bh);
}
/* Calculate the correlation between the different processes */ /* Calculate the correlation between the different processes */
total_sf += r_sf; total_sf += r_sf;
...@@ -266,11 +281,11 @@ int main(int argc, char* argv[]) { ...@@ -266,11 +281,11 @@ int main(int argc, char* argv[]) {
1. / 12., 0.); 1. / 12., 0.);
message("ID part"); message("ID part");
message( message(
"Result: count%d mean=%f var=%f" "Result: count=%d mean=%f var=%f"
" correlation=%f", " correlation=%f",
count, meanID, varID, correlationID); count, meanID, varID, correlationID);
message( message(
"Expected: count%d mean=%f var=%f" "Expected: count=%d mean=%f var=%f"
" correlation=%f", " correlation=%f",
count, .5f, 1. / 12., 0.); count, .5f, 1. / 12., 0.);
message("Different physical processes:"); message("Different physical processes:");
...@@ -291,12 +306,12 @@ int main(int argc, char* argv[]) { ...@@ -291,12 +306,12 @@ int main(int argc, char* argv[]) {
" enrichement=%f black holes=%f", " enrichement=%f black holes=%f",
1. / 12., 1. / 12., 1 / 12., 1. / 12.); 1. / 12., 1. / 12., 1 / 12., 1. / 12.);
message( message(
"Correlation: stars-sf=%f stars-se=%f stars-bh=%f" "Correlation: stars-sf=%f stars-se=%f stars-bh=%f "
"sf-se=%f sf-bh=%f se-bh=%f", "sf-se=%f sf-bh=%f se-bh=%f",
corr_star_sf, corr_star_se, corr_star_bh, corr_sf_se, corr_sf_bh, corr_star_sf, corr_star_se, corr_star_bh, corr_sf_se, corr_sf_bh,
corr_se_bh); corr_se_bh);
message( message(
"Expected: stars-sf=%f stars-se=%f stars-bh=%f" "Expected: stars-sf=%f stars-se=%f stars-bh=%f "
"sf-se=%f sf-bh=%f se-bh=%f", "sf-se=%f sf-bh=%f se-bh=%f",
0., 0., 0., 0., 0., 0.); 0., 0., 0., 0., 0., 0.);
return 1; return 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment