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