From d9884e5588b563b2c92a2ad0fec17303972e4f8c Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 10 Oct 2012 16:16:07 +0200 Subject: const-ify the integer matrix library --- libcrystfel/src/integer_matrix.c | 19 ++++++++++--------- libcrystfel/src/integer_matrix.h | 15 +++++++++------ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/libcrystfel/src/integer_matrix.c b/libcrystfel/src/integer_matrix.c index 477d16a6..f975fa8b 100644 --- a/libcrystfel/src/integer_matrix.c +++ b/libcrystfel/src/integer_matrix.c @@ -127,7 +127,7 @@ void intmat_set(IntegerMatrix *m, unsigned int i, unsigned int j, signed int v) * * Returns: the @i,@j element of @m. **/ -signed int intmat_get(IntegerMatrix *m, unsigned int i, unsigned int j) +signed int intmat_get(const IntegerMatrix *m, unsigned int i, unsigned int j) { assert(i < m->rows); assert(j < m->cols); @@ -147,7 +147,7 @@ signed int intmat_get(IntegerMatrix *m, unsigned int i, unsigned int j) * Returns: a newly allocated array of signed integers containing the answer, * or NULL on error. **/ -signed int *intmat_intvec_mult(IntegerMatrix *m, signed int *vec) +signed int *intmat_intvec_mult(const IntegerMatrix *m, const signed int *vec) { signed int *ans; unsigned int i; @@ -180,7 +180,8 @@ signed int *intmat_intvec_mult(IntegerMatrix *m, signed int *vec) * Returns: a newly allocated %IntegerMatrix containing the answer, or NULL on * error. **/ -IntegerMatrix *intmat_intmat_mult(IntegerMatrix *a, IntegerMatrix *b) +IntegerMatrix *intmat_intmat_mult(const IntegerMatrix *a, + const IntegerMatrix *b) { unsigned int i, j; IntegerMatrix *ans; @@ -208,7 +209,7 @@ IntegerMatrix *intmat_intmat_mult(IntegerMatrix *a, IntegerMatrix *b) } -static IntegerMatrix *delete_row_and_column(IntegerMatrix *m, +static IntegerMatrix *delete_row_and_column(const IntegerMatrix *m, unsigned int di, unsigned int dj) { IntegerMatrix *n; @@ -235,7 +236,7 @@ static IntegerMatrix *delete_row_and_column(IntegerMatrix *m, } -static signed int cofactor(IntegerMatrix *m, +static signed int cofactor(const IntegerMatrix *m, unsigned int i, unsigned int j) { IntegerMatrix *n; @@ -265,7 +266,7 @@ static signed int cofactor(IntegerMatrix *m, * * Returns: the determinant of @m. **/ -signed int intmat_det(IntegerMatrix *m) +signed int intmat_det(const IntegerMatrix *m) { unsigned int i, j; signed int det = 0; @@ -288,7 +289,7 @@ signed int intmat_det(IntegerMatrix *m) } -static IntegerMatrix *intmat_cofactors(IntegerMatrix *m) +static IntegerMatrix *intmat_cofactors(const IntegerMatrix *m) { IntegerMatrix *n; signed int i, j; @@ -316,7 +317,7 @@ static IntegerMatrix *intmat_cofactors(IntegerMatrix *m) * * Returns: the inverse of @m, or NULL on error. **/ -IntegerMatrix *intmat_inverse(IntegerMatrix *m) +IntegerMatrix *intmat_inverse(const IntegerMatrix *m) { IntegerMatrix *adjugateT; IntegerMatrix *inverse; @@ -361,7 +362,7 @@ IntegerMatrix *intmat_inverse(IntegerMatrix *m) * Prints @m to stderr. * */ -void intmat_print(IntegerMatrix *m) +void intmat_print(const IntegerMatrix *m) { unsigned int i, j; diff --git a/libcrystfel/src/integer_matrix.h b/libcrystfel/src/integer_matrix.h index 41780629..1c930720 100644 --- a/libcrystfel/src/integer_matrix.h +++ b/libcrystfel/src/integer_matrix.h @@ -48,21 +48,24 @@ extern void intmat_free(IntegerMatrix *m); /* Get/set */ extern void intmat_set(IntegerMatrix *m, unsigned int i, unsigned int j, signed int v); -extern signed int intmat_get(IntegerMatrix *m, unsigned int i, unsigned int j); +extern signed int intmat_get(const IntegerMatrix *m, + unsigned int i, unsigned int j); /* Matrix-(int)vector multiplication */ -extern signed int *intmat_intvec_mult(IntegerMatrix *m, signed int *vec); +extern signed int *intmat_intvec_mult(const IntegerMatrix *m, + const signed int *vec); /* Matrix-matrix multiplication */ -extern IntegerMatrix *intmat_intmat_mult(IntegerMatrix *a, IntegerMatrix *b); +extern IntegerMatrix *intmat_intmat_mult(const IntegerMatrix *a, + const IntegerMatrix *b); /* Inverse */ -extern IntegerMatrix *intmat_inverse(IntegerMatrix *m); +extern IntegerMatrix *intmat_inverse(const IntegerMatrix *m); /* Determinant */ -extern signed int intmat_det(IntegerMatrix *m); +extern signed int intmat_det(const IntegerMatrix *m); /* Diagnostics */ -extern void intmat_print(IntegerMatrix *m); +extern void intmat_print(const IntegerMatrix *m); #endif /* INTEGER_MATRIX_H */ -- cgit v1.2.3