This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package eu.mihosoft.vrl.user; | |
| @ComponentInfo(name="VectorInput", category="ODE") | |
| public class VectorInput implements java.io.Serializable { | |
| private static final long serialVersionUID=1L; | |
| // add your code here | |
| @MethodInfo(name="", valueName="v", valueStyle="default", valueOptions="", hide=false) | |
| public double[] vector(@ParamInfo(name="", style="array", options="") Double[] v) { | |
| return v | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // first | |
| m = [ | |
| [1, 1, 1], | |
| [0, 2, 5], | |
| [2, 5, -1] | |
| ] | |
| // second | |
| m = [ | |
| [2, 0, 2], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package eu.mihosoft.vrl.user; | |
| import java.text.NumberFormat; | |
| import java.text.DecimalFormat; | |
| @ComponentInfo(name="Vector2String", category="ODE") | |
| public class Vector2String implements java.io.Serializable { | |
| private static final long serialVersionUID=1L; | |
| @OutputInfo(style="default") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package eu.mihosoft.vrl.user; | |
| @ComponentInfo(name="JacobianInput", category="ODE") | |
| public class JacobianInput implements Serializable, JacobianInputInterface { | |
| private static final long serialVersionUID = 1L; | |
| private transient Script script; | |
| @MethodInfo(name="", valueName="", valueStyle="default", valueOptions="", hide=false) | |
| public JacobianInputInterface setExpression( | |
| @ParamInfo(name="<html><b>Jacobian J(t,u)</b>: <br>Param: double t, double[] <b>u</b><br>Return: double[][] <b>j</b></hmtl>", style="code", options="") String expression) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.text.NumberFormat; | |
| import java.text.DecimalFormat; | |
| @ComponentInfo(name="Matrix2String", category="ODE") | |
| public class Matrix2String implements java.io.Serializable { | |
| private static final long serialVersionUID=1L; | |
| @OutputInfo(style="editor") | |
| public String print(@ParamInfo(name="Matrix", options="serialization=false") double[][] matrix) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ComponentInfo(name="SimplePlotter", category="ODE") | |
| public class SimplePlotter implements Serializable { | |
| private static final long serialVersionUID = 1L; | |
| transient private BufferedImage image; | |
| @OutputInfo(options="fixedAspectRatio=true") | |
| public BufferedImage plot( | |
| @ParamInfo(name = "Input Trajectory") ArrayList<double[]> t1) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ComponentInfo(name="VectorRhsODE", category="ODE") | |
| public class VectorRhsODE implements Serializable, VectorRhsODEInterface { | |
| private static final long serialVersionUID = 1L; | |
| private transient Script script; | |
| @MethodInfo(name="", valueName="", valueStyle="default", valueOptions="", hide=false) | |
| public VectorRhsODEInterface setExpression( | |
| @ParamInfo(name="<html><b>Vector-valued Function f(t,u)</b>: <br>Param: double t, double[] <b>u</b><br>Return: double[] <b>f</b></hmtl>", style="code", options="") String expression) { | |
| GroovyShell shell = new GroovyShell(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ComponentInfo(name="EvaluatorTemplate", category="ODE") | |
| public class EvaluatorTemplate implements java.io.Serializable { | |
| private static final long serialVersionUID=1L; | |
| public Trajectory run( | |
| @ParamInfo(name="f(x)") | |
| Function1D f, | |
| @ParamInfo(name="x0", options="value=0.0D") | |
| double x0, | |
| @ParamInfo(name="xn", options="value=1.0D") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Algorithm is exponential - very bad. It is just meant to exercise the CPU a bit and | |
| to see what happens with different languages. Not representative of real code. | |
| Interesting that Java beats C, thanks to HotSpot. I expected Swift to be as fast as C | |
| at least. I also expected the compiled Swift to be faster than when run as a script. | |
| A bit disappointed, but more time needed to see where the bottlenecks are. Plus I | |
| need to run some real code for benchmarking. | |
| Update: swiftc -O improved the speed quite a bit to be about the same speed as Java | |