Skip to content

Commit 5828c95

Browse files
committed
added getsubmatrix variant
1 parent 7c312d6 commit 5828c95

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

include/maxplus/algebra/mpmatrix.h

+2
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ class Matrix {
182182

183183
[[nodiscard]] Matrix getSubMatrix(const std::list<unsigned int> &indices) const;
184184

185+
[[nodiscard]] virtual std::shared_ptr<Matrix> getSubMatrixPtr(const std::list<unsigned int> &indices) const;
186+
185187
[[nodiscard]] Matrix getSubMatrixNonSquare(const std::list<unsigned int> &indices) const;
186188

187189
/**

src/algebra/mpmatrix.cc

+6
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,12 @@ Matrix Matrix::getSubMatrix(const std::list<unsigned int> &indices) const {
608608
return this->getSubMatrix(indices, indices);
609609
}
610610

611+
std::shared_ptr<Matrix> Matrix::getSubMatrixPtr(const std::list<unsigned int> &indices) const {
612+
assert(this->getRows() == this->getCols());
613+
return this->getSubMatrixPtr(indices, indices);
614+
}
615+
616+
611617
/**
612618
* Make sub matrix with indices in list for non-square matrix. The new matrix only keeps the columns
613619
* of the original matrix with the selected indices.

0 commit comments

Comments
 (0)