diff options
-rw-r--r-- | Makefile.am | 8 | ||||
-rw-r--r-- | tests/.gitignore | 1 | ||||
-rw-r--r-- | tests/linear_scale_check.c | 77 |
3 files changed, 84 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am index fe9c5cb3..b5708225 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,7 +12,8 @@ noinst_PROGRAMS = tests/list_check tests/integration_check \ tests/centering_check tests/transformation_check \ tests/cell_check tests/ring_check \ tests/prof2d_check tests/ambi_check \ - tests/prediction_gradient_check + tests/prediction_gradient_check \ + tests/linear_scale_check MERGE_CHECKS = tests/first_merge_check tests/second_merge_check \ tests/third_merge_check tests/fourth_merge_check @@ -25,7 +26,7 @@ TESTS = tests/list_check $(MERGE_CHECKS) $(PARTIAL_CHECKS) \ tests/integration_check \ tests/symmetry_check tests/centering_check tests/transformation_check \ tests/cell_check tests/ring_check tests/prof2d_check tests/ambi_check \ - tests/prediction_gradient_check + tests/prediction_gradient_check tests/linear_scale_check EXTRA_DIST += $(MERGE_CHECKS) $(PARTIAL_CHECKS) EXTRA_DIST += relnotes-0.6.3 announcement-0.6.3 @@ -122,6 +123,9 @@ tests_ring_check_SOURCES = tests/ring_check.c tests_cell_check_SOURCES = tests/cell_check.c +tests_linear_scale_check_SOURCES = tests/linear_scale_check.c src/scaling.c \ + src/merge.c + INCLUDES = -I$(top_srcdir)/libcrystfel/src -I$(top_srcdir)/data EXTRA_DIST += src/dw-hdfsee.h src/hdfsee.h src/render_hkl.h \ diff --git a/tests/.gitignore b/tests/.gitignore index 2afe2ec8..083e0eaa 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -13,3 +13,4 @@ ring_check prof2d_check ambi_check prediction_gradient_check +linear_scale_check diff --git a/tests/linear_scale_check.c b/tests/linear_scale_check.c new file mode 100644 index 00000000..21e21945 --- /dev/null +++ b/tests/linear_scale_check.c @@ -0,0 +1,77 @@ +/* + * linear_scale_check.c + * + * Check that linear scaling works + * + * Copyright © 2017 Deutsches Elektronen-Synchrotron DESY, + * a research centre of the Helmholtz Association. + * + * Authors: + * 2017 Thomas White <taw@physics.org> + * + * This file is part of CrystFEL. + * + * CrystFEL is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CrystFEL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CrystFEL. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + + +#include <stdlib.h> +#include <stdio.h> + +#include <reflist.h> + +#include "../src/scaling.h" + +int main(int argc, char *argv[]) +{ + int fail = 0; + int i; + gsl_rng *rng; + RefList *list1; + RefList *list2; + double G; + int r; + + list1 = reflist_new(); + list2 = reflist_new(); + + rng = gsl_rng_alloc(gsl_rng_mt19937); + + for ( i=0; i<50; i++ ) { + signed int h, k, l; + Reflection *refl1; + Reflection *refl2; + double intens; + h = gsl_rng_uniform_int(rng, 20) - gsl_rng_uniform_int(rng, 40); + k = gsl_rng_uniform_int(rng, 20) - gsl_rng_uniform_int(rng, 40); + l = gsl_rng_uniform_int(rng, 20) - gsl_rng_uniform_int(rng, 40); + refl1 = add_refl(list1, h, k, l); + refl2 = add_refl(list2, h, k, l); + intens = gsl_rng_uniform(rng); /* [0,1) */ + set_intensity(refl1, intens); + set_partiality(refl1, 1.0); + set_intensity(refl2, intens*2.0); + set_partiality(refl2, 1.0); + } + + r = linear_scale(list1, list2, &G); + STATUS("Scaling result: %i, G = %f\n", r, G); + + return fail; +} |