Re: Call native wrapper function with double argument

2020-11-24 Thread Alexander Burger
Hi Thorsten, > Luckily, If I manage to wrap one such C function, I can reuse that > understanding for many others Yes, and don't worry to ask. 'native' is a complex issue (I also need to look into the reference each time), so others may benefit from the records too. ☺/ A!ex --

Re: Call native wrapper function with double argument

2020-11-24 Thread Thorsten Jolitz
Hi Alex, thanks for your tips ... and patience! My lack of experience with C, Pointers and low level programming clearly shows in my questions, and most real world libraries of 'native' wrappers I find don't really implement complex C signatures, so I have to experiment myself. I'll try to digest

Re: Call native wrapper function with double argument

2020-11-23 Thread Alexander Burger
On Mon, Nov 23, 2020 at 06:17:46PM +0100, Alexander Burger wrote: > Something like '("Dx" (24 . 1.0) '(1.0 1.0 2.0 3.0)) could make sense, if the > C > argument is "double dx[3];". oops (24 . 1.0) is of course not returning "double dx[3];", but a single double. Try (24 1.0 1.0 1.0) or better

Re: Call native wrapper function with double argument

2020-11-23 Thread Alexander Burger
Hi Thorsten, > libblas.so is on my machine, the C function "idamax_" is found,which is > actually a C wrapper for Fortran Code. > In the Fortran docs, the parameters are described exactly, see below. Hmm, the signature of the C function would be more helpful, as we want to call it, and it should

Re: Call native wrapper function with double argument

2020-11-23 Thread Thorsten Jolitz
Hi Alex, one more 'native' question, this time a bit more complicated: libblas.so is on my machine, the C function "idamax_" is found,which is actually a C wrapper for Fortran Code. In the Fortran docs, the parameters are described exactly, see below. Since the Parameters of the C function are

Re: Call native wrapper function with double argument

2020-11-17 Thread Thorsten Jolitz
Hi Alex, the wrappers with primitive arguments do work now when defined like this with transient symbols: (de pgamma ("X" "Y" "Z" "I" "J") (native `*LibRmath "pgamma" 1.0 (cons "X" 1.0) (cons "Y" 1.0) (cons "Z" 1.0) "I" "J" ) ) ## double› pgamma(double, double, double, int, int); With

Re: Call native wrapper function with double argument

2020-11-15 Thread Alexander Burger
Hi Thorsten, hmm, this is not correct: > (de pnorm_both ("X" "Y" "Z" "I" "J") > (! native `*LibRmath "pnorm_both" 1.0 (cons "X" 1.0) '("Y" (1.0 . 4)) > '("Z" (1.0 . 4)) "I" "J" ) ) "Z" is an argument to the function, so it is bound to some evaluated value. But this value is ignored,

Re: Call native wrapper function with double argument

2020-11-15 Thread Thorsten Jolitz
Hi Alex, I actually do use a namespace, and there is not much going on wrt to assignments: >From line 8 on there are only some 100+ mostly trivial wrapper functions, see PS. I first thought it might have something to do with Picolisp Linebreaks "delta J", but I have seen the same issue now with an

Re: Call native wrapper function with double argument

2020-11-15 Thread Alexander Burger
On Sun, Nov 15, 2020 at 06:44:20PM +0100, Alexander Burger wrote: > So somewhere 'J' is bound to "J". > ... > Right, so it is a binding issue. Think hard what values are exactly bound to > which variables at runtime. I forgot to add: You can perhaps see what is happening, by inspecting a

Re: Call native wrapper function with double argument

2020-11-15 Thread Alexander Burger
Hi Thorsten, > But with my real wrapper functions, where ever I use J, as first or second > arg, its interpreted as a transient symbol So somewhere 'J' is bound to "J". > But when I rename J to H in my real wrapper function, the problem is gone: Right, so it is a binding issue. Think hard

Re: Call native wrapper function with double argument

2020-11-15 Thread Thorsten Jolitz
Hi Alex, this is strange indeed. I checked on Bash/Archlinux as well, same problem as Win Term / WSL2, so this is not about WSL or so. I can like you define a dummy wrapper, and debug it, and it looks fine: : (de foo (I J) (! native NIL NIL 1.0 I J)) -> foo : (foo 2 3) (native NIL NIL 1 I J) ! J

Re: Call native wrapper function with double argument

2020-11-15 Thread Alexander Burger
Hi Thorsten, > (de pwilcox (X Y Z I J) > ... > : (rmath~pwilcox 2.7 6.20 5.4 1 3) > (native "libRmath.so" "pwilcox" 1 (cons X 1) (cons Y 1) (cons Z 1) I "J") > ... > ! J > -> NIL > Why is that second Integer argument interpreted as transient symbol, and > then NIL although the actual arg = 3?

Re: Call native wrapper function with double argument

2020-11-14 Thread Thorsten Jolitz
Hi Alex, one more question: (de pwilcox (X Y Z I J) (! native `*LibRmath "pwilcox" 1.0 (cons X 1.0) (cons Y 1.0) (cons Z 1.0) I J ) ) ## double pwilcox(double, double, double, int, int); : (rmath~pwilcox 2.7 6.20 5.4 1 3) (native "libRmath.so" "pwilcox" 1 (cons X 1) (cons Y 1) (cons Z 1) I

Re: Call native wrapper function with double argument

2020-11-13 Thread Thorsten Jolitz
Hi Alex, yes that works with (cons X 1.0), I knew it was a trivial problem. Thanks! Cheers Thorsten Am Fr., 13. Nov. 2020 um 08:00 Uhr schrieb Alexander Burger < a...@software-lab.de>: > Hi Thorsten, > > welcome back! :) > > > I'm playing around with the native function again (after a long long

Re: Call native wrapper function with double argument

2020-11-12 Thread Alexander Burger
Hi Thorsten, welcome back! :) > I'm playing around with the native function again (after a long long time > ;-) and somehow I don't manage to call a native wrapper with double arg. > > Using rmath from R, random value from poisson distribution:^ > ## double› rpois(double); > ... > This works

Call native wrapper function with double argument

2020-11-12 Thread Thorsten Jolitz
Hello List, Hi Alex, I'm playing around with the native function again (after a long long time ;-) and somehow I don't manage to call a native wrapper with double arg. Using rmath from R, random value from poisson distribution:^ ## double› rpois(double); This works : (native "libRmath.so"