Skip to content

Instantly share code, notes, and snippets.

@chamathabeysinghe
Created February 17, 2018 18:37
Show Gist options
  • Save chamathabeysinghe/9dcbbf1f1066877fbeb11d78fffaa355 to your computer and use it in GitHub Desktop.
Save chamathabeysinghe/9dcbbf1f1066877fbeb11d78fffaa355 to your computer and use it in GitHub Desktop.
import org.apache.sysml.api.DMLException;
import org.apache.sysml.api.jmlc.Connection;
import org.apache.sysml.api.jmlc.PreparedScript;
public class Main {
public Main() throws DMLException {
}
public static void main(String args[]) throws DMLException {
Connection conn = new Connection();
String dml = "fileM = '/home/chamath/Software/systemml-1.0.0-bin/test_data/test_csv.csv'\n" +
"\n" +
"numRowsToPrint = ifdef($rowsToPrint, 2) # default to 2\n" +
"numColsToPrint = ifdef($colsToPrint, 2) # default to 2\n" +
"\n" +
"m = read(fileM)\n" +
"\n" +
"for (i in 1:numRowsToPrint) {\n" +
" for (j in 1:numColsToPrint) {\n" +
" print('[' + i + ',' + j + ']:' + as.scalar(m[i,j]))\n" +
" }\n" +
"}\n";
PreparedScript script = conn.prepareScript(dml, new String[0], new String[0], false);
script.executeScript();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment