SCM

SCM Repository

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

Diff of /pkg/R/Matrix.R

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

revision 1738, Tue Jan 23 17:17:15 2007 UTC revision 1747, Mon Jan 29 20:17:33 2007 UTC
# Line 85  Line 85 
85  setMethod("any", signature(x = "Matrix"),  setMethod("any", signature(x = "Matrix"),
86            function(x, ..., na.rm) { x <- as(x, "lMatrix"); callGeneric()})            function(x, ..., na.rm) { x <- as(x, "lMatrix"); callGeneric()})
87    
88    setMethod("!", "Matrix", function(e1) !as(e1, "lMatrix"))
89    
90    
91    
92  Matrix <-  Matrix <-
# Line 127  Line 129 
129              dimnames(data) <- dimnames              dimnames(data) <- dimnames
130          }          }
131          doDN <- FALSE          doDN <- FALSE
132      }      } else if(!missing(nrow) || !missing(ncol))
133            warning("'nrow', 'ncol', etc, are disregarded for matrix 'data'")
134    
135      ## 'data' is now a "matrix" or "Matrix"      ## 'data' is now a "matrix" or "Matrix"
136      if (doDN && !is.null(dimnames))      if (doDN && !is.null(dimnames))
137          dimnames(data) <- dimnames          dimnames(data) <- dimnames
# Line 206  Line 210 
210  ## when no sub-class method is found, bail out  ## when no sub-class method is found, bail out
211  setMethod("solve", signature(a = "Matrix", b = "matrix"),  setMethod("solve", signature(a = "Matrix", b = "matrix"),
212            function(a, b, ...) .bail.out.2("solve", class(a), "matrix"))            function(a, b, ...) .bail.out.2("solve", class(a), "matrix"))
213    setMethod("solve", signature(a = "Matrix", b = "Matrix"),
214              function(a, b, ...) .bail.out.2("solve", class(a), class(b)))
215    
216  ## bail-out methods in order to get better error messages  ## bail-out methods in order to get better error messages
217  setMethod("%*%", signature(x = "Matrix", y = "Matrix"),  setMethod("%*%", signature(x = "Matrix", y = "Matrix"),
# Line 300  Line 306 
306          stop("not-yet-implemented 'Matrix' subsetting") ## FIXME          stop("not-yet-implemented 'Matrix' subsetting") ## FIXME
307    
308      } else stop("nargs() = ", nA,      } else stop("nargs() = ", nA,
309                  " should never happen; please report.")                  ".  Extraneous illegal arguments inside '[ .. ]' ?")
310  }  }
311  setMethod("[", signature(x = "Matrix", i = "lMatrix", j = "missing",  setMethod("[", signature(x = "Matrix", i = "lMatrix", j = "missing",
312                           drop = "ANY"),                           drop = "ANY"),
# Line 330  Line 336 
336          ## potentially inefficient -- FIXME --          ## potentially inefficient -- FIXME --
337          unlist(lapply(seq_len(m), function(j) x[i1[j], i2[j]]))          unlist(lapply(seq_len(m), function(j) x[i1[j], i2[j]]))
338    
339      } else stop("nargs() = ", nA, " should never happen; please report.")      } else stop("nargs() = ", nA,
340                    ".  Extraneous illegal arguments inside '[ .. ]' ?")
341  }  }
342  setMethod("[", signature(x = "Matrix", i = "matrix", j = "missing"),# drop="ANY"  setMethod("[", signature(x = "Matrix", i = "matrix", j = "missing"),# drop="ANY"
343            .M.sub.i.2col)            .M.sub.i.2col)
# Line 343  Line 350 
350                                  value = "ANY"),## double/logical/...                                  value = "ANY"),## double/logical/...
351            function (x, value) {            function (x, value) {
352                ## Fails for 'nMatrix' ... FIXME : make sure have method there                ## Fails for 'nMatrix' ... FIXME : make sure have method there
353                x@x <- value                x@x <- rep(value, length = length(x@x))
354                validObject(x)# check if type and lengths above match                validObject(x)# check if type and lengths above match
355                x                x
356            })            })
# Line 385  Line 392 
392              x[i1[k], i2[k]] <- value[k]              x[i1[k], i2[k]] <- value[k]
393    
394          x          x
395      } else stop("nargs() = ", nA, " should never happen; please report.")      } else stop("nargs() = ", nA,
396                    ".  Extraneous illegal arguments inside '[ .. ]' ?")
397  }  }
398    
399  setReplaceMethod("[", signature(x = "Matrix", i = "matrix", j = "missing",  setReplaceMethod("[", signature(x = "Matrix", i = "matrix", j = "missing",

Legend:
Removed from v.1738  
changed lines
  Added in v.1747

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