File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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.
Original file line number Diff line number Diff 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 ())
You can’t perform that action at this time.
0 commit comments