s-news
[Top] [All Lists]

c code & splus

To: s-news@lists.biostat.wustl.edu
Subject: c code & splus
From: Joe Cerniglia <cj5815@yahoo.com>
Date: Mon, 30 Oct 2006 12:04:33 -0800 (PST)
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=1rB25WsQTSKjBT+WrnlBy2zr7/zZxlqyNo0htbAEFMsfGFfDJX+71lENnWZbi+Wu9Vi1ZV8QlJWrodQ3O5B4DsOeUz0GP5KGga7mHACRksCeLuY9iB9mtevXQPx0lsgRoIlsY/USeEP6FFWrf8F24NRGuFHgr7cqXpllTePeZt4= ;
All,

I  have a question about using c and splus.


To compile my c code I am using cygwin gcc. 

gcc -c mh2.c
gcc -shared -o mh2.dll mh2.o

#
# splus code

mh2 <- function(m,start){
out <- numeric(m)
out[1] <- start
.C("mh2",
    m=as.integer(m), norms=as.double(rnorm(m)),
    unifs=as.double(runif(m)), out=as.double(out),
    cand=as.double(numeric(m)),
accept=as.double(numeric(m)))
}


#
# I GET THE FOLLOWING ERRORS IN SPLUS
dll.load("C:\\temp\\mh2.dll")  # S-PLUS/

> dll.load("C:\\temp\\mh2.dll")
[1] -2

dyn.open("C:\\temp\\mh2.dll")  # S-PLUS/
> dyn.open("C:\\temp\\mh2.dll")
Warning messages:
  "C:\temp\mh2.dll" can't be opened as a DLL; check
how it was loaded in: dyn.open("C:\\temp\\mh2.dll")



temp <- mh2(3000, 3)
plot(density(temp$out))1


Thanks in advance.

Joe



 
__________________________________________________________________________________________
Check out the New Yahoo! Mail - Fire up a more powerful email and get things 
done faster. 
(http://advision.webevents.yahoo.com/mailbeta) 


<Prev in Thread] Current Thread [Next in Thread>