314 |
setReplaceMethod("[", signature(x = "Matrix", i = "missing", j = "missing", |
setReplaceMethod("[", signature(x = "Matrix", i = "missing", j = "missing", |
315 |
value = "ANY"),## double/logical/... |
value = "ANY"),## double/logical/... |
316 |
function (x, value) { |
function (x, value) { |
317 |
|
## Fails for 'nMatrix' ... FIXME : make sure have method there |
318 |
x@x <- value |
x@x <- value |
319 |
validObject(x)# check if type and lengths above match |
validObject(x)# check if type and lengths above match |
320 |
x |
x |
321 |
}) |
}) |
322 |
|
|
323 |
## Method for all 'Matrix' kinds (rather than incomprehensible error messages); |
setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY", |
324 |
|
value = "Matrix"), |
325 |
|
function (x, i, j, value) |
326 |
|
callGeneric(x=x, i=i, j=j, value = as.vector(value))) |
327 |
|
setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY", |
328 |
|
value = "matrix"), |
329 |
|
function (x, i, j, value) |
330 |
|
callGeneric(x=x, i=i, j=j, value = c(value))) |
331 |
|
|
332 |
## (ANY,ANY,ANY) is used when no `real method' is implemented : |
## (ANY,ANY,ANY) is used when no `real method' is implemented : |
333 |
setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY", |
setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY", |
334 |
value = "ANY"), |
value = "ANY"), |
335 |
function (x, i, j, value) { |
function (x, i, j, value) { |
336 |
if(!is.atomic(value)) |
if(!is.atomic(value)) |
337 |
stop("RHS 'value' must match matrix class ", class(x)) |
stop(sprintf("RHS 'value' (class %s) matches 'ANY', but must match matrix class %s", |
338 |
|
class(value),class(x))) |
339 |
else stop("not-yet-implemented 'Matrix[<-' method") |
else stop("not-yet-implemented 'Matrix[<-' method") |
340 |
}) |
}) |
341 |
|
|