aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/cell.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-03-09 11:37:34 +0100
committerThomas White <taw@physics.org>2019-03-11 16:49:37 +0100
commit252f4073f0041027b5e9e6773fe892ffe465ed23 (patch)
tree5143d2b86c6ef0f7ea93c93149ffad7f015e71d3 /libcrystfel/src/cell.c
parente94501d025e8d6b4f4e446004e80a1badfbba30f (diff)
Single point of truth for matrix memory layout
Diffstat (limited to 'libcrystfel/src/cell.c')
-rw-r--r--libcrystfel/src/cell.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/libcrystfel/src/cell.c b/libcrystfel/src/cell.c
index 32e45856..130a24b1 100644
--- a/libcrystfel/src/cell.c
+++ b/libcrystfel/src/cell.c
@@ -910,6 +910,7 @@ UnitCell *cell_transform_rational(UnitCell *cell, RationalMatrix *m)
UnitCell *out;
gsl_matrix *tm;
char ncen;
+ int i, j;
if ( m == NULL ) return NULL;
@@ -918,15 +919,12 @@ UnitCell *cell_transform_rational(UnitCell *cell, RationalMatrix *m)
return NULL;
}
- gsl_matrix_set(tm, 0, 0, rtnl_as_double(rtnl_mtx_get(m, 0, 0)));
- gsl_matrix_set(tm, 0, 1, rtnl_as_double(rtnl_mtx_get(m, 0, 1)));
- gsl_matrix_set(tm, 0, 2, rtnl_as_double(rtnl_mtx_get(m, 0, 2)));
- gsl_matrix_set(tm, 1, 0, rtnl_as_double(rtnl_mtx_get(m, 1, 0)));
- gsl_matrix_set(tm, 1, 1, rtnl_as_double(rtnl_mtx_get(m, 1, 1)));
- gsl_matrix_set(tm, 1, 2, rtnl_as_double(rtnl_mtx_get(m, 1, 2)));
- gsl_matrix_set(tm, 2, 0, rtnl_as_double(rtnl_mtx_get(m, 2, 0)));
- gsl_matrix_set(tm, 2, 1, rtnl_as_double(rtnl_mtx_get(m, 2, 1)));
- gsl_matrix_set(tm, 2, 2, rtnl_as_double(rtnl_mtx_get(m, 2, 2)));
+ for ( i=0; i<3; i++ ) {
+ for ( j=0; j<3; j++ ) {
+ gsl_matrix_set(tm, i, j,
+ rtnl_as_double(rtnl_mtx_get(m, i, j)));
+ }
+ }
out = cell_transform_gsl_direct(cell, tm);
gsl_matrix_free(tm);
@@ -983,6 +981,7 @@ UnitCell *cell_transform_rational_inverse(UnitCell *cell, RationalMatrix *m)
gsl_matrix *inv;
gsl_permutation *perm;
int s;
+ int i, j;
if ( m == NULL ) return NULL;
@@ -991,15 +990,12 @@ UnitCell *cell_transform_rational_inverse(UnitCell *cell, RationalMatrix *m)
return NULL;
}
- gsl_matrix_set(tm, 0, 0, rtnl_as_double(rtnl_mtx_get(m, 0, 0)));
- gsl_matrix_set(tm, 0, 1, rtnl_as_double(rtnl_mtx_get(m, 0, 1)));
- gsl_matrix_set(tm, 0, 2, rtnl_as_double(rtnl_mtx_get(m, 0, 2)));
- gsl_matrix_set(tm, 1, 0, rtnl_as_double(rtnl_mtx_get(m, 1, 0)));
- gsl_matrix_set(tm, 1, 1, rtnl_as_double(rtnl_mtx_get(m, 1, 1)));
- gsl_matrix_set(tm, 1, 2, rtnl_as_double(rtnl_mtx_get(m, 1, 2)));
- gsl_matrix_set(tm, 2, 0, rtnl_as_double(rtnl_mtx_get(m, 2, 0)));
- gsl_matrix_set(tm, 2, 1, rtnl_as_double(rtnl_mtx_get(m, 2, 1)));
- gsl_matrix_set(tm, 2, 2, rtnl_as_double(rtnl_mtx_get(m, 2, 2)));
+ for ( i=0; i<3; i++ ) {
+ for ( j=0; j<3; j++ ) {
+ gsl_matrix_set(tm, i, j,
+ rtnl_as_double(rtnl_mtx_get(m, i, j)));
+ }
+ }
perm = gsl_permutation_alloc(3);
if ( perm == NULL ) {