SCM

SCM Repository

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

Annotation of /pkg/R/dsTMatrix.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1366 - (view) (download)

1 : maechler 1174 ### Coercion and Methods for Symmetric Triplet Matrices
2 : bates 557
3 : bates 589 setAs("dsTMatrix", "dsCMatrix",
4 : maechler 946 function(from)
5 : maechler 1280 ## pre-Cholmod: .Call(dsTMatrix_as_dsCMatrix, from)
6 : bates 1366 .Call(Tsparse_to_Csparse, from, FALSE)
7 : maechler 946 )
8 : bates 589
9 : maechler 956 if(FALSE) # have C method below
10 : maechler 946 setAs("dsTMatrix", "dgTMatrix",
11 : maechler 956 function(from) {
12 :     d <- from@Dim
13 :     new("dgTMatrix", Dim = d, Dimnames = from@Dimnames,
14 :     i = c(from@i, from@j),
15 :     j = c(from@j, from@i),
16 :     x = c(from@x, from@x))
17 :     })
18 :    
19 :     setAs("dsTMatrix", "dgTMatrix",
20 : maechler 1280 function(from) .Call(dsTMatrix_as_dgTMatrix, from))
21 : maechler 946
22 : maechler 956 setAs("dsTMatrix", "lsTMatrix",
23 :     function(from) new("lsTMatrix", i = from@i, j = from@j, uplo = from@uplo,
24 :     Dim = from@Dim, Dimnames = from@Dimnames))
25 : maechler 946
26 : maechler 956
27 : maechler 1202 ## Conversion <--> dense storage is via dsyMatrix :
28 : bates 557 setAs("dsTMatrix", "dsyMatrix",
29 : maechler 1280 function(from) .Call(dsTMatrix_as_dsyMatrix, from))
30 : bates 557
31 :     setAs("dsTMatrix", "dgeMatrix",
32 :     function(from) as(as(from, "dsyMatrix"), "dgeMatrix"))
33 :     setAs("dsTMatrix", "matrix",
34 :     function(from) as(as(from, "dsyMatrix"), "matrix"))
35 : bates 862
36 : maechler 1202 to_dsT <- function(from) as(as(from, "dsyMatrix"), "dsTMatrix")
37 :     setAs("dgeMatrix", "dsTMatrix", to_dsT)
38 :     setAs("matrix", "dsTMatrix", to_dsT)
39 :    
40 : bates 557 setMethod("t", signature(x = "dsTMatrix"),
41 :     function(x)
42 :     new("dsTMatrix", Dim = x@Dim,
43 :     i = x@j, j = x@i, x = x@x,
44 :     uplo = if (x@uplo == "U") "L" else "U"),
45 :     valueClass = "dsTMatrix")
46 : bates 835
47 :     setMethod("writeHB", signature(obj = "dsTMatrix"),
48 :     function(obj, file, ...)
49 : maechler 1280 .Call(Matrix_writeHarwellBoeing,
50 : bates 835 if (obj@uplo == "U") t(obj) else obj,
51 : maechler 1280 as.character(file), "DST"))
52 : bates 835
53 :     setMethod("writeMM", signature(obj = "dsTMatrix"),
54 :     function(obj, file, ...)
55 : maechler 1280 .Call(Matrix_writeMatrixMarket,
56 : bates 835 if (obj@uplo == "U") t(obj) else obj,
57 : maechler 1280 as.character(file), "DST"))

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