SCM

SCM Repository

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

Diff of /pkg/R/dtpMatrix.R

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

revision 656, Wed Mar 16 16:55:32 2005 UTC revision 657, Wed Mar 16 16:57:52 2005 UTC
# Line 8  Line 8 
8    
9  setAs("dtpMatrix", "matrix",  setAs("dtpMatrix", "matrix",
10        function(from) as(as(from, "dtrMatrix"), "matrix"))        function(from) as(as(from, "dtrMatrix"), "matrix"))
11    setAs("matrix", "dtpMatrix",
12          function(from) as(as(from, "dtrMatrix"), "dtpMatrix"))
13    
14    
15  setMethod("%*%", signature(x = "dtpMatrix", y = "dgeMatrix"),  setMethod("%*%", signature(x = "dtpMatrix", y = "dgeMatrix"),
16            function(x, y) .Call("dtpMatrix_dgeMatrix_mm", x, y))            function(x, y) .Call("dtpMatrix_dgeMatrix_mm", x, y))
17  setMethod("%*%", signature(x = "dgeMatrix", y = "dtpMatrix"),  setMethod("%*%", signature(x = "dgeMatrix", y = "dtpMatrix"),
18            function(x, y) .Call("dgeMatrix_dtpMatrix_mm", x, y))            function(x, y) .Call("dgeMatrix_dtpMatrix_mm", x, y))
19  ## "matrix"  ## %*% should always work for  <fooMatrix> %*% <fooMatrix>
20    setMethod("%*%", signature(x = "dtpMatrix", y = "dtpMatrix"),
21              function(x, y)
22              ## FIXME: this is cheap; could we optimize chosing the better of
23              ## callGeneric(x, as(y, "dgeMatrix"))  and
24              ## callGeneric(as(x "dgeMatrix"), y))  depending on their 'uplo' ?
25              callGeneric(x, as(y, "dgeMatrix")))
26    
27    ## dtpMatrix <-> matrix : will be used by the "numeric" one
28  setMethod("%*%", signature(x = "dtpMatrix", y = "matrix"),  setMethod("%*%", signature(x = "dtpMatrix", y = "matrix"),
29            function(x, y) .Call("dtpMatrix_matrix_mm", x, y))# result = "matrix"            function(x, y) callGeneric(x, as(y, "dgeMatrix")))
30  setMethod("%*%", signature(x = "matrix", y = "dtpMatrix"),  setMethod("%*%", signature(x = "matrix", y = "dtpMatrix"),
31            function(x, y) callGeneric(as(x,"dgeMatrix"), y))# result: "dgeMatrix"            function(x, y) callGeneric(as(x, "dgeMatrix"), y))
32    
33    ## dtpMatrix <-> numeric : the auxiliary functions are R version specific!
34    setMethod("%*%", signature(x = "dtpMatrix", y = "numeric"), .M.v)
35    setMethod("%*%", signature(x = "numeric", y = "dtpMatrix"), .v.M)
36    
 ## "numeric" (same as "dgeMatrix")  
 setMethod("%*%", signature(x = "dtpMatrix", y = "numeric"), .M.n)  
 setMethod("%*%", signature(x = "numeric", y = "dtpMatrix"), .n.M)  
37    
38  setMethod("determinant", signature(x = "dtpMatrix", logarithm = "missing"),  setMethod("determinant", signature(x = "dtpMatrix", logarithm = "missing"),
39            function(x, logarithm, ...) determinant(x, TRUE))            function(x, logarithm, ...) determinant(x, TRUE))
40    
 setMethod("diag", signature(x = "dtpMatrix"),  
           function(x = 1, nrow, ncol = n) .Call("dtpMatrix_getDiag", x),  
           valueClass = "numeric")  
   
41  setMethod("determinant", signature(x = "dtpMatrix", logarithm = "logical"),  setMethod("determinant", signature(x = "dtpMatrix", logarithm = "logical"),
42            function(x, logarithm, ...) {            function(x, logarithm, ...) {
43                dg <- diag(x)                dg <- diag(x)
# Line 48  Line 55 
55                val                val
56            })            })
57    
58    setMethod("diag", signature(x = "dtpMatrix"),
59              function(x = 1, nrow, ncol = n) .Call("dtpMatrix_getDiag", x),
60              valueClass = "numeric")
61    
62  setMethod("norm", signature(x = "dtpMatrix", type = "character"),  setMethod("norm", signature(x = "dtpMatrix", type = "character"),
63            function(x, type, ...)            function(x, type, ...)
64            .Call("dtpMatrix_norm", x, type),            .Call("dtpMatrix_norm", x, type),

Legend:
Removed from v.656  
changed lines
  Added in v.657

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