From 0b1db945a12c0e68491412baf322b761511eb016 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 21 Aug 2019 12:23:39 +0200 Subject: Tidy up comparison function definitions Especially, remove the last ltl/atl tolerance values. --- tests/cellcompare_check.c | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) (limited to 'tests/cellcompare_check.c') diff --git a/tests/cellcompare_check.c b/tests/cellcompare_check.c index f5787753..0c3709ba 100644 --- a/tests/cellcompare_check.c +++ b/tests/cellcompare_check.c @@ -126,7 +126,7 @@ static int check_ccpao(UnitCell *cell, UnitCell *cref, double *tols, b = " with compare_cell_parameters_and_orientation"; if ( compare_cell_parameters_and_orientation(cell, cref, - tols[0], tols[3]) != should_match ) + tols) != should_match ) { complain(cell, cref, a, b); return 1; @@ -145,8 +145,8 @@ static int check_cpcpao(UnitCell *cell, UnitCell *cref, double *tols, a = should_match ? "" : "NOT "; b = " with compare_permuted_cell_parameters_and_orientation"; - if ( compare_permuted_cell_parameters_and_orientation(cell, cref, - tols[0], tols[3], &m) != should_match ) + if ( compare_permuted_cell_parameters_and_orientation(cell, cref, tols, &m) + != should_match ) { complain(cell, cref, a, b); intmat_free(m); @@ -157,17 +157,46 @@ static int check_cpcpao(UnitCell *cell, UnitCell *cref, double *tols, } +static int check_cdcp(UnitCell *cell, UnitCell *cref, double *tols, + RationalMatrix *tr, int should_match) +{ + RationalMatrix *m = NULL; + const char *a; + const char *b; + + a = should_match ? "" : "NOT "; + b = " with compare_derivative_cell_parameters"; + + if ( compare_derivative_cell_parameters(cref, cell, tols, 1, &m) != should_match ) + { + complain(cell, cref, a, b); + STATUS("The transformation matrix to create the cell was:\n"); + rtnl_mtx_print(tr); + STATUS("Cell comparison says do this to the reference to " + "create the cell:\n"); + rtnl_mtx_print(m); + rtnl_mtx_free(m); + return 1; + } + rtnl_mtx_free(m); + return 0; +} + + static int check_crcp(UnitCell *cell, UnitCell *cref, double *tols, RationalMatrix *tr, int should_match) { RationalMatrix *m = NULL; const char *a; const char *b; + UnitCell *match; a = should_match ? "" : "NOT "; b = " with compare_reindexed_cell_parameters"; - if ( compare_reindexed_cell_parameters(cref, cell, tols, 1, &m) != should_match ) + match = compare_reindexed_cell_parameters(cell, cref, tols, &m); + + if ( (match != NULL) != should_match ) { complain(cell, cref, a, b); STATUS("The transformation matrix to create the cell was:\n"); @@ -250,6 +279,7 @@ int main(int argc, char *argv[]) if ( check_ccp(cell, cref, tols, 1) ) return 1; if ( check_ccpao(cell, cref, tols, 0) ) return 1; if ( check_cpcpao(cell, cref, tols, 0) ) return 1; + if ( check_cdcp(cell, cref, tols, NULL, 1) ) return 1; if ( check_crcp(cell, cref, tols, NULL, 1) ) return 1; cell_free(cell); @@ -267,6 +297,7 @@ int main(int argc, char *argv[]) if ( check_ccp(cell, cref, tols, intmat_is_identity(tr)) ) return 1; if ( check_ccpao(cell, cref, tols, intmat_is_identity(tr)) ) return 1; if ( check_cpcpao(cell, cref, tols, 1) ) return 1; + if ( check_cdcp(cell, cref, tols, NULL, 1) ) return 1; if ( check_crcp(cell, cref, tols, NULL, 1) ) return 1; cell_free(cell); @@ -290,6 +321,7 @@ int main(int argc, char *argv[]) if ( check_ccp(cell, cref, tols, intmat_is_identity(tr)) ) return 1; if ( check_ccpao(cell, cref, tols, 0) ) return 1; if ( check_cpcpao(cell, cref, tols, 0) ) return 1; + if ( check_cdcp(cell, cref, tols, NULL, 1) ) return 1; if ( check_crcp(cell, cref, tols, NULL, 1) ) return 1; cell_free(cell); @@ -318,7 +350,8 @@ int main(int argc, char *argv[]) if ( check_ccp(cell, cref, tols, rtnl_mtx_is_identity(tr)) ) return 1; if ( check_ccpao(cell, cref, tols, rtnl_mtx_is_identity(tr)) ) return 1; if ( check_cpcpao(cell, cref, tols, rtnl_mtx_is_perm(tr)) ) return 1; - if ( check_crcp(cell, cref, tols, tr, 1) ) return 1; + if ( check_cdcp(cell, cref, tols, tr, 1) ) return 1; + /* check_crcp: Sometimes yes, hard to tell */ cell_free(cell); rtnl_mtx_free(tr); @@ -348,7 +381,8 @@ int main(int argc, char *argv[]) if ( check_ccp(cell, cref, tols, rtnl_mtx_is_identity(tr)) ) return 1; if ( check_ccpao(cell, cref, tols, 0) ) return 1; if ( check_cpcpao(cell, cref, tols, 0) ) return 1; - if ( check_crcp(cell, cref, tols, tr, 1) ) return 1; + if ( check_cdcp(cell, cref, tols, tr, 1) ) return 1; + /* check_crcp: Sometimes yes, hard to tell */ cell_free(cell); rtnl_mtx_free(tr); -- cgit v1.2.3