]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
refs #4960
authorvillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 18 Jun 2014 06:27:17 +0000 (06:27 +0000)
committervillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 18 Jun 2014 06:27:17 +0000 (06:27 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@29641 ac1ea38d-2e2b-0410-8846-a27921b304fc

fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwiseDivision.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwiseProduct.java

index 69688355e7db8db12fa813b4e894306e817e12e9..77362aa55ac60b302fdaef36d042ad86aecc58a3 100644 (file)
@@ -48,7 +48,20 @@ public class ElementwiseDivision implements IExpression {
                                result.addElement(ld/rd);\r
                        }\r
                        return result;\r
-               } else throw new UnsupportedOperationException();\r
+               } else if(left instanceof Array && right instanceof Double) {\r
+                       Array la = (Array)left;\r
+                       double rd = (Double)right;\r
+                       Collection<Object> lae = la.elements();\r
+                       Iterator<Object> li = lae.iterator();\r
+                       Array result = new Array();\r
+                       for(int i=0;i<lae.size();i++) {\r
+                               double ld = (Double)li.next();\r
+                               result.addElement(ld/rd);\r
+                       }\r
+                       return result;\r
+               } else {\r
+                       throw new UnsupportedOperationException();\r
+               }\r
        }\r
        \r
        @Override\r
index 59ea9718f7aa8885879d907ac3cfbb940c9264d3..e3198cfeca802c842bbd872682e2bce778559873 100644 (file)
@@ -48,7 +48,20 @@ public class ElementwiseProduct implements IExpression {
                                result.addElement(ld*rd);\r
                        }\r
                        return result;\r
-               } else throw new UnsupportedOperationException();\r
+               } else if (left instanceof Array && right instanceof Double) {\r
+                       Array la = (Array)left;\r
+                       Double rd = (Double)right;\r
+                       Collection<Object> lae = la.elements();\r
+                       Iterator<Object> li = lae.iterator();\r
+                       Array result = new Array();\r
+                       for(int i=0;i<lae.size();i++) {\r
+                               double ld = (Double)li.next();\r
+                               result.addElement(ld*rd);\r
+                       }\r
+                       return result;\r
+               } else {\r
+                       throw new UnsupportedOperationException();\r
+               }\r
        }\r
        \r
        @Override\r