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 1174 - (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 : bates 1037 ## pre-Cholmod: .Call("dsTMatrix_as_dsCMatrix", from, PACKAGE = "Matrix")
6 : bates 1038 .Call("Tsparse_to_Csparse", from, PACKAGE = "Matrix")
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 : bates 1037 function(from) .Call("dsTMatrix_as_dgTMatrix", from, PACKAGE = "Matrix"))
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 : bates 557 ## Conversion to dense storage is first to a dsyMatrix
28 :     setAs("dsTMatrix", "dsyMatrix",
29 : bates 1037 function(from) .Call("dsTMatrix_as_dsyMatrix", from, PACKAGE = "Matrix"))
30 : bates 557
31 :     setAs("dsTMatrix", "dgeMatrix",
32 :     function(from) as(as(from, "dsyMatrix"), "dgeMatrix"))
33 :    
34 :     setAs("dsTMatrix", "matrix",
35 :     function(from) as(as(from, "dsyMatrix"), "matrix"))
36 : bates 862
37 : bates 557 setMethod("t", signature(x = "dsTMatrix"),
38 :     function(x)
39 :     new("dsTMatrix", Dim = x@Dim,
40 :     i = x@j, j = x@i, x = x@x,
41 :     uplo = if (x@uplo == "U") "L" else "U"),
42 :     valueClass = "dsTMatrix")
43 : bates 835
44 :     setMethod("writeHB", signature(obj = "dsTMatrix"),
45 :     function(obj, file, ...)
46 :     .Call("Matrix_writeHarwellBoeing",
47 :     if (obj@uplo == "U") t(obj) else obj,
48 : bates 1037 as.character(file), "DST", PACKAGE = "Matrix"))
49 : bates 835
50 :     setMethod("writeMM", signature(obj = "dsTMatrix"),
51 :     function(obj, file, ...)
52 :     .Call("Matrix_writeMatrixMarket",
53 :     if (obj@uplo == "U") t(obj) else obj,
54 : bates 1037 as.character(file), "DST", PACKAGE = "Matrix"))

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