3#include "storm-config.h"
18template<
typename ValueType>
23template<
typename ValueType>
28template<
typename ValueType>
30 std::vector<ValueType>& result)
const {
31 std::vector<ValueType>* target = &result;
33 target = &this->provideCachedVector(x.size());
35 if (parallelize(env)) {
36 multAddParallel(x, b, *target);
38 multAdd(x, b, *target);
41 std::swap(result, *target);
45template<
typename ValueType>
47 bool backwards)
const {
49 this->matrix.multiplyWithVectorBackward(x, x, b);
51 this->matrix.multiplyWithVectorForward(x, x, b);
55template<
typename ValueType>
57 std::vector<ValueType>
const& x, std::vector<ValueType>
const* b, std::vector<ValueType>& result,
58 std::vector<uint_fast64_t>* choices)
const {
59 std::vector<ValueType>* target = &result;
61 target = &this->provideCachedVector(x.size());
63 if (parallelize(env)) {
64 multAddReduceParallel(dir, rowGroupIndices, x, b, *target, choices);
66 multAddReduce(dir, rowGroupIndices, x, b, *target, choices);
69 std::swap(result, *target);
73template<
typename ValueType>
75 std::vector<uint64_t>
const& rowGroupIndices, std::vector<ValueType>& x,
76 std::vector<ValueType>
const* b, std::vector<uint_fast64_t>* choices,
bool backwards)
const {
78 this->matrix.multiplyAndReduceBackward(dir, rowGroupIndices, x, b, x, choices);
80 this->matrix.multiplyAndReduceForward(dir, rowGroupIndices, x, b, x, choices);
84template<
typename ValueType>
86 for (
auto const& entry : this->matrix.getRow(rowIndex)) {
87 value += entry.getValue() * x[entry.getColumn()];
91template<
typename ValueType>
93 ValueType& val2)
const {
94 for (
auto const& entry : this->matrix.getRow(rowIndex)) {
95 val1 += entry.getValue() * x1[entry.getColumn()];
96 val2 += entry.getValue() * x2[entry.getColumn()];
100template<
typename ValueType>
102 this->matrix.multiplyWithVector(x, result, b);
105template<
typename ValueType>
107 std::vector<ValueType>
const& x, std::vector<ValueType>
const* b, std::vector<ValueType>& result,
108 std::vector<uint64_t>* choices)
const {
112template<
typename ValueType>
113void NativeMultiplier<ValueType>::multAddParallel(std::vector<ValueType>
const& x, std::vector<ValueType>
const* b, std::vector<ValueType>& result)
const {
114#ifdef STORM_HAVE_INTELTBB
115 this->matrix.multiplyWithVectorParallel(x, result, b);
117 STORM_LOG_WARN(
"Storm was built without support for Intel TBB, defaulting to sequential version.");
118 multAdd(x, b, result);
122template<
typename ValueType>
124 std::vector<ValueType>
const& x, std::vector<ValueType>
const* b, std::vector<ValueType>& result,
125 std::vector<uint64_t>* choices)
const {
126#ifdef STORM_HAVE_INTELTBB
127 this->matrix.multiplyAndReduceParallel(dir, rowGroupIndices, x, b, result, choices);
129 STORM_LOG_WARN(
"Storm was built without support for Intel TBB, defaulting to sequential version.");
130 multAddReduce(dir, rowGroupIndices, x, b, result, choices);
134template class NativeMultiplier<double>;
135template class NativeMultiplier<storm::RationalNumber>;
136template class NativeMultiplier<storm::RationalFunction>;
137template 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.
#define STORM_LOG_WARN(message)