Browse Source

avoid temporary in Eigen solver by providing .noalias(). slightly rewrote matrix-vector expression to benefit more from Eigen's optimization capabilities

Former-commit-id: 838eac1449
tempestpy_adaptions
dehnert 9 years ago
parent
commit
d24fb0cf9a
  1. 23
      src/solver/EigenLinearEquationSolver.cpp

23
src/solver/EigenLinearEquationSolver.cpp

@ -147,9 +147,10 @@ namespace storm {
auto currentX = &eigenX;
auto nextX = &eigenMultiplyResult;
for (uint64_t iteration = 0; iteration < n; ++iteration) {
*nextX = *eigenA * *currentX;
if (eigenB != nullptr) {
*nextX += *eigenB;
if (eigenB) {
nextX->noalias() = *eigenA * *currentX + *eigenB;
} else {
nextX->noalias() = *eigenA * *currentX;
}
std::swap(nextX, currentX);
}
@ -209,11 +210,11 @@ namespace storm {
auto currentX = &eigenX;
auto nextX = &eigenMultiplyResult;
for (uint64_t iteration = 0; iteration < n; ++iteration) {
*nextX = *eigenA * *currentX;
if (eigenB != nullptr) {
*nextX += *eigenB;
if (eigenB) {
nextX->noalias() = *eigenA * *currentX + *eigenB;
} else {
nextX->noalias() = *eigenA * *currentX;
}
std::swap(currentX, nextX);
}
// If the last result we obtained is not the one in the input vector x, we swap the result there.
@ -261,11 +262,11 @@ namespace storm {
auto currentX = &eigenX;
auto nextX = &eigenMultiplyResult;
for (uint64_t iteration = 0; iteration < n; ++iteration) {
*nextX = *eigenA * *currentX;
if (eigenB != nullptr) {
*nextX += *eigenB;
if (eigenB) {
nextX->noalias() = *eigenA * *currentX + *eigenB;
} else {
nextX->noalias() = *eigenA * *currentX;
}
std::swap(nextX, currentX);
}
// If the last result we obtained is not the one in the input vector x, we swap the result there.

Loading…
Cancel
Save