[Numpy-discussion] How do I make a diagonal matrix?

Sven Schreiber svetosch at gmx.net
Fri Jun 23 09:34:14 CDT 2006


Keith Goodman schrieb:
> How do I make a NxN diagonal matrix with a Nx1 column vector x along
> the diagonal?
> 

>>> help(n.diag)
Help on function diag in module numpy.lib.twodim_base:

diag(v, k=0)
    returns the k-th diagonal if v is a array or returns a array
    with v as the k-th diagonal if v is a vector.




More information about the Numpy-discussion mailing list