[Rd] bug or correct behaviour ?

Alex Nu notulei at yahoo.com
Fri Jun 11 02:29:08 CEST 2004


 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



More information about the R-devel mailing list