SCM

SCM Repository

[matrix] Diff of /pkg/Matrix/R/ddenseMatrix.R
ViewVC logotype

Diff of /pkg/Matrix/R/ddenseMatrix.R

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

revision 946, Wed Sep 28 08:56:42 2005 UTC revision 1447, Fri Aug 25 20:38:36 2006 UTC
# Line 1  Line 1 
1  ### Define Methods that can be inherited for all subclasses  ### Define Methods that can be inherited for all subclasses
2    
3    ## This replaces many "d..Matrix" -> "dgeMatrix" ones
4    ## >> but << needs all sub(sub(sub)) classes of "ddenseMatrix" listed
5    ##   -----  in  ../src/Mutils.c
6    setAs("ddenseMatrix", "dgeMatrix",
7          function(from) .Call(dup_mMatrix_as_dgeMatrix, from))
8    
9    ## d(ouble) to l(ogical):
10    setAs("dgeMatrix", "lgeMatrix", d2l_Matrix)
11    setAs("dtrMatrix", "ltrMatrix", d2l_Matrix)
12    setAs("dtpMatrix", "ltpMatrix", d2l_Matrix)
13    setAs("dsyMatrix", "lsyMatrix", d2l_Matrix)
14    setAs("dspMatrix", "lspMatrix", d2l_Matrix)
15    
16    setMethod("as.numeric", signature(x = "ddenseMatrix"),
17              function(x, ...) as(x, "dgeMatrix")@x)
18    
19  ## -- see also ./Matrix.R  e.g., for a show() method  ## -- see also ./Matrix.R  e.g., for a show() method
20    
21  ## These methods are the 'fallback' methods for all dense numeric  ## These methods are the 'fallback' methods for all dense numeric
# Line 22  Line 38 
38  ## setMethod("t", signature(x = "ddenseMatrix"),  ## setMethod("t", signature(x = "ddenseMatrix"),
39  ##        function(x) callGeneric(as(x, "dgeMatrix")))  ##        function(x) callGeneric(as(x, "dgeMatrix")))
40    
41  setMethod("tcrossprod", signature(x = "ddenseMatrix"),  setMethod("tcrossprod", signature(x = "ddenseMatrix", y = "missing"),
42            function(x) callGeneric(as(x, "dgeMatrix")))            function(x, y = NULL) callGeneric(as(x, "dgeMatrix")))
43    
44  setMethod("crossprod", signature(x = "ddenseMatrix", y = "missing"),  setMethod("crossprod", signature(x = "ddenseMatrix", y = "missing"),
45            function(x, y = NULL) callGeneric(as(x, "dgeMatrix")))            function(x, y = NULL) callGeneric(as(x, "dgeMatrix")))
# Line 47  Line 63 
63            function(x, logarithm, ...)            function(x, logarithm, ...)
64            callGeneric(as(x, "dgeMatrix"), logarithm))            callGeneric(as(x, "dgeMatrix"), logarithm))
65    
66  setMethod("expm", signature(x = "ddenseMatrix"),  ## now done for "dMatrix":
67            function(x) callGeneric(as(x, "dgeMatrix")))  ## setMethod("expm", signature(x = "ddenseMatrix"),
68    ##           function(x) callGeneric(as(x, "dgeMatrix")))
69    
70  setMethod("Schur", signature(x = "ddenseMatrix", vectors = "missing"),  setMethod("Schur", signature(x = "ddenseMatrix", vectors = "missing"),
71            function(x, vectors, ...) callGeneric(as(x, "dgeMatrix")))            function(x, vectors, ...) callGeneric(as(x, "dgeMatrix")))
# Line 57  Line 74 
74            function(x, vectors, ...) callGeneric(as(x, "dgeMatrix"), vectors))            function(x, vectors, ...) callGeneric(as(x, "dgeMatrix"), vectors))
75    
76    
77  ### NAMESPACE must export this -- also only for R version 2.2.x:  ## Cheap version: work via "dgeMatrix" and use the group methods there:
78  if(paste(R.version$major, R.version$minor, sep=".") >= "2.2") {  ## FIXME(?): try to preserve "symmetric", "triangular", ...
79      ## for R 2.2.x (and later):  setMethod("Arith", ##  "+", "-", "*", "^", "%%", "%/%", "/"
80              signature(e1 = "ddenseMatrix", e2 = "ddenseMatrix"),
81              function(e1, e2) callGeneric(as(e1, "dgeMatrix"),
82                                           as(e2, "dgeMatrix")))
83    setMethod("Arith",
84              signature(e1 = "ddenseMatrix", e2 = "numeric"),
85              function(e1, e2) callGeneric(as(e1, "dgeMatrix"), e2))
86    setMethod("Arith",
87              signature(e1 = "numeric", e2 = "ddenseMatrix"),
88              function(e1, e2) callGeneric(e1, as(e2, "dgeMatrix")))
89    
90    setMethod("Math",
91              signature(x = "ddenseMatrix"),
92              function(x) callGeneric(as(x, "dgeMatrix")))
93    
94    
95    
96    ### for R 2.2.x (and later): -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
97    
98  ### cbind2  ### cbind2
99      setMethod("cbind2", signature(x = "ddenseMatrix", y = "numeric"),      setMethod("cbind2", signature(x = "ddenseMatrix", y = "numeric"),
# Line 161  Line 195 
195                    new("dgeMatrix", Dim = c(nrx + nry, nc), Dimnames = dn,                    new("dgeMatrix", Dim = c(nrx + nry, nc), Dimnames = dn,
196                        x = c(rbind2(as(x,"matrix"), as(y,"matrix"))))                        x = c(rbind2(as(x,"matrix"), as(y,"matrix"))))
197                })                })
   
 }## R-2.2.x ff  

Legend:
Removed from v.946  
changed lines
  Added in v.1447

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