diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/iprtest.c | 5 | ||||
-rw-r--r-- | src/refine.c | 11 | ||||
-rw-r--r-- | src/utils.c | 19 | ||||
-rw-r--r-- | src/utils.h | 2 |
4 files changed, 31 insertions, 6 deletions
diff --git a/src/iprtest.c b/src/iprtest.c index 1fd96d9..e24d7ed 100644 --- a/src/iprtest.c +++ b/src/iprtest.c @@ -110,7 +110,7 @@ int main(int argc, char *argv[]) { ctx->image = malloc(sizeof(ImageRecord)); ctx->image->image = NULL; - ctx->image->tilt = 0.0; + ctx->image->tilt = 45.0; ctx->image->omega = 0.0; ctx->image->slop = 0.0; ctx->image->fmode = FORMULATION_PIXELSIZE; @@ -141,8 +141,9 @@ int main(int argc, char *argv[]) { window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "IPR Test"); - gtk_window_set_default_size(GTK_WINDOW(window), 640, 640); + gtk_widget_set_size_request(GTK_WIDGET(window), 640, 640); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(main_window_closed), ctx); + gtk_window_set_resizable(GTK_WINDOW(window), FALSE); drawing = gtk_drawing_area_new(); gtk_container_add(GTK_CONTAINER(window), drawing); diff --git a/src/refine.c b/src/refine.c index f173e99..6bd2225 100644 --- a/src/refine.c +++ b/src/refine.c @@ -3,7 +3,7 @@ * * Refine the reconstruction * - * (c) 2007 Thomas White <taw27@cam.ac.uk> + * (c) 2007-2008 Thomas White <taw27@cam.ac.uk> * * dtr - Diffraction Tomography Reconstruction * @@ -61,6 +61,7 @@ ImageFeature *refine_fit_image(Basis *cell, ImageRecord *image) { gsl_permutation *perm; int s; + double det; gsl_matrix_set_zero(M); gsl_vector_set_zero(p); @@ -107,7 +108,7 @@ ImageFeature *refine_fit_image(Basis *cell, ImageRecord *image) { val = gsl_vector_get(p, 0); val += xy * h; gsl_vector_set(p, 0, val); val = gsl_vector_get(p, 1); val += xy * k; gsl_vector_set(p, 1, val); val = gsl_vector_get(p, 2); val += xy * l; gsl_vector_set(p, 2, val); - + gsl_matrix_get(M, 2, 2); /* Elements of "M" */ val = gsl_matrix_get(M, 0, 0); val += h * h; gsl_matrix_set(M, 0, 0, val); val = gsl_matrix_get(M, 0, 1); val += k * h; gsl_matrix_set(M, 0, 1, val); @@ -125,7 +126,7 @@ ImageFeature *refine_fit_image(Basis *cell, ImageRecord *image) { } - if ( !ns ) { + if ( ns == 0 ) { printf("RF: No partners found\n"); gsl_matrix_free(M); gsl_vector_free(p); @@ -133,8 +134,12 @@ ImageFeature *refine_fit_image(Basis *cell, ImageRecord *image) { } /* Do the fitting */ + //gsl_matrix_set(M, 2, 2, 1.0); + matrix_vector_show(M, p); perm = gsl_permutation_alloc(M->size1); gsl_linalg_LU_decomp(M, perm, &s); + det = gsl_linalg_LU_det(M, s); + printf("Determinant of M = %f\n", det); q = gsl_vector_alloc(3); /* This is the "answer" */ gsl_vector_set_zero(q); diff --git a/src/utils.c b/src/utils.c index 457beb3..8fc3cf6 100644 --- a/src/utils.c +++ b/src/utils.c @@ -3,13 +3,14 @@ * * Utility stuff * - * (c) 2007 Thomas White <taw27@cam.ac.uk> + * (c) 2007-2008 Thomas White <taw27@cam.ac.uk> * * dtr - Diffraction Tomography Reconstruction * */ #include <math.h> +#include <gsl/gsl_matrix.h> #include "utils.h" #include "string.h" @@ -94,3 +95,19 @@ void chomp(char *s) { } } + +void matrix_vector_show(const gsl_matrix *m, const gsl_vector *v) { + + int i, j; + + for ( i=0; i<m->size1; i++ ) { + printf("[ "); + for ( j=0; j<m->size2; j++ ) { + printf("%12.8f ", gsl_matrix_get(m, i, j)); + } + printf(" ] [ q%i ] = [ %15.2f ]\n", i+1, gsl_vector_get(v, i)); + } + +} + + diff --git a/src/utils.h b/src/utils.h index 1abd04b..47e283a 100644 --- a/src/utils.h +++ b/src/utils.h @@ -18,6 +18,7 @@ #include <stdlib.h> #include <math.h> +#include <gsl/gsl_matrix.h> extern unsigned int biggest(signed int a, signed int b); extern unsigned int smallest(signed int a, signed int b); @@ -29,6 +30,7 @@ extern double lambda(double voltage); extern double distance3d(double x1, double y1, double z1, double x2, double y2, double z2); extern size_t skipspace(const char *s); extern void chomp(char *s); +extern void matrix_vector_show(const gsl_matrix *m, const gsl_vector *v); #define rad2deg(a) ((a)*180/M_PI) #define deg2rad(a) ((a)*M_PI/180) |