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/src/utils.c | |
parent | 9f48b5952cd894ae44cff93a2451963418cd15d3 (diff) |
Improve show_matrix_eqn()
Diffstat (limited to 'libcrystfel/src/utils.c')
-rw-r--r-- | libcrystfel/src/utils.c | 21 |
1 files changed, 14 insertions, 7 deletions
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)); + } } } |