From 68061d0e3c42f61fa7664e0f0996cade13057391 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 5 Mar 2019 14:16:26 +0100 Subject: Add rtnl_mtx_identity() --- libcrystfel/src/rational.c | 16 ++++++++++++++++ libcrystfel/src/rational.h | 1 + 2 files changed, 17 insertions(+) (limited to 'libcrystfel') diff --git a/libcrystfel/src/rational.c b/libcrystfel/src/rational.c index 0f2bcaee..58178559 100644 --- a/libcrystfel/src/rational.c +++ b/libcrystfel/src/rational.c @@ -292,6 +292,7 @@ struct _rationalmatrix RationalMatrix *rtnl_mtx_new(unsigned int rows, unsigned int cols) { RationalMatrix *m; + int i; m = malloc(sizeof(RationalMatrix)); if ( m == NULL ) return NULL; @@ -305,6 +306,21 @@ RationalMatrix *rtnl_mtx_new(unsigned int rows, unsigned int cols) m->rows = rows; m->cols = cols; + for ( i=0; irows*m->cols; i++ ) { + m->v[i] = rtnl_zero(); + } + + return m; +} + + +RationalMatrix *rtnl_mtx_identity(int rows) +{ + int i; + RationalMatrix *m = rtnl_mtx_new(rows, rows); + for ( i=0; i