Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Removed immutability of diagonal matrix and edited documentation appr…
Browse files Browse the repository at this point in the history
…opriately
  • Loading branch information
SagnikDey92 authored and jhpalmieri committed Mar 2, 2020
1 parent 5c2a5b2 commit 14c422a
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/sage/matrix/matrix_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -1588,9 +1588,7 @@ def diagonal_matrix(self, entries):
``self`` must be a space of square matrices. Length of ``entries`` must be less
than or equal to matrix dimensions.If length of ``entries`` is less than matrix
dimensions, ``entries`` is padded with zeroes at the end.
The returned matrix is immutable. Please use ``copy`` if
you want a modified copy.
dimensions, ``entries`` is padded with zeroes at the end.
EXAMPLES::
Expand All @@ -1611,13 +1609,6 @@ def diagonal_matrix(self, entries):
...
TypeError: number of diagonal matrix entries (5) exceeds the matrix size (4)
TESTS::
sage: MS1.diag([1, 2, 3, 4])[1,2] = 3
Traceback (most recent call last):
...
ValueError: matrix is immutable; please change a copy instead (i.e., use copy(M) to change a copy of M).
Check different implementations::
sage: M1 = MatrixSpace(ZZ, 2, implementation='flint')
Expand All @@ -1636,7 +1627,6 @@ def diagonal_matrix(self, entries):
A = self.zero_matrix().__copy__()
for i in range(len(entries)):
A[i, i] = entries[i]
A.set_immutable()
return A

diag = diagonal_matrix
Expand Down

0 comments on commit 14c422a

Please sign in to comment.