SCM

SCM Repository

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

Diff of /pkg/R/dtpMatrix.R

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

revision 1038, Fri Nov 11 21:22:08 2005 UTC revision 1174, Mon Jan 16 20:03:48 2006 UTC
# Line 6  Line 6 
6  setAs("dtpMatrix", "dgeMatrix",  setAs("dtpMatrix", "dgeMatrix",
7        function(from) as(as(from, "dtrMatrix"), "dgeMatrix"))        function(from) as(as(from, "dtrMatrix"), "dgeMatrix"))
8    
9    setAs("dtpMatrix", "dtTMatrix",
10          ## FIXME this is NOT efficient:
11          function(from) {
12              x <- as(from, "TsparseMatrix")
13              if(is(x, "dtTMatrix"))
14                  x
15              else
16                  gt2tT(as(x, "dgTMatrix"), uplo = from@uplo, diag = from@diag)
17          })
18    
19    gt2tT <- function(x, uplo, diag) {
20        ## coerce *gtMatrix to *tTMatrix {general -> triangular}
21        i <- x@i
22        j <- x@j
23        sel <-
24            if(uplo == "U") {
25                if(diag == "U") i < j else i <= j
26            } else {
27                if(diag == "U") i > j else i >= j
28            }
29        i <- i[sel]
30        j <- j[sel]
31        if(is(x, "lMatrix"))
32            new("ltTMatrix", i = i, j = j, uplo = uplo, diag = diag,
33                Dim = x@Dim, Dimnames = x@Dimnames) # no 'x' slot
34        else
35            new(paste(substr(class(x), 1,1), # "d", "l", "i" or "z"
36                      "tTMatrix", sep=''),
37                i = i, j = j, uplo = uplo, diag = diag,
38                x = x@x[sel], Dim = x@Dim, Dimnames = x@Dimnames)
39    }
40    
41  setAs("dtpMatrix", "matrix",  setAs("dtpMatrix", "matrix",
42        function(from) as(as(from, "dtrMatrix"), "matrix"))        function(from) as(as(from, "dtrMatrix"), "matrix"))
43  setAs("matrix", "dtpMatrix",  setAs("matrix", "dtpMatrix",

Legend:
Removed from v.1038  
changed lines
  Added in v.1174

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