diff --git a/M2/Macaulay2/e/mutablemat-defs.hpp b/M2/Macaulay2/e/mutablemat-defs.hpp index ee5c76aa00c..b41e74a8d01 100644 --- a/M2/Macaulay2/e/mutablemat-defs.hpp +++ b/M2/Macaulay2/e/mutablemat-defs.hpp @@ -518,8 +518,7 @@ class MutableMat : public MutableMatrix n_cols() - 1); return 0; } - MutableMat* result = - new MutableMat(*this); // zero matrix, over the same ring + MutableMat* result = makeZeroMatrix(rows->len, cols->len); MatOps::setFromSubmatrix(getMat(), rows, cols, result->getMat()); return result; } @@ -534,8 +533,7 @@ class MutableMat : public MutableMatrix n_cols() - 1); return 0; } - MutableMat* result = - new MutableMat(*this); // zero matrix, over the same ring + MutableMat* result = makeZeroMatrix(n_rows(), cols->len); MatOps::setFromSubmatrix(getMat(), cols, result->getMat()); return result; } diff --git a/M2/Macaulay2/tests/normal/mutmat.m2 b/M2/Macaulay2/tests/normal/mutmat.m2 index d7ee8dcc57c..7e9ab1d6890 100644 --- a/M2/Macaulay2/tests/normal/mutmat.m2 +++ b/M2/Macaulay2/tests/normal/mutmat.m2 @@ -72,3 +72,8 @@ assert(ring mutableMatrix(ZZ/101, {{1,2,3}}) === ZZ/101) M = mutableMatrix {{1, 2, 3}, {4, 5, 6}} assert Equation(target M, ZZ^2) assert Equation(source M, ZZ^3) + +-- issue #997 +A = mutableMatrix {{10}} +B = submatrix(A, {0}, {0}) +assert(hash A != hash B)