Hi:
    I have some problems when I use the function "solve" function in a loop. In 
the following code, I have a diagonal martix "ttt" whose  elements change in 
every iteration in a loop. I defined a "dpoMatrix"class  before the loop so I 
do not need to define this class every time in the loop. The reason is to save 
some computing time. The code is below. The inverse of the matrix "ttt"
 should change according to the change of "ttt" in the loop. However, the 
values in "sigma.dpo.solve", which is the inverse of "ttt" does not change.  
Can anybody figure out what is wrong with my code? Thanks a lot in advance!
 
 liu 
 ############################
 library(Matrix)
 ttt<-diag(1,2)
 sigma.dpo<-as(ttt, "dpoMatrix")
 for(i in 1:5)
   { ttt<-diag(i,2)
     [EMAIL PROTECTED]<-as.vector(ttt)
     sigma.dpo.solve<-solve(sigma.dpo)
     print("-------------")
     print(sigma.dpo)
     print(sigma.dpo.solve)
   }
 ##########################
 
 
        
---------------------------------

        [[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to