From 484016abbba559b32f67b15755f4fbc805f81b42 Mon Sep 17 00:00:00 2001 From: villberg Date: Tue, 26 Aug 2014 11:59:08 +0000 Subject: [PATCH] refs #5224 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30141 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../fi/semantum/sysdyn/solver/Negation.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Negation.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Negation.java index 8cdad84e..97959451 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Negation.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Negation.java @@ -12,6 +12,8 @@ package fi.semantum.sysdyn.solver; import java.util.Map; +import fi.semantum.sysdyn.solver.Array.Modifier; + public class Negation implements IExpression { public IExpression exp; @@ -27,9 +29,26 @@ public class Negation implements IExpression { @Override public Object evaluate(IEnvironment environment) { - Double d = (Double)exp.evaluate(environment); - if(d == null) return null; - return -d; + Object value = exp.evaluate(environment); + if(value == null) return null; + if(value instanceof Double) { + return -((Double)value); + } else if(value instanceof Array) { + return ((Array)value).copy(new Modifier() { + + @Override + public Object modify(Object o) { + if(o instanceof Double) { + return -((Double)o); + } else { + throw new IllegalStateException(); + } + } + + }); + } else { + throw new IllegalStateException(); + } } @Override -- 2.47.1