diff options
author | Thomas White <taw@physics.org> | 2019-08-28 13:29:48 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2019-08-28 13:29:48 +0200 |
commit | da1de864442781c2bb993fc15a5c9dca18940e38 (patch) | |
tree | 3f6845529ad5000c516d25853fd28979d9d08af9 /libcrystfel/src/rational.c | |
parent | 71e7acb7668073b8f37565aa59bfd67d3b4cd166 (diff) |
Avoid converting IntegerMatrix to RationalMatrix
Diffstat (limited to 'libcrystfel/src/rational.c')
-rw-r--r-- | libcrystfel/src/rational.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libcrystfel/src/rational.c b/libcrystfel/src/rational.c index ce286d7a..f8d3cb68 100644 --- a/libcrystfel/src/rational.c +++ b/libcrystfel/src/rational.c @@ -553,6 +553,29 @@ void rtnl_mtx_mtxmult(const RationalMatrix *A, const RationalMatrix *B, } +void rtnl_mtx_intmatmult(const RationalMatrix *A, const IntegerMatrix *B, + RationalMatrix *ans) +{ + int i, j; + + assert(ans->rows == A->rows); + + for ( i=0; i<ans->rows; i++ ) { + for ( j=0; j<ans->cols; j++ ) { + int k; + Rational sum = rtnl_zero(); + for ( k=0; k<A->rows; k++ ) { + Rational add; + add = rtnl_mul(rtnl_mtx_get(A, i, k), + rtnl(intmat_get(B, k, j), 1)); + sum = rtnl_add(sum, add); + } + rtnl_mtx_set(ans, i, j, sum); + } + } +} + + /* Given a "P-matrix" (see ITA chapter 5.1), calculate the fractional * coordinates of point "vec" in the original axes, given its fractional * coordinates in the transformed axes. |