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 1746, Mon Jan 29 16:04:38 2007 UTC revision 1747, Mon Jan 29 20:17:33 2007 UTC
# Line 7  Line 7 
7    
8  ### contains = "dMatrix"  ### contains = "dMatrix"
9    
10  setAs("dgRMatrix", "dgTMatrix",  setAs("RsparseMatrix", "TsparseMatrix",
11        function(from) .Call(compressed_to_dgTMatrix, from, FALSE))        function(from) .Call(compressed_to_TMatrix, from, FALSE))
12    
13    setAs("RsparseMatrix", "CsparseMatrix",
14          function(from) .Call(R_to_CMatrix, from))
15    
16  ### FIXME: Activate the following with "little" change in ../src/dgCMatrix.c  ##--- and all these are just "the essential low-level coercions" : ----------
 ### -----  similar to compressed_to_dgTMatrix above       ~~~~~~~~~~~~~~~~~~  
17    
 ##setAs("dgRMatrix", "matrix",  
 ##      function(from) .Call(csc_to_matrix, from))  
 ## easy "cheap" alternative:  
18  setAs("dgRMatrix", "matrix",  setAs("dgRMatrix", "matrix",
19        function(from) as(as(from, "dgTMatrix"), "matrix"))        function(from) as(.Call(compressed_to_TMatrix, from, FALSE), "matrix"))
20    setAs("lgRMatrix", "matrix",
21          function(from) as(.Call(compressed_to_TMatrix, from, FALSE), "matrix"))
22    setAs("ngRMatrix", "matrix",
23          function(from) as(.Call(compressed_to_TMatrix, from, FALSE), "matrix"))
24    
25    setAs("dgRMatrix", "dgeMatrix",
26          function(from) as(.Call(compressed_to_TMatrix, from, FALSE), "dgeMatrix"))
27    setAs("lgRMatrix", "lgeMatrix",
28          function(from) as(.Call(compressed_to_TMatrix, from, FALSE), "lgeMatrix"))
29    setAs("ngRMatrix", "ngeMatrix",
30          function(from) as(.Call(compressed_to_TMatrix, from, FALSE), "ngeMatrix"))
31    
32    setAs("dgRMatrix", "dgCMatrix",
33          function(from) .Call(R_to_CMatrix, from))
34    setAs("lgRMatrix", "lgCMatrix",
35          function(from) .Call(R_to_CMatrix, from))
36    setAs("ngRMatrix", "ngCMatrix",
37          function(from) .Call(R_to_CMatrix, from))
38    ## really needed? :
39    setAs("dgRMatrix", "CsparseMatrix", function(from) as(from, "dgCMatrix"))
40    
41  ##setAs("dgRMatrix", "dgeMatrix",  
42  ##      function(from) .Call(csc_to_dgeMatrix, from))  setAs("dgRMatrix", "dgTMatrix",
43          function(from) .Call(compressed_to_TMatrix, from, FALSE))
44    setAs("lgRMatrix", "lgTMatrix",
45          function(from) .Call(compressed_to_TMatrix, from, FALSE))
46    setAs("ngRMatrix", "ngTMatrix",
47          function(from) .Call(compressed_to_TMatrix, from, FALSE))
48    
49    setAs("dsRMatrix", "dsyMatrix",
50          function(from) .Call(compressed_to_TMatrix, from, FALSE))
51    setAs("lsRMatrix", "lsyMatrix",
52          function(from) .Call(compressed_to_TMatrix, from, FALSE))
53    setAs("nsRMatrix", "nsyMatrix",
54          function(from) .Call(compressed_to_TMatrix, from, FALSE))
55    
56    setAs("dtRMatrix", "dtrMatrix",
57          function(from) .Call(compressed_to_TMatrix, from, FALSE))
58    setAs("ltRMatrix", "ltrMatrix",
59          function(from) .Call(compressed_to_TMatrix, from, FALSE))
60    setAs("ntRMatrix", "ntrMatrix",
61          function(from) .Call(compressed_to_TMatrix, from, FALSE))
62    
63  ##setAs("matrix", "dgRMatrix",  ##setAs("matrix", "dgRMatrix",
64  ##      function(from) {  ##      function(from) {
# Line 28  Line 66 
66  ##          .Call(matrix_to_csc, from)  ##          .Call(matrix_to_csc, from)
67  ##      })  ##      })
68    
   
 ##setMethod("diag", signature(x = "dgRMatrix"),  
 ##          function(x = 1, nrow, ncol = n) .Call(csc_getDiag, x))  
   
 setAs("dgRMatrix", "dgCMatrix",  
       function(from) as(as(from, "dgTMatrix"), "dgCMatrix"))  
 setAs("dgRMatrix", "CsparseMatrix", function(from) as(from, "dgCMatrix"))  
   
69  ## **VERY** cheap substitutes:  work via dgC and t(.)  ## **VERY** cheap substitutes:  work via dgC and t(.)
70  .to.dgR <- function(from) {  .to.dgR <- function(from) {
71      m <- as(t(from), "dgCMatrix")      m <- as(t(from), "dgCMatrix")
# Line 69  Line 99 
99  ##      })  ##      })
100    
101    
102    ##setMethod("diag", signature(x = "dgRMatrix"),
103    ##          function(x = 1, nrow, ncol = n) .Call(csc_getDiag, x))
104    
105  ## 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 __
106  ## setMethod("dim", signature(x = "dgRMatrix"),  ## setMethod("dim", signature(x = "dgRMatrix"),
107  ##           function(x) x@Dim, valueClass = "integer")  ##           function(x) x@Dim, valueClass = "integer")

Legend:
Removed from v.1746  
changed lines
  Added in v.1747

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