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, labels=None)[source]
Returns a square, diagonal matrix of entries s.
The resulting matrix has legs
(leg, leg.conj())
and charge 0.- Parameters:
s (scalar | 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.dtype (None | type) – The data type to be used for the result. By default, use dtype of s.
labels (list of {str | None}) – Labels associated to each leg,
None
for non-named labels.
- Returns:
diagonal – A square matrix with diagonal entries s.
- Return type:
See also
Array.scale_axis
similar as
tensordot(diag(s), ...)
, but faster.