Browse Source

Few extra methods in StateValues.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@5622 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 13 years ago
parent
commit
1b5dc955e6
  1. 80
      prism/src/explicit/StateValues.java

80
prism/src/explicit/StateValues.java

@ -707,6 +707,46 @@ public class StateValues
}
}
/**
* Modify the vector by applying 'plus' with a constant.
*/
public void plusConstant(int val) throws PrismException
{
if (type instanceof TypeInt) {
for (int i = 0; i < size; i++) {
valuesI[i] += val;
}
} else if (type instanceof TypeDouble) {
for (int i = 0; i < size; i++) {
valuesD[i] += val;
}
} else {
throw new PrismException("Operator + can not be applied to Boolean vectors");
}
}
/**
* Modify the vector by applying 'plus' with a constant.
*/
public void plusConstant(double val) throws PrismException
{
if (type instanceof TypeInt) {
// Change type
valuesD = new double[size];
type = TypeDouble.getInstance();
for (int i = 0; i < size; i++) {
valuesD[i] = valuesI[i] + val;
}
valuesI = null;
} else if (type instanceof TypeDouble) {
for (int i = 0; i < size; i++) {
valuesD[i] += val;
}
} else {
throw new PrismException("Operator + can not be applied to Boolean vectors");
}
}
/**
* Modify the vector by applying 'minus' with operand {@code sv}.
*/
@ -781,6 +821,46 @@ public class StateValues
}
}
/**
* Modify the vector by applying 'times' with a constant.
*/
public void timesConstant(int val) throws PrismException
{
if (type instanceof TypeInt) {
for (int i = 0; i < size; i++) {
valuesI[i] *= val;
}
} else if (type instanceof TypeDouble) {
for (int i = 0; i < size; i++) {
valuesD[i] *= val;
}
} else {
throw new PrismException("Operator + can not be applied to Boolean vectors");
}
}
/**
* Modify the vector by applying 'times' with a constant.
*/
public void timesConstant(double val) throws PrismException
{
if (type instanceof TypeInt) {
// Change type
valuesD = new double[size];
type = TypeDouble.getInstance();
for (int i = 0; i < size; i++) {
valuesD[i] = valuesI[i] * val;
}
valuesI = null;
} else if (type instanceof TypeDouble) {
for (int i = 0; i < size; i++) {
valuesD[i] *= val;
}
} else {
throw new PrismException("Operator + can not be applied to Boolean vectors");
}
}
/**
* Modify the vector by applying 'divide' with operand {@code sv}.
*/

Loading…
Cancel
Save