diff options
author | Thomas White <taw@physics.org> | 2016-10-19 12:02:45 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2016-10-19 12:02:45 +0200 |
commit | 22a20b5b3374a4c776c6efcbed738434cc1c9a6b (patch) | |
tree | ff790e9dada2ffab9359d553797629305695c23b /libcrystfel | |
parent | 508df3a968c08bf262b059a6e0d6e8edefc7401e (diff) |
Add transform_cell_gsl()
Diffstat (limited to 'libcrystfel')
-rw-r--r-- | libcrystfel/src/cell-utils.c | 44 | ||||
-rw-r--r-- | libcrystfel/src/cell-utils.h | 3 |
2 files changed, 46 insertions, 1 deletions
diff --git a/libcrystfel/src/cell-utils.c b/libcrystfel/src/cell-utils.c index 69d4174a..74a6b905 100644 --- a/libcrystfel/src/cell-utils.c +++ b/libcrystfel/src/cell-utils.c @@ -38,7 +38,6 @@ #include <string.h> #include <gsl/gsl_matrix.h> #include <gsl/gsl_blas.h> -#include <gsl/gsl_linalg.h> #include <assert.h> #include "cell.h" @@ -1432,6 +1431,49 @@ void cell_fudge_gslcblas() } +UnitCell *transform_cell_gsl(UnitCell *in, gsl_matrix *m) +{ + gsl_matrix *c; + double asx, asy, asz; + double bsx, bsy, bsz; + double csx, csy, csz; + gsl_matrix *res; + UnitCell *out; + + cell_get_reciprocal(in, &asx, &asy, &asz, &bsx, &bsy, + &bsz, &csx, &csy, &csz); + + c = gsl_matrix_alloc(3, 3); + gsl_matrix_set(c, 0, 0, asx); + gsl_matrix_set(c, 0, 1, asy); + gsl_matrix_set(c, 0, 2, asz); + gsl_matrix_set(c, 1, 0, bsx); + gsl_matrix_set(c, 1, 1, bsy); + gsl_matrix_set(c, 1, 2, bsz); + gsl_matrix_set(c, 2, 0, csx); + gsl_matrix_set(c, 2, 1, csy); + gsl_matrix_set(c, 2, 2, csz); + + res = gsl_matrix_calloc(3, 3); + gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1.0, m, c, 0.0, res); + + out = cell_new_from_cell(in); + cell_set_reciprocal(out, gsl_matrix_get(res, 0, 0), + gsl_matrix_get(res, 0, 1), + gsl_matrix_get(res, 0, 2), + gsl_matrix_get(res, 1, 0), + gsl_matrix_get(res, 1, 1), + gsl_matrix_get(res, 1, 2), + gsl_matrix_get(res, 2, 0), + gsl_matrix_get(res, 2, 1), + gsl_matrix_get(res, 2, 2)); + + gsl_matrix_free(res); + gsl_matrix_free(c); + return out; +} + + /** * rotate_cell: * @in: A %UnitCell to rotate diff --git a/libcrystfel/src/cell-utils.h b/libcrystfel/src/cell-utils.h index 000c863a..efb4b25b 100644 --- a/libcrystfel/src/cell-utils.h +++ b/libcrystfel/src/cell-utils.h @@ -35,6 +35,8 @@ #include <config.h> #endif +#include <gsl/gsl_matrix.h> + #include "cell.h" #ifdef __cplusplus @@ -47,6 +49,7 @@ extern double resolution(UnitCell *cell, extern UnitCell *cell_rotate(UnitCell *in, struct quaternion quat); extern UnitCell *rotate_cell(UnitCell *in, double omega, double phi, double rot); +extern UnitCell *transform_cell_gsl(UnitCell *in, gsl_matrix *m); extern void cell_print(UnitCell *cell); |