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 if (this->cachedVector) {
34 this->cachedVector->resize(x.size());
36 this->cachedVector = std::make_unique<std::vector<ValueType>>(x.size());
38 target = this->cachedVector.get();
40 if (parallelize(env)) {
41 multAddParallel(x, b, *target);
43 multAdd(x, b, *target);
46 std::swap(result, *this->cachedVector);
50template<
typename ValueType>
52 bool backwards)
const {
54 this->matrix.multiplyWithVectorBackward(x, x, b);
56 this->matrix.multiplyWithVectorForward(x, x, b);
60template<
typename ValueType>
62 std::vector<ValueType>
const& x, std::vector<ValueType>
const* b, std::vector<ValueType>& result,
63 std::vector<uint_fast64_t>* choices)
const {
64 std::vector<ValueType>* target = &result;
66 if (this->cachedVector) {
67 this->cachedVector->resize(x.size());
69 this->cachedVector = std::make_unique<std::vector<ValueType>>(x.size());
71 target = this->cachedVector.get();
73 if (parallelize(env)) {
74 multAddReduceParallel(dir, rowGroupIndices, x, b, *target, choices);
76 multAddReduce(dir, rowGroupIndices, x, b, *target, choices);
79 std::swap(result, *this->cachedVector);
83template<
typename ValueType>
85 std::vector<uint64_t>
const& rowGroupIndices, std::vector<ValueType>& x,
86 std::vector<ValueType>
const* b, std::vector<uint_fast64_t>* choices,
bool backwards)
const {
88 this->matrix.multiplyAndReduceBackward(dir, rowGroupIndices, x, b, x, choices);
90 this->matrix.multiplyAndReduceForward(dir, rowGroupIndices, x, b, x, choices);
94template<
typename ValueType>
96 for (
auto const& entry : this->matrix.getRow(rowIndex)) {
97 value += entry.getValue() * x[entry.getColumn()];
101template<
typename ValueType>
103 ValueType& val2)
const {
104 for (
auto const& entry : this->matrix.getRow(rowIndex)) {
105 val1 += entry.getValue() * x1[entry.getColumn()];
106 val2 += entry.getValue() * x2[entry.getColumn()];
110template<
typename ValueType>
112 this->matrix.multiplyWithVector(x, result, b);
115template<
typename ValueType>
117 std::vector<ValueType>
const& x, std::vector<ValueType>
const* b, std::vector<ValueType>& result,
118 std::vector<uint64_t>* choices)
const {
122template<
typename ValueType>
123void NativeMultiplier<ValueType>::multAddParallel(std::vector<ValueType>
const& x, std::vector<ValueType>
const* b, std::vector<ValueType>& result)
const {
124#ifdef STORM_HAVE_INTELTBB
125 this->matrix.multiplyWithVectorParallel(x, result, b);
127 STORM_LOG_WARN(
"Storm was built without support for Intel TBB, defaulting to sequential version.");
128 multAdd(x, b, result);
132template<
typename ValueType>
134 std::vector<ValueType>
const& x, std::vector<ValueType>
const* b, std::vector<ValueType>& result,
135 std::vector<uint64_t>* choices)
const {
136#ifdef STORM_HAVE_INTELTBB
137 this->matrix.multiplyAndReduceParallel(dir, rowGroupIndices, x, b, result, choices);
139 STORM_LOG_WARN(
"Storm was built without support for Intel TBB, defaulting to sequential version.");
140 multAddReduce(dir, rowGroupIndices, x, b, result, choices);
144template class NativeMultiplier<double>;
145template class NativeMultiplier<storm::RationalNumber>;
146template class NativeMultiplier<storm::RationalFunction>;
147template 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
virtual void multiplyRow2(uint64_t const &rowIndex, std::vector< ValueType > const &x1, ValueType &val1, std::vector< ValueType > const &x2, ValueType &val2) const override
Multiplies the row with the given index with x1 and x2 and adds the given offset o1 and o2,...
NativeMultiplier(storm::storage::SparseMatrix< ValueType > const &matrix)
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 multiplyRow(uint64_t const &rowIndex, std::vector< ValueType > const &x, ValueType &value) const override
Multiplies the row with the given index with x and adds the result to the provided value.
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)