Module: R::ExecBinOp

Included in:
Matrix, Object, RSymbol, Vector
Defined in:
lib/R_interface/rbinary_operators.rb

Overview


Module for binary operators with normal elements: matrix, vector, etc.

Instance Method Summary collapse

Instance Method Details

#coerce(numeric) ⇒ Object





52
53
54
# File 'lib/R_interface/rbinary_operators.rb', line 52

def coerce(numeric)
 [R.c(numeric), self]
end

#exec_bin_oper(operator, other_object) ⇒ Object





36
37
38
39
40
41
42
43
44
45
46
# File 'lib/R_interface/rbinary_operators.rb', line 36

def exec_bin_oper(operator, other_object)
  # Use infix notation: lhs operator rhs
  # We need to strip backticks from operator if present
  op = operator.delete("`")
  
  var_name = R::Support.generate_var_name
  rhs = R::Support.parse_arg(other_object)
  
  R.bridge.eval_r("#{var_name} <- #{@r_interop} #{op} #{rhs}")
  R::Object.build(var_name)
end