SCM

SCM Repository

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

Diff of /pkg/R/Rsparse.R

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

revision 1329, Fri Jul 21 06:47:06 2006 UTC revision 1332, Thu Jul 27 13:42:18 2006 UTC
# Line 10  Line 10 
10    
11  ##setAs("dgRMatrix", "matrix",  ##setAs("dgRMatrix", "matrix",
12  ##      function(from) .Call(csc_to_matrix, from))  ##      function(from) .Call(csc_to_matrix, from))
13    ## easy "cheap" alternative:
14    setAs("dgRMatrix", "matrix",
15          function(from) as(as(from, "dgTMatrix"), "matrix"))
16    
17  ##setAs("dgRMatrix", "dgeMatrix",  ##setAs("dgRMatrix", "dgeMatrix",
18  ##      function(from) .Call(csc_to_dgeMatrix, from))  ##      function(from) .Call(csc_to_dgeMatrix, from))
# Line 20  Line 23 
23  ##          .Call(matrix_to_csc, from)  ##          .Call(matrix_to_csc, from)
24  ##      })  ##      })
25    
26    
27  ##setMethod("diag", signature(x = "dgRMatrix"),  ##setMethod("diag", signature(x = "dgRMatrix"),
28  ##          function(x = 1, nrow, ncol = n) .Call(csc_getDiag, x))  ##          function(x = 1, nrow, ncol = n) .Call(csc_getDiag, x))
29    
30  setAs("dgRMatrix", "dgCMatrix",  setAs("dgRMatrix", "dgCMatrix",
31        function(from) as(as(from, "dgTMatrix"), "dgCMatrix"))        function(from) as(as(from, "dgTMatrix"), "dgCMatrix"))
32    
33    ## **VERY** cheap substitutes:  work via dgC and t(.)
34    .to.dgR <- function(from) {
35        m <- as(t(from), "dgCMatrix")
36        new("dgRMatrix", Dim = dim(from), Dimnames = .M.DN(from),
37            p = m@p, j = m@i, x = m@x)
38    }
39    
40    setAs("matrix",    "dgRMatrix", .to.dgR)
41    setAs("dgCMatrix", "dgRMatrix", .to.dgR)
42    setAs("dgTMatrix", "dgRMatrix", .to.dgR)
43    
44    
45    
46    ##setAs("dgRMatrix", "dgeMatrix",
47    ##      function(from) .Call(csc_to_dgeMatrix, from))
48    
49    ##setAs("matrix", "dgRMatrix",
50    ##      function(from) {
51    ##          storage.mode(from) <- "double"
52    ##          .Call(matrix_to_csc, from)
53    ##      })
54    
55    
56  ## try to define for "Matrix" -- once and for all -- but that fails -- why? __ FIXME __  ## try to define for "Matrix" -- once and for all -- but that fails -- why? __ FIXME __
57  ## setMethod("dim", signature(x = "dgRMatrix"),  ## setMethod("dim", signature(x = "dgRMatrix"),
58  ##           function(x) x@Dim, valueClass = "integer")  ##           function(x) x@Dim, valueClass = "integer")

Legend:
Removed from v.1329  
changed lines
  Added in v.1332

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