]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Added @mod(x,y)@ function to internal solver and changed the current @IEEEremainder...
authorlehtonen <lehtonen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 22 Dec 2015 10:59:19 +0000 (10:59 +0000)
committerlehtonen <lehtonen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 22 Dec 2015 10:59:19 +0000 (10:59 +0000)
refs #6217

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@32145 ac1ea38d-2e2b-0410-8846-a27921b304fc

fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Environment.java

index 1a367696157cc46bc7bfc31aee505f0448b5f1f6..baf91ac64413628f2867a93a15fdb87585676ac9 100644 (file)
@@ -219,7 +219,21 @@ final public class Environment implements IEnvironment, ISystem {
                        }\r
                        \r
                });\r
-               model.functions.put("IEEEremainder", new Fn1(2) {\r
+               model.functions.put("mod", new Fn1(2) {\r
+\r
+                       @Override\r
+                       public Object evaluate(IEnvironment environment, int argc) {\r
+                               Double x = (Double)environment.getValue(0);\r
+                               Double y = (Double)environment.getValue(1);\r
+                               return mod(x, y);\r
+                       }\r
+\r
+                       double mod(double x, double y) {\r
+                               return x - Math.floor(x/y)*y;\r
+                       }\r
+\r
+               });\r
+               model.functions.put("rem", new Fn1(2) {\r
 \r
                        @Override\r
                        public Object evaluate(IEnvironment environment, int argc) {\r
@@ -227,7 +241,7 @@ final public class Environment implements IEnvironment, ISystem {
                                Double y = (Double)environment.getValue(1);\r
                                return Math.IEEEremainder(x, y);\r
                        }\r
-                       \r
+\r
                });\r
                model.functions.put("ceil", new Fn1(1) {\r
 \r
@@ -1125,5 +1139,5 @@ final public class Environment implements IEnvironment, ISystem {
        }\r
        \r
        private Set<Object> assigned = new HashSet<Object>();\r
-       \r
+\r
 }\r