Search in sources :

Example 1 with ValueComparisonFunction

use of org.apache.sysml.runtime.functionobjects.ValueComparisonFunction in project incubator-systemml by apache.

the class ScalarScalarRelationalCPInstruction method processInstruction.

@Override
public void processInstruction(ExecutionContext ec) throws DMLRuntimeException {
    ScalarObject so1 = ec.getScalarInput(input1.getName(), input1.getValueType(), input1.isLiteral());
    ScalarObject so2 = ec.getScalarInput(input2.getName(), input2.getValueType(), input2.isLiteral());
    ValueComparisonFunction vcomp = ((ValueComparisonFunction) ((BinaryOperator) _optr).fn);
    boolean rval = false;
    //compute output value, incl implicit type promotion if necessary
    if (so1 instanceof StringObject || so2 instanceof StringObject)
        rval = vcomp.compare(so1.getStringValue(), so2.getStringValue());
    else if (so1 instanceof DoubleObject || so2 instanceof DoubleObject)
        rval = vcomp.compare(so1.getDoubleValue(), so2.getDoubleValue());
    else if (so1 instanceof IntObject || so2 instanceof IntObject)
        rval = vcomp.compare(so1.getLongValue(), so2.getLongValue());
    else
        //all boolean
        rval = vcomp.compare(so1.getBooleanValue(), so2.getBooleanValue());
    //set boolean output value
    ec.setScalarOutput(output.getName(), new BooleanObject(rval));
}
Also used : ValueComparisonFunction(org.apache.sysml.runtime.functionobjects.ValueComparisonFunction) BinaryOperator(org.apache.sysml.runtime.matrix.operators.BinaryOperator)

Aggregations

ValueComparisonFunction (org.apache.sysml.runtime.functionobjects.ValueComparisonFunction)1 BinaryOperator (org.apache.sysml.runtime.matrix.operators.BinaryOperator)1