Skip to content

Instantly share code, notes, and snippets.

@miho
Last active November 16, 2017 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miho/b0b6c4c0e082173f7a2df38965bfff91 to your computer and use it in GitHub Desktop.
Save miho/b0b6c4c0e082173f7a2df38965bfff91 to your computer and use it in GitHub Desktop.
package eu.mihosoft.vrl.user;
@ComponentInfo(name="MatrixInput", category="ODE")
public class MatrixInput implements Serializable {
private static final long serialVersionUID = 1L;
private transient Script script;
@MethodInfo(name="", valueName="Matrix", valueStyle="default", valueOptions="serialization=false", hide=false)
public double[][] matrix(
@ParamInfo(name="<html><b>Matrix m</b></hmtl>", style="code", options="") String expression) {
GroovyShell shell = new GroovyShell();
script = shell.parse("import static java.lang.Math.*;"
+ "import eu.mihosoft.vrl.types.*;"
+ "m = [];"
+ expression);
script.run()
return script.getProperty("m")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment