... something for tomorrow.
It's apparently a problem with the gsl library:
/*
This file: gsl_spmatrix.c
Modify the following "-I..." and "-L..." arguments accordingly.
Using the gsl-2.6 library that ships with Strawberry Perl 5.32.1-PDL,
+build with:
gcc -o gsl_spmatrix.exe gsl_spmatrix.c -ID:/sp/_64/sp-5.32.1-PDL/c/inc
+lude -LD:/sp/_64/sp-5.32.1-PDL/c/lib -lgsl -lgslcblas -lm
Then execute gsl_spmatrix.exe
Using the gsl-2.7.1 library provided by Alien, build with:
gcc -o gsl_spmatrix.exe gsl_spmatrix.c -ID:/sp/_64/sp-5.32.1/perl/site
+/lib/auto/share/dist/Alien-GSL/include -LD:/sp/_64/sp-5.32.1/perl/sit
+e/lib/auto/share/dist/Alien-GSL/lib -lgsl -lgslcblas -lm
Then execute gsl_spmatrix.exe
*/
#include <stdio.h>
#include <stdlib.h>
#include <gsl/gsl_spmatrix.h>
int main(void) {
size_t v = 1;
v <<= 32;
v += 1;
printf("size of size_t is %d bytes\n", sizeof(size_t));
gsl_spmatrix *m = gsl_spmatrix_alloc(1,1);
gsl_spmatrix_set( m, 1, 0, 1.5 );
printf("1: got: %f\n", gsl_spmatrix_get( m, 1, 0));
printf("1: nnz: %d\n", gsl_spmatrix_nnz( m ));
gsl_spmatrix_set( m, v, 0, 1.75 );
if (v >= m->size1) printf("will be reported as 'out of range'\n");
printf("2: got: %f\n", gsl_spmatrix_get( m, v, 0 ));
printf("2: nnz: %d\n", gsl_spmatrix_nnz( m ));
return 0;
}
/*
As is, the built executable outputs (for both gsl-2.6 and gsl-2.7.1):
D:\C>gsl_spmatrix.exe
size of _size_t is 8 bytes
1: got: 1.500000
1: nnz: 1
will be reported as 'out of range'
gsl: getset_source.c:27: ERROR: first index out of range
Default GSL error handler invoked.
But if the line "v += 1;" is changed to "v += 2" or to "v += 3" or to
+"v += 0" then the output is:
D:\C>gsl_spmatrix.exe
size of _size_t is 8 bytes
1: got: 1.500000
1: nnz: 1
2: got: 1.750000
2: nnz: 2
*/
I haven't yet reached an understanding of the problem.
I think it should be reported to the gsl developers unless that has already been done.
Cheers, Rob |