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 1331 - (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 1280 function(from) .Call(sCMatrix_to_gCMatrix, from))
10 : maechler 946
11 :     setAs("lsCMatrix", "lsTMatrix",
12 : maechler 1280 function(from) .Call(Csparse_to_Tsparse, from))
13 : maechler 946
14 : bates 723 setAs("lsCMatrix", "dsCMatrix",
15 :     function(from) new("dsCMatrix", i = from@i, p = from@p,
16 :     x = rep(1, length(from@i)), uplo = from@uplo,
17 :     Dim = from@Dim, Dimnames = from@Dimnames))
18 : bates 729
19 : maechler 946 setAs("lsCMatrix", "dgTMatrix",
20 : maechler 1201 function(from) as(as(x, "dsCMatrix"), "dgTMatrix"))
21 : maechler 946
22 : maechler 1331 ## have rather tril() and triu() methods than
23 :     ## setAs("lsCMatrix", "ltCMatrix", ....)
24 :     setMethod("tril", "lsCMatrix",
25 :     function(x, k = 0, ...) {
26 :     if(x@uplo == "L" && k == 0)
27 :     ## same internal structure (speedup potential !?)
28 :     new("ltCMatrix", uplo = x@uplo, i = x@i, p = x@p,
29 :     Dim = x@Dim, Dimnames = x@Dimnames)
30 :     else tril(as(x, "lgCMatrix"), k = k, ...)
31 :     })
32 :     setMethod("triu", "lsCMatrix",
33 :     function(x, k = 0, ...) {
34 :     if(x@uplo == "U" && k == 0)
35 :     ## same internal structure (speedup potential !?)
36 :     new("ltCMatrix", uplo = x@uplo, i = x@i, p = x@p,
37 :     Dim = x@Dim, Dimnames = x@Dimnames)
38 :     else triu(as(x, "lgCMatrix"), k = k, ...)
39 :     })
40 :    
41 : maechler 1189 ## FIXME: generalize to "lsparseMatrix" or (class union) "symmetric sparse"
42 : bates 729 setMethod("image", "lsCMatrix",
43 :     function(x, ...) {
44 :     x <- as(as(x, "dsCMatrix"), "dgTMatrix")
45 :     callGeneric()
46 :     })
47 :    
48 :     setMethod("chol", signature(x = "lsCMatrix", pivot = "missing"),
49 : bates 1038 function(x, pivot, LINPACK)
50 : maechler 1280 .Call(lsCMatrix_chol, x, TRUE))
51 : bates 729
52 :     setMethod("chol", signature(x = "lsCMatrix", pivot = "logical"),
53 : bates 1038 function(x, pivot, LINPACK)
54 : maechler 1280 .Call(lsCMatrix_chol, x, pivot))
55 : bates 729
56 :     setMethod("t", signature(x = "lsCMatrix"),
57 : bates 1038 function(x)
58 : maechler 1280 .Call(lsCMatrix_trans, x),
59 : bates 729 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