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.DomainNotNumbersException; |
6 | |
7 | /** |
8 | * Implements the operation "division" for different kinds of operands. |
9 | * @author martens, koziolek |
10 | */ |
11 | public class DivOperation extends TermProductOperation { |
12 | |
13 | @Override |
14 | public double compute(double left, double right) { |
15 | return left / right; |
16 | } |
17 | |
18 | @Override |
19 | public int compute(int left, int right) { |
20 | return left / right; |
21 | } |
22 | |
23 | @Override |
24 | public IProbabilityMassFunction compute(IProbabilityMassFunction left, |
25 | double right) throws DomainNotNumbersException { |
26 | return left.stretchDomain(1/right); |
27 | } |
28 | |
29 | @Override |
30 | public IProbabilityDensityFunction compute(IProbabilityDensityFunction left, double right) throws DomainNotNumbersException { |
31 | return left.stretchDomain(1/right); |
32 | } |
33 | |
34 | @Override |
35 | protected Double calculateOperationForValues(Double value1, Double value2) { |
36 | return value1 / value2; |
37 | } |
38 | |
39 | } |