help-gsl
[Top][All Lists]
Advanced

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

Re: [Help-gsl] Turn off range checking in GSL


From: Patrick Alken
Subject: Re: [Help-gsl] Turn off range checking in GSL
Date: Thu, 10 Apr 2014 08:57:36 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0

Range checking needs to be turned off when compiling the GSL library (see section 8.3.2 of the manual)

On 04/10/2014 06:17 AM, Khoa Tran wrote:
Hello everyone,

I’m following up with an old topic here 
http://lists.gnu.org/archive/html/help-gsl/2010-07/msg00027.html. I tried the 
suggestion their in or either:
#define GSL_RANGE_CHECK 0
or
#define GSL_RANGE_CHECK_OFF

Neither of these options would disable the range checking feature. Would any of 
us have any success at this? I’m using clang/llvm on a MAC OS 10.9.

The test case is below:

#include <stdlib.h> // Contain size_t, exit()...
#include <stdio.h> // Standard I/O
#include <gsl/gsl_errno.h> // Error handler
#include <math.h> // Native C math functions
#include <gsl/gsl_math.h>  // GSL basic math fucntions
#define GSL_RANGE_CHECK 0
//#define GSL_RANGE_CHECK_OFF // Turn off range checking for arrays
#include <gsl/gsl_check_range.h>
#include <gsl/gsl_block.h> // Allocating blocks
#include <gsl/gsl_vector.h> // Allocating vectors and more
#include <gsl/gsl_matrix.h> // Allocating matrices and more

int main(void)
{
    int i;
gsl_vector * v = gsl_vector_alloc(3);
     for (i = 0; i < 3; i++)
     {
      gsl_vector_set(v, i, 1.23 + i);
     }
printf ("length of vector = %d\n", (int)v->size);
printf ("length of stride = %d\n", (int)v->stride);
printf ("first element from data = %lf\n", * v->data);
printf ("address of block = %#x\n", v->block);
printf ("Owner flag of block = %d\n\n", v->owner);
for (i = 0; i < 4; i++) /* OUT OF RANGE ERROR */
{
printf(“v_%d = %g\n", i, gsl_vector_get(v, i));
}
    return 0;
}

My compilation commands are:
  gcc -Wall -I/usr/local/include -DHAVE_INLINE -c main.c
  gcc -L/usr/local/lib main.o -lgsl -lgslcblas -lm -o main

Best regards!
Khoa




reply via email to

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