Browse Source

Add dotProduct method to explicit.StateValues (already in symbolic ones).

accumulation-v4.7
Dave Parker 6 years ago
parent
commit
0bdae8bed0
  1. 16
      prism/src/explicit/StateValues.java

16
prism/src/explicit/StateValues.java

@ -1267,6 +1267,22 @@ public class StateValues implements StateVector
} }
} }
/**
* Compute dot (inner) product of this and another vector {@code sv}.
*/
public double dotProduct(StateValues sv) throws PrismException
{
if (type instanceof TypeDouble) {
double dotProduct = 0;
for (int i = 0; i < size; i++) {
dotProduct += valuesD[i] * sv.valuesI[i];
}
return dotProduct;
} else {
throw new PrismException("Dot product can only be applied to double vectors");
}
}
/** /**
* Set the elements of this vector by reading them in from a file. * Set the elements of this vector by reading them in from a file.
*/ */

Loading…
Cancel
Save