use of org.apache.sysml.udf.BinaryObject in project incubator-systemml by apache.
the class ExternalFunctionProgramBlock method getInputObjects.
/**
* Method to convert string representation of input into function input
* object.
*
* @param inputs list of inputs
* @param variableMapping local variable map
* @return list of function parameters
*/
protected ArrayList<FunctionParameter> getInputObjects(ArrayList<String> inputs, LocalVariableMap variableMapping) {
ArrayList<FunctionParameter> inputObjects = new ArrayList<FunctionParameter>();
for (int i = 0; i < inputs.size(); i++) {
ArrayList<String> tokens = new ArrayList<String>();
StringTokenizer tk = new StringTokenizer(inputs.get(i), ":");
while (tk.hasMoreTokens()) {
tokens.add(tk.nextToken());
}
if (tokens.get(0).equals("Matrix")) {
String varName = tokens.get(1);
MatrixObject mobj = (MatrixObject) variableMapping.get(varName);
MatrixCharacteristics mc = mobj.getMatrixCharacteristics();
Matrix m = new Matrix(mobj.getFileName(), mc.getRows(), mc.getCols(), getMatrixValueType(tokens.get(2)));
modifyInputMatrix(m, mobj);
inputObjects.add(m);
}
if (tokens.get(0).equals("Scalar")) {
String varName = tokens.get(1);
ScalarObject so = (ScalarObject) variableMapping.get(varName);
Scalar s = new Scalar(getScalarValueType(tokens.get(2)), so.getStringValue());
inputObjects.add(s);
}
if (tokens.get(0).equals("Object")) {
String varName = tokens.get(1);
Object o = variableMapping.get(varName);
BinaryObject obj = new BinaryObject(o);
inputObjects.add(obj);
}
}
return inputObjects;
}
Aggregations