SCM

SCM Repository

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

Diff of /pkg/R/dgeMatrix.R

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

revision 1279, Tue May 23 08:01:11 2006 UTC revision 1280, Tue May 23 08:01:44 2006 UTC
# Line 123  Line 123 
123    
124  setMethod("norm", signature(x = "dgeMatrix", type = "character"),  setMethod("norm", signature(x = "dgeMatrix", type = "character"),
125            function(x, type, ...)            function(x, type, ...)
126            .Call("dgeMatrix_norm", x, type, PACKAGE = "Matrix"),            .Call(dgeMatrix_norm, x, type),
127            valueClass = "numeric")            valueClass = "numeric")
128    
129  setMethod("rcond", signature(x = "dgeMatrix", type = "missing"),  setMethod("rcond", signature(x = "dgeMatrix", type = "missing"),
# Line 131  Line 131 
131    
132  setMethod("rcond", signature(x = "dgeMatrix", type = "character"),  setMethod("rcond", signature(x = "dgeMatrix", type = "character"),
133            function(x, type, ...)            function(x, type, ...)
134            .Call("dgeMatrix_rcond", x, type, PACKAGE = "Matrix"),            .Call(dgeMatrix_rcond, x, type),
135            valueClass = "numeric")            valueClass = "numeric")
136    
137  setMethod("t", signature(x = "dgeMatrix"), t_geMatrix)  setMethod("t", signature(x = "dgeMatrix"), t_geMatrix)
138    
139  ## crossprod(x) & tcrossprod(x) :  ## crossprod(x) & tcrossprod(x) :
140  setMethod("crossprod", signature(x = "dgeMatrix", y = "missing"),  setMethod("crossprod", signature(x = "dgeMatrix", y = "missing"),
141            function(x, y = NULL) .Call("dgeMatrix_crossprod", x, FALSE, PACKAGE = "Matrix"),            function(x, y = NULL) .Call(dgeMatrix_crossprod, x, FALSE),
142            valueClass = "dpoMatrix")            valueClass = "dpoMatrix")
143    
144  setMethod("tcrossprod", signature(x = "dgeMatrix", y = "missing"),  setMethod("tcrossprod", signature(x = "dgeMatrix", y = "missing"),
145            function(x, y = NULL) .Call("dgeMatrix_crossprod", x, TRUE, PACKAGE = "Matrix"),            function(x, y = NULL) .Call(dgeMatrix_crossprod, x, TRUE),
146            valueClass = "dpoMatrix")            valueClass = "dpoMatrix")
147  setMethod("tcrossprod", signature(x = "matrix", y = "missing"),  setMethod("tcrossprod", signature(x = "matrix", y = "missing"),
148            function(x, y = NULL) .Call("dgeMatrix_crossprod", as(x, "dgeMatrix"), TRUE, PACKAGE = "Matrix"),            function(x, y = NULL) .Call(dgeMatrix_crossprod, as(x, "dgeMatrix"), TRUE),
149            valueClass = "dpoMatrix")            valueClass = "dpoMatrix")
150  setMethod("tcrossprod", signature(x = "numeric", y = "missing"),  setMethod("tcrossprod", signature(x = "numeric", y = "missing"),
151            function(x, y = NULL) callGeneric(as.matrix(as.double(x))))            function(x, y = NULL) callGeneric(as.matrix(as.double(x))))
152    
153  ## crossprod (x,y)  ## crossprod (x,y)
154  setMethod("crossprod", signature(x = "dgeMatrix", y = "dgeMatrix"),  setMethod("crossprod", signature(x = "dgeMatrix", y = "dgeMatrix"),
155            function(x, y = NULL) .Call("dgeMatrix_dgeMatrix_crossprod", x, y, FALSE, PACKAGE = "Matrix"),            function(x, y = NULL) .Call(dgeMatrix_dgeMatrix_crossprod, x, y, FALSE),
156            valueClass = "dgeMatrix")            valueClass = "dgeMatrix")
157    
158  setMethod("crossprod", signature(x = "dgeMatrix", y = "matrix"),  setMethod("crossprod", signature(x = "dgeMatrix", y = "matrix"),
159            function(x, y = NULL) .Call("dgeMatrix_matrix_crossprod", x, y, FALSE, PACKAGE = "Matrix"),            function(x, y = NULL) .Call(dgeMatrix_matrix_crossprod, x, y, FALSE),
160            valueClass = "dgeMatrix")            valueClass = "dgeMatrix")
161  setMethod("crossprod", signature(x = "dgeMatrix", y = "numeric"),  setMethod("crossprod", signature(x = "dgeMatrix", y = "numeric"),
162            function(x, y = NULL)            function(x, y = NULL)
163            .Call("dgeMatrix_matrix_crossprod", x, as.matrix(as.double(y)), FALSE, PACKAGE = "Matrix"),            .Call(dgeMatrix_matrix_crossprod, x, as.matrix(as.double(y)), FALSE),
164            valueClass = "dgeMatrix")            valueClass = "dgeMatrix")
165  setMethod("crossprod", signature(x = "matrix", y = "dgeMatrix"),  setMethod("crossprod", signature(x = "matrix", y = "dgeMatrix"),
166            function(x, y = NULL) callGeneric(as(x, "dgeMatrix"), y),            function(x, y = NULL) callGeneric(as(x, "dgeMatrix"), y),
# Line 171  Line 171 
171    
172  ## tcrossprod (x,y)  ## tcrossprod (x,y)
173  setMethod("tcrossprod", signature(x = "dgeMatrix", y = "dgeMatrix"),  setMethod("tcrossprod", signature(x = "dgeMatrix", y = "dgeMatrix"),
174            function(x, y = NULL) .Call("dgeMatrix_dgeMatrix_crossprod", x, y, TRUE, PACKAGE = "Matrix"),            function(x, y = NULL) .Call(dgeMatrix_dgeMatrix_crossprod, x, y, TRUE),
175            valueClass = "dgeMatrix")            valueClass = "dgeMatrix")
176    
177  setMethod("tcrossprod", signature(x = "dgeMatrix", y = "matrix"),  setMethod("tcrossprod", signature(x = "dgeMatrix", y = "matrix"),
178            function(x, y = NULL) .Call("dgeMatrix_matrix_crossprod", x, y, TRUE, PACKAGE = "Matrix"),            function(x, y = NULL) .Call(dgeMatrix_matrix_crossprod, x, y, TRUE),
179            valueClass = "dgeMatrix")            valueClass = "dgeMatrix")
180  setMethod("tcrossprod", signature(x = "dgeMatrix", y = "numeric"),  setMethod("tcrossprod", signature(x = "dgeMatrix", y = "numeric"),
181            function(x, y = NULL)            function(x, y = NULL)
182            .Call("dgeMatrix_matrix_crossprod", x, as.matrix(as.double(y)), TRUE, PACKAGE = "Matrix"),            .Call(dgeMatrix_matrix_crossprod, x, as.matrix(as.double(y)), TRUE),
183            valueClass = "dgeMatrix")            valueClass = "dgeMatrix")
184  setMethod("tcrossprod", signature(x = "matrix", y = "dgeMatrix"),  setMethod("tcrossprod", signature(x = "matrix", y = "dgeMatrix"),
185            function(x, y = NULL) callGeneric(as(x, "dgeMatrix"), y),            function(x, y = NULL) callGeneric(as(x, "dgeMatrix"), y),
# Line 191  Line 191 
191    
192  setMethod("%*%", signature(x = "dgeMatrix", y = "dgeMatrix"),  setMethod("%*%", signature(x = "dgeMatrix", y = "dgeMatrix"),
193            function(x, y)            function(x, y)
194            .Call("dgeMatrix_matrix_mm", x, y, TRUE, FALSE, PACKAGE = "Matrix"),            .Call(dgeMatrix_matrix_mm, x, y, TRUE, FALSE),
195            valueClass = "dgeMatrix")            valueClass = "dgeMatrix")
196    
197  ## dgeMatrix <-> matrix ("matrix" dispatches before "numeric" since R 2.1.0)  ## dgeMatrix <-> matrix ("matrix" dispatches before "numeric" since R 2.1.0)
198  setMethod("%*%", signature(x = "dgeMatrix", y = "matrix"),  setMethod("%*%", signature(x = "dgeMatrix", y = "matrix"),
199            function(x, y) {            function(x, y) {
200                storage.mode(y) <- "double"                storage.mode(y) <- "double"
201                .Call("dgeMatrix_matrix_mm", x, y, FALSE, FALSE, PACKAGE = "Matrix")                .Call(dgeMatrix_matrix_mm, x, y, FALSE, FALSE)
202            }, valueClass = "dgeMatrix")            }, valueClass = "dgeMatrix")
203    
204    
205  setMethod("%*%", signature(x = "matrix", y = "dgeMatrix"),  setMethod("%*%", signature(x = "matrix", y = "dgeMatrix"),
206            function(x, y) {            function(x, y) {
207                storage.mode(x) <- "double"                storage.mode(x) <- "double"
208                .Call("dgeMatrix_matrix_mm", y, x, FALSE, TRUE, PACKAGE = "Matrix")                .Call(dgeMatrix_matrix_mm, y, x, FALSE, TRUE)
209            }, valueClass = "dgeMatrix")            }, valueClass = "dgeMatrix")
210    
211  ## dgeMatrix <-> numeric: conceptually dispatch to "matrix" one, but shortcut  ## dgeMatrix <-> numeric: conceptually dispatch to "matrix" one, but shortcut
212  setMethod("%*%", signature(x = "dgeMatrix", y = "numeric"),  setMethod("%*%", signature(x = "dgeMatrix", y = "numeric"),
213            function(x, y)            function(x, y)
214            .Call("dgeMatrix_matrix_mm", x, as.matrix(as.double(y)), FALSE, FALSE, PACKAGE = "Matrix"),            .Call(dgeMatrix_matrix_mm, x, as.matrix(as.double(y)), FALSE, FALSE),
215            valueClass = "dgeMatrix")            valueClass = "dgeMatrix")
216  setMethod("%*%", signature(x = "numeric", y = "dgeMatrix"),  setMethod("%*%", signature(x = "numeric", y = "dgeMatrix"),
217            function(x, y)            function(x, y)
218            .Call("dgeMatrix_matrix_mm", y, rbind(as.double(x)), FALSE, TRUE, PACKAGE = "Matrix"),            .Call(dgeMatrix_matrix_mm, y, rbind(as.double(x)), FALSE, TRUE),
219            valueClass = "dgeMatrix")            valueClass = "dgeMatrix")
220    
221  setMethod("diag", signature(x = "dgeMatrix"),  setMethod("diag", signature(x = "dgeMatrix"),
222            function(x = 1, nrow, ncol = n)            function(x = 1, nrow, ncol = n)
223            .Call("dgeMatrix_getDiag", x, PACKAGE = "Matrix"))            .Call(dgeMatrix_getDiag, x))
224    
225    
226  ## DB - I don't think this is a good idea without first checking symmetry  ## DB - I don't think this is a good idea without first checking symmetry
# Line 229  Line 229 
229    
230  setMethod("solve", signature(a = "dgeMatrix", b = "missing"),  setMethod("solve", signature(a = "dgeMatrix", b = "missing"),
231            function(a, b, ...)            function(a, b, ...)
232            .Call("dgeMatrix_solve", a, PACKAGE = "Matrix"),            .Call(dgeMatrix_solve, a),
233            valueClass = "dgeMatrix")            valueClass = "dgeMatrix")
234    
235  setMethod("solve", signature(a = "dgeMatrix", b = "dgeMatrix"),  setMethod("solve", signature(a = "dgeMatrix", b = "dgeMatrix"),
236            function(a, b, ...)            function(a, b, ...)
237            .Call("dgeMatrix_matrix_solve", a, b, TRUE, PACKAGE = "Matrix"),            .Call(dgeMatrix_matrix_solve, a, b, TRUE),
238            valueClass = "dgeMatrix")            valueClass = "dgeMatrix")
239    
240  setMethod("solve", signature(a = "dgeMatrix", b = "matrix"),  setMethod("solve", signature(a = "dgeMatrix", b = "matrix"),
241            function(a, b, ...) {            function(a, b, ...) {
242                storage.mode(b) <- "double"                storage.mode(b) <- "double"
243                .Call("dgeMatrix_matrix_solve", a, b, FALSE, PACKAGE = "Matrix")                .Call(dgeMatrix_matrix_solve, a, b, FALSE)
244            }, valueClass = "dgeMatrix")            }, valueClass = "dgeMatrix")
245    
246  setMethod("solve", signature(a = "dgeMatrix", b = "numeric"),  setMethod("solve", signature(a = "dgeMatrix", b = "numeric"),
247            function(a, b, ...)            function(a, b, ...)
248            .Call("dgeMatrix_matrix_solve", a, as.matrix(as.double(b)), FALSE, PACKAGE = "Matrix"))            .Call(dgeMatrix_matrix_solve, a, as.matrix(as.double(b)), FALSE))
249    
250  setMethod("lu", signature(x = "dgeMatrix"),  setMethod("lu", signature(x = "dgeMatrix"),
251            function(x, ...) .Call("dgeMatrix_LU", x, PACKAGE = "Matrix"),            function(x, ...) .Call(dgeMatrix_LU, x),
252            valueClass = "LU")            valueClass = "LU")
253    
254  setMethod("determinant", signature(x = "dgeMatrix", logarithm = "missing"),  setMethod("determinant", signature(x = "dgeMatrix", logarithm = "missing"),
255            function(x, logarithm, ...)            function(x, logarithm, ...)
256            .Call("dgeMatrix_determinant", x, TRUE, PACKAGE = "Matrix"))            .Call(dgeMatrix_determinant, x, TRUE))
257    
258  setMethod("determinant", signature(x = "dgeMatrix", logarithm = "logical"),  setMethod("determinant", signature(x = "dgeMatrix", logarithm = "logical"),
259            function(x, logarithm, ...)            function(x, logarithm, ...)
260            .Call("dgeMatrix_determinant", x, logarithm, PACKAGE = "Matrix"))            .Call(dgeMatrix_determinant, x, logarithm))
261    
262    
263  setMethod("expm", signature(x = "dgeMatrix"),  setMethod("expm", signature(x = "dgeMatrix"),
264            function(x) .Call("dgeMatrix_exp", x, PACKAGE = "Matrix"),            function(x) .Call(dgeMatrix_exp, x),
265            valueClass = "dgeMatrix")            valueClass = "dgeMatrix")
266    
267  setMethod("colSums", signature(x = "dgeMatrix"),  setMethod("colSums", signature(x = "dgeMatrix"),
268            function(x, na.rm = FALSE, dims = 1)            function(x, na.rm = FALSE, dims = 1)
269            .Call("dgeMatrix_colsums", x, na.rm, TRUE, FALSE, PACKAGE = "Matrix"),            .Call(dgeMatrix_colsums, x, na.rm, TRUE, FALSE),
270            valueClass = "numeric")            valueClass = "numeric")
271    
272  setMethod("colMeans", signature(x = "dgeMatrix"),  setMethod("colMeans", signature(x = "dgeMatrix"),
273            function(x, na.rm = FALSE, dims = 1)            function(x, na.rm = FALSE, dims = 1)
274            .Call("dgeMatrix_colsums", x, na.rm, TRUE, TRUE, PACKAGE = "Matrix"),            .Call(dgeMatrix_colsums, x, na.rm, TRUE, TRUE),
275            valueClass = "numeric")            valueClass = "numeric")
276    
277  setMethod("rowSums", signature(x = "dgeMatrix"),  setMethod("rowSums", signature(x = "dgeMatrix"),
278            function(x, na.rm = FALSE, dims = 1)            function(x, na.rm = FALSE, dims = 1)
279            .Call("dgeMatrix_colsums", x, na.rm, FALSE, FALSE, PACKAGE = "Matrix"),            .Call(dgeMatrix_colsums, x, na.rm, FALSE, FALSE),
280            valueClass = "numeric")            valueClass = "numeric")
281    
282  setMethod("rowMeans", signature(x = "dgeMatrix"),  setMethod("rowMeans", signature(x = "dgeMatrix"),
283            function(x, na.rm = FALSE, dims = 1)            function(x, na.rm = FALSE, dims = 1)
284            .Call("dgeMatrix_colsums", x, na.rm, FALSE, TRUE, PACKAGE = "Matrix"),            .Call(dgeMatrix_colsums, x, na.rm, FALSE, TRUE),
285            valueClass = "numeric")            valueClass = "numeric")
286    
287  ### The following all serve for  as.Matrix()  ### The following all serve for  as.Matrix()

Legend:
Removed from v.1279  
changed lines
  Added in v.1280

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge