Storm 2.0.0.3
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
BackwardTransitionCache.cpp
Go to the documentation of this file.
2
6
7namespace storm::storage {
8
9template<typename ValueType>
11 : forwardTransitionMatrixRef(forwardTransitionMatrix),
12 keepZeros(keepZeros),
13 backwardTransitions(std::make_shared<std::optional<SparseMatrix<ValueType>>>()) {
14 // Intentionally left empty.
15}
16
17template<typename ValueType>
19 SparseMatrix<ValueType>&& backwardTransitionMatrix, bool keepZeros)
20 : forwardTransitionMatrixRef(forwardTransitionMatrix),
21 keepZeros(keepZeros),
22 backwardTransitions(std::make_shared<std::optional<SparseMatrix<ValueType>>>(std::move(backwardTransitionMatrix))) {
23 // Intentionally left empty.
24}
25
26template<typename ValueType>
28 STORM_LOG_ASSERT(this->backwardTransitions != nullptr, "Backward transitions should never be nullptr");
29 if (!isCached()) {
30 this->backwardTransitions->emplace(forwardTransitionMatrixRef.transpose(true, keepZeros));
31 }
32 return **this->backwardTransitions;
33}
34
35template<typename ValueType>
37 STORM_LOG_ASSERT(this->backwardTransitions != nullptr, "Backward transitions should never be nullptr");
38 this->backwardTransitions->reset();
39}
40
41template<typename ValueType>
43 STORM_LOG_ASSERT(this->backwardTransitions != nullptr, "Backward transitions should never be nullptr");
44 return this->backwardTransitions->has_value();
45}
46
49
50} // namespace storm::storage
This class caches the backward transitions of a given forward transition matrix.
bool isCached() const
Retrieves whether the backward transitions are currently cached.
void clearCache() const
Clears the cache (for this and all copies of this cache).
SparseMatrix< ValueType > const & get() const
Retrieves the backward transitions.
A class that holds a possibly non-square matrix in the compressed row storage format.
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:9