Dear All:
using Visual C++ 6.0 and S+ 6
I am having trouble figuring out how
to pass a 2d array to a C function, and
receiving a 2d array in return via
a function addup. The function addup
simply adds a matrix to itself (I obviously
know this can be done in S). Anyway, the
.dll compiles fine, and I made necessary
changes to header file. The .dll loads
in S, but nithing happens when I run the
S function. My C program is
probably wrong and perhaps I should be
sending this to a C list, but if anyone
could help me out, I'd greatly appreciate
it. Thank you very much.
void addup(double **x, long *n, long *k)
{
long i;
long j;
long nrow = *n;
long ncol = *k;
for(i=0;i<nrow;i++){
for(j=0;j<ncol;j++){
x[i][j] = x[i][j] * x[i][j];
}
}
}
matp <- function(x)
{
.C("addup",
x,
as.integer(nrow(x)),
as.integer(ncol(x)))
}
is.loaded("addup")
T
x <- as.matrix(rnorm(16),4,4)
storage.mode(x)
"double"
matp(x)
#nothing happens when I run function.
|