diff options
author | Thomas White <taw@physics.org> | 2013-08-09 17:52:36 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2013-08-12 10:38:19 +0200 |
commit | ecfe23ca70540e2f8ee6efb600c7b577d95f236f (patch) | |
tree | 28392b1652b7939c5c385a3d057a1f5d31f05024 /libcrystfel | |
parent | 9f48b5952cd894ae44cff93a2451963418cd15d3 (diff) |
Improve show_matrix_eqn()
Diffstat (limited to 'libcrystfel')
-rw-r--r-- | libcrystfel/src/integration.c | 2 | ||||
-rw-r--r-- | libcrystfel/src/utils.c | 21 | ||||
-rw-r--r-- | libcrystfel/src/utils.h | 2 |
3 files changed, 16 insertions, 9 deletions
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; i<r; i++ ) { + if ( M->size1 != v->size ) { + ERROR("Matrix and vector sizes don't agree.\n"); + return; + } + + for ( i=0; i<M->size1; i++ ) { STATUS("[ "); - for ( j=0; j<r; j++ ) { + for ( j=0; j<M->size2; 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); |