| 1 | package de.uka.ipd.sdq.stoex.analyser.operations; |
| 2 | |
| 3 | import de.uka.ipd.sdq.probfunction.math.IProbabilityDensityFunction; |
| 4 | import de.uka.ipd.sdq.probfunction.math.IProbabilityMassFunction; |
| 5 | import de.uka.ipd.sdq.probfunction.math.exception.DifferentDomainsException; |
| 6 | import de.uka.ipd.sdq.probfunction.math.exception.DomainNotNumbersException; |
| 7 | import de.uka.ipd.sdq.probfunction.math.exception.FunctionsInDifferenDomainsException; |
| 8 | import de.uka.ipd.sdq.probfunction.math.exception.IncompatibleUnitsException; |
| 9 | import de.uka.ipd.sdq.probfunction.math.exception.UnknownPDFTypeException; |
| 10 | |
| 11 | /** |
| 12 | * Implements the operation "addition" for different kinds of operands. |
| 13 | * @author martens, koziolek |
| 14 | */ |
| 15 | public class AddOperation extends TermProductOperation { |
| 16 | |
| 17 | @Override |
| 18 | public int compute(int left, int right) { |
| 19 | return left+right; |
| 20 | } |
| 21 | |
| 22 | @Override |
| 23 | public double compute(double left, double right) { |
| 24 | return left+right; |
| 25 | } |
| 26 | |
| 27 | @Override |
| 28 | public IProbabilityMassFunction compute(IProbabilityMassFunction left, double right) throws DomainNotNumbersException { |
| 29 | if (right == 0){ |
| 30 | return left; |
| 31 | } else { |
| 32 | return left.shiftDomain(right); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | @Override |
| 37 | public IProbabilityDensityFunction compute(IProbabilityDensityFunction left, double right) throws DomainNotNumbersException { |
| 38 | if (right == 0){ |
| 39 | return left; |
| 40 | } else { |
| 41 | return left.shiftDomain(right); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | @Override |
| 46 | protected Double calculateOperationForValues(Double value1, Double value2) { |
| 47 | return value1 + value2; |
| 48 | } |
| 49 | |
| 50 | } |