diag¶
full name: tenpy.linalg.np_conserved.diag
parent module:
tenpy.linalg.np_conserved
type: function
-
tenpy.linalg.np_conserved.
diag
(s, leg, dtype=None)[source]¶ Returns a square, diagonal matrix of entries s.
The resulting matrix has legs
(leg, leg.conj())
and charge 0.- Parameters
- sscalar | 1D array
The entries to put on the diagonal. If scalar, all diagonal entries are the same.
- leg
LegCharge
The first leg of the resulting matrix.
- dtypeNone | type
The data type to be used for the result. By default, use dtype of s.
- Returns
- diagonal
Array
A square matrix with diagonal entries s.
- diagonal
See also
Array.scale_axis
similar as
tensordot(diag(s), ...)
, but faster.