Alexander Burger <a...@software-lab.de> writes:

Hi Alex, 

> On Sun, Aug 12, 2012 at 08:19:41AM +0200, Alexander Burger wrote:

>> I would recommend in general to call (load "@lib/math.l") before any
>> floating point math, which sets the scale to 6 by default (unless it is
>> set to another value beforehand).

ok

> And, one more point: 'sqrt' expects a double, so you must pass a cons
> pair with the scale. In total, this should work (I didn't try, though):
>
>    (load "@lib/math.l")

done

>    (native "libR.so" "sqrt" 1.0 (16.0 . 1.0))

this works, thanks. 

,---------------------------------------------
| : (native "libR.so" "sqrt" 1.0 (16.0 . 1.0))
| -> 4
| : (native "libR.so" "sqrt" 1.0 (4.0 . 1.0))
| -> 2
`---------------------------------------------

> This will probably return 4000000 (4.0 as a scaled fixpoint number). To
> get more readable results, try
>
>    (round (native "libR.so" "sqrt" 1.0 (16.0 . 1.0)))

.. it looks good even without that. 


As a non-C programmer I look at the sources of R and wonder: 

1. are .h files (optional) interfaces to .c files, and if they exist, all
  I would need to define the native calls?

2. there are many functions in R that look like this:

,--------------------------------
| SEXP Invtrans(SEXP pG, SEXP x);
`--------------------------------

taking two lists, returning one list?

3. what about the many functions of R written in R itself, e.g.

,---------------------------------------------------------------
| mean.default <- function(x, trim = 0, na.rm = FALSE, ...){}
`---------------------------------------------------------------

There is a system of generic functions a bit similar to the CLOS system
(dispatching on all arguments). Can these functions be called via
'native'?

4. I guess for operators like '+' (1 + 2) there must be a
   function call like this somewhere +(1,2) that must be used by 'native'? 


-- 
cheers,
Thorsten

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to