The R Project SVN R-packages

Rev

Rev 3411 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3411 Rev 3543
1
#### Superclass Methods for all sparse logical matrices
1
#### Superclass Methods for all sparse logical matrices
2
 
2
 
3
setAs("CsparseMatrix", "lsparseMatrix",
3
setAs("CsparseMatrix", "lsparseMatrix",
4
      function(from) .Call(Csparse_to_logical, from,
4
      function(from) .Call(Csparse_to_logical, from,
5
			   is(from, "triangularMatrix")))
5
			   is(from, "triangularMatrix")))
6
 
6
 
7
 
7
 
8
###------- Work via  as(*, lgC) : ------------
8
###------- Work via  as(*, lgC) : ------------
9
 
9
 
10
## For multiplication operations, sparseMatrix overrides other method
10
## For multiplication operations, sparseMatrix overrides other method
11
## selections.  Coerce a ddensematrix argument to a lsparseMatrix.
11
## selections.  Coerce a ddensematrix argument to a lsparseMatrix.
12
 
12
 
13
setMethod("%*%", signature(x = "lsparseMatrix", y = "ldenseMatrix"),
13
setMethod("%*%", signature(x = "lsparseMatrix", y = "ldenseMatrix"),
14
          function(x, y) callGeneric(x, as(y, "lsparseMatrix")))
14
          function(x, y) callGeneric(x, as(y, "lsparseMatrix")))
15
 
15
 
16
setMethod("%*%", signature(x = "ldenseMatrix", y = "lsparseMatrix"),
16
setMethod("%*%", signature(x = "ldenseMatrix", y = "lsparseMatrix"),
17
          function(x, y) callGeneric(as(x, "lsparseMatrix"), y))
17
          function(x, y) callGeneric(as(x, "lsparseMatrix"), y))
18
 
18
 
19
setMethod("crossprod", signature(x = "lsparseMatrix", y = "ldenseMatrix"),
19
setMethod("crossprod", signature(x = "lsparseMatrix", y = "ldenseMatrix"),
20
          function(x, y = NULL) callGeneric(x, as(y, "lsparseMatrix")))
20
          function(x, y = NULL) callGeneric(x, as(y, "lsparseMatrix")))
21
 
21
 
22
setMethod("crossprod", signature(x = "ldenseMatrix", y = "lsparseMatrix"),
22
setMethod("crossprod", signature(x = "ldenseMatrix", y = "lsparseMatrix"),
23
          function(x, y = NULL) callGeneric(as(x, "lsparseMatrix"), y))
23
          function(x, y = NULL) callGeneric(as(x, "lsparseMatrix"), y))
24
 
24
 
25
## and coerce lsparse* to lgC*
25
## and coerce lsparse* to lgC*
26
setMethod("%*%", signature(x = "lsparseMatrix", y = "lsparseMatrix"),
26
setMethod("%*%", signature(x = "lsparseMatrix", y = "lsparseMatrix"),
27
          function(x, y) callGeneric(as(x, "lgCMatrix"), as(y, "lgCMatrix")))
27
          function(x, y) callGeneric(as(x, "lgCMatrix"), as(y, "lgCMatrix")))
28
 
28
 
29
setMethod("crossprod", signature(x = "lsparseMatrix", y = "lsparseMatrix"),
29
setMethod("crossprod", signature(x = "lsparseMatrix", y = "lsparseMatrix"),
30
          function(x, y = NULL)
30
          function(x, y = NULL)
31
          callGeneric(as(x, "lgCMatrix"), as(y, "lgCMatrix")))
31
          callGeneric(as(x, "lgCMatrix"), as(y, "lgCMatrix")))
32
 
32
 
33
setMethod("!", "lsparseMatrix",
33
setMethod("!", "lsparseMatrix",
34
          ## turns FALSE to TRUE --> dense matrix
34
          ## turns FALSE to TRUE --> dense matrix
35
          function(e1) !as(e1, "lgeMatrix"))
35
          function(e1) !as(e1, "lgeMatrix"))
36
 
36
 
37
setMethod("diag", signature(x = "lsparseMatrix"),
37
setMethod("diag", signature(x = "lsparseMatrix"),
38
	  function(x, nrow, ncol = n) diag(as(x, "lgCMatrix")))
38
	  function(x, nrow, ncol = n) diag(as(x, "lgCMatrix")))