3#include "storm-config.h"
14template<
typename ValueType>
19template<
typename ValueType>
21 std::vector<ValueType>& result)
const {
22 std::vector<ValueType>* target = &result;
24 target = &this->provideCachedVector(x.size());
26 multAdd(x, b, *target);
28 std::swap(result, *target);
32template<
typename ValueType>
34 bool backwards)
const {
36 this->matrix.multiplyWithVectorBackward(x, x, b);
38 this->matrix.multiplyWithVectorForward(x, x, b);
42template<
typename ValueType>
44 std::vector<ValueType>
const& x, std::vector<ValueType>
const* b, std::vector<ValueType>& result,
45 std::vector<uint_fast64_t>* choices)
const {
46 std::vector<ValueType>* target = &result;
48 target = &this->provideCachedVector(x.size());
50 multAddReduce(dir, rowGroupIndices, x, b, *target, choices);
52 std::swap(result, *target);
56template<
typename ValueType>
58 std::vector<uint64_t>
const& rowGroupIndices, std::vector<ValueType>& x,
59 std::vector<ValueType>
const* b, std::vector<uint_fast64_t>* choices,
bool backwards)
const {
61 this->matrix.multiplyAndReduceBackward(dir, rowGroupIndices, x, b, x, choices);
63 this->matrix.multiplyAndReduceForward(dir, rowGroupIndices, x, b, x, choices);
67template<
typename ValueType>
69 for (
auto const& entry : this->matrix.getRow(rowIndex)) {
70 value += entry.getValue() * x[entry.getColumn()];
74template<
typename ValueType>
76 ValueType& val2)
const {
77 for (
auto const& entry : this->matrix.getRow(rowIndex)) {
78 val1 += entry.getValue() * x1[entry.getColumn()];
79 val2 += entry.getValue() * x2[entry.getColumn()];
83template<
typename ValueType>
85 this->matrix.multiplyWithVector(x, result, b);
88template<
typename ValueType>
90 std::vector<ValueType>
const& x, std::vector<ValueType>
const* b, std::vector<ValueType>& result,
91 std::vector<uint64_t>* choices)
const {
95template class NativeMultiplier<double>;
96template class NativeMultiplier<storm::RationalNumber>;
97template class NativeMultiplier<storm::RationalFunction>;
98template class NativeMultiplier<storm::Interval>;
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, 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
Performs a matrix-vector multiplication in gauss-seidel style.
virtual void multiply(Environment const &env, std::vector< ValueType > const &x, std::vector< ValueType > const *b, std::vector< ValueType > &result) const override
Performs a matrix-vector multiplication x' = A*x + b.
A class that holds a possibly non-square matrix in the compressed row storage format.