97 |
setMethod("solve", signature(a = "Matrix", b = "numeric"), |
setMethod("solve", signature(a = "Matrix", b = "numeric"), |
98 |
function(a, b, ...) callGeneric(a, as.matrix(b))) |
function(a, b, ...) callGeneric(a, as.matrix(b))) |
99 |
|
|
100 |
## Subsetting : The "missing" cases can be dealt with here, "at the top": |
### -------------------------------------------------------------------------- |
101 |
|
### |
102 |
|
### Subsetting "[" and |
103 |
|
### SubAssign "[<-" : The "missing" cases can be dealt with here, "at the top": |
104 |
|
|
105 |
## "x[]": |
## "x[]": |
106 |
setMethod("[", signature(x = "Matrix", |
setMethod("[", signature(x = "Matrix", |
107 |
i = "missing", j = "missing", drop = "ANY"), |
i = "missing", j = "missing", drop = "ANY"), |
108 |
function (x, i, j, drop) x) |
function (x, i, j, drop) x) |
|
|
|
109 |
## missing 'drop' --> 'drop = TRUE' |
## missing 'drop' --> 'drop = TRUE' |
110 |
## ----------- |
## ----------- |
111 |
## select rows |
## select rows |
120 |
drop = "missing"), |
drop = "missing"), |
121 |
function(x,i,j, drop) callGeneric(x, i=i, j=j, drop= TRUE)) |
function(x,i,j, drop) callGeneric(x, i=i, j=j, drop= TRUE)) |
122 |
|
|
|
|
|
123 |
## "FIXME:" |
## "FIXME:" |
124 |
## How can we get at A[ ij ] where ij is (i,j) 2-column matrix? |
## How can we get at A[ ij ] where ij is (i,j) 2-column matrix? |
125 |
## and A[ LL ] where LL is a logical *vector* |
## and A[ LL ] where LL is a logical *vector* |
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
### "[<-" : ----------------- |
130 |
|
|
131 |
|
## x[] <- value : |
132 |
|
setReplaceMethod("[", signature(x = "Matrix", i = "missing", j = "missing", |
133 |
|
value = "vector"),## double/logical/... |
134 |
|
function (x, value) { x@x <- value ; validObject(x); x }) |
135 |
|
|
136 |
|
## Otherwise (value is not "vector"): bail out |
137 |
|
setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY", |
138 |
|
value = "ANY"), |
139 |
|
function (x, i, j, value) stop("RHS 'value' must be of class \"vector\"")) |
140 |
|
|
141 |
|
|
142 |
|
|
143 |
if(FALSE) ## The following can't work as long as cbind is function(..., *) |
if(FALSE) ## The following can't work as long as cbind is function(..., *) |
144 |
setMethod("cbind", signature(a = "Matrix", b = "Matrix"), |
setMethod("cbind", signature(a = "Matrix", b = "Matrix"), |
148 |
if(da[1] != db[1]) |
if(da[1] != db[1]) |
149 |
stop("Matrices must have same number of rows for cbind()ing") |
stop("Matrices must have same number of rows for cbind()ing") |
150 |
}) |
}) |
|
|
|
|
|
|
|
|
|