Error in gsl.lsp ?

For the Compleat Fan

Error in gsl.lsp ?

Postby hds1 » Wed Jul 05, 2017 11:43 am

The example for (gsl:CholeskyD) throws an error, newlisp v.10.7.1, libgsl.so.19 on XUBUNTU, gsl Ver 2.1:
All other examples are working.

Code: Select all
(gsl:CholeskyD '((4 2 -2) (2 10 2) (-2 2 5))))

ERR: mismatch in number of arguments
called from user function gsl:(CholeskyD '((4 2 -2) (2 10 2) (-2 2 5)))


Debug output:
Code: Select all
-----

(define (CholeskyD MAIN:A)
  (letn (MAIN:Ar (MAIN:get-matrix-from-list MAIN:A) MAIN:Aptr (MAIN:Ar 0) MAIN:m
    (MAIN:Ar 1) MAIN:n
    (MAIN:Ar 2) MAIN:result 0)
   (set 'MAIN:result (MAIN:gsl_linalg_cholesky_decomp MAIN:Aptr))
   (unless (zero? MAIN:result)
    (throw-error (MAIN:gsl_strerror MAIN:result)))
   (for (MAIN:i 0 (- MAIN:m 2))
    (for (MAIN:j (+ MAIN:i 1) (- MAIN:n 1))
     #(MAIN:gsl_matrix_set MAIN:Aptr MAIN:i MAIN:j 0 MAIN:.0)#))
   (set 'MAIN:result (MAIN:get-list-from-matrix MAIN:Ar))
   (MAIN:gsl_matrix_free MAIN:Aptr) MAIN:result))


[-> 6 gsl] s|tep n|ext c|ont q|uit > s

ERR: mismatch in number of arguments
called from user function gsl:(CholeskyD '((4 2 -2) (2 10 2) (-2 2 5)))

Process newlisp speicherzugriffsfehler
hds1
 
Posts: 27
Joined: Thu Mar 20, 2014 5:02 pm

Re: Error in gsl.lsp ?

Postby ralph.ronnquist » Wed Jul 05, 2017 10:41 pm

#(MAIN:gsl_matrix_set MAIN:Aptr MAIN:i MAIN:j 0 MAIN:.0)#))

Apparently the input "0.0" gets broken up into the two tokens "0" and ".0" with the latter being a symbol when the module is loaded. Odd.
ralph.ronnquist
 
Posts: 178
Joined: Mon Jun 02, 2014 1:40 am
Location: Melbourne, Australia

Re: Error in gsl.lsp ?

Postby Lutz » Wed Jul 05, 2017 11:19 pm

The string "Process newlisp speicherzugriffsfehler" in your output seems to indicate you are running a German localization of your operating system either change the 0.0 in gsl.lsp to 0,0 in the definition of gsl:CholeskyD or use a different locale or change to (float 0) to make the code work on all locales.

In a newLISP shell type (set-locale "") to find out what locale and decimal separator your are using.
Lutz
 
Posts: 5258
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: Error in gsl.lsp ?

Postby hds1 » Thu Jul 06, 2017 6:45 am

Thks for pointing to this one. It is indeed the locale setting. This works.

Code: Select all
(set-locale "en_US.utf8")
(load "/usr/local/share/newlisp/modules/gsl.lsp")
(trace (open "trace.txt" "write"))
(gsl:CholeskyD '((4 2 -2) (2 10 2) (-2 2 5)))
> ((2 0 0) (1 3 0) (-1 1 1.732050807568877))


Setting (set-locale "de_DE.utf8") results in the error.
hds1
 
Posts: 27
Joined: Thu Mar 20, 2014 5:02 pm


Return to Anything else we might add?

Who is online

Users browsing this forum: No registered users and 3 guests

cron