Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
0902c43c
Commit
0902c43c
authored
Aug 13, 2019
by
Matthieu Schaller
Browse files
Options
Downloads
Plain Diff
Merge branch 'randomspacing_debug' into 'master'
Update testRandomSpacing See merge request
!886
parents
4f738eae
e3c27064
No related branches found
No related tags found
1 merge request
!886
Update testRandomSpacing
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/swift.h
+1
-0
1 addition, 0 deletions
src/swift.h
tests/testRandomSpacing.c
+22
-6
22 additions, 6 deletions
tests/testRandomSpacing.c
with
23 additions
and
6 deletions
src/swift.h
+
1
−
0
View file @
0902c43c
...
...
@@ -55,6 +55,7 @@
#include
"map.h"
#include
"memuse.h"
#include
"mesh_gravity.h"
#include
"minmax.h"
#include
"multipole.h"
#include
"outputlist.h"
#include
"parallel_io.h"
...
...
...
...
This diff is collapsed.
Click to expand it.
tests/testRandomSpacing.c
+
22
−
6
View file @
0902c43c
...
...
@@ -75,6 +75,7 @@ int main(int argc, char* argv[]) {
const
double
r
=
random_unit_interval
(
id
,
ti_current
,
random_number_star_formation
);
/* Count the number of random numbers below the boundaries */
if
(
r
<
boundary
[
0
])
count
[
0
]
+=
1
;
if
(
r
<
boundary
[
1
])
count
[
1
]
+=
1
;
if
(
r
<
boundary
[
2
])
count
[
2
]
+=
1
;
...
...
@@ -83,6 +84,7 @@ int main(int argc, char* argv[]) {
if
(
r
<
boundary
[
5
])
count
[
5
]
+=
1
;
}
/* Print counted number of random numbers below the boundaries */
message
(
"Categories | %6.0e %6.0e %6.0e %6.0e %6.0e %6.0e"
,
boundary
[
0
],
boundary
[
1
],
boundary
[
2
],
boundary
[
3
],
boundary
[
4
],
boundary
[
5
]);
...
...
@@ -105,21 +107,34 @@ int main(int argc, char* argv[]) {
expected_result_int
[
4
]
=
(
int
)
expected_result
[
4
];
expected_result_int
[
5
]
=
(
int
)
expected_result
[
5
];
/* Print the expected numbers */
message
(
"expected | %6d %6d %6d %6d %6d %6d"
,
expected_result_int
[
0
],
expected_result_int
[
1
],
expected_result_int
[
2
],
expected_result_int
[
3
],
expected_result_int
[
4
],
expected_result_int
[
5
]);
int
std_expected_result
[
6
];
std_expected_result
[
0
]
=
(
int
)
max
(
sqrt
(
expected_result
[
0
]),
1
);
std_expected_result
[
1
]
=
(
int
)
max
(
sqrt
(
expected_result
[
1
]),
1
);
std_expected_result
[
2
]
=
(
int
)
max
(
sqrt
(
expected_result
[
2
]),
1
);
std_expected_result
[
3
]
=
(
int
)
max
(
sqrt
(
expected_result
[
3
]),
1
);
std_expected_result
[
4
]
=
(
int
)
max
(
sqrt
(
expected_result
[
4
]),
1
);
std_expected_result
[
5
]
=
(
int
)
max
(
sqrt
(
expected_result
[
5
]),
1
);
/* Calculate the allowed standard error deviation the maximum of:
* 1. the standard error of the expected number doing sqrt(N_expected)
* 2. The standard error of the counted number doing sqrt(N_count)
* 3. 1 to prevent low number statistics to crash for 1 while expected
* close to zero.
*
* 1 and 2 are for large numbers essentially the same but for small numbers
* it becomes imporatant (e.g. count=6 expected=.9, allowed 5+.9 so 6
* fails, but sqrt(6) ~ 2.5 so it should be fine) */
std_expected_result
[
0
]
=
(
int
)
max3
(
sqrt
(
expected_result
[
0
]),
1
,
sqrt
(
count
[
0
]));
std_expected_result
[
1
]
=
(
int
)
max3
(
sqrt
(
expected_result
[
1
]),
1
,
sqrt
(
count
[
1
]));
std_expected_result
[
2
]
=
(
int
)
max3
(
sqrt
(
expected_result
[
2
]),
1
,
sqrt
(
count
[
2
]));
std_expected_result
[
3
]
=
(
int
)
max3
(
sqrt
(
expected_result
[
3
]),
1
,
sqrt
(
count
[
3
]));
std_expected_result
[
4
]
=
(
int
)
max3
(
sqrt
(
expected_result
[
4
]),
1
,
sqrt
(
count
[
4
]));
std_expected_result
[
5
]
=
(
int
)
max3
(
sqrt
(
expected_result
[
5
]),
1
,
sqrt
(
count
[
5
]));
/* We want 5 sigma (can be changed if necessary) */
const
int
numb_sigma
=
5
;
/* Print the differences and the 5 sigma differences */
message
(
"Difference | %6d %6d %6d %6d %6d %6d"
,
abs
(
expected_result_int
[
0
]
-
count
[
0
]),
abs
(
expected_result_int
[
1
]
-
count
[
1
]),
...
...
@@ -136,6 +151,7 @@ int main(int argc, char* argv[]) {
numb_sigma
*
std_expected_result
[
4
],
numb_sigma
*
std_expected_result
[
5
]);
/* Fail if it is not within numb_sigma (5) of the expected difference. */
if
(
count
[
0
]
>
expected_result_int
[
0
]
+
numb_sigma
*
std_expected_result
[
0
]
||
count
[
0
]
<
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment