SCM

SCM Repository

[matrix] View of /pkg/R/nsparseMatrix.R
ViewVC logotype

View of /pkg/R/nsparseMatrix.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1548 - (download) (annotate)
Mon Sep 11 22:13:07 2006 UTC (12 years, 5 months ago) by maechler
File size: 1539 byte(s)
new nMatrix and subclasses; lsparse change to have x slot; many consequences
#### Superclass Methods for all sparse nonzero-pattern matrices

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


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

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

setMethod("%*%", signature(x = "nsparseMatrix", y = "ndenseMatrix"),
          function(x, y) callGeneric(x, as(y, "nsparseMatrix")))

setMethod("%*%", signature(x = "ndenseMatrix", y = "nsparseMatrix"),
          function(x, y) callGeneric(as(x, "nsparseMatrix"), y))

setMethod("crossprod", signature(x = "nsparseMatrix", y = "ndenseMatrix"),
          function(x, y = NULL) callGeneric(x, as(y, "nsparseMatrix")))

setMethod("crossprod", signature(x = "ndenseMatrix", y = "nsparseMatrix"),
          function(x, y = NULL) callGeneric(as(x, "nsparseMatrix"), y))

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

setMethod("crossprod", signature(x = "nsparseMatrix", y = "nsparseMatrix"),
          function(x, y = NULL)
          callGeneric(as(x, "ngCMatrix"), as(y, "ngCMatrix")))

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

setMethod("diag", signature(x = "nsparseMatrix"),
	  function(x, nrow, ncol = n) diag(as(x, "ngCMatrix")))

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