15template<
typename ValueType>
20template<
typename ValueType>
22 std::vector<ValueType>& result)
const {
23 std::vector<ValueType>* target = &result;
27 multAdd(x, b, *target);
29 std::swap(result, *target);
33template<
typename ValueType>
35 bool backwards)
const {
37 this->
matrix.multiplyWithVectorBackward(x, x, b);
39 this->
matrix.multiplyWithVectorForward(x, x, b);
43template<
typename ValueType>
45 std::vector<ValueType>
const& x, std::vector<ValueType>
const* b, std::vector<ValueType>& result,
47 STORM_LOG_THROW(uncertaintyResolutionMode == UncertaintyResolutionMode::Unset, storm::exceptions::NotSupportedException,
48 "Uncertainty resolution modes other than 'Unset' are not supported by the native multiplier.");
50 std::vector<ValueType>* target = &result;
54 multAddReduce(dir, rowGroupIndices, x, b, *target, choices);
56 std::swap(result, *target);
60template<
typename ValueType>
62 std::vector<uint64_t>
const& rowGroupIndices, std::vector<ValueType>& x,
63 std::vector<ValueType>
const* b, std::vector<uint_fast64_t>* choices,
bool backwards)
const {
65 this->
matrix.multiplyAndReduceBackward(dir, rowGroupIndices, x, b, x, choices);
67 this->
matrix.multiplyAndReduceForward(dir, rowGroupIndices, x, b, x, choices);
71template<
typename ValueType>
73 for (
auto const& entry : this->
matrix.getRow(rowIndex)) {
74 value += entry.getValue() * x[entry.getColumn()];
78template<
typename ValueType>
80 ValueType& val2)
const {
81 for (
auto const& entry : this->
matrix.getRow(rowIndex)) {
82 val1 += entry.getValue() * x1[entry.getColumn()];
83 val2 += entry.getValue() * x2[entry.getColumn()];
87template<
typename ValueType>
88void NativeMultiplier<ValueType>::multAdd(std::vector<ValueType>
const& x, std::vector<ValueType>
const* b, std::vector<ValueType>& result)
const {
89 this->matrix.multiplyWithVector(x, result, b);
92template<
typename ValueType>
94 std::vector<ValueType>
const& x, std::vector<ValueType>
const* b, std::vector<ValueType>& result,
95 std::vector<uint64_t>* choices)
const {
96 this->matrix.multiplyAndReduce(dir, rowGroupIndices, x, b, result, choices);
99template class NativeMultiplier<double>;
100template class NativeMultiplier<storm::RationalNumber>;
101template class NativeMultiplier<storm::RationalFunction>;
102template class NativeMultiplier<storm::Interval>;
Multiplier(storm::storage::SparseMatrix< ValueType > const &matrix)
std::vector< SolutionType > & provideCachedVector(uint64_t size) const
storm::storage::SparseMatrix< ValueType > const & matrix
virtual void multiplyAndReduceGaussSeidel(Environment const &env, OptimizationDirection const &dir, std::vector< uint64_t > const &rowGroupIndices, std::vector< ValueType > &x, std::vector< ValueType > const *b, std::vector< uint_fast64_t > *choices=nullptr, bool backwards=true) const override
void multiplyRow(uint64_t const &rowIndex, std::vector< ValueType > const &x, ValueType &value) const
Multiplies the row with the given index with x and adds the result to the provided value.
NativeMultiplier(storm::storage::SparseMatrix< ValueType > const &matrix)
void multiplyRow2(uint64_t const &rowIndex, std::vector< ValueType > const &x1, ValueType &val1, std::vector< ValueType > const &x2, ValueType &val2) const
Multiplies the row with the given index with x1 and x2 and adds the given offset o1 and o2,...
virtual void multiplyAndReduce(Environment const &env, OptimizationDirection const &dir, std::vector< uint64_t > const &rowGroupIndices, std::vector< ValueType > const &x, std::vector< ValueType > const *b, std::vector< ValueType > &result, UncertaintyResolutionMode const &uncertaintyResolutionMode=UncertaintyResolutionMode::Unset, std::vector< uint_fast64_t > *choices=nullptr) const override
virtual void multiplyGaussSeidel(Environment const &env, std::vector< ValueType > &x, std::vector< ValueType > const *b, bool backwards=true) const override
virtual void multiply(Environment const &env, std::vector< ValueType > const &x, std::vector< ValueType > const *b, std::vector< ValueType > &result) const override
A class that holds a possibly non-square matrix in the compressed row storage format.
#define STORM_LOG_THROW(cond, exception, message)
UncertaintyResolutionMode