# SCM Repository

[matrix] View of /pkg/R/lsparseMatrix.R
 [matrix] / pkg / R / lsparseMatrix.R

# View of /pkg/R/lsparseMatrix.R

Mon Sep 11 22:13:07 2006 UTC (12 years, 5 months ago) by maechler
File size: 1650 byte(s)
`new nMatrix and subclasses; lsparse change to have x slot; many consequences`
```#### Superclass Methods for all sparse logical matrices

setAs("CsparseMatrix", "lsparseMatrix",
function(from) as(.Call(Csparse_to_nz_pattern, from,
is(from, "triangularMatrix")), "lsparseMatrix"))

setAs("lsparseMatrix", "matrix",
function(from) as(as(from, "ldenseMatrix"), "matrix"))

###------- Work via  as(*, lgC) : ------------

## For multiplication operations, sparseMatrix overrides other method
## selections.  Coerce a ddensematrix argument to a lsparseMatrix.

setMethod("%*%", signature(x = "lsparseMatrix", y = "ldenseMatrix"),
function(x, y) callGeneric(x, as(y, "lsparseMatrix")))

setMethod("%*%", signature(x = "ldenseMatrix", y = "lsparseMatrix"),
function(x, y) callGeneric(as(x, "lsparseMatrix"), y))

setMethod("crossprod", signature(x = "lsparseMatrix", y = "ldenseMatrix"),
function(x, y = NULL) callGeneric(x, as(y, "lsparseMatrix")))

setMethod("crossprod", signature(x = "ldenseMatrix", y = "lsparseMatrix"),
function(x, y = NULL) callGeneric(as(x, "lsparseMatrix"), y))

## and coerce lsparse* to lgC*
setMethod("%*%", signature(x = "lsparseMatrix", y = "lsparseMatrix"),
function(x, y) callGeneric(as(x, "lgCMatrix"), as(y, "lgCMatrix")))

setMethod("crossprod", signature(x = "lsparseMatrix", y = "lsparseMatrix"),
function(x, y = NULL)
callGeneric(as(x, "lgCMatrix"), as(y, "lgCMatrix")))

setMethod("!", "lsparseMatrix",
## turns FALSE to TRUE --> dense matrix
function(e1) !as(e1, "lgeMatrix"))

setMethod("diag", signature(x = "lsparseMatrix"),
function(x, nrow, ncol = n) diag(as(x, "lgCMatrix")))
```

 R-Forge@R-project.org ViewVC Help Powered by ViewVC 1.0.0
Thanks to: