From W.E.Wolski at newcastle.ac.uk  Tue Sep 13 20:26:18 2005
From: W.E.Wolski at newcastle.ac.uk (nwew)
Date: Tue, 13 Sep 2005 19:26:18 +0100
Subject: [Rd] NUMERIC_POINTER question
Message-ID: <43161F2B@webmail.ncl.ac.uk>

Dear R-developers,

Using .Call I pass a S4 class with e.g. the following class definition:

setClass("mmatrix",representation(
   data="matrix")
)

On the "C side" i do
mat = GET_SLOT(vs,install("data"));
and then:
printf("%f\n",NUMERIC_POINTER(mat)[1]);


The above print statement produces the correct output if 
xx<- new("mmatrix")
xx at data<-matrix(1:12+0.1,3,4). (data is double)

However it prints 
0.0000 
if xx at data are integers ( xx at data<-matrix(1:12,3,4) ).

Can anyone explain it to me why? 
I thought that NUMERIC_POINTER makes it clear that i expect datatype numeric.
(Why otherwise the distinction with INTEGER_POINTER)


cheers
Eryk



[Rd] NUMERIC_POINTER question
nwew