Skip to content

Commit dd79826

Browse files
committed
copy variants for sdf3
1 parent a6904f1 commit dd79826

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

include/maxplus/algebra/mpmatrix.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ class Matrix {
171171

172172
void pasteRowVector(unsigned int top_row, unsigned int left_column, const Vector *pastedVector);
173173

174-
[[nodiscard]] virtual std::shared_ptr<Matrix> createCopy() const;
174+
[[nodiscard]] virtual std::shared_ptr<Matrix> createCopyPtr() const;
175+
[[nodiscard]] virtual Matrix createCopy() const;
175176

176177
[[nodiscard]] virtual std::shared_ptr<Matrix> getTransposedCopy() const;
177178

src/algebra/mpmatrix.cc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,9 +573,9 @@ Matrix Matrix::mp_power(const unsigned int p) const {
573573
}
574574

575575
/**
576-
* Matrix copy.
577-
*/
578-
std::shared_ptr<Matrix> Matrix::createCopy() const
576+
* Matrix copy.
577+
*/
578+
std::shared_ptr<Matrix> Matrix::createCopyPtr() const
579579
{
580580
std::shared_ptr<Matrix> newMatrix = std::make_shared<Matrix>(this->getRows(), this->getCols());
581581
unsigned int nEls = this->getRows() * this->getCols();
@@ -584,6 +584,18 @@ std::shared_ptr<Matrix> Matrix::createCopy() const
584584
}
585585
return newMatrix;
586586
}
587+
/**
588+
* Matrix copy.
589+
*/
590+
Matrix Matrix::createCopy() const
591+
{
592+
Matrix newMatrix(this->getRows(), this->getCols());
593+
unsigned int nEls = this->getRows() * this->getCols();
594+
for (unsigned int pos = 0; pos < nEls; pos++) {
595+
newMatrix.table[pos] = this->table[pos];
596+
}
597+
return newMatrix;
598+
}
587599

588600
/**
589601
* Matrix transposed copy.

src/graph/smpls.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ namespace MaxPlus::SMPLS {
473473
throw MPException("mode " + output + " not found in dissected matrices!");
474474
}
475475

476-
sMatrix = disSm->core.begin()->second->createCopy();
476+
sMatrix = disSm->core.begin()->second->createCopyPtr();
477477

478478
// look if it has any events to emit
479479
if (!disSm->eventRows.empty())

0 commit comments

Comments
 (0)