Error in gsl.lsp ?

Started by hds1, July 05, 2017, 04:43:53 AM

Previous topic - Next topic

hds1

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.



(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:

-----

(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

rrq

#1
Quote#(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.

Lutz

#2
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.

hds1

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



(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.