use of org.apache.sysml.runtime.instructions.cp.DoubleObject in project incubator-systemml by apache.
the class ExternalFunctionInvocationInstruction method verifyAndAttachOutputs.
private void verifyAndAttachOutputs(ExecutionContext ec, PackageFunction fun, CPOperand[] outputs) {
for (int i = 0; i < outputs.length; i++) {
CPOperand output = outputs[i];
switch(fun.getFunctionOutput(i).getType()) {
case Matrix:
Matrix m = (Matrix) fun.getFunctionOutput(i);
MatrixObject newVar = createOutputMatrixObject(m);
ec.setVariable(output.getName(), newVar);
break;
case Scalar:
Scalar s = (Scalar) fun.getFunctionOutput(i);
ScalarObject scalarObject = null;
switch(s.getScalarType()) {
case Integer:
scalarObject = new IntObject(Long.parseLong(s.getValue()));
break;
case Double:
scalarObject = new DoubleObject(Double.parseDouble(s.getValue()));
break;
case Boolean:
scalarObject = new BooleanObject(Boolean.parseBoolean(s.getValue()));
break;
case Text:
scalarObject = new StringObject(s.getValue());
break;
default:
throw new DMLRuntimeException("Unknown scalar value type '" + s.getScalarType() + "' of output '" + output.getName() + "'.");
}
ec.setVariable(output.getName(), scalarObject);
break;
default:
throw new DMLRuntimeException("Unsupported data type: " + fun.getFunctionOutput(i).getType().name());
}
}
}
Aggregations