Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Math::GSL::SparseMatrix is broken if installed on latest 5.32.1.1 "Strawberry Perl PDL edition", whom to report this issue to?

by Anonymous Monk
on Nov 10, 2022 at 12:03 UTC ( [id://11148095]=note: print w/replies, xml ) Need Help??


in reply to Re: Math::GSL::SparseMatrix is broken if installed on latest 5.32.1.1 "Strawberry Perl PDL edition", whom to report this issue to?
in thread Math::GSL::SparseMatrix is broken if installed on latest 5.32.1.1 "Strawberry Perl PDL edition", whom to report this issue to?

Thanks, Rob, this was really bad choice, on my part, of example data, and I appreciate you pointed this out.

With real script, I'm observing smaller matrix population (non-zero elements count) after feeding 64-bit data in, than expected, when running with 5.32 PDL-SP (2.6 GSL), compared to correct count (population equals items fed in) running with 5.26 PDL-SP (2.3 GSL).

Then I tried to present exaggerated examples, and, yes, you are right, I messed operator precedence, and so result looks silly and not trustworthy.

There's still wrong output of "1 1" with:

die if gsl_spmatrix_set( $m, 1, 0, 1 ); say gsl_spmatrix_nnz( $m ); die if gsl_spmatrix_set( $m, 1 + (1 << 32), 0, 1 ); say gsl_spmatrix_nnz( $m );

or similar. I mean, my blunder doesn't cancel out Math::GSL (and perhaps GSL) issues.

Replies are listed 'Best First'.
Re^3: Math::GSL::SparseMatrix is broken if installed on latest 5.32.1.1 "Strawberry Perl PDL edition", whom to report this issue to?
by syphilis (Archbishop) on Nov 10, 2022 at 14:16 UTC
    I messed operator precedence, and so result looks silly and not trustworthy

    Oh, no worries - that happens. (I know ;-)
    For me, irrespective of the values assigned in the script, both gsl-2.6 and gsl-2.7.1 produce the same results.
    That would suggest that the problem lies with the recent versions of the gsl library.
    But, of course, the way I built Math-GSL-0.43 against gsl-2.7.1 (along with the test failures) doesn't inspire complete confidence in it ;-(

    Playing around with it a bit, I find there's something (very strangely) buggy for the index 1 + (1 << 32), with both gsl-2.6 and gsl-2.7.1.
    Have a fiddle with this, and you'll see what I mean:
    use strict; use warnings; use feature 'say'; use Alien::GSL; use Math::GSL; use Math::GSL::SparseMatrix ':all'; my $m = gsl_spmatrix_alloc( 1, 1 ); my $v; #$v = 3 + (1 << 32); # no problem with this value #$v = 2 + (1 << 32); # no problem with this value #$v = 0 + (1 << 32); # no problem with this value $v = 1 + (1 << 32); # blows up, but only if # gsl_spmatrix_get($m, $v, 0) # is called. die if gsl_spmatrix_set( $m, 1, 0, 1.5 ); say gsl_spmatrix_get($m, 1, 0); say gsl_spmatrix_nnz( $m ); die if gsl_spmatrix_set( $m, $v, 0, 1.75 ); say gsl_spmatrix_get($m, $v, 0); # comment out to avoid blow up # when $v is 1 + (1 << 32). # But still gives wrong result # (for that value only). say gsl_spmatrix_nnz( $m );
    The first thing to try is to run that as a C program and see if the same issue arises.
    If not, then it's an issue with Math::GSL.
    It's getting late over here ... something for tomorrow.

    Cheers,
    Rob
      ... 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

        Did you compile it from shell, created with portableshell.bat of Strawberry Perl 5.32.1-PDL? If I'm not using this shell, then gsl_spmatrix.exe complains it can't find libgsl-25__.dll, which would be in PATH created with portableshell.bat. I'm confused about this "25", does it mean anything? Should it be "26", i.e. is it "clean and correct" GSL 2.6 which ships with PDL-SP?

        Using "gsl-2.7.1 library provided by Alien", there's no such complaint. I can only add, that "v += 1;" is not special. If 1st setter sets at index 2, then "v += 2;" leads to "out of range". They both set the same element. If two setters set different values, and 1st getter gets value after that, then it retrieves value set by 2nd setter. 1st value was overwritten.

        I haven't reported yet, would it be better to write to both GSL and Math::GSL queues? (Math::GSL ignores whatever Alien::GSL has built) Or reporting to Math::GSL is enough, they'll see further?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11148095]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-29 10:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found