Re: [Rd] NUMERIC_POINTER question

2005-09-14 Thread Witold Eryk Wolski
Thanks Roger, Simon, Reid, It's indeed trivial, if you stop to believe that S4 provides any type of type safety. However, having in mind all the arguments why S4, and that it was designed in order to incorporate type safety on both the R and C side I was not expecting that when trying for th

Re: [Rd] NUMERIC_POINTER question

2005-09-13 Thread Huntsinger, Reid
You have to coerce to numeric yourself if that's what you want. Eg in the R code, as.numeric(1:12) rather than 1:12. Or check the type first in C with TYPEOF before doing NUMERIC_POINTER or INTEGER_POINTER (the difference is that the two do different casts; they both point a fixed offset into the R

Re: [Rd] NUMERIC_POINTER question

2005-09-13 Thread Simon Urbanek
Eryk, On Sep 13, 2005, at 2:26 PM, nwew wrote: > printf("%f\n",NUMERIC_POINTER(mat)[1]); > [...] > However it prints > 0. > if [EMAIL PROTECTED] are integers ( [EMAIL PROTECTED]<-matrix(1:12,3,4) ). > > Can anyone explain it to me why? > I thought that NUMERIC_POINTER makes it clear that i ex

Re: [Rd] NUMERIC_POINTER question

2005-09-13 Thread Roger Bivand
On Tue, 13 Sep 2005, nwew wrote: > 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_POI