[Numpy-discussion] fixing diag() for matrices
Christopher Barker
Chris.Barker at noaa.gov
Fri Jul 28 12:43:44 EDT 2006
Keith Goodman wrote:
> diag(NxN matrix) should return a Nx1 matrix
> diag(Nx1 or 1xN matrix) should return a NxN matrix
This is the key problem: extracting the diagonal of a matrix and
creating a matrix from a diagonal are two different operations:
overloading one function to do both was a bad idea to begin with.
Maybe we should just keep diag() as is is for backward compatibility
(deprecated), and make:
get_diag() and make_diag() instead.
Then it would be unambiguous what you wanted with:
make_diag(<Nx1array>)
You can call them something else, but you get the idea.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the NumPy-Discussion
mailing list