aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/rational.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcrystfel/src/rational.c')
-rw-r--r--libcrystfel/src/rational.c16
1 files changed, 16 insertions, 0 deletions
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; i<m->rows*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<rows; i++ ) {
+ rtnl_mtx_set(m, i, i, rtnl(1,1));
+ }
return m;
}