SCM

SCM Repository

[matrix] Diff of /pkg/R/dgCMatrix.R
ViewVC logotype

Diff of /pkg/R/dgCMatrix.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1279, Tue May 23 08:01:11 2006 UTC revision 1280, Tue May 23 08:01:44 2006 UTC
# Line 3  Line 3 
3  ### contains = "dsparseMatrix"  ### contains = "dsparseMatrix"
4    
5  setAs("dgCMatrix", "dgTMatrix",  setAs("dgCMatrix", "dgTMatrix",
6        function(from) .Call("compressed_to_dgTMatrix", from, TRUE, PACKAGE = "Matrix"))        function(from) .Call(compressed_to_dgTMatrix, from, TRUE))
7    
8  setAs("dgCMatrix", "matrix",  setAs("dgCMatrix", "matrix",
9        function(from) .Call("csc_to_matrix", from, PACKAGE = "Matrix"))        function(from) .Call(csc_to_matrix, from))
10    
11  setAs("dgCMatrix", "dgeMatrix",  setAs("dgCMatrix", "dgeMatrix",
12        function(from) .Call("csc_to_dgeMatrix", from, PACKAGE = "Matrix"))        function(from) .Call(csc_to_dgeMatrix, from))
13    
14  setAs("dgCMatrix", "lgCMatrix",  setAs("dgCMatrix", "lgCMatrix",
15        function(from) new("lgCMatrix", i = from@i, p = from@p,        function(from) new("lgCMatrix", i = from@i, p = from@p,
# Line 18  Line 18 
18  setAs("matrix", "dgCMatrix",  setAs("matrix", "dgCMatrix",
19        function(from) {        function(from) {
20            storage.mode(from) <- "double"            storage.mode(from) <- "double"
21            .Call("matrix_to_csc", from, PACKAGE = "Matrix")            .Call(matrix_to_csc, from)
22        })        })
23    
24  setAs("dgeMatrix", "dgCMatrix",  setAs("dgeMatrix", "dgCMatrix",
25        function(from) .Call("dgeMatrix_to_csc", from, PACKAGE = "Matrix"))        function(from) .Call(dgeMatrix_to_csc, from))
26    
27    
28  setMethod("crossprod", signature(x = "dgCMatrix", y = "missing"),  setMethod("crossprod", signature(x = "dgCMatrix", y = "missing"),
29            function(x, y = NULL) .Call("csc_crossprod", x, PACKAGE = "Matrix"),            function(x, y = NULL) .Call(csc_crossprod, x),
30            valueClass = "dsCMatrix")            valueClass = "dsCMatrix")
31    
32  setMethod("crossprod", signature(x = "dgCMatrix", y = "dgeMatrix"),  setMethod("crossprod", signature(x = "dgCMatrix", y = "dgeMatrix"),
33            function(x, y = NULL)            function(x, y = NULL)
34            .Call("csc_matrix_crossprod", x, y, TRUE, PACKAGE = "Matrix"),            .Call(csc_matrix_crossprod, x, y, TRUE),
35            valueClass = "dgeMatrix")            valueClass = "dgeMatrix")
36    
37  setMethod("crossprod", signature(x = "dgCMatrix", y = "matrix"),  setMethod("crossprod", signature(x = "dgCMatrix", y = "matrix"),
38            function(x, y = NULL) {            function(x, y = NULL) {
39                storage.mode(y) <- "double"                storage.mode(y) <- "double"
40                .Call("csc_matrix_crossprod", x, y, FALSE, PACKAGE = "Matrix")                .Call(csc_matrix_crossprod, x, y, FALSE)
41            }, valueClass = "dgeMatrix")            }, valueClass = "dgeMatrix")
42    
43  ##setMethod("crossprod", signature(x = "dgCMatrix", y = "numeric"),  ##setMethod("crossprod", signature(x = "dgCMatrix", y = "numeric"),
# Line 45  Line 45 
45  ##          valueClass = "dgeMatrix")  ##          valueClass = "dgeMatrix")
46    
47  ## setMethod("crossprod", signature(x = "dgCMatrix", y = "numeric"),  ## setMethod("crossprod", signature(x = "dgCMatrix", y = "numeric"),
48  ##           function(x, y = NULL) .Call("csc_matrix_crossprod", x, as.matrix(y)))  ##           function(x, y = NULL) .Call(csc_matrix_crossprod, x, as.matrix(y)))
49    
50  setMethod("tcrossprod", signature(x = "dgCMatrix", y = "missing"),  setMethod("tcrossprod", signature(x = "dgCMatrix", y = "missing"),
51            function(x, y = NULL) .Call("csc_tcrossprod", x, PACKAGE = "Matrix"))            function(x, y = NULL) .Call(csc_tcrossprod, x))
52    
53  setMethod("diag", signature(x = "dgCMatrix"),  setMethod("diag", signature(x = "dgCMatrix"),
54            function(x = 1, nrow, ncol = n)            function(x = 1, nrow, ncol = n)
55            .Call("csc_getDiag", x, PACKAGE = "Matrix"))            .Call(csc_getDiag, x))
56    
57  ## try to define for "Matrix" -- once and for all -- but that fails -- why? __ FIXME __  ## try to define for "Matrix" -- once and for all -- but that fails -- why? __ FIXME __
58  ## setMethod("dim", signature(x = "dgCMatrix"),  ## setMethod("dim", signature(x = "dgCMatrix"),
59  ##           function(x) x@Dim, valueClass = "integer")  ##           function(x) x@Dim, valueClass = "integer")
60    
61  setMethod("t", signature(x = "dgCMatrix"),  setMethod("t", signature(x = "dgCMatrix"),
62            function(x) .Call("csc_transpose", x, PACKAGE = "Matrix"),            function(x) .Call(csc_transpose, x),
63            valueClass = "dgCMatrix")            valueClass = "dgCMatrix")
64    
65  setMethod("image", "dgCMatrix",  setMethod("image", "dgCMatrix",
# Line 69  Line 69 
69            })            })
70    
71  setMethod("%*%", signature(x = "dgCMatrix", y = "dgeMatrix"),  setMethod("%*%", signature(x = "dgCMatrix", y = "dgeMatrix"),
72            function(x, y) .Call("csc_matrix_mm", x, y, TRUE, FALSE, PACKAGE = "Matrix"),            function(x, y) .Call(csc_matrix_mm, x, y, TRUE, FALSE),
73            valueClass = "dgeMatrix")            valueClass = "dgeMatrix")
74    
75  setMethod("%*%", signature(x = "dgCMatrix", y = "matrix"),  setMethod("%*%", signature(x = "dgCMatrix", y = "matrix"),
76            function(x, y) {            function(x, y) {
77                storage.mode(y) <- "double"                storage.mode(y) <- "double"
78                .Call("csc_matrix_mm", x, y, FALSE, FALSE, PACKAGE = "Matrix")                .Call(csc_matrix_mm, x, y, FALSE, FALSE)
79            }, valueClass = "dgeMatrix")            }, valueClass = "dgeMatrix")
80    
81  setMethod("%*%", signature(x = "dgeMatrix", y = "dgCMatrix"),  setMethod("%*%", signature(x = "dgeMatrix", y = "dgCMatrix"),
82            function(x, y) .Call("csc_matrix_mm", y, x, TRUE, TRUE, PACKAGE = "Matrix"),            function(x, y) .Call(csc_matrix_mm, y, x, TRUE, TRUE),
83            valueClass = "dgeMatrix")            valueClass = "dgeMatrix")
84    
85  setMethod("%*%", signature(x = "matrix", y = "dgCMatrix"),  setMethod("%*%", signature(x = "matrix", y = "dgCMatrix"),
86            function(x, y) {            function(x, y) {
87                storage.mode(x) <- "double"                storage.mode(x) <- "double"
88                .Call("csc_matrix_mm", y, x, FALSE, TRUE, PACKAGE = "Matrix")                .Call(csc_matrix_mm, y, x, FALSE, TRUE)
89            }, valueClass = "dgeMatrix")            }, valueClass = "dgeMatrix")
90    
91  ## Group Methods, see ?Arith (e.g.)  ## Group Methods, see ?Arith (e.g.)
# Line 243  Line 243 
243      if(lenV > lenRepl)      if(lenV > lenRepl)
244          stop("too many replacement values")          stop("too many replacement values")
245    
246      xj <- .Call("Matrix_expand_pointers", x@p, PACKAGE = "Matrix")      xj <- .Call(Matrix_expand_pointers, x@p)
247      sel <- (!is.na(match(x@i, i1)) &      sel <- (!is.na(match(x@i, i1)) &
248              !is.na(match( xj, i2)))              !is.na(match( xj, i2)))
249    
# Line 278  Line 278 
278    
279  setMethod("writeHB", signature(obj = "dgCMatrix"),  setMethod("writeHB", signature(obj = "dgCMatrix"),
280            function(obj, file, ...)            function(obj, file, ...)
281            .Call("Matrix_writeHarwellBoeing", obj, as.character(file), "DGC", PACKAGE = "Matrix"))            .Call(Matrix_writeHarwellBoeing, obj, as.character(file), "DGC"))
282    
283  setMethod("writeMM", signature(obj = "dgCMatrix"),  setMethod("writeMM", signature(obj = "dgCMatrix"),
284            function(obj, file, ...)            function(obj, file, ...)
285            .Call("Matrix_writeMatrixMarket", obj, as.character(file), "DGC", PACKAGE = "Matrix"))            .Call(Matrix_writeMatrixMarket, obj, as.character(file), "DGC"))

Legend:
Removed from v.1279  
changed lines
  Added in v.1280

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge