You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by lx...@apache.org on 2017/07/07 15:58:46 UTC

[33/50] [abbrv] incubator-mxnet-test git commit: [R] fix the operations between MXSymbol and scalar. close #4994 (#6758)

[R] fix the operations between MXSymbol and scalar. close #4994 (#6758)



Project: http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/commit/2e9943b2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/tree/2e9943b2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/diff/2e9943b2

Branch: refs/heads/master
Commit: 2e9943b20f772acfe87ed38f22731c892deb0035
Parents: c8289d1
Author: Qiang Kou (KK) <qk...@qkou.info>
Authored: Mon Jul 3 08:33:24 2017 -0700
Committer: GitHub <no...@github.com>
Committed: Mon Jul 3 08:33:24 2017 -0700

----------------------------------------------------------------------
 R-package/R/symbol.R | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/blob/2e9943b2/R-package/R/symbol.R
----------------------------------------------------------------------
diff --git a/R-package/R/symbol.R b/R-package/R/symbol.R
index f222c55..541cce4 100644
--- a/R-package/R/symbol.R
+++ b/R-package/R/symbol.R
@@ -176,34 +176,61 @@ init.symbol.methods <- function() {
   setMethod("+", signature(e1 = "Rcpp_MXSymbol", e2 = "numeric"), function(e1, e2) {
     mx.varg.symbol.internal.PlusScalar(list(e1, scalar = e2))
   })
+  setMethod("+", signature(e1 = "numeric", e2 = "Rcpp_MXSymbol"), function(e1, e2) {
+    mx.varg.symbol.internal.PlusScalar(list(e2, scalar = e1))
+  })  
   setMethod("-", signature(e1 = "Rcpp_MXSymbol", e2 = "Rcpp_MXSymbol"), function(e1, e2) {
     mx.varg.symbol.internal.Minus(list(e1, e2))
   })
   setMethod("-", signature(e1 = "Rcpp_MXSymbol", e2 = "numeric"), function(e1, e2) {
     mx.varg.symbol.internal.MinusScalar(list(e1, scalar = e2))
   })
+  setMethod("-", signature(e1 = "numeric", e2 = "Rcpp_MXSymbol"), function(e1, e2) {
+    mx.varg.symbol.internal.rminus_scalar(list(e2, scalar = e1))
+  })  
   setMethod("*", signature(e1 = "Rcpp_MXSymbol", e2 = "Rcpp_MXSymbol"), function(e1, e2) {
     mx.varg.symbol.internal.Mul(list(e1, e2))
   })
   setMethod("*", signature(e1 = "Rcpp_MXSymbol", e2 = "numeric"), function(e1, e2) {
     mx.varg.symbol.internal.MulScalar(list(e1, scalar = e2))
   })
+  setMethod("*", signature(e1 = "numeric", e2 = "Rcpp_MXSymbol"), function(e1, e2) {
+    mx.varg.symbol.internal.MulScalar(list(e2, scalar = e1))
+  })  
   setMethod("/", signature(e1 = "Rcpp_MXSymbol", e2 = "Rcpp_MXSymbol"), function(e1, e2) {
     mx.varg.symbol.internal.Div(list(e1, e2))
   })
   setMethod("/", signature(e1 = "Rcpp_MXSymbol", e2 = "numeric"), function(e1, e2) {
     mx.varg.symbol.internal.DivScalar(list(e1, scalar = e2))
   })
+  setMethod("/", signature(e1 = "numeric", e2 = "Rcpp_MXSymbol"), function(e1, e2) {
+    mx.varg.symbol.internal.rdiv_scalar(list(e2, scalar = e1))
+  })  
   setMethod("%%", signature(e1 = "Rcpp_MXSymbol", e2 = "Rcpp_MXSymbol"), function(e1, e2) {
     mx.varg.symbol.internal.Mod(list(e1, e2))
   })
   setMethod("%%", signature(e1 = "Rcpp_MXSymbol", e2 = "numeric"), function(e1, e2) {
     mx.varg.symbol.internal.ModScalar(list(e1, scalar = e2))
   })
+  setMethod("%%", signature(e1 = "numeric", e2 = "Rcpp_MXSymbol"), function(e1, e2) {
+    mx.varg.symbol.internal.RModScalar(list(e2, scalar = e1))
+  })  
   setMethod("%/%", signature(e1 = "Rcpp_MXSymbol", e2 = "Rcpp_MXSymbol"), function(e1, e2) {
     mx.varg.symbol.internal.Mod(list(e1, e2))
   })
   setMethod("%/%", signature(e1 = "Rcpp_MXSymbol", e2 = "numeric"), function(e1, e2) {
     mx.varg.symbol.internal.ModScalar(list(e1, scalar = e2))
   })
+  setMethod("%/%", signature(e1 = "numeric", e2 = "Rcpp_MXSymbol"), function(e1, e2) {
+    mx.varg.symbol.internal.RModScalar(list(e2, scalar = e1))
+  })
+  setMethod("^", signature(e1 = "Rcpp_MXSymbol", e2 = "Rcpp_MXSymbol"), function(e1, e2) {
+    mx.varg.symbol.internal.power(list(e1, e2))
+  })
+  setMethod("^", signature(e1 = "Rcpp_MXSymbol", e2 = "numeric"), function(e1, e2) {
+    mx.varg.symbol.internal.power_scalar(list(e1, scalar = e2))
+  })
+  setMethod("^", signature(e1 = "numeric", e2 = "Rcpp_MXSymbol"), function(e1, e2) {
+    mx.varg.symbol.internal.rpower_scalar(list(e2, scalar = e1))
+  })
 }