diff --git a/mcstas-comps/examples/ILL/ILL_H22_D1B/ILL_H22_D1B.instr b/mcstas-comps/examples/ILL/ILL_H22_D1B/ILL_H22_D1B.instr index c512acc704..b9b902fc0c 100644 --- a/mcstas-comps/examples/ILL/ILL_H22_D1B/ILL_H22_D1B.instr +++ b/mcstas-comps/examples/ILL/ILL_H22_D1B/ILL_H22_D1B.instr @@ -33,7 +33,7 @@ * obtained by scanning the temperature. A complete thermal variation of the * diffraction patterns (1.5 - 300 K) can be achieved in few hours (3-5h). * -* %Example: lambda=2.52 Detector: D1B_BananaTheta_I=5097.25 +* %Example: lambda=2.52 Detector: D1B_BananaTheta_I=4400 * * %Parameters: * lambda: [AA] mean incident wavelength. diff --git a/mcstas-comps/samples/PowderN.comp b/mcstas-comps/samples/PowderN.comp index 893dae362b..3087a7443b 100644 --- a/mcstas-comps/samples/PowderN.comp +++ b/mcstas-comps/samples/PowderN.comp @@ -268,14 +268,24 @@ struct line_info_struct // PN_list_compare ***************************************************************** - int PN_list_compare (void const *a, void const *b) - { - struct line_data const *pa = a; - struct line_data const *pb = b; - double s = pa->q - pb->q; +int PN_list_compare(const void *a, const void *b) +{ + const struct line_data *pa = a; + const struct line_data *pb = b; + + /* Sort by q */ + if (pa->q < pb->q) return -1; + if (pa->q > pb->q) return 1; + + /* In case of tie, sort by F2 also */ + if (pa->F2 < pb->F2) return -1; + if (pa->F2 > pb->F2) return 1; - if (!s) return 0; - else return (s < 0 ? -1 : 1); + /* In case of tie, sort by j also */ + if (pa->j < pb->j) return -1; + if (pa->j > pb->j) return 1; + + return 0; } /* PN_list_compare */ #ifndef CIF2HKL @@ -1140,7 +1150,7 @@ TRACE l_1 = v*(t3 - t2 + t1 - t0); /* Length to exit */ - + pmul *= Nq*l_full*my_s_n *exp(-(line_info.my_a_v/v+my_s)*(l+l_1)) /(1-(p_inc+p_transmit)); diff --git a/mcstas-comps/union/Powder_process.comp b/mcstas-comps/union/Powder_process.comp index f6acba56df..e6dafce79e 100755 --- a/mcstas-comps/union/Powder_process.comp +++ b/mcstas-comps/union/Powder_process.comp @@ -138,14 +138,24 @@ SHARE // PN_list_compare ***************************************************************** - int PN_list_compare_union (void const *a, void const *b) - { - struct line_data_union const *pa = a; - struct line_data_union const *pb = b; - double s = pa->q - pb->q; - - if (!s) return 0; - else return (s < 0 ? -1 : 1); +int PN_list_compare_union(const void *a, const void *b) +{ + const struct line_data_union *pa = a; + const struct line_data_union *pb = b; + + /* Sort by q */ + if (pa->q < pb->q) return -1; + if (pa->q > pb->q) return 1; + + /* In case of tie, sort by F2 also */ + if (pa->F2 < pb->F2) return -1; + if (pa->F2 > pb->F2) return 1; + + /* In case of tie, sort by j also */ + if (pa->j < pb->j) return -1; + if (pa->j > pb->j) return 1; + + return 0; } /* PN_list_compare */ int read_line_data_union(char *SC_file, struct line_info_struct_union *info) diff --git a/mcxtrace-comps/samples/PowderN.comp b/mcxtrace-comps/samples/PowderN.comp index bb5e2a1697..c980b30e99 100644 --- a/mcxtrace-comps/samples/PowderN.comp +++ b/mcxtrace-comps/samples/PowderN.comp @@ -261,14 +261,24 @@ SHARE // used for qsort, to sort reflections // input: a,b: two 'line_data' reflection pointers. // output: -1,0,1 for ab - int PN_list_compare (void const *a, void const *b) - { - struct line_data const *pa = a; - struct line_data const *pb = b; - double s = pa->q - pb->q; +int PN_list_compare(const void *a, const void *b) +{ + const struct line_data *pa = a; + const struct line_data *pb = b; + + /* Sort by q */ + if (pa->q < pb->q) return -1; + if (pa->q > pb->q) return 1; + + /* In case of tie, sort by F2 also */ + if (pa->F2 < pb->F2) return -1; + if (pa->F2 > pb->F2) return 1; - if (!s) return 0; - else return (s < 0 ? -1 : 1); + /* In case of tie, sort by j also */ + if (pa->j < pb->j) return -1; + if (pa->j > pb->j) return 1; + + return 0; } /* PN_list_compare */ #ifndef CIF2HKL