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 1760, Sat Feb 3 21:13:22 2007 UTC revision 1766, Mon Feb 5 16:35:49 2007 UTC
# Line 9  Line 9 
9    
10  ## compressed_to_TMatrix -- fails on 32bit--enable-R-shlib with segfault {Kurt}  ## compressed_to_TMatrix -- fails on 32bit--enable-R-shlib with segfault {Kurt}
11  ## ------------ --> ../src/dgCMatrix.c  ## ------------ --> ../src/dgCMatrix.c
12  ##_SF_ .R.2.T <- function(from) .Call(compressed_to_TMatrix, from, FALSE)  .R.2.T <- function(from) .Call(compressed_to_TMatrix, from, FALSE)
13  ## slow R-level workaround  ## slow R-level workaround
14  ## this is cheap; alternative: going there directly, using  ## this is cheap; alternative: going there directly, using
15  ##      i <- .Call(Matrix_expand_pointers, from@p),  ##      i <- .Call(Matrix_expand_pointers, from@p),
16    if(FALSE)
17  .R.2.T <- function(from) as(.R.2.C(from), "TsparseMatrix")  .R.2.T <- function(from) as(.R.2.C(from), "TsparseMatrix")
18    
19  ## R_to_CMatrix -- fails on 32bit--enable-R-shlib with segfault {Kurt}  ## R_to_CMatrix -- fails on 32bit--enable-R-shlib with segfault {Kurt}
20  ## ------------ --> ../src/dgCMatrix.c  ## ------------ --> ../src/dgCMatrix.c
21  ##_SF_ .R.2.C <- function(from) .Call(R_to_CMatrix, from)  .R.2.C <- function(from) .Call(R_to_CMatrix, from)
22  ## "slow" R-level workaround  if(FALSE)## "slow" R-level workaround
23  .R.2.C <- function(from)  .R.2.C <- function(from)
24  {  {
25      cl <- class(from)      cl <- class(from)
# Line 55  Line 56 
56    
57  setAs("RsparseMatrix", "dsparseMatrix",  setAs("RsparseMatrix", "dsparseMatrix",
58        function(from) as(.R.2.C(from), "dsparseMatrix"))        function(from) as(.R.2.C(from), "dsparseMatrix"))
 ##_SF_       function(from) as(.Call(R_to_CMatrix, from), "dsparseMatrix"))  
59  setAs("RsparseMatrix", "lsparseMatrix",  setAs("RsparseMatrix", "lsparseMatrix",
60        function(from) as(.R.2.C(from), "lsparseMatrix"))        function(from) as(.R.2.C(from), "lsparseMatrix"))
 ##_SF_      function(from) as(.Call(R_to_CMatrix, from), "lsparseMatrix"))  
61  setAs("RsparseMatrix", "nsparseMatrix",  setAs("RsparseMatrix", "nsparseMatrix",
62        function(from) as(.R.2.C(from), "nsparseMatrix"))        function(from) as(.R.2.C(from), "nsparseMatrix"))
 ##_SF_      function(from) as(.Call(R_to_CMatrix, from), "nsparseMatrix"))  
63    
64  setAs("RsparseMatrix", "dMatrix",  setAs("RsparseMatrix", "dMatrix",
65        function(from) as(.R.2.C(from), "dMatrix"))        function(from) as(.R.2.C(from), "dMatrix"))
 ##_SF_      function(from) as(.Call(R_to_CMatrix, from), "dMatrix"))  
66  setAs("RsparseMatrix", "lMatrix",  setAs("RsparseMatrix", "lMatrix",
67        function(from) as(.R.2.C(from), "lMatrix"))        function(from) as(.R.2.C(from), "lMatrix"))
 ##_SF_      function(from) as(.Call(R_to_CMatrix, from), "lMatrix"))  
68  setAs("RsparseMatrix", "nMatrix",  setAs("RsparseMatrix", "nMatrix",
69        function(from) as(.R.2.C(from), "nMatrix"))        function(from) as(.R.2.C(from), "nMatrix"))
 ##_SF_      function(from) as(.Call(R_to_CMatrix, from), "nMatrix"))  
70    
71    
72  ## for printing etc:  ## for printing etc:
# Line 80  Line 75 
75  setAs("RsparseMatrix", "matrix",  setAs("RsparseMatrix", "matrix",
76        function(from) as(.R.2.C(from), "matrix"))        function(from) as(.R.2.C(from), "matrix"))
77    
   
 ##--- and all these are just "the essential low-level coercions" : ----------  
   
 ## setAs("dgRMatrix", "matrix",  
 ##       function(from) as(.Call(compressed_to_TMatrix, from, FALSE), "matrix"))  
 ## setAs("lgRMatrix", "matrix",  
 ##       function(from) as(.Call(compressed_to_TMatrix, from, FALSE), "matrix"))  
 ## setAs("ngRMatrix", "matrix",  
 ##       function(from) as(.Call(compressed_to_TMatrix, from, FALSE), "matrix"))  
   
 ## setAs("dgRMatrix", "dgeMatrix",  
 ##       function(from) as(.R.2.C(from), "dgeMatrix"))  
 ## setAs("lgRMatrix", "lgeMatrix",  
 ##       function(from) as(.R.2.C(from), "lgeMatrix"))  
 ## setAs("ngRMatrix", "ngeMatrix",  
 ##       function(from) as(.R.2.C(from), "ngeMatrix"))  
   
 ## setAs("dgRMatrix", "dgCMatrix", .R.2.C)  
 ## setAs("lgRMatrix", "lgCMatrix", .R.2.C)  
 ## setAs("ngRMatrix", "ngCMatrix", .R.2.C)  
 ## ## really needed? :  
 ## setAs("dgRMatrix", "CsparseMatrix", .R.2.C)  
   
   
 ## setAs("dgRMatrix", "dgTMatrix", .R.2.T)  
 ## setAs("lgRMatrix", "lgTMatrix", .R.2.T)  
 ## setAs("ngRMatrix", "ngTMatrix", .R.2.T)  
   
 ##=== Now the same stories for the "s" (symmetric) and "t" (triangular) ones ===  
   
 ## setAs("dsRMatrix", "dsCMatrix", .R.2.C)  
 ## setAs("lsRMatrix", "lsCMatrix", .R.2.C)  
 ## setAs("nsRMatrix", "nsCMatrix", .R.2.C)  
   
 ## setAs("dsRMatrix", "dsTMatrix", .R.2.T)  
 ## setAs("lsRMatrix", "lsTMatrix", .R.2.T)  
 ## setAs("nsRMatrix", "nsTMatrix", .R.2.T)  
   
 ## setAs("dsRMatrix", "dsyMatrix",  
 ##       function(from) as(.R.2.C(from), "dsyMatrix"))  
 ## setAs("lsRMatrix", "lsyMatrix",  
 ##       function(from) as(.R.2.C(from), "lsyMatrix"))  
 ## setAs("nsRMatrix", "nsyMatrix",  
 ##       function(from) as(.R.2.C(from), "nsyMatrix"))  
   
 ## setAs("dtRMatrix", "dtCMatrix", .R.2.C)  
 ## setAs("ltRMatrix", "ltCMatrix", .R.2.C)  
 ## setAs("ntRMatrix", "ntCMatrix", .R.2.C)  
   
 ## setAs("dtRMatrix", "dtTMatrix", .R.2.T)  
 ## setAs("ltRMatrix", "ltTMatrix", .R.2.T)  
 ## setAs("ntRMatrix", "ntTMatrix", .R.2.T)  
   
 ## setAs("dtRMatrix", "dtrMatrix",  
 ##       function(from) as(.R.2.C(from), "dtrMatrix"))  
 ## setAs("ltRMatrix", "ltrMatrix",  
 ##       function(from) as(.R.2.C(from), "ltrMatrix"))  
 ## setAs("ntRMatrix", "ntrMatrix",  
 ##       function(from) as(.R.2.C(from), "ntrMatrix"))  
   
 ##setAs("matrix", "dgRMatrix",  
 ##      function(from) {  
 ##          storage.mode(from) <- "double"  
 ##          .Call(matrix_to_csc, from)  
 ##      })  
   
78  ## **VERY** cheap substitutes:  work via dgC and t(.)  ## **VERY** cheap substitutes:  work via dgC and t(.)
79  .viaC.to.dgR <- function(from) {  .viaC.to.dgR <- function(from) {
80      m <- as(t(from), "dgCMatrix")      m <- as(t(from), "dgCMatrix")

Legend:
Removed from v.1760  
changed lines
  Added in v.1766

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