SCM

SCM Repository

[bigmemory] Diff of /pkg/bigalgebra/R/methods.R
ViewVC logotype

Diff of /pkg/bigalgebra/R/methods.R

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

revision 421, Tue Dec 11 05:18:32 2012 UTC revision 422, Wed Dec 26 23:03:04 2012 UTC
# Line 1  Line 1 
1  setMethod("%*%",signature(x="big.matrix", y="big.matrix"),  setMethod("%*%",signature(x="big.matrix", y="big.matrix"),
2    function(x,y) dgemm(A=x, B=y),    function(x,y)
3      {
4        dgemm(A=x, B=y)
5      },
6    valueClass="big.matrix"    valueClass="big.matrix"
7  )  )
8    
# Line 7  Line 10 
10    function(x,y)    function(x,y)
11    {    {
12      if(dim(x)[2] != dim(y)[1]) stop("non-conformant matrices")      if(dim(x)[2] != dim(y)[1]) stop("non-conformant matrices")
13      R = options("bigalgebra.mixed_airthmetic_returns_R_matrix")[[1]]      R = options("bigalgebra.mixed_arithmetic_returns_R_matrix")[[1]]
14      if(!is.null(R) && R) return(dgemm(A=x, B=y, C=0))      if(!is.null(R) && R) return(dgemm(A=x, B=y, C=0.0))
15      dgemm(A=x, B=y)      dgemm(A=x, B=y)
16    },    },
17    valueClass="matrix"    valueClass="matrix"
# Line 18  Line 21 
21    function(x,y)    function(x,y)
22    {    {
23      if(dim(x)[2] != dim(y)[1]) stop("non-conformant matrices")      if(dim(x)[2] != dim(y)[1]) stop("non-conformant matrices")
24      R = options("bigalgebra.mixed_airthmetic_returns_R_matrix")[[1]]      R = options("bigalgebra.mixed_arithmetic_returns_R_matrix")[[1]]
25      if(!is.null(R) && R) return(dgemm(A=x, B=y, C=0))      if(!is.null(R) && R) return(dgemm(A=x, B=y, C=0.0))
26      dgemm(A=x, B=y)      dgemm(A=x, B=y)
27    },    },
28    valueClass="matrix"    valueClass="matrix"
29  )  )
30    
31    setMethod("Arith",c(e1="big.matrix", e2="big.matrix"),
32      function(e1,e2)
33      {
34        op = .Generic[[1]]
35        switch(op,
36          `+` = daxpy(1.0,e1,e2),
37          `-` = daxpy(-1.0,e2,e1),
38          stop("Undefined operation")
39        )
40      }
41    )
42    setMethod("Arith",c(e1="big.matrix", e2="matrix"),
43      function(e1,e2)
44      {
45        op = .Generic[[1]]
46        switch(op,
47          `+` = daxpy(1.0,e1,e2),
48          `-` = daxpy(-1.0,e2,e1),
49          stop("Undefined operation")
50        )
51      }
52    )
53    setMethod("Arith",c(e1="matrix", e2="big.matrix"),
54      function(e1,e2)
55      {
56        op = .Generic[[1]]
57        switch(op,
58          `+` = daxpy(1.0,e1,e2),
59          `-` = daxpy(-1.0,e2,e1),
60          stop("Undefined operation")
61        )
62      }
63    )
64    setMethod("Arith",c(e1="numeric", e2="big.matrix"),
65      function(e1,e2)
66      {
67        op = .Generic[[1]]
68        if(length(e1)==1 && op=="*") return(daxpy(e1,e2))
69        switch(op,
70          `+` = daxpy(1.0,e1,e2),
71          `-` = daxpy(-1.0,e2,e1),
72          stop("Undefined operation")
73        )
74      }
75    )
76    setMethod("Arith",c(e1="big.matrix", e2="numeric"),
77      function(e1,e2)
78      {
79        op = .Generic[[1]]
80        if(length(e2)==1 && op=="*") return(daxpy(e2,e1))
81        switch(op,
82          `+` = daxpy(1.0,e1,e2),
83          `-` = daxpy(-1.0,e2,e1),
84          stop("Undefined operation")
85        )
86      }
87    )

Legend:
Removed from v.421  
changed lines
  Added in v.422

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