SCM

SCM Repository

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

Annotation of /pkg/R/lsCMatrix.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1599 - (view) (download)

1 : bates 723 #### Logical Symmetric Sparse Matrices in Compressed column-oriented format
2 :    
3 :     ### contains = "lsparseMatrix"
4 :    
5 : maechler 946 setAs("lsCMatrix", "matrix",
6 :     function(from) as(as(from, "lgCMatrix"), "matrix"))
7 :    
8 :     setAs("lsCMatrix", "lgCMatrix",
9 : maechler 1375 function(from) .Call(Csparse_symmetric_to_general, from))
10 : maechler 946
11 : maechler 1599 if(FALSE) ## FIXME : partially done in C ../src/Csparse.c :
12 :     setAs("lgCMatrix", "lsCMatrix",
13 :     function(from) .Call(Csparse_general_to_symmetric, from))
14 :    
15 : bates 1366 ## Specific conversions, should they be necessary. Better to convert as
16 :     ## as(x, "TsparseMatrix") or as(x, "denseMatrix")
17 : maechler 946 setAs("lsCMatrix", "lsTMatrix",
18 : bates 1366 function(from) .Call(Csparse_to_Tsparse, from, FALSE))
19 : maechler 946
20 : bates 723 setAs("lsCMatrix", "dsCMatrix",
21 :     function(from) new("dsCMatrix", i = from@i, p = from@p,
22 : maechler 1571 x = as.double(from@x), uplo = from@uplo,
23 : bates 723 Dim = from@Dim, Dimnames = from@Dimnames))
24 : bates 729
25 : maechler 946 setAs("lsCMatrix", "dgTMatrix",
26 : maechler 1201 function(from) as(as(x, "dsCMatrix"), "dgTMatrix"))
27 : maechler 946
28 : maechler 1331 ## have rather tril() and triu() methods than
29 :     ## setAs("lsCMatrix", "ltCMatrix", ....)
30 :     setMethod("tril", "lsCMatrix",
31 :     function(x, k = 0, ...) {
32 :     if(x@uplo == "L" && k == 0)
33 :     ## same internal structure (speedup potential !?)
34 :     new("ltCMatrix", uplo = x@uplo, i = x@i, p = x@p,
35 :     Dim = x@Dim, Dimnames = x@Dimnames)
36 :     else tril(as(x, "lgCMatrix"), k = k, ...)
37 :     })
38 :     setMethod("triu", "lsCMatrix",
39 :     function(x, k = 0, ...) {
40 :     if(x@uplo == "U" && k == 0)
41 :     ## same internal structure (speedup potential !?)
42 :     new("ltCMatrix", uplo = x@uplo, i = x@i, p = x@p,
43 :     Dim = x@Dim, Dimnames = x@Dimnames)
44 :     else triu(as(x, "lgCMatrix"), k = k, ...)
45 :     })
46 :    
47 : maechler 1189 ## FIXME: generalize to "lsparseMatrix" or (class union) "symmetric sparse"
48 : bates 729 setMethod("image", "lsCMatrix",
49 :     function(x, ...) {
50 :     x <- as(as(x, "dsCMatrix"), "dgTMatrix")
51 :     callGeneric()
52 :     })
53 :    
54 :     setMethod("chol", signature(x = "lsCMatrix", pivot = "missing"),
55 : maechler 1571 function(x, pivot, ...) chol(as(x, "dgCMatrix"), pivot = FALSE))
56 :     ## .Call(lsCMatrix_chol, x, FALSE))
57 : bates 729
58 :     setMethod("chol", signature(x = "lsCMatrix", pivot = "logical"),
59 : maechler 1571 function(x, pivot, ...) chol(as(x, "dgCMatrix"), pivot = pivot))
60 :     ## .Call(lsCMatrix_chol, x, pivot))
61 : bates 729
62 : bates 1448 ## Use more general method from CsparseMatrix class
63 :     ## setMethod("t", signature(x = "lsCMatrix"),
64 :     ## function(x)
65 :     ## .Call(lsCMatrix_trans, x),
66 :     ## valueClass = "lsCMatrix")

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