Hi, I'm sure this is a fairly simple problem, but I can't seem to find any
specific information in the documentation as to what is going on.  I am
writing a simple nearest neighbor program that takes in a set of of points
on a plane and returns the neighbors of those points, for a fixed number of
neighbors.  However, the returned integer array that is allocated in R
seems to occasionally return incorrect results.

I thought this would be because of GC, but I thought this was only for
SEXPs, or at least this is the impression I got from reading the
documentation.  So is there some obvious reason why my results seem to get
mangled by this call?  I have checked my program through several thousand
loops in C, and always get the same results, so I assume that this is
something I'm doing wrong in R.

Here is the code for my .C call.  I could post the C code if someone thinks
it's important, but I'm just changing the values of integer array specified
in R.

r.result <-
.C("evalPoly",
 as.double(c.polygonX),
 as.double(c.polygonY),
 as.double(c.neighborX),
 as.double(c.neighborY),
 integer(c.numberOfNeighbors*c.height*c.length),
 as.integer(c.polygonLength),
 as.integer(c.neighborLength),
 as.integer(c.numberOfNeighbors),
 as.integer(c.length),
 as.integer(c.height),
 DUP=TRUE
)[[5]]


Cheers,

Jonathan

        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to