unit_matrix() uses a heap-allocated matrix
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Thu, 27 Feb 2003 21:08:19 +0000 (21:08 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Thu, 27 Feb 2003 21:08:19 +0000 (21:08 +0000)
ginac/matrix.cpp

index 146127f..d82abab 100644 (file)
@@ -1481,9 +1481,11 @@ ex diag_matrix(const lst & l)
 
 ex unit_matrix(unsigned r, unsigned c)
 {
-       matrix Id(r,c);
-       for (unsigned i=0; i<r && i<c; ++i)
+       matrix &Id = *new matrix(r, c);
+       Id.setflag(status_flags::dynallocated);
+       for (unsigned i=0; i<r && i<c; i++)
                Id(i,i) = _ex1;
+
        return Id;
 }