SCM

SCM Repository

[matrix] Diff of /pkg/R/dsyMatrix.R
ViewVC logotype

Diff of /pkg/R/dsyMatrix.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1200, Mon Jan 23 16:01:20 2006 UTC revision 1201, Mon Jan 23 16:04:12 2006 UTC
# Line 23  Line 23 
23        function(from) .Call("dsyMatrix_as_dspMatrix", from, PACKAGE = "Matrix"))        function(from) .Call("dsyMatrix_as_dspMatrix", from, PACKAGE = "Matrix"))
24    
25  setAs("dsyMatrix", "dsTMatrix",  setAs("dsyMatrix", "dsTMatrix",
26        function(from) {        function(from) { # 'dsT': only store upper *or* lower
27            ## This is not very efficient (FIXME)            ## working via "matrix" : not very efficient  (FIXME)
28            ij <- which(as(from,"matrix") != 0, arr.ind = TRUE)            ij <- which((m <- as(from,"matrix")) != 0, arr.ind = TRUE)
29            new("dsTMatrix", i = ij[,1], j = ij[,2],            uplo <- from@uplo
30              ij <- ij[if(uplo == "U") ij[,1] <= ij[,2] else ij[,1] >= ij[,2] ,
31                       , drop = FALSE]
32              new("dsTMatrix", i = ij[,1] - 1:1, j = ij[,2] - 1:1,
33                  x = as.vector(m[ij]), uplo = uplo,
34                Dim = from@Dim, Dimnames = from@Dimnames)                Dim = from@Dim, Dimnames = from@Dimnames)
35        })        })
36    
37  setAs("dsyMatrix", "dsCMatrix",  setAs("dsyMatrix", "dsCMatrix",
38        function(from) callGeneric(as(from, "dsTMatrix")))        function(from) as(as(from, "dsTMatrix"), "dsCMatrix"))
39    
40    
41  ## Note: Just *because* we have an explicit  dtr -> dge coercion,  ## Note: Just *because* we have an explicit  dtr -> dge coercion,
# Line 95  Line 100 
100  setIs("dsyMatrix", "dpoMatrix",  setIs("dsyMatrix", "dpoMatrix",
101        test = function(obj)        test = function(obj)
102            "try-error" != class(try(.Call("dpoMatrix_chol", obj, PACKAGE = "Matrix"), silent=TRUE)),            "try-error" != class(try(.Call("dpoMatrix_chol", obj, PACKAGE = "Matrix"), silent=TRUE)),
103        ## MM: The following copying is necessary        replace = function(obj, value) { ## copy all slots (is needed)
       ## -- but shouldn't it be the default in such a case ??  
       replace = function(obj, value) ## copy all slots  
104        for(n in slotNames(obj)) slot(obj, n) <- slot(value, n)        for(n in slotNames(obj)) slot(obj, n) <- slot(value, n)
105        )            obj
106          })
107    
108  ## Now that we have "chol", we can define  "determinant" methods,  ## Now that we have "chol", we can define  "determinant" methods,
109  ## exactly like in ./dsCMatrix.R  ## exactly like in ./dsCMatrix.R

Legend:
Removed from v.1200  
changed lines
  Added in v.1201

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge