# SCM Repository

[matrix] Diff of /pkg/Matrix/R/diagMatrix.R
 [matrix] / pkg / Matrix / R / diagMatrix.R

# Diff of /pkg/Matrix/R/diagMatrix.R

revision 2608, Tue Aug 10 08:23:48 2010 UTC revision 2633, Sun Dec 12 21:23:17 2010 UTC
# Line 515  Line 515
515  ##       ---------------------  ##       ---------------------
516  ## Note that "ldi" logical are treated as numeric  ## Note that "ldi" logical are treated as numeric
517  diagdiagprod <- function(x, y) {  diagdiagprod <- function(x, y) {
518      n <- dimCheck(x,y)[1]      dimCheck(x,y)
519      if(x@diag != "U") {      if(x@diag != "U") {
520          if(y@diag != "U") {          if(y@diag != "U") {
521              nx <- x@x * y@x              nx <- x@x * y@x
# Line 547  Line 547
547      dx <- dim(x)      dx <- dim(x)
548      dy <- dim(y)      dy <- dim(y)
549      if(dx[2] != dy[1]) stop("non-matching dimensions")      if(dx[2] != dy[1]) stop("non-matching dimensions")
n <- dx[1]
550      as(if(x@diag == "U") y else x@x * y, "Matrix")      as(if(x@diag == "U") y else x@x * y, "Matrix")
551  }  }
552  setMethod("%*%", signature(x = "diagonalMatrix", y = "matrix"),  setMethod("%*%", signature(x = "diagonalMatrix", y = "matrix"),
# Line 698  Line 697
697            })            })
698
699  solveDiag <- function(a, b, ...) {  solveDiag <- function(a, b, ...) {
700      if((n <- a@Dim[1]) != nrow(b))      if(a@Dim[1] != nrow(b))
701          stop("incompatible matrix dimensions")          stop("incompatible matrix dimensions")
702      ## trivially invert a 'in place' and multiply:      ## trivially invert a 'in place' and multiply:
703      a@x <- 1/ a@x      a@x <- 1/ a@x

Legend:
 Removed from v.2608 changed lines Added in v.2633