diff options
author | Thomas White <taw@physics.org> | 2019-02-18 16:56:52 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2019-03-11 16:49:37 +0100 |
commit | a2f4977e0f8bd9becd50ab5a2ef903038273133c (patch) | |
tree | e754341a53aa89f821a5fc6a39bc6d34fb2a3806 /libcrystfel/src/rational.c | |
parent | 169e7c5677ffc9c296c0a7eeddb0b77e024a4a55 (diff) |
Implement parse_symmetry_operations
Diffstat (limited to 'libcrystfel/src/rational.c')
-rw-r--r-- | libcrystfel/src/rational.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libcrystfel/src/rational.c b/libcrystfel/src/rational.c index b6ca5dd4..5db83165 100644 --- a/libcrystfel/src/rational.c +++ b/libcrystfel/src/rational.c @@ -326,6 +326,31 @@ RationalMatrix *rtnl_mtx_from_intmat(const IntegerMatrix *m) } +IntegerMatrix *intmat_from_rtnl_mtx(const RationalMatrix *m) +{ + IntegerMatrix *n; + int i, j; + + n = intmat_new(m->rows, m->cols); + if ( n == NULL ) return NULL; + + for ( i=0; i<m->rows; i++ ) { + for ( j=0; j<m->cols; j++ ) { + Rational v = rtnl_mtx_get(m, i, j); + squish(&v); + if ( v.den != 1 ) { + ERROR("Rational matrix can't be converted to integers\n"); + intmat_free(n); + return NULL; + } + intmat_set(n, i, j, v.num); + } + } + + return n; +} + + void rtnl_mtx_free(RationalMatrix *mtx) { if ( mtx == NULL ) return; |