SCM

SCM Repository

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

View of /pkg/R/dpoMatrix.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1642 - (download) (annotate)
Fri Oct 20 21:08:28 2006 UTC (13 years, 1 month ago) by maechler
File size: 1784 byte(s)
small changes related to "corMatrix" and other newly seen classes in tests/Class+Meth.R
#### Positive-definite Symmetric Matrices -- Coercion and Methods

setAs("dpoMatrix", "dppMatrix",
      function(from) as(as(from, "dspMatrix"), "dppMatrix"))

setAs("dpoMatrix", "corMatrix",
      function(from) {
          sd <- sqrt(diag(from))
          if (!is.null(nms <- from@Dimnames[[1]])) names(sd) <- nms
          new("corMatrix", as(t(from/sd)/sd, "dpoMatrix"), sd = sd)
      })

to_dpo <- function(from) as(as(from, "dsyMatrix"), "dpoMatrix")
setAs("Matrix", "dpoMatrix", to_dpo)
setAs("matrix", "dpoMatrix", to_dpo)


setMethod("chol", signature(x = "dpoMatrix"),
	  function(x, pivot, ...) .Call(dpoMatrix_chol, x))

setMethod("rcond", signature(x = "dpoMatrix", type = "character"),
          function(x, type, ...)
          .Call(dpoMatrix_rcond, x, type),
          valueClass = "numeric")

setMethod("rcond", signature(x = "dpoMatrix", type = "missing"),
          function(x, type, ...)
          .Call(dpoMatrix_rcond, x, "O"),
          valueClass = "numeric")

setMethod("solve", signature(a = "dpoMatrix", b = "missing"),
          function(a, b, ...)
          .Call(dpoMatrix_solve, a),
          valueClass = "dpoMatrix")

setMethod("solve", signature(a = "dpoMatrix", b = "dgeMatrix"),
          function(a, b, ...)
          .Call(dpoMatrix_dgeMatrix_solve, a, b),
          valueClass = "dgeMatrix")

setMethod("solve", signature(a = "dpoMatrix", b = "matrix"),
          function(a, b, ...)
          .Call(dpoMatrix_matrix_solve, a, b),
          valueClass = "matrix")

## Is this usable / necessary?  -- FIXME!
## setMethod("solve", signature(a = "dpoMatrix", b = "numeric"),
##          function(a, b, ...)
##          as.numeric(.Call(dpoMatrix_matrix_solve,
##                           a, as.matrix(b))),
##          valueClass = "numeric")


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