aboutsummaryrefslogtreecommitdiff
path: root/tests/transformation_check.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-03-06 11:40:37 +0100
committerThomas White <taw@physics.org>2019-03-11 16:49:37 +0100
commit4f11a9f8530178cfb510f11c7bc4b1829bbd0be4 (patch)
treece4e620e54773e0f17fb653ccfe21f0490e3e373 /tests/transformation_check.c
parent68061d0e3c42f61fa7664e0f0996cade13057391 (diff)
Keep track of the "un-centering" matrix, as well as the "centering"
This makes it easy to reverse the transformation, if required, which it is when comparing centered cells.
Diffstat (limited to 'tests/transformation_check.c')
-rw-r--r--tests/transformation_check.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/tests/transformation_check.c b/tests/transformation_check.c
index c5dad16c..06521061 100644
--- a/tests/transformation_check.c
+++ b/tests/transformation_check.c
@@ -224,25 +224,50 @@ static int check_transformation(UnitCell *cell, IntegerMatrix *tfn,
static int check_uncentering(UnitCell *cell)
{
UnitCell *ct;
- IntegerMatrix *tr;
+ IntegerMatrix *C;
+ RationalMatrix *Ci;
+ UnitCell *cback;
+ double a[9], b[9];
+ int i;
int fail = 0;
STATUS("-----------------------\n");
STATUS("----> Before transformation:\n");
- cell_print(cell);
+ cell_print_full(cell);
- ct = uncenter_cell(cell, &tr);
+ ct = uncenter_cell(cell, &C, &Ci);
if ( ct == NULL ) return 1;
STATUS("----> The primitive unit cell:\n");
cell_print(ct);
STATUS("----> The matrix to put the centering back:\n");
- intmat_print(tr);
+ intmat_print(C);
+
+ STATUS("----> The recovered centered cell:\n");
+ cback = cell_transform_intmat(ct, C);
+ cell_print(cback);
+
+ cell_get_cartesian(cell, &a[0], &a[1], &a[2],
+ &a[3], &a[4], &a[5],
+ &a[6], &a[7], &a[8]);
+ cell_get_cartesian(cback, &b[0], &b[1], &b[2],
+ &b[3], &b[4], &b[5],
+ &b[6], &b[7], &b[8]);
+ for ( i=0; i<9; i++ ) {
+ if ( fabs(a[i] - b[i]) > 1e-12 ) {
+ fail = 1;
+ }
+ }
+
+ if ( fail ) {
+ ERROR("Original cell not recovered after back transformation\n");
+ }
- fail = check_same_reflections(cell, ct);
+ fail += check_same_reflections(cell, ct);
cell_free(ct);
+ cell_free(cback);
return fail;
}