From b65ff35322544fcb0ad7494987145e9c8aa75d5c Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 17 Oct 2014 17:19:55 +0200 Subject: Add intmat_identity() --- libcrystfel/src/integer_matrix.c | 31 +++++++++++++++++++++++++++++++ libcrystfel/src/integer_matrix.h | 1 + 2 files changed, 32 insertions(+) (limited to 'libcrystfel/src') diff --git a/libcrystfel/src/integer_matrix.c b/libcrystfel/src/integer_matrix.c index 018f0ca6..c31072b4 100644 --- a/libcrystfel/src/integer_matrix.c +++ b/libcrystfel/src/integer_matrix.c @@ -501,3 +501,34 @@ int intmat_equals(const IntegerMatrix *a, const IntegerMatrix *b) return 1; } + + +/** + * intmat_identity + * @size: The size of the (square) matrix + * + * Returns: an identity %IntegerMatrix with side length @size, or NULL on error. + * + */ +IntegerMatrix *intmat_identity(int size) +{ + IntegerMatrix *m; + int i, j; + + m = intmat_new(size, size); + if ( m == NULL ) return NULL; + + for ( i=0; i