trace¶
full name: tenpy.linalg.np_conserved.trace
parent module:
tenpy.linalg.np_conserved
type: function
-
tenpy.linalg.np_conserved.
trace
(a, leg1=0, leg2=1)[source]¶ Trace of a, summing over leg1 and leg2.
Requires that the contracted legs are contractible (i.e. have opposite charges). Labels are inherited from a.
- Parameters
leg2 (leg1,) – The leg label or index for the two legs which should be contracted (i.e. summed over).
- Returns
traced – A scalar if
a.rank == 2
, else anArray
of ranka.rank - 2
. Equivalent tosum([a.take_slice([i, i], [leg1, leg2]) for i in range(a.shape[leg1])])
.- Return type
Array
|a.dtype