From ecfe23ca70540e2f8ee6efb600c7b577d95f236f Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 9 Aug 2013 17:52:36 +0200 Subject: Improve show_matrix_eqn() --- libcrystfel/src/integration.c | 2 +- libcrystfel/src/utils.c | 21 ++++++++++++++------- libcrystfel/src/utils.h | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/integration.c b/libcrystfel/src/integration.c index 0b82d9e5..2816784f 100644 --- a/libcrystfel/src/integration.c +++ b/libcrystfel/src/integration.c @@ -411,7 +411,7 @@ static void fit_bg(struct intcontext *ic, struct peak_box *bx) } if ( bx->verbose ) { - show_matrix_eqn(bx->bgm, v, 3); + show_matrix_eqn(bx->bgm, v); } /* SVD is massive overkill here */ diff --git a/libcrystfel/src/utils.c b/libcrystfel/src/utils.c index 697c773f..6c731a83 100644 --- a/libcrystfel/src/utils.c +++ b/libcrystfel/src/utils.c @@ -57,22 +57,29 @@ * show_matrix_eqn: * @M: A matrix * @v: A vector - * @r: The number of elements in @v and the side length of @M. * * Displays a matrix equation of the form @M.a = @v. - * - * @M must be square. **/ -void show_matrix_eqn(gsl_matrix *M, gsl_vector *v, int r) +void show_matrix_eqn(gsl_matrix *M, gsl_vector *v) { int i, j; - for ( i=0; isize1 != v->size ) { + ERROR("Matrix and vector sizes don't agree.\n"); + return; + } + + for ( i=0; isize1; i++ ) { STATUS("[ "); - for ( j=0; jsize2; j++ ) { STATUS("%+9.3e ", gsl_matrix_get(M, i, j)); } - STATUS("][ a%2i ] = [ %+9.3e ]\n", i, gsl_vector_get(v, i)); + if ( i < M->size2 ) { + STATUS("][ a%2i ] = [ %+9.3e ]\n", i, + gsl_vector_get(v, i)); + } else { + STATUS("] = [ +%9.3e ]\n", gsl_vector_get(v, i)); + } } } diff --git a/libcrystfel/src/utils.h b/libcrystfel/src/utils.h index a206ccfd..f4477717 100644 --- a/libcrystfel/src/utils.h +++ b/libcrystfel/src/utils.h @@ -96,7 +96,7 @@ extern struct rvec quat_rot(struct rvec q, struct quaternion z); /* --------------------------- Useful functions ----------------------------- */ -extern void show_matrix_eqn(gsl_matrix *M, gsl_vector *v, int r); +extern void show_matrix_eqn(gsl_matrix *M, gsl_vector *v); extern void show_matrix(gsl_matrix *M); extern size_t notrail(char *s); extern void chomp(char *s); -- cgit v1.2.3