# SCM Repository

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

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

revision 1708, Fri Dec 22 19:53:37 2006 UTC revision 1710, Tue Dec 26 15:57:06 2006 UTC
# Line 180  Line 180
180  ## When you assign to a diagonalMatrix, the result should be  ## When you assign to a diagonalMatrix, the result should be
181  ## diagonal or sparse ---  ## diagonal or sparse ---
182  ## FIXME: this now fails because the "denseMatrix" methods come first in dispatch  ## FIXME: this now fails because the "denseMatrix" methods come first in dispatch
183  setReplaceMethod("[", signature(x = "diagonalMatrix",
184                                  i = "ANY", j = "ANY", value = "ANY"),  replDiag <- function(x, i, j, value) {
185                   function(x, i, j, value) {      x <- as(x, "sparseMatrix")
186                       r <- callGeneric(x = as(x,"sparseMatrix"),      if(missing(i))
187                                        i=i, j=j, value=value)          x[, j] <- value
188                       if(isDiagonal(r)) as(r, "diagonalMatrix") else r      else if(missing(j))
189                   })          x[i, ] <- value
190        else
191            x[i,j] <- value
192        if(isDiagonal(x)) as(x, "diagonalMatrix") else x
193    }
194
195    setReplaceMethod("[", signature(x = "diagonalMatrix", i = "index",
196                                    j = "index", value = "replValue"), replDiag)
197    setReplaceMethod("[", signature(x = "diagonalMatrix", i = "index",
198                                    j = "missing", value = "replValue"),
199                     function(x, i, value) replDiag(x, i=i, value=value))
200    setReplaceMethod("[", signature(x = "diagonalMatrix", i = "missing",
201                                    j = "index", value = "replValue"),
202                     function(x, j, value) replDiag(x, j=j, value=value))
203
204
205  setMethod("t", signature(x = "diagonalMatrix"),  setMethod("t", signature(x = "diagonalMatrix"),

Legend:
 Removed from v.1708 changed lines Added in v.1710