From 55ff27424adb20e3f934fb52be5242e03b745939 Mon Sep 17 00:00:00 2001 From: Joachim Klein Date: Thu, 25 Feb 2016 16:26:44 +0000 Subject: [PATCH] JDD: add multi-operand Plus, Max and Min operations (convenience wrappers around Apply) git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@11220 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/src/jdd/JDD.java | 50 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/prism/src/jdd/JDD.java b/prism/src/jdd/JDD.java index c8d7797f..565c9c31 100644 --- a/prism/src/jdd/JDD.java +++ b/prism/src/jdd/JDD.java @@ -448,14 +448,52 @@ public class JDD * Operands are processed from left-to-right. *
[ REFS: result, DEREFS: all arguments ] */ - public static JDDNode Times(JDDNode... nodes) { - if (nodes.length <= 1) { - throw new IllegalArgumentException("JDD.Times needs at least two arguments."); + public static JDDNode Times(JDDNode node, JDDNode... nodes) { + JDDNode result = node; + for (JDDNode n : nodes) { + result = Apply(JDD.TIMES, result, n); } - JDDNode result = nodes[0]; - for (int i = 1; i[ REFS: result, DEREFS: all arguments ] + */ + public static JDDNode Plus(JDDNode node, JDDNode... nodes) { + JDDNode result = node; + for (JDDNode n : nodes) { + result = Apply(JDD.PLUS, result, n); + } + + return result; + } + + /** + * Multi-operand Apply(JDD.MAX) (maximum) operation. + * Operands are processed from left-to-right. + *
[ REFS: result, DEREFS: all arguments ] + */ + public static JDDNode Max(JDDNode node, JDDNode... nodes) { + JDDNode result = node; + for (JDDNode n : nodes) { + result = Apply(JDD.MAX, result, n); + } + + return result; + } + + /** + * Multi-operand Apply(JDD.MIN) (minimum) operation. + * Operands are processed from left-to-right. + *
[ REFS: result, DEREFS: all arguments ] + */ + public static JDDNode Min(JDDNode node, JDDNode... nodes) { + JDDNode result = node; + for (JDDNode n : nodes) { + result = Apply(JDD.MIN, result, n); } return result;