From notulei at yahoo.com  Fri Jun 11 02:29:08 2004
From: notulei at yahoo.com (Alex Nu)
Date: Fri Jun 11 02:29:14 2004
Subject: [Rd] bug or correct behaviour ?
Message-ID: <20040611002908.42114.qmail@web60109.mail.yahoo.com>


 This is the general outline of my code::
 
main(argc,argv){
   ...
   Rf_initEmbeddedR(argc,argv);
   ...
   Test_tryEval("source(test.r)");
   ...
}
############# 
# test.r
#############
...
dyn.load("toload.so")

tmp <-matrix(data=1,nrow=narray*2,ncol=nclust)

.Call("Init",tmp,...)
while(...) {
   criteria <-feval(tmp)
   if (criteria < criteria.min) 
        tmp.last <- tmp
   else  
       tmp <- tmp.last
   ...
   .Call("replace",tmp,...)
}
####################################


 When I try to recover tmp 

      tmp <- tmp.last
 
 I got the modified value of tmp.
 It means that tmp.last is modified
 when I modified tmp in the C funciont replace.
 
 The program seems to work fine if I change 
 to this::
            
  tmp.last <- tmp*1.0
  
  tmp <- tmp.last*1.0


 Any comments ?

 Alex


[Rd] bug or correct behaviour ?
Alex Nu