help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] Comparing GSL Vector Elements with Double Precision Value


From: John Gehman
Subject: Re: [Help-gsl] Comparing GSL Vector Elements with Double Precision Values
Date: Sun, 26 Aug 2007 07:46:10 +1000

Hello Matt,

I didn't think gsl_vectors could be indexed like usual dynamically allocated vectors, i.e. by [index]. You need gsl_vector_get( gsl_vector, index). But I might have guessed that the errors would have more to do with that than the operators. Insofar as your code goes (I guess there's nested loops over i and j which aren't shown), all vector values are zero by using gsl_vector_calloc. Unless you do some kind of conversion of your data into gsl vectors, you'll also want to use gsl_vector_set for to set individual elements.

Cheers,
john



On 26/08/2007, at 1:38 AM, Matthew Boulton wrote:

Hello. I'm having difficult making comparisons between the elements in my GSL vectors and some double precision values in my programmes. I've produced a test programme below which illustrates the problem I am having:

#include <stdio.h>

#include <gsl/gsl_vector.h>

gsl_vector *sub_ref;
gsl_vector *sub_image;

int main()

{

 int i,j;
 int sub_width = 1536;
 int sub_height = 1536;
 int width = 10000;

 double PIX_MIN = 100.0, SATURATION = 59000.0;

 sub_ref = gsl_vector_calloc( sub_width * sub_height );
 sub_image = gsl_vector_calloc( sub_width * sub_height );

if ( sub_image[ i + width * j ] < PIX_MIN || sub_ref[ i + width * j ] < PIX_MIN )
 {
     printf("IF 1 executed\n");

 }
if (sub_image[ i + width * j ] >= SATURATION || sub_ref[ i + width * j ] >= SATURATION )
 {
     printf("IF 2 executed\n");

 }

 return 0;

}

The GSL vectors are being declared as double precision, yet I am getting the following errors:

PIX_MIN_test.c: In function 'main':
PIX_MIN_test.c:22: error: invalid operands to binary <
PIX_MIN_test.c:22: error: invalid operands to binary <
PIX_MIN_test.c:30: error: invalid operands to binary >=
PIX_MIN_test.c:30: error: invalid operands to binary >=

Can anyone advise me on what I'm doing wrong?

Kind Regards,

Matt

--
Matthew Boulton
Level 4 Physics and Astronomy
Collingwood College

address@hidden



_______________________________________________
Help-gsl mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/help-gsl


---------------------------------------------------------

Dr John Gehman (address@hidden)
Research Fellow; Separovic Lab
School of Chemistry
University of Melbourne (Australia)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]