aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2012-10-10 16:16:07 +0200
committerThomas White <taw@physics.org>2012-10-10 16:16:07 +0200
commitd9884e5588b563b2c92a2ad0fec17303972e4f8c (patch)
tree9cc9bd81e600f6dee7f64bbbedea7e2ec2eb17e7
parent9b7696c48970b09d5852ea7515f362688afcfcb7 (diff)
const-ify the integer matrix library
-rw-r--r--libcrystfel/src/integer_matrix.c19
-rw-r--r--libcrystfel/src/integer_matrix.h15
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 */