Spenso · latest
On this page

trace

symbolica.community.tensor Function

trace(representation: Representation, *factors: TensorExpression | Expression | FactorProjector[TensorExpression]) -> TensorExpression

Close an ordered product along a representation channel.

Parameters

representation Representation

Space over which the matrix indices are traced.

*factors TensorExpression, scalar expression, Tensor, TensorNetwork, or FactorProjector

Ordered factors with compatible matrix channels. Additional axes are retained as spectator axes. Scalar factors multiply the whole trace. In the overloads, factor, first, and second name leading entries in this same sequence of positional factors.

Returns

TensorExpression or TensorNetwork

Symbolic operands produce a symbolic trace. Any component-bearing factor produces a lazy TensorNetwork.

Examples

from symbolica.community.tensor import Representation, TensorName, TensorExpression
space = Representation.euc(2)
A = TensorName("M")(space, space)
from symbolica.community.tensor import trace
trace(space, A, A).is_scalar

Member details

Overloads

Overload 1 #

trace(representation: Representation, *factors: TensorExpression | Expression | FactorProjector[TensorExpression]) -> TensorExpression

Close an ordered product along a representation channel.

Returns

TensorExpression or TensorNetwork

Symbolic operands produce a symbolic trace. Any component-bearing factor produces a lazy TensorNetwork.

Examples
from symbolica.community.tensor import Representation, TensorName, TensorExpression
space = Representation.euc(2)
A = TensorName("M")(space, space)
from symbolica.community.tensor import trace
trace(space, A, A).is_scalar
Parameters
NameTypeDefaultDescription
representationRepresentation—

Space over which the matrix indices are traced.

factorsTensorExpression | Expression | FactorProjector[TensorExpression]——

Overload 2 #

trace(representation: Representation, factor: Tensor | TensorNetwork | FactorProjector[TensorNetwork], /, *factors: TensorExpression | _ScalarInput | Tensor | TensorNetwork | FactorProjector[TensorExpression] | FactorProjector[TensorNetwork]) -> TensorNetwork

Close an ordered product along a representation channel.

Returns

TensorExpression or TensorNetwork

Symbolic operands produce a symbolic trace. Any component-bearing factor produces a lazy TensorNetwork.

Examples
from symbolica.community.tensor import Representation, TensorName, TensorExpression
space = Representation.euc(2)
A = TensorName("M")(space, space)
from symbolica.community.tensor import trace
trace(space, A, A).is_scalar
Parameters
NameTypeDefaultDescription
representationRepresentation—

Space over which the matrix indices are traced.

factorTensor | TensorNetwork | FactorProjector[TensorNetwork]——
factorsTensorExpression | _ScalarInput | Tensor | TensorNetwork | FactorProjector[TensorExpression] | FactorProjector[TensorNetwork]——

Overload 3 #

trace(representation: Representation, first: _ScalarInput | TensorExpression | TensorNetwork | Tensor | FactorProjector[TensorExpression] | FactorProjector[TensorNetwork], second: Tensor | TensorNetwork | FactorProjector[TensorNetwork], /, *factors: TensorExpression | _ScalarInput | Tensor | TensorNetwork | FactorProjector[TensorExpression] | FactorProjector[TensorNetwork]) -> TensorNetwork

Close an ordered product along a representation channel.

Returns

TensorExpression or TensorNetwork

Symbolic operands produce a symbolic trace. Any component-bearing factor produces a lazy TensorNetwork.

Examples
from symbolica.community.tensor import Representation, TensorName, TensorExpression
space = Representation.euc(2)
A = TensorName("M")(space, space)
from symbolica.community.tensor import trace
trace(space, A, A).is_scalar
Parameters
NameTypeDefaultDescription
representationRepresentation—

Space over which the matrix indices are traced.

first_ScalarInput | TensorExpression | TensorNetwork | Tensor | FactorProjector[TensorExpression] | FactorProjector[TensorNetwork]——
secondTensor | TensorNetwork | FactorProjector[TensorNetwork]——
factorsTensorExpression | _ScalarInput | Tensor | TensorNetwork | FactorProjector[TensorExpression] | FactorProjector[TensorNetwork]——

Overload 4 #

trace(representation: Representation, *factors: TensorExpression | _ScalarInput | Tensor | TensorNetwork | FactorProjector[TensorExpression] | FactorProjector[TensorNetwork]) -> TensorExpression | TensorNetwork

Close an ordered product along a representation channel.

Returns

TensorExpression or TensorNetwork

Symbolic operands produce a symbolic trace. Any component-bearing factor produces a lazy TensorNetwork.

Examples
from symbolica.community.tensor import Representation, TensorName, TensorExpression
space = Representation.euc(2)
A = TensorName("M")(space, space)
from symbolica.community.tensor import trace
trace(space, A, A).is_scalar
Parameters
NameTypeDefaultDescription
representationRepresentation—

Space over which the matrix indices are traced.

factorsTensorExpression | _ScalarInput | Tensor | TensorNetwork | FactorProjector[TensorExpression] | FactorProjector[TensorNetwork]——