# SCM Repository

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

# Diff of /pkg/R/Matrix.R

revision 1174, Mon Jan 16 20:03:48 2006 UTC revision 1189, Fri Jan 20 18:13:39 2006 UTC
# Line 24  Line 24
24  setMethod("isSymmetric", signature(object = "triangularMatrix"),  setMethod("isSymmetric", signature(object = "triangularMatrix"),
25            ## TRUE iff diagonal:            ## TRUE iff diagonal:
26            function(object,tol) isDiagonal(object))            function(object,tol) isDiagonal(object))
27
28  if(paste(R.version\$major, R.version\$minor, sep=".") < "2.3")  if(paste(R.version\$major, R.version\$minor, sep=".") < "2.3")
29      ## need a "matrix" method as in R 2.3 and later      ## need a "matrix" method as in R 2.3 and later
30      setMethod("isSymmetric", signature(object = "matrix"),      setMethod("isSymmetric", signature(object = "matrix"),
# Line 32  Line 33
33                ## pretest: is it square?                ## pretest: is it square?
34                d <- dim(object)                d <- dim(object)
35                if(d[1] != d[2]) return(FALSE)                if(d[1] != d[2]) return(FALSE)
36                  ## for `broken' all.equal in R <= 2.2.x:
37                  dn <- dimnames(object)
38                  if(!identical(dn[1], dn[2])) return(FALSE)
39                test <-                test <-
40                    if(is.complex(object))                    if(is.complex(object))
41                        all.equal.numeric(object, Conj(t(object)), tol = tol, ...)                        all.equal.numeric(object, Conj(t(object)), tol = tol, ...)
# Line 97  Line 101
101          if(is.null(sparse))          if(is.null(sparse))
102              sparse <- sparseDefault(data)              sparse <- sparseDefault(data)
103          dimnames(data) <- dimnames          dimnames(data) <- dimnames
104      }      } else if (!is.null(dimnames))
105            dimnames(data) <- dimnames
106
107      ## 'data' is now a "matrix" or "Matrix"      ## 'data' is now a "matrix" or "Matrix"
108
# Line 253  Line 258
258
259  ## x[] <- value :  ## x[] <- value :
260  setReplaceMethod("[", signature(x = "Matrix", i = "missing", j = "missing",  setReplaceMethod("[", signature(x = "Matrix", i = "missing", j = "missing",
261                                  value = "index"),##  double/logical/...                                  value = "ANY"),## double/logical/...
262            function (x, value) { x@x <- value ; validObject(x); x })            function (x, value) {
263                  x@x <- value
264                  validObject(x)# check if type and lengths above match
265                  x
266              })
267
268  ## Otherwise (value is not "index"): bail out  ## Method for all 'Matrix' kinds (rather than incomprehensible error messages);
269    ## (ANY,ANY,ANY) is used when no `real method' is implemented :
270  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",
271                                  value = "ANY"),                                  value = "ANY"),
272            function (x, i, j, value)            function (x, i, j, value) {
273                   if(!is(value,"index"))                if(!is.atomic(value))
274                   stop("RHS 'value' must be of class \"index\"")                    stop("RHS 'value' must match matrix class ", class(x))
275                   else stop("not-yet-implemented 'Matrix[<-' method"))                else stop("not-yet-implemented 'Matrix[<-' method")
276              })
277
278
279

Legend:
 Removed from v.1174 changed lines Added in v.1189