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 1757, Sat Feb 3 00:21:11 2007 UTC revision 1758, Sat Feb 3 16:34:51 2007 UTC
# Line 8  Line 8 
8  ### contains = "dMatrix"  ### contains = "dMatrix"
9    
10  .R.2.T <- function(from) .Call(compressed_to_TMatrix, from, FALSE)  .R.2.T <- function(from) .Call(compressed_to_TMatrix, from, FALSE)
11    
12    ## R_to_CMatrix -- fails on 32bit--enable-R-shlib with segfault {Kurt}
13    ## ------------ --> ../src/dgCMatrix.c
14  .R.2.C <- function(from) .Call(R_to_CMatrix, from)  .R.2.C <- function(from) .Call(R_to_CMatrix, from)
15    ## "slow" R-level workaround
16    .R.2.C <- function(from)
17    {
18        cl <- class(from)
19        valid <- c("dgRMatrix", "dsRMatrix", "dtRMatrix",
20                   "lgRMatrix", "lsRMatrix", "ltRMatrix",
21                   "ngRMatrix", "nsRMatrix", "ntRMatrix",
22                   "zgRMatrix", "zsRMatrix", "ztRMatrix")
23        icl <- match(cl, valid) - 1:1
24        if(is.na(icl)) stop("invalid class:", cl)
25        Ccl <- sub("^(..)R","\\1C", cl)  # corresponding Csparse class name
26        r <- new(Ccl)
27        r@Dim <- rev(from@Dim)
28        if(icl %/% 3 != 2) ## not "n..Matrix" --> has 'x' slot
29            r@x <- from@x
30        if(icl %% 3 != 0) {                 # symmetric or triangular
31            r@uplo <- from@uplo
32            if(icl %% 3 == 2)               # triangular
33                r@diag <- from@diag
34        }
35        r@i <- from@j
36        r@p <- from@p
37        r <- t(r)
38        r@Dimnames <- from@Dimnames
39        r
40    }
41    
42  setAs("RsparseMatrix", "TsparseMatrix", .R.2.T)  setAs("RsparseMatrix", "TsparseMatrix", .R.2.T)
43  setAs("RsparseMatrix", "CsparseMatrix", .R.2.C)  setAs("RsparseMatrix", "CsparseMatrix", .R.2.C)

Legend:
Removed from v.1757  
changed lines
  Added in v.1758

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