SCM

SCM Repository

[matrix] Annotation of /pkg/R/dtCMatrix.R
ViewVC logotype

Annotation of /pkg/R/dtCMatrix.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1209 - (view) (download)

1 : bates 483 setMethod("t", signature(x = "dtCMatrix"),
2 : bates 1209 function(x) {
3 :     tg <- t(as(x, "dgCMatrix"))
4 :     new("dtCMatrix", Dim = tg@Dim, Dimnames = tg@Dimnames,
5 :     p = tg@p, i = tg@i, x = tg@x, diag = x@diag,
6 :     uplo = ifelse(x@uplo == "U", "L", "U"))
7 :     }, valueClass = "dtCMatrix")
8 : bates 70
9 : maechler 1202 setAs("dtCMatrix", "ltCMatrix", # just drop 'x' slot:
10 : maechler 956 function(from) new("ltCMatrix", i = from@i, p = from@p,
11 :     uplo = from@uplo, diag = from@diag,
12 : maechler 1202 ## FIXME?: use from@factors smartly
13 : maechler 956 Dim = from@Dim, Dimnames = from@Dimnames))
14 : bates 923
15 : maechler 1174 setAs("matrix", "dtCMatrix",
16 :     function(from) as(as(from, "dtTMatrix"), "dtCMatrix"))
17 :    
18 : maechler 959 setAs("dtCMatrix", "dgCMatrix",
19 :     function(from) {
20 :     if(from@diag == "U") { ## add diagonal of 1's
21 :     ##FIXME: do this smartly - directly {in C or R}
22 :     as(as(from, "dgTMatrix"), "dgCMatrix")
23 :     }
24 :     else
25 :     new("dgCMatrix",
26 :     i = from@i, p = from@p, x = from@x,
27 :     Dim = from@Dim, Dimnames = from@Dimnames)
28 :     })
29 :    
30 : bates 483 setAs("dtCMatrix", "dgTMatrix",
31 : bates 1037 function(from)
32 :     .Call("tsc_to_dgTMatrix", from, PACKAGE = "Matrix"))
33 : bates 70
34 : bates 483 setAs("dtCMatrix", "dgeMatrix",
35 : bates 477 function(from) as(as(from, "dgTMatrix"), "dgeMatrix"))
36 : maechler 1174
37 :     ## These are all needed because cholmod doesn't support triangular:
38 :     ## (see end of ./Csparse.R )
39 :     setAs("dtCMatrix", "dtTMatrix",
40 :     function(from) {# and this is not elegant:
41 :     x <- as(from, "dgTMatrix")
42 :     ## FIXME: if(from@diag == "U") should drop diagonal entries:
43 :     new("dtTMatrix", x = x@x, i = x@i, j = x@j,
44 :     Dim = x@Dim, Dimnames = x@Dimnames,
45 :     uplo = from@uplo, diag = "N")
46 :     })
47 :    
48 :     setAs("dtCMatrix", "TsparseMatrix", function(from) as(from, "dtTMatrix"))
49 :     setAs("dtCMatrix", "dtrMatrix",
50 :     function(from) as(as(from, "dtTMatrix"), "dtrMatrix"))

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