SCM

SCM Repository

[matrix] Diff of /pkg/R/diagMatrix.R
ViewVC logotype

Diff of /pkg/R/diagMatrix.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1709, Sat Dec 23 06:22:50 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.1709  
changed lines
  Added in v.1710

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