SCM

SCM Repository

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

Diff of /pkg/R/ldenseMatrix.R

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

revision 1547, Mon Sep 11 14:49:39 2006 UTC revision 1548, Mon Sep 11 22:13:07 2006 UTC
# Line 10  Line 10 
10  setAs("ltrMatrix", "dtrMatrix", l2d_Matrix)  setAs("ltrMatrix", "dtrMatrix", l2d_Matrix)
11  setAs("ltpMatrix", "dtpMatrix", l2d_Matrix)  setAs("ltpMatrix", "dtpMatrix", l2d_Matrix)
12    
13    ### NOTA BENE: Much of this is *very* parallel to ./ndenseMatrix.R
14    ###                                               ~~~~~~~~~~~~~~~~
15    
16  ## all need be coercable to "lgeMatrix":  ## all need be coercable to "lgeMatrix":
17    
18  setAs("lsyMatrix", "lgeMatrix",  function(from)  setAs("lsyMatrix", "lgeMatrix",  function(from)
19        .Call(lsyMatrix_as_lgeMatrix, from))        .Call(lsyMatrix_as_lgeMatrix, from, 0:0))
20  setAs("ltrMatrix", "lgeMatrix",  function(from)  setAs("ltrMatrix", "lgeMatrix",  function(from)
21        .Call(ltrMatrix_as_lgeMatrix, from))        .Call(ltrMatrix_as_lgeMatrix, from, 0:0))
22  setAs("ltpMatrix", "lgeMatrix",  setAs("ltpMatrix", "lgeMatrix",
23        function(from) as(as(from, "ltrMatrix"), "lgeMatrix"))        function(from) as(as(from, "ltrMatrix"), "lgeMatrix"))
24  setAs("lspMatrix", "lgeMatrix",  setAs("lspMatrix", "lgeMatrix",
# Line 31  Line 34 
34    
35  setAs("lspMatrix", "lsyMatrix",  setAs("lspMatrix", "lsyMatrix",
36        function(from)        function(from)
37        .Call(lspMatrix_as_lsyMatrix, from))        .Call(lspMatrix_as_lsyMatrix, from, 0:0))
38    
39  setAs("lsyMatrix", "lspMatrix",  setAs("lsyMatrix", "lspMatrix",
40        function(from)        function(from)
41        .Call(lsyMatrix_as_lspMatrix, from))        .Call(lsyMatrix_as_lspMatrix, from, 0:0))
42    
43  setAs("ltpMatrix", "ltrMatrix",  setAs("ltpMatrix", "ltrMatrix",
44        function(from)        function(from)
45        .Call(ltpMatrix_as_ltrMatrix, from))        .Call(ltpMatrix_as_ltrMatrix, from, 0:0))
46    
47  setAs("ltrMatrix", "ltpMatrix",  setAs("ltrMatrix", "ltpMatrix",
48        function(from)        function(from)
49        .Call(ltrMatrix_as_ltpMatrix, from))        .Call(ltrMatrix_as_ltpMatrix, from, 0:0))
50    
51    
52    
53  ### -> symmetric :  ### -> symmetric :
54    
55  if(FALSE) ## cannot easily work around R bug  -- FIXME --  if(FALSE) ## not sure if this is a good idea ... -- FIXME?
56  setIs("lgeMatrix", "lsyMatrix",  setIs("lgeMatrix", "lsyMatrix",
57  ### BUG in R: this fails, because isSymmetric() is namespace hidden and NOT found        test = function(obj) isSymmetric(obj),
58  ##B      test = function(obj) isSymmetric(obj),        replace = function(obj, value) { ## copy all slots
 ##B and this fails too:  
 ##B      test = function(obj) Matrix:::isSymmetric(obj),  
       replace = function(obj, value) {  
           ## copy all slots  
59            for(n in slotNames(obj)) slot(obj, n) <- slot(value, n)            for(n in slotNames(obj)) slot(obj, n) <- slot(value, n)
60        })        })
61    
# Line 162  Line 161 
161    
162  setMethod("!", "ltpMatrix", function(e1) !as(e1, "ltrMatrix"))  setMethod("!", "ltpMatrix", function(e1) !as(e1, "ltrMatrix"))
163    
164  ## for the other ldense* ones:  ## for the other ldense* ones
165  setMethod("!", "ldenseMatrix",  setMethod("!", "lgeMatrix",
166            function(e1) { e1@x <- !e1@x ; e1 })            function(e1) { e1@x <- !e1@x ; e1 })
167    ## FIXME : this loses symmetry "lsy" and "lsp":
168    setMethod("!", "ldenseMatrix",
169              function(e1) !as(e1, "lgeMatrix"))
170    
171    
172    setMethod("|", signature(e1="lgeMatrix", e2="lgeMatrix"),
173              function(e1,e2) {
174                  d <- dimCheck(e1, e2)
175                  e1@x <- e1@x | e2@x
176                  e1
177              })
178    setMethod("&", signature(e1="lgeMatrix", e2="lgeMatrix"),
179              function(e1,e2) {
180                  d <- dimCheck(e1, e2)
181                  e1@x <- e1@x & e2@x
182                  e1
183              })
184    
185    setMethod("|", signature(e1="ldenseMatrix", e2="ldenseMatrix"),
186              function(e1,e2) {
187                  d <- dimCheck(e1, e2)
188                  as(e1, "lgeMatrix") | as(e2, "lgeMatrix")
189              })
190    
191    setMethod("&", signature(e1="ldenseMatrix", e2="ldenseMatrix"),
192              function(e1,e2) {
193                  d <- dimCheck(e1, e2)
194                  as(e1, "lgeMatrix") & as(e2, "lgeMatrix")
195              })
196    
197    
198  setMethod("as.vector", signature(x = "ldenseMatrix", mode = "missing"),  setMethod("as.vector", signature(x = "ldenseMatrix", mode = "missing"),
199            function(x) as(x, "lgeMatrix")@x)            function(x) as(x, "lgeMatrix")@x)

Legend:
Removed from v.1547  
changed lines
  Added in v.1548

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