diff --git a/.configs/registration-config-multi-dim.json b/.configs/registration-config-multi-dim.json index e8e0c481d..d3ebe75a4 100644 --- a/.configs/registration-config-multi-dim.json +++ b/.configs/registration-config-multi-dim.json @@ -10,6 +10,15 @@ "bool", "bigint" ] + }, + "binop": { + "dtype": [ + "int", + "uint", + "real", + "bool", + "bigint" + ] } } } diff --git a/.configs/registration-config-single-dim.json b/.configs/registration-config-single-dim.json index 44afced3b..0975fd843 100644 --- a/.configs/registration-config-single-dim.json +++ b/.configs/registration-config-single-dim.json @@ -10,6 +10,15 @@ "bool", "bigint" ] + }, + "binop": { + "dtype": [ + "int", + "uint", + "real", + "bool", + "bigint" + ] } } } diff --git a/arkouda/pdarrayclass.py b/arkouda/pdarrayclass.py index d0d0d860a..4e8eb46b4 100644 --- a/arkouda/pdarrayclass.py +++ b/arkouda/pdarrayclass.py @@ -482,7 +482,10 @@ def format_other(self, other) -> str: fmt = NUMBER_FORMAT_STRINGS[self.dtype.name] return fmt.format(other) - def _binop_cmd_group(op: str) -> str: + def _binop_cmd_group(self, op: str) -> str: + """ + get the name of the command that implements an operator + """ if op in ["+", "-", "*", "%", "**", "//"]: op_cmd = "arithmeticOp" elif op in ["==", "!=", "<", ">", "<=", ">="]: @@ -527,8 +530,7 @@ def _binop(self, other: pdarray, op: str) -> pdarray: return NotImplemented if op not in self.BinOps: raise ValueError(f"bad operator {op}") - - op_cmd = pdarray._binop_cmd_group(op) + op_cmd = self._binop_cmd_group(op) # pdarray binop pdarray if isinstance(other, pdarray): @@ -601,9 +603,10 @@ def _r_binop(self, other: pdarray, op: str) -> pdarray: other = self.dtype.type(other) if dt not in DTypes: raise TypeError(f"Unhandled scalar type: {other} ({type(other)})") + op_cmd = self._binop_cmd_group(op) repMsg = generic_msg( - cmd=f"binopsv{self.ndim}D", - args={"op": op, "dtype": dt, "value": other, "a": self}, + cmd=f"{op_cmd}SV<{dt},{self.dtype},{self.ndim}>", + args={"op": op, "value": other, "b": self}, ) return create_pdarray(repMsg) diff --git a/src/OperatorMsg.chpl b/src/OperatorMsg.chpl index e6ae291f1..7fe7a739d 100644 --- a/src/OperatorMsg.chpl +++ b/src/OperatorMsg.chpl @@ -262,7 +262,7 @@ module OperatorMsg /* Supports the following binary operations between two arrays: - |, &, ^, <<, >> + |, &, ^, <<, >>, <<<, >>> */ @arkouda.instantiateAndRegister proc bitwiseOpVV(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab, @@ -742,7 +742,7 @@ module OperatorMsg /* Supports the following binary operations between an array and scalar - |, &, ^, <<, >> + |, &, ^, <<, >>, <<<, >>> */ @arkouda.instantiateAndRegister proc bitwiseOpVS(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab, @@ -974,717 +974,519 @@ module OperatorMsg (has_max_bits, max_size, max_bits) = getMaxBits(a); var result = a.a; - forall rx in result with (const local_val = val, const local_max_size = max_size) { rx /= local_val; - if has_max_bits then rx &= local_max_size; + if has_max_bits then rx &= local_max_size; } return st.insert(new shared SymEntry(result, max_bits)); } /* - Parse and respond to binopvs message. - vs == vector op scalar + Supports the following binary operations between an array and scalar: + +, -, *, %, **, // + */ + @arkouda.instantiateAndRegister + proc arithmeticOpSV(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab, + type binop_dtype_a, + type binop_dtype_b, + param array_nd: int + ): MsgTuple throws + where (binop_dtype_a != bool || binop_dtype_b != bool) && + binop_dtype_a != bigint && binop_dtype_b != bigint + { + const val = msgArgs['value'].toScalar(binop_dtype_a), + b = st[msgArgs['b']]: borrowed SymEntry(binop_dtype_b, array_nd), + op = msgArgs['op'].toScalar(string); - :arg reqMsg: request containing (cmd,op,aname,dtype,value) - :type reqMsg: string + type resultType = promotedType(binop_dtype_a, binop_dtype_b); + var result = makeDistArray((...b.tupShape), resultType); - :arg st: SymTab to act on - :type st: borrowed SymTab + select op { + when '+' do result = val:resultType + b.a:resultType; + when '-' do result = val:resultType - b.a:resultType; + when '*' do result = val:resultType * b.a:resultType; + when '%' { // ' + ref bb = b.a; + if isRealType(resultType) + then [(bi,ri) in zip(bb,result)] ri = modHelper(val:resultType, bi:resultType); + else [(bi,ri) in zip(bb,result)] ri = if val != 0:binop_dtype_a then val:resultType % bi:resultType else 0:resultType; + } + when '**' { + if isIntegralType(binop_dtype_b) && (|| reduce (b.a < 0)) { + return MsgTuple.error("Attempt to exponentiate integer base to negative exponent"); + } + result = val:resultType ** b.a:resultType; + } + when '//' { + ref bb = b.a; + if isRealType(resultType) + then [(bi,ri) in zip(bb,result)] ri = floorDivisionHelper(val:resultType, bi:resultType); + else [(bi,ri) in zip(bb,result)] ri = if val != 0:binop_dtype_a then (val / bi):resultType else 0:resultType; + } + otherwise return MsgTuple.error("unknown arithmetic binary operation: " + op); + } - :returns: (MsgTuple) - :throws: `UndefinedSymbolError(name)` - */ - // @arkouda.registerND - // proc binopvsMsg(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab, param nd: int): MsgTuple throws { - // param pn = Reflection.getRoutineName(); - // var repMsg: string = ""; // response message - - // const aname = msgArgs.getValueOf("a"); - // const op = msgArgs.getValueOf("op"); - // const value = msgArgs.get("value"); - - // const dtype = str2dtype(msgArgs.getValueOf("dtype")); - // var rname = st.nextName(); - // var left: borrowed GenSymEntry = getGenericTypedArrayEntry(aname, st); - - // omLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - // "op: %s dtype: %? pdarray: %? scalar: %?".format( - // op,dtype,st.attrib(aname),value.getValue())); - - // use Set; - // // This boolOps set is a filter to determine the output type for the operation. - // // All operations that involve one of these operations result in a `bool` symbol - // // table entry. - // var boolOps: set(string); - // boolOps.add("<"); - // boolOps.add("<="); - // boolOps.add(">"); - // boolOps.add(">="); - // boolOps.add("=="); - // boolOps.add("!="); - - // var realOps: set(string); - // realOps.add("+"); - // realOps.add("-"); - // realOps.add("/"); - // realOps.add("//"); - - // select (left.dtype, dtype) { - // when (DType.Int64, DType.Int64) { - // var l = toSymEntry(left,int, nd); - // var val = value.getIntValue(); - - // if boolOps.contains(op) { - // var e = st.addEntry(rname, l.tupShape, bool); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } else if op == "/" { - // // True division is the only case in this int, int case - // // that results in a `real` symbol table entry. - // var e = st.addEntry(rname, l.tupShape, real); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // var e = st.addEntry(rname, l.tupShape, int); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // when (DType.Int64, DType.Float64) { - // var l = toSymEntry(left,int, nd); - // var val = value.getRealValue(); - // // Only two possible resultant types are `bool` and `real` - // // for this case - // if boolOps.contains(op) { - // var e = st.addEntry(rname, l.tupShape, bool); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // var e = st.addEntry(rname, l.tupShape, real); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // when (DType.Float64, DType.Int64) { - // var l = toSymEntry(left,real, nd); - // var val = value.getIntValue(); - // if boolOps.contains(op) { - // var e = st.addEntry(rname, l.tupShape, bool); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // var e = st.addEntry(rname, l.tupShape, real); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // when (DType.UInt64, DType.Float64) { - // var l = toSymEntry(left,uint, nd); - // var val = value.getRealValue(); - // // Only two possible resultant types are `bool` and `real` - // // for this case - // if boolOps.contains(op) { - // var e = st.addEntry(rname, l.tupShape, bool); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // var e = st.addEntry(rname, l.tupShape, real); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // when (DType.Float64, DType.UInt64) { - // var l = toSymEntry(left,real, nd); - // var val = value.getUIntValue(); - // if boolOps.contains(op) { - // var e = st.addEntry(rname, l.tupShape, bool); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // var e = st.addEntry(rname, l.tupShape, real); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // when (DType.Float64, DType.Float64) { - // var l = toSymEntry(left,real, nd); - // var val = value.getRealValue(); - // if boolOps.contains(op) { - // var e = st.addEntry(rname, l.tupShape, bool); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // var e = st.addEntry(rname, l.tupShape, real); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // // For cases where a boolean operand is involved, the only - // // possible resultant type is `bool` - // when (DType.Bool, DType.Bool) { - // var l = toSymEntry(left,bool, nd); - // var val = value.getBoolValue(); - // if (op == "<<") || (op == ">>") { - // var e = st.addEntry(rname, l.tupShape, int); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // var e = st.addEntry(rname, l.tupShape, bool); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // when (DType.Bool, DType.Int64) { - // var l = toSymEntry(left,bool, nd); - // var val = value.getIntValue(); - // if boolOps.contains(op) { - // var e = st.addEntry(rname, l.tupShape, bool); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // var e = st.addEntry(rname, l.tupShape, int); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // when (DType.Int64, DType.Bool) { - // var l = toSymEntry(left,int, nd); - // var val = value.getBoolValue(); - // if boolOps.contains(op) { - // var e = st.addEntry(rname, l.tupShape, bool); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // var e = st.addEntry(rname, l.tupShape, int); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // when (DType.Bool, DType.Float64) { - // var l = toSymEntry(left,bool, nd); - // var val = value.getRealValue(); - // if boolOps.contains(op) { - // var e = st.addEntry(rname, l.tupShape, bool); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // var e = st.addEntry(rname, l.tupShape, real); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // when (DType.Float64, DType.Bool) { - // var l = toSymEntry(left,real, nd); - // var val = value.getBoolValue(); - // if boolOps.contains(op) { - // var e = st.addEntry(rname, l.tupShape, bool); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // var e = st.addEntry(rname, l.tupShape, real); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // when (DType.Bool, DType.UInt64) { - // var l = toSymEntry(left,bool, nd); - // var val = value.getUIntValue(); - // if boolOps.contains(op) { - // var e = st.addEntry(rname, l.tupShape, bool); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // var e = st.addEntry(rname, l.tupShape, uint); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // when (DType.UInt64, DType.Bool) { - // var l = toSymEntry(left,uint, nd); - // var val = value.getBoolValue(); - // if boolOps.contains(op) { - // var e = st.addEntry(rname, l.tupShape, bool); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // var e = st.addEntry(rname, l.tupShape, uint); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // when (DType.UInt64, DType.UInt64) { - // var l = toSymEntry(left,uint, nd); - // var val = value.getUIntValue(); - // if boolOps.contains(op) { - // var e = st.addEntry(rname, l.tupShape, bool); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // if op == "/"{ - // var e = st.addEntry(rname, l.tupShape, real); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } else { - // var e = st.addEntry(rname, l.tupShape, uint); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // } - // when (DType.UInt64, DType.Int64) { - // var l = toSymEntry(left,uint, nd); - // var val = value.getIntValue(); - // if boolOps.contains(op) { - // var e = st.addEntry(rname, l.tupShape, bool); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // // +, -, /, // both result in real outputs to match NumPy - // if realOps.contains(op) { - // var e = st.addEntry(rname, l.tupShape, real); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } else { - // // isn't +, -, /, // so we can use LHS to determine type - // var e = st.addEntry(rname, l.tupShape, uint); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // } - // when (DType.Int64, DType.UInt64) { - // var l = toSymEntry(left,int, nd); - // var val = value.getUIntValue(); - // if boolOps.contains(op) { - // var e = st.addEntry(rname, l.tupShape, bool); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // // +, -, /, // both result in real outputs to match NumPy - // if realOps.contains(op) { - // var e = st.addEntry(rname, l.tupShape, real); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } else { - // // isn't +, -, /, // so we can use LHS to determine type - // var e = st.addEntry(rname, l.tupShape, int); - // return doBinOpvs(l, val, e, op, dtype, rname, pn, st); - // } - // } - // when (DType.BigInt, DType.BigInt) { - // var l = toSymEntry(left,bigint, nd); - // var val = value.getBigIntValue(); - // if boolOps.contains(op) { - // // call bigint specific func which returns distr bool array - // var e = st.addEntry(rname, createSymEntry(doBigIntBinOpvsBoolReturn(l, val, op))); - // var repMsg = "created %s".format(st.attrib(rname)); - // return new MsgTuple(repMsg, MsgType.NORMAL); - // } - // // call bigint specific func which returns dist bigint array - // var (tmp, max_bits) = doBigIntBinOpvs(l, val, op); - // var e = st.addEntry(rname, createSymEntry(tmp, max_bits)); - // var repMsg = "created %s".format(st.attrib(rname)); - // return new MsgTuple(repMsg, MsgType.NORMAL); - // } - // when (DType.BigInt, DType.Int64) { - // var l = toSymEntry(left,bigint, nd); - // var val = value.getIntValue(); - // if boolOps.contains(op) { - // // call bigint specific func which returns distr bool array - // var e = st.addEntry(rname, createSymEntry(doBigIntBinOpvsBoolReturn(l, val, op))); - // var repMsg = "created %s".format(st.attrib(rname)); - // return new MsgTuple(repMsg, MsgType.NORMAL); - // } - // // call bigint specific func which returns dist bigint array - // var (tmp, max_bits) = doBigIntBinOpvs(l, val, op); - // var e = st.addEntry(rname, createSymEntry(tmp, max_bits)); - // var repMsg = "created %s".format(st.attrib(rname)); - // return new MsgTuple(repMsg, MsgType.NORMAL); - // } - // when (DType.BigInt, DType.UInt64) { - // var l = toSymEntry(left,bigint, nd); - // var val = value.getUIntValue(); - // if boolOps.contains(op) { - // // call bigint specific func which returns distr bool array - // var e = st.addEntry(rname, createSymEntry(doBigIntBinOpvsBoolReturn(l, val, op))); - // var repMsg = "created %s".format(st.attrib(rname)); - // return new MsgTuple(repMsg, MsgType.NORMAL); - // } - // // call bigint specific func which returns dist bigint array - // var (tmp, max_bits) = doBigIntBinOpvs(l, val, op); - // var e = st.addEntry(rname, createSymEntry(tmp, max_bits)); - // var repMsg = "created %s".format(st.attrib(rname)); - // return new MsgTuple(repMsg, MsgType.NORMAL); - // } - // when (DType.BigInt, DType.Bool) { - // var l = toSymEntry(left,bigint, nd); - // var val = value.getBoolValue(); - // if boolOps.contains(op) { - // // call bigint specific func which returns distr bool array - // var e = st.addEntry(rname, createSymEntry(doBigIntBinOpvsBoolReturn(l, val, op))); - // var repMsg = "created %s".format(st.attrib(rname)); - // return new MsgTuple(repMsg, MsgType.NORMAL); - // } - // // call bigint specific func which returns dist bigint array - // var (tmp, max_bits) = doBigIntBinOpvs(l, val, op); - // var e = st.addEntry(rname, createSymEntry(tmp, max_bits)); - // var repMsg = "created %s".format(st.attrib(rname)); - // return new MsgTuple(repMsg, MsgType.NORMAL); - // } - // when (DType.Int64, DType.BigInt) { - // var l = toSymEntry(left,int, nd); - // var val = value.getBigIntValue(); - // if boolOps.contains(op) { - // // call bigint specific func which returns distr bool array - // var e = st.addEntry(rname, createSymEntry(doBigIntBinOpvsBoolReturn(l, val, op))); - // var repMsg = "created %s".format(st.attrib(rname)); - // return new MsgTuple(repMsg, MsgType.NORMAL); - // } - // // call bigint specific func which returns dist bigint array - // var (tmp, max_bits) = doBigIntBinOpvs(l, val, op); - // var e = st.addEntry(rname, createSymEntry(tmp, max_bits)); - // var repMsg = "created %s".format(st.attrib(rname)); - // return new MsgTuple(repMsg, MsgType.NORMAL); - // } - // when (DType.UInt64, DType.BigInt) { - // var l = toSymEntry(left,uint, nd); - // var val = value.getBigIntValue(); - // if boolOps.contains(op) { - // // call bigint specific func which returns distr bool array - // var e = st.addEntry(rname, createSymEntry(doBigIntBinOpvsBoolReturn(l, val, op))); - // var repMsg = "created %s".format(st.attrib(rname)); - // return new MsgTuple(repMsg, MsgType.NORMAL); - // } - // // call bigint specific func which returns dist bigint array - // var (tmp, max_bits) = doBigIntBinOpvs(l, val, op); - // var e = st.addEntry(rname, createSymEntry(tmp, max_bits)); - // var repMsg = "created %s".format(st.attrib(rname)); - // return new MsgTuple(repMsg, MsgType.NORMAL); - // } - // when (DType.Bool, DType.BigInt) { - // var l = toSymEntry(left,bool, nd); - // var val = value.getBigIntValue(); - // if boolOps.contains(op) { - // // call bigint specific func which returns distr bool array - // var e = st.addEntry(rname, createSymEntry(doBigIntBinOpvsBoolReturn(l, val, op))); - // var repMsg = "created %s".format(st.attrib(rname)); - // return new MsgTuple(repMsg, MsgType.NORMAL); - // } - // // call bigint specific func which returns dist bigint array - // var (tmp, max_bits) = doBigIntBinOpvs(l, val, op); - // var e = st.addEntry(rname, createSymEntry(tmp, max_bits)); - // var repMsg = "created %s".format(st.attrib(rname)); - // return new MsgTuple(repMsg, MsgType.NORMAL); - // } - // } - // var errorMsg = unrecognizedTypeError(pn, "("+dtype2str(left.dtype)+","+dtype2str(dtype)+")"); - // omLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); - // return new MsgTuple(errorMsg, MsgType.ERROR); - // } + return st.insert(new shared SymEntry(result)); + } - /* - Parse and respond to binopsv message. - sv == scalar op vector + // special handling for bool-bool arithmetic + proc arithmeticOpSV(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab, + type binop_dtype_a, + type binop_dtype_b, + param array_nd: int + ): MsgTuple throws + where binop_dtype_a == bool && binop_dtype_b == bool + { + const val = msgArgs['value'].toScalar(binop_dtype_a), + b = st[msgArgs['b']]: borrowed SymEntry(binop_dtype_b, array_nd), + op = msgArgs['op'].toScalar(string); - :arg reqMsg: request containing (cmd,op,dtype,value,aname) - :type reqMsg: string + var result = makeDistArray((...b.tupShape), bool); - :arg st: SymTab to act on - :type st: borrowed SymTab + // TODO: implement %, **, and // following NumPy's behavior + select op { + when '+' do result = val | b.a; + when '-' do return MsgTuple.error("cannot subtract boolean array from boolean"); + when '*' do result = val & b.a; + when '%' do return MsgTuple.error("modulo of boolean by a boolean array is not supported"); // ' + when '**' do return MsgTuple.error("exponentiation of a boolean by a boolean array is not supported"); + when '//' do return MsgTuple.error("floor-division of a boolean by a boolean array is not supported"); + otherwise return MsgTuple.error("unknown arithmetic binary operation: " + op); + } - :returns: (MsgTuple) - :throws: `UndefinedSymbolError(name)` - */ - @arkouda.registerND - proc binopsvMsg(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab, param nd: int): MsgTuple throws { - param pn = Reflection.getRoutineName(); - var repMsg: string = ""; // response message + return st.insert(new shared SymEntry(result)); + } - const op = msgArgs.getValueOf("op"); - const aname = msgArgs.getValueOf("a"); - const value = msgArgs.get("value"); + // special handling for bigint arithmetic + proc arithmeticOpSV(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab, + type binop_dtype_a, + type binop_dtype_b, + param array_nd: int + ): MsgTuple throws + where (binop_dtype_a == bigint && !isRealType(binop_dtype_b)) || + (binop_dtype_b == bigint && !isRealType(binop_dtype_a)) + { + const val = msgArgs['value'].toScalar(binop_dtype_a), + b = st[msgArgs['b']]: borrowed SymEntry(binop_dtype_b, array_nd), + op = msgArgs['op'].toScalar(string), + (has_max_bits, max_size, max_bits) = getMaxBits(b); - var dtype = str2dtype(msgArgs.getValueOf("dtype")); - var rname = st.nextName(); - var right: borrowed GenSymEntry = getGenericTypedArrayEntry(aname, st); - - omLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "command = %? op = %? scalar dtype = %? scalar = %? pdarray = %?".format( - cmd,op,dtype2str(dtype),value,st.attrib(aname))); - - use Set; - // This boolOps set is a filter to determine the output type for the operation. - // All operations that involve one of these operations result in a `bool` symbol - // table entry. - var boolOps: set(string); - boolOps.add("<"); - boolOps.add("<="); - boolOps.add(">"); - boolOps.add(">="); - boolOps.add("=="); - boolOps.add("!="); - - var realOps: set(string); - realOps.add("+"); - realOps.add("-"); - realOps.add("/"); - realOps.add("//"); - - select (dtype, right.dtype) { - when (DType.Int64, DType.Int64) { - var val = value.getIntValue(); - var r = toSymEntry(right,int, nd); - - if boolOps.contains(op) { - var e = st.addEntry(rname, r.tupShape, bool); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } else if op == "/" { - // True division is the only case in this int, int case - // that results in a `real` symbol table entry. - var e = st.addEntry(rname, r.tupShape, real); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - var e = st.addEntry(rname, r.tupShape, int); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - when (DType.Int64, DType.Float64) { - var val = value.getIntValue(); - var r = toSymEntry(right,real, nd); - // Only two possible resultant types are `bool` and `real` - // for this case - if boolOps.contains(op) { - var e = st.addEntry(rname, r.tupShape, bool); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - var e = st.addEntry(rname, r.tupShape, real); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - when (DType.Float64, DType.Int64) { - var val = value.getRealValue(); - var r = toSymEntry(right,int, nd); - if boolOps.contains(op) { - var e = st.addEntry(rname, r.tupShape, bool); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - var e = st.addEntry(rname, r.tupShape, real); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - when (DType.UInt64, DType.Float64) { - var val = value.getUIntValue(); - var r = toSymEntry(right,real, nd); - // Only two possible resultant types are `bool` and `real` - // for this case - if boolOps.contains(op) { - var e = st.addEntry(rname, r.tupShape, bool); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - var e = st.addEntry(rname, r.tupShape, real); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - when (DType.Float64, DType.UInt64) { - var val = value.getRealValue(); - var r = toSymEntry(right,uint, nd); - if boolOps.contains(op) { - var e = st.addEntry(rname, r.tupShape, bool); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - var e = st.addEntry(rname, r.tupShape, real); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - when (DType.Float64, DType.Float64) { - var val = value.getRealValue(); - var r = toSymEntry(right,real, nd); - if boolOps.contains(op) { - var e = st.addEntry(rname, r.tupShape, bool); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - var e = st.addEntry(rname, r.tupShape, real); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - // For cases where a boolean operand is involved, the only - // possible resultant type is `bool` - when (DType.Bool, DType.Bool) { - var val = value.getBoolValue(); - var r = toSymEntry(right,bool, nd); - if (op == "<<") || (op == ">>") { - var e = st.addEntry(rname, r.tupShape, int); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - var e = st.addEntry(rname, r.tupShape, bool); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); + var result = makeDistArray((...b.tupShape), bigint); + result = val:bigint; + + ref bb = b.a; + + select op { + when '+' { + forall (rx, bi) in zip(result, bb) with (const local_max_size = max_size) { + rx += bi; + if has_max_bits then rx &= local_max_size; } - when (DType.Bool, DType.Int64) { - var val = value.getBoolValue(); - var r = toSymEntry(right,int, nd); - if boolOps.contains(op) { - var e = st.addEntry(rname, r.tupShape, bool); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - var e = st.addEntry(rname, r.tupShape, int); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); + } + when '-' { + forall (rx, bi) in zip(result, bb) with (const local_max_size = max_size) { + rx -= bi; + if has_max_bits then rx &= local_max_size; } - when (DType.Int64, DType.Bool) { - var val = value.getIntValue(); - var r = toSymEntry(right,bool, nd); - if boolOps.contains(op) { - var e = st.addEntry(rname, r.tupShape, bool); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - var e = st.addEntry(rname, r.tupShape, int); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); + } + when '*' { + forall (rx, bi) in zip(result, bb) with (const local_max_size = max_size) { + rx *= bi; + if has_max_bits then rx &= local_max_size; } - when (DType.Bool, DType.Float64) { - var val = value.getBoolValue(); - var r = toSymEntry(right,real, nd); - if boolOps.contains(op) { - var e = st.addEntry(rname, r.tupShape, bool); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - var e = st.addEntry(rname, r.tupShape, real); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); + } + when '%' { // ' + if binop_dtype_a != bigint then return MsgTuple.error("cannot mod a non-bigint value by a bigint array"); + if binop_dtype_b == bool then return MsgTuple.error("cannot mod a bigint value by a bool array"); + forall (rx, bi) in zip(result, bb) with (const local_max_size = max_size) { + if bi != 0 then mod(rx, rx, bi); else rx = 0:bigint; + if has_max_bits then rx &= local_max_size; } - when (DType.Float64, DType.Bool) { - var val = value.getRealValue(); - var r = toSymEntry(right,bool, nd); - if boolOps.contains(op) { - var e = st.addEntry(rname, r.tupShape, bool); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - var e = st.addEntry(rname, r.tupShape, real); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); + } + when '**' { + if binop_dtype_a != bigint then return MsgTuple.error("cannot exponentiate a non-bigint value by a bigint array"); + if binop_dtype_b == bool then return MsgTuple.error("cannot exponentiate a bigint value by a bool array"); + if || reduce (bb < 0) then return MsgTuple.error("Attempt to exponentiate bigint base to negative exponent"); + + if has_max_bits + then forall (rx, bi) in zip(result, bb) with (const local_max_size = max_size) do + powMod(rx, rx, bi, local_max_size + 1); + else forall (rx, bi) in zip(result, bb) do + rx **= bi:uint; + } + when '//' { + if binop_dtype_a != bigint then return MsgTuple.error("cannot floor-div a non-bigint value by a bigint array"); + if binop_dtype_b == bool then return MsgTuple.error("cannot floor-div a bigint value by a bool array"); + + forall (rx, bi) in zip(result, bb) with (const local_max_size = max_size) { + if bi != 0 then rx /= bi; else rx = 0:bigint; + if has_max_bits then rx &= local_max_size; } - when (DType.Bool, DType.UInt64) { - var val = value.getBoolValue(); - var r = toSymEntry(right,uint, nd); - if boolOps.contains(op) { - var e = st.addEntry(rname, r.tupShape, bool); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - var e = st.addEntry(rname, r.tupShape, uint); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); + } + } + + return st.insert(new shared SymEntry(result, max_bits)); + } + + proc arithmeticOpSV(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab, + type binop_dtype_a, + type binop_dtype_b, + param array_nd: int + ): MsgTuple throws + where (binop_dtype_a == bigint && isRealType(binop_dtype_b)) || + (binop_dtype_b == bigint && isRealType(binop_dtype_a)) + { + return MsgTuple.error("binary arithmetic operations between real and bigint arrays/values are not supported"); + } + + /* + Supports the following binary operations between an array and scalar: + ==, !=, <, <=, >, >= + */ + @arkouda.instantiateAndRegister + proc comparisonOpSV(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab, + type binop_dtype_a, + type binop_dtype_b, + param array_nd: int + ): MsgTuple throws + where !(binop_dtype_a == bigint && isRealType(binop_dtype_b)) && + !(binop_dtype_b == bigint && isRealType(binop_dtype_a)) + { + const val = msgArgs['value'].toScalar(binop_dtype_a), + b = st[msgArgs['b']]: borrowed SymEntry(binop_dtype_b, array_nd), + op = msgArgs['op'].toScalar(string); + + var result = makeDistArray((...b.tupShape), bool); + + if (binop_dtype_a == real && binop_dtype_b == bool) || + (binop_dtype_a == bool && binop_dtype_b == real) + { + select op { + when '==' do result = val:real == b.a:real; + when '!=' do result = val:real != b.a:real; + when '<' do result = val:real < b.a:real; + when '<=' do result = val:real <= b.a:real; + when '>' do result = val:real > b.a:real; + when '>=' do result = val:real >= b.a:real; + otherwise return MsgTuple.error("unknown comparison binary operation: " + op); + } + } else { + select op { + when '==' do result = val == b.a; + when '!=' do result = val != b.a; + when '<' do result = val < b.a; + when '<=' do result = val <= b.a; + when '>' do result = val > b.a; + when '>=' do result = val >= b.a; + otherwise return MsgTuple.error("unknown comparison binary operation: " + op); + } + } + + return st.insert(new shared SymEntry(result)); + } + + proc comparisonOpSV(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab, + type binop_dtype_a, + type binop_dtype_b, + param array_nd: int + ): MsgTuple throws + where (binop_dtype_a == bigint && isRealType(binop_dtype_b)) || + (binop_dtype_b == bigint && isRealType(binop_dtype_a)) + { + return MsgTuple.error("comparison operations between real and bigint arrays/values are not supported"); + } + + /* + Supports the following binary operations between an array and scalar + |, &, ^, <<, >>, <<<, >>> + */ + @arkouda.instantiateAndRegister + proc bitwiseOpSV(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab, + type binop_dtype_a, + type binop_dtype_b, + param array_nd: int + ): MsgTuple throws + where binop_dtype_a != bigint && binop_dtype_b != bigint && + !isRealType(binop_dtype_a) && !isRealType(binop_dtype_b) && + !(binop_dtype_a == bool && binop_dtype_b == bool) + { + const val = msgArgs['value'].toScalar(binop_dtype_a), + b = st[msgArgs['b']]: borrowed SymEntry(binop_dtype_b, array_nd), + op = msgArgs['op'].toScalar(string); + + type resultType = if (isIntType(binop_dtype_a) && isUintType(binop_dtype_b)) || + (isUintType(binop_dtype_a) && isIntType(binop_dtype_b)) + then binop_dtype_a // use LHS type for integer types with non-matching signed-ness + else promotedType(binop_dtype_a, binop_dtype_b); // otherwise, use regular type promotion + var result = makeDistArray((...b.tupShape), resultType); + + select op { + when '|' do result = (val | b.a):resultType; + when '&' do result = (val & b.a):resultType; + when '^' do result = (val ^ b.a):resultType; + when '<<' { + ref bb = b.a; + [(ri,bi) in zip(result,bb)] if 0 <= bi && bi < 64 then ri = val:resultType << bi:resultType; + } + when '>>' { + ref bb = b.a; + [(ri,bi) in zip(result,bb)] if 0 <= bi && bi < 64 then ri = val:resultType >> bi:resultType; + } + when '<<<' { + if !isIntegral(binop_dtype_a) || !isIntegral(binop_dtype_b) + then return MsgTuple.error("cannot perform bitwise rotation with boolean arrays"); + result = rotl(val, b.a):resultType; + } + when '>>>' { + if !isIntegral(binop_dtype_a) || !isIntegral(binop_dtype_b) + then return MsgTuple.error("cannot perform bitwise rotation with boolean arrays"); + result = rotr(val, b.a):resultType; + } + otherwise return MsgTuple.error("unknown bitwise binary operation: " + op); + } + + return st.insert(new shared SymEntry(result)); + } + + // special handling for bitwise ops with two boolean arrays + proc bitwiseOpSV(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab, + type binop_dtype_a, + type binop_dtype_b, + param array_nd: int + ): MsgTuple throws + where binop_dtype_a == bool && binop_dtype_b == bool + { + const val = msgArgs['value'].toScalar(binop_dtype_a), + b = st[msgArgs['b']]: borrowed SymEntry(binop_dtype_b, array_nd), + op = msgArgs['op'].toScalar(string); + + if op == '<<' || op == '>>' { + var result = makeDistArray((...b.tupShape), int); + + if op == '<<' { + ref bb = b.a; + [(ri,bi) in zip(result,bb)] if 0 <= bi && bi < 64 then ri = val:int << bi:int; + } else { + ref bb = b.a; + [(ri,bi) in zip(result,bb)] if 0 <= bi && bi < 64 then ri = val:int >> bi:int; + } + + return st.insert(new shared SymEntry(result)); + } else { + var result = makeDistArray((...b.tupShape), bool); + + select op { + when '|' do result = val | b.a; + when '&' do result = val & b.a; + when '^' do result = val ^ b.a; + when '<<<' do return MsgTuple.error("bitwise rotation on boolean arrays is not supported"); + when '>>>' do return MsgTuple.error("bitwise rotation on boolean arrays is not supported"); + otherwise return MsgTuple.error("unknown bitwise binary operation: " + op); + } + + return st.insert(new shared SymEntry(result)); + } + } + + // special handling for bitwise ops with at least one bigint array/value + proc bitwiseOpSV(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab, + type binop_dtype_a, + type binop_dtype_b, + param array_nd: int + ): MsgTuple throws + where (binop_dtype_a == bigint || binop_dtype_b == bigint) && + !isRealType(binop_dtype_a) && !isRealType(binop_dtype_b) + { + const val = msgArgs['value'].toScalar(binop_dtype_a), + b = st[msgArgs['b']]: borrowed SymEntry(binop_dtype_b, array_nd), + op = msgArgs['op'].toScalar(string), + (has_max_bits, max_size, max_bits) = getMaxBits(b); + + // 'a' must be a bigint, and 'b' must not be real for the operations below + // (for some operations, both a and b must be bigint) + if binop_dtype_a != bigint || isRealType(binop_dtype_b) then + return MsgTuple.error("bitwise operations between a LHS bigint and RHS non-bigint arrays are not supported"); + + var result = makeDistArray((...b.tupShape), bigint); + result = val:bigint; + param bothBigint = binop_dtype_a == bigint && binop_dtype_b == bigint; + ref bb = b.a; + + select op { + when '|' { + if !bothBigint then return MsgTuple.error("bitwise OR between bigint and non-bigint arrays/values is not supported"); + forall (rx, bi) in zip(result, bb) with (const local_max_size = max_size) { + rx |= bi; + if has_max_bits then rx &= local_max_size; } - when (DType.UInt64, DType.Bool) { - var val = value.getUIntValue(); - var r = toSymEntry(right,bool, nd); - if boolOps.contains(op) { - var e = st.addEntry(rname, r.tupShape, bool); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - var e = st.addEntry(rname, r.tupShape, uint); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); + } + when '&' { + if !bothBigint then return MsgTuple.error("bitwise AND between bigint and non-bigint arrays/values is not supported"); + forall (rx, bi) in zip(result, bb) with (const local_max_size = max_size) { + rx &= bi; + if has_max_bits then rx &= local_max_size; } - when (DType.UInt64, DType.UInt64) { - var val = value.getUIntValue(); - var r = toSymEntry(right,uint, nd); - if boolOps.contains(op) { - var e = st.addEntry(rname, r.tupShape, bool); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - if op == "/"{ - var e = st.addEntry(rname, r.tupShape, real); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } else { - var e = st.addEntry(rname, r.tupShape, uint); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } + } + when '^' { + if !bothBigint then return MsgTuple.error("bitwise XOR between bigint and non-bigint arrays/values is not supported"); + forall (rx, bi) in zip(result, bb) with (const local_max_size = max_size) { + rx ^= bi; + if has_max_bits then rx &= local_max_size; } - when (DType.UInt64, DType.Int64) { - var val = value.getUIntValue(); - var r = toSymEntry(right,int, nd); - if boolOps.contains(op) { - var e = st.addEntry(rname, r.tupShape, bool); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - // +, -, /, // both result in real outputs to match NumPy - if realOps.contains(op) { - var e = st.addEntry(rname, r.tupShape, real); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); + } + when '<<' { + if binop_dtype_b == bigint then return MsgTuple.error("left-shift of a bigint array by a non-bigint value is not supported"); + forall (rx, bi) in zip(result, bb) with (const local_max_size = max_size) { + if has_max_bits { + if bi >= max_bits then rx = 0:bigint; + else { + rx <<= bi; + rx &= local_max_size; + } } else { - // isn't +, -, /, // so we can use LHS to determine type - var e = st.addEntry(rname, r.tupShape, uint); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); + rx <<= bi; } } - when (DType.Int64, DType.UInt64) { - var val = value.getIntValue(); - var r = toSymEntry(right,uint, nd); - if boolOps.contains(op) { - var e = st.addEntry(rname, r.tupShape, bool); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - // +, -, /, // both result in real outputs to match NumPy - if realOps.contains(op) { - var e = st.addEntry(rname, r.tupShape, real); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); + } + when '>>' { + if binop_dtype_b == bigint then return MsgTuple.error("right-shift of a bigint array by a non-bigint value is not supported"); + forall (rx, bi) in zip(result, bb) with (const local_max_size = max_size) { + if has_max_bits { + if bi >= max_bits then rx = 0:bigint; + else { + rx >>= bi; + rx &= local_max_size; + } } else { - // isn't +, -, /, // so we can use LHS to determine type - var e = st.addEntry(rname, r.tupShape, int); - return doBinOpsv(val, r, e, op, dtype, rname, pn, st); - } - } - when (DType.BigInt, DType.BigInt) { - var val = value.getBigIntValue(); - var r = toSymEntry(right,bigint, nd); - if boolOps.contains(op) { - // call bigint specific func which returns distr bool array - var e = st.addEntry(rname, createSymEntry(doBigIntBinOpsvBoolReturn(val, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); - return new MsgTuple(repMsg, MsgType.NORMAL); - } - // call bigint specific func which returns dist bigint array - var (tmp, max_bits) = doBigIntBinOpsv(val, r, op); - var e = st.addEntry(rname, createSymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); - return new MsgTuple(repMsg, MsgType.NORMAL); - } - when (DType.BigInt, DType.Int64) { - var val = value.getBigIntValue(); - var r = toSymEntry(right,int, nd); - if boolOps.contains(op) { - // call bigint specific func which returns distr bool array - var e = st.addEntry(rname, createSymEntry(doBigIntBinOpsvBoolReturn(val, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); - return new MsgTuple(repMsg, MsgType.NORMAL); - } - // call bigint specific func which returns dist bigint array - var (tmp, max_bits) = doBigIntBinOpsv(val, r, op); - var e = st.addEntry(rname, createSymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); - return new MsgTuple(repMsg, MsgType.NORMAL); - } - when (DType.BigInt, DType.UInt64) { - var val = value.getBigIntValue(); - var r = toSymEntry(right,uint, nd); - if boolOps.contains(op) { - // call bigint specific func which returns distr bool array - var e = st.addEntry(rname, createSymEntry(doBigIntBinOpsvBoolReturn(val, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); - return new MsgTuple(repMsg, MsgType.NORMAL); - } - // call bigint specific func which returns dist bigint array - var (tmp, max_bits) = doBigIntBinOpsv(val, r, op); - var e = st.addEntry(rname, createSymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); - return new MsgTuple(repMsg, MsgType.NORMAL); - } - when (DType.BigInt, DType.Bool) { - var val = value.getBigIntValue(); - var r = toSymEntry(right,bool, nd); - if boolOps.contains(op) { - // call bigint specific func which returns distr bool array - var e = st.addEntry(rname, createSymEntry(doBigIntBinOpsvBoolReturn(val, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); - return new MsgTuple(repMsg, MsgType.NORMAL); - } - // call bigint specific func which returns dist bigint array - var (tmp, max_bits) = doBigIntBinOpsv(val, r, op); - var e = st.addEntry(rname, createSymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); - return new MsgTuple(repMsg, MsgType.NORMAL); - } - when (DType.Int64, DType.BigInt) { - var val = value.getIntValue(); - var r = toSymEntry(right,bigint, nd); - if boolOps.contains(op) { - // call bigint specific func which returns distr bool array - var e = st.addEntry(rname, createSymEntry(doBigIntBinOpsvBoolReturn(val, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); - return new MsgTuple(repMsg, MsgType.NORMAL); + rx >>= bi; } - // call bigint specific func which returns dist bigint array - var (tmp, max_bits) = doBigIntBinOpsv(val, r, op); - var e = st.addEntry(rname, createSymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); - return new MsgTuple(repMsg, MsgType.NORMAL); } - when (DType.UInt64, DType.BigInt) { - var val = value.getUIntValue(); - var r = toSymEntry(right,bigint, nd); - if boolOps.contains(op) { - // call bigint specific func which returns distr bool array - var e = st.addEntry(rname, createSymEntry(doBigIntBinOpsvBoolReturn(val, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); - return new MsgTuple(repMsg, MsgType.NORMAL); - } - // call bigint specific func which returns dist bigint array - var (tmp, max_bits) = doBigIntBinOpsv(val, r, op); - var e = st.addEntry(rname, createSymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); - return new MsgTuple(repMsg, MsgType.NORMAL); + } + when '<<<' { + if !has_max_bits then return MsgTuple.error("bitwise rotation on bigint arrays requires a max_bits value"); + if binop_dtype_a == bigint then return MsgTuple.error("right-shift of a bigint array by a non-bigint array is not supported"); + forall (rx, bi) in zip(result, bb) with (const local_max_size = max_size) { + var bot_bits = rx; + const modded_shift = if binop_dtype_b == int then bi%max_bits else bi%max_bits:uint; + rx <<= modded_shift; + const shift_amt = if binop_dtype_b == int then max_bits - modded_shift else max_bits:uint - modded_shift; + bot_bits >>= shift_amt; + rx += bot_bits; + rx &= local_max_size; } - when (DType.Bool, DType.BigInt) { - var val = value.getBoolValue(); - var r = toSymEntry(right,bigint, nd); - if boolOps.contains(op) { - // call bigint specific func which returns distr bool array - var e = st.addEntry(rname, createSymEntry(doBigIntBinOpsvBoolReturn(val, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); - return new MsgTuple(repMsg, MsgType.NORMAL); - } - // call bigint specific func which returns dist bigint array - var (tmp, max_bits) = doBigIntBinOpsv(val, r, op); - var e = st.addEntry(rname, createSymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); - return new MsgTuple(repMsg, MsgType.NORMAL); + } + when '>>>' { + if !has_max_bits then return MsgTuple.error("bitwise rotation on bigint arrays requires a max_bits value"); + if binop_dtype_a == bigint then return MsgTuple.error("right-shift of a bigint array by a non-bigint array is not supported"); + forall (rx, bi) in zip(result, bb) with (const local_max_size = max_size) { + var top_bits = rx; + const modded_shift = if binop_dtype_b == int then bi%max_bits else bi%max_bits:uint; + rx >>= modded_shift; + const shift_amt = if binop_dtype_b == int then max_bits - modded_shift else max_bits:uint - modded_shift; + top_bits <<= shift_amt; + rx += top_bits; + rx &= local_max_size; } } - var errorMsg = unrecognizedTypeError(pn, "("+dtype2str(dtype)+","+dtype2str(right.dtype)+")"); - omLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); - return new MsgTuple(errorMsg, MsgType.ERROR); + otherwise return MsgTuple.error("unknown bitwise binary operation: " + op); + } + + return st.insert(new shared SymEntry(result, max_bits)); + } + + // special error message for bitwise ops with real-valued arrays + proc bitwiseOpSV(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab, + type binop_dtype_a, + type binop_dtype_b, + param array_nd: int + ): MsgTuple throws + where isRealType(binop_dtype_a) || isRealType(binop_dtype_b) + do return MsgTuple.error("bitwise operations with real-valued arrays are not supported"); + + /* + Supports real division between a scalar and an array + */ + @arkouda.instantiateAndRegister + proc divOpSV(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab, + type binop_dtype_a, + type binop_dtype_b, + param array_nd: int + ): MsgTuple throws { + const val = msgArgs['value'].toScalar(binop_dtype_a), + b = st[msgArgs['b']]: borrowed SymEntry(binop_dtype_b, array_nd); + + const result = val:real / b.a:real; + + return st.insert(new shared SymEntry(result)); + } + + // special handling for bigint-bigint division + proc divOpSV(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab, + type binop_dtype_a, + type binop_dtype_b, + param array_nd: int + ): MsgTuple throws + where binop_dtype_a == bigint && binop_dtype_b == bigint + { + const val = msgArgs['value'].toScalar(binop_dtype_a), + b = st[msgArgs['b']]: borrowed SymEntry(binop_dtype_b, array_nd), + (has_max_bits, max_size, max_bits) = getMaxBits(b); + + var result = makeDistArray((...b.tupShape), bigint); + result = val:bigint; + ref bb = b.a; + + forall (rx, bi) in zip(result, bb) with (const local_max_size = max_size) { + rx /= bi; + if has_max_bits then rx &= local_max_size; + } + + return st.insert(new shared SymEntry(result, max_bits)); } + // @arkouda.instantiateAndRegister + // proc opeqVV(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab + // type binop_dtype_a, + // type binop_dtype_b, + // param array_nd: int + // ): MsgTuple throws + // // result of operation must be the same type as the left operand + // where binop_dtype_a == promotedType(binop_dtype_a, binop_dtype_b) && + // binop_dtype_a != bigint && binop_dtype_b != bigint + // { + + // } + + // // special handling for bigint ops + // proc opeqVV(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab + // type binop_dtype_a, + // type binop_dtype_b, + // param array_nd: int + // ): MsgTuple throws + // where binop_dtype_a == bigint || binop_dtype_b == bigint + // { + + // } + + // // error message when result cannot be stored in 'binop_dtype_a' + // proc opeqVV(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab + // type binop_dtype_a, + // type binop_dtype_b, + // param array_nd: int + // ): MsgTuple throws + // where binop_dtype_a != promotedType(binop_dtype_a, binop_dtype_b) && + // binop_dtype_a != bigint && binop_dtype_b != bigint + // { + // const op = msgArgs['op'].toScalar(string); + // return MsgTuple.error(notImplementedError( + // cmd, + // whichDtype(binop_dtype_a), + // op, + // whichDtype(right.dtype) + // )); + // } + /* Parse and respond to opeqvv message. vector op= vector diff --git a/src/registry/Commands.chpl b/src/registry/Commands.chpl index 9e7a98ead..0c1a25385 100644 --- a/src/registry/Commands.chpl +++ b/src/registry/Commands.chpl @@ -2387,6 +2387,406 @@ proc ark_divOpVS_bigint_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: return OperatorMsg.divOpVS(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=bigint, array_nd=1); registerFunction('divOpVS', ark_divOpVS_bigint_bigint_1, 'OperatorMsg', 951); +proc ark_arithmeticOpSV_int_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=int, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_int_int_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_int_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=uint, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_int_uint_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_int_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=real, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_int_real_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_int_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=bool, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_int_bool_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_int_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=bigint, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_int_bigint_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_uint_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=int, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_uint_int_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_uint_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=uint, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_uint_uint_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_uint_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=real, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_uint_real_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_uint_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=bool, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_uint_bool_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_uint_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=bigint, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_uint_bigint_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_real_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=int, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_real_int_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_real_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=uint, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_real_uint_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_real_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=real, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_real_real_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_real_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=bool, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_real_bool_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_real_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=bigint, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_real_bigint_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_bool_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=int, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_bool_int_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_bool_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=uint, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_bool_uint_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_bool_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=real, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_bool_real_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_bool_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=bool, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_bool_bool_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_bool_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=bigint, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_bool_bigint_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_bigint_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=int, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_bigint_int_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_bigint_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=uint, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_bigint_uint_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_bigint_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=real, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_bigint_real_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_bigint_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=bool, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_bigint_bool_1, 'OperatorMsg', 991); + +proc ark_arithmeticOpSV_bigint_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.arithmeticOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=bigint, array_nd=1); +registerFunction('arithmeticOpSV', ark_arithmeticOpSV_bigint_bigint_1, 'OperatorMsg', 991); + +proc ark_comparisonOpSV_int_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=int, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_int_int_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_int_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=uint, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_int_uint_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_int_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=real, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_int_real_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_int_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=bool, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_int_bool_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_int_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=bigint, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_int_bigint_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_uint_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=int, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_uint_int_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_uint_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=uint, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_uint_uint_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_uint_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=real, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_uint_real_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_uint_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=bool, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_uint_bool_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_uint_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=bigint, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_uint_bigint_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_real_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=int, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_real_int_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_real_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=uint, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_real_uint_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_real_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=real, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_real_real_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_real_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=bool, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_real_bool_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_real_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=bigint, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_real_bigint_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_bool_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=int, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_bool_int_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_bool_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=uint, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_bool_uint_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_bool_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=real, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_bool_real_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_bool_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=bool, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_bool_bool_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_bool_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=bigint, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_bool_bigint_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_bigint_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=int, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_bigint_int_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_bigint_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=uint, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_bigint_uint_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_bigint_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=real, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_bigint_real_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_bigint_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=bool, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_bigint_bool_1, 'OperatorMsg', 1149); + +proc ark_comparisonOpSV_bigint_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.comparisonOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=bigint, array_nd=1); +registerFunction('comparisonOpSV', ark_comparisonOpSV_bigint_bigint_1, 'OperatorMsg', 1149); + +proc ark_bitwiseOpSV_int_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=int, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_int_int_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_int_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=uint, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_int_uint_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_int_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=real, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_int_real_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_int_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=bool, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_int_bool_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_int_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=bigint, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_int_bigint_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_uint_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=int, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_uint_int_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_uint_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=uint, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_uint_uint_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_uint_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=real, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_uint_real_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_uint_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=bool, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_uint_bool_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_uint_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=bigint, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_uint_bigint_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_real_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=int, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_real_int_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_real_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=uint, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_real_uint_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_real_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=real, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_real_real_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_real_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=bool, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_real_bool_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_real_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=bigint, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_real_bigint_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_bool_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=int, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_bool_int_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_bool_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=uint, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_bool_uint_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_bool_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=real, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_bool_real_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_bool_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=bool, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_bool_bool_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_bool_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=bigint, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_bool_bigint_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_bigint_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=int, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_bigint_int_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_bigint_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=uint, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_bigint_uint_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_bigint_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=real, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_bigint_real_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_bigint_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=bool, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_bigint_bool_1, 'OperatorMsg', 1206); + +proc ark_bitwiseOpSV_bigint_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.bitwiseOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=bigint, array_nd=1); +registerFunction('bitwiseOpSV', ark_bitwiseOpSV_bigint_bigint_1, 'OperatorMsg', 1206); + +proc ark_divOpSV_int_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=int, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_int_int_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_int_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=uint, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_int_uint_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_int_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=real, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_int_real_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_int_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=bool, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_int_bool_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_int_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=int, binop_dtype_b=bigint, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_int_bigint_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_uint_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=int, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_uint_int_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_uint_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=uint, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_uint_uint_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_uint_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=real, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_uint_real_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_uint_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=bool, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_uint_bool_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_uint_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=uint, binop_dtype_b=bigint, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_uint_bigint_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_real_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=int, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_real_int_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_real_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=uint, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_real_uint_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_real_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=real, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_real_real_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_real_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=bool, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_real_bool_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_real_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=real, binop_dtype_b=bigint, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_real_bigint_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_bool_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=int, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_bool_int_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_bool_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=uint, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_bool_uint_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_bool_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=real, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_bool_real_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_bool_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=bool, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_bool_bool_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_bool_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=bool, binop_dtype_b=bigint, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_bool_bigint_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_bigint_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=int, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_bigint_int_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_bigint_uint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=uint, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_bigint_uint_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_bigint_real_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=real, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_bigint_real_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_bigint_bool_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=bool, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_bigint_bool_1, 'OperatorMsg', 1412); + +proc ark_divOpSV_bigint_bigint_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do + return OperatorMsg.divOpSV(cmd, msgArgs, st, binop_dtype_a=bigint, binop_dtype_b=bigint, array_nd=1); +registerFunction('divOpSV', ark_divOpSV_bigint_bigint_1, 'OperatorMsg', 1412); + import RandMsg; proc ark_randint_int_1(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws do