Direction¶
Arrow direction for tensor network edges.
Direction
¶
Arrow direction for a tensor network edge: incoming (+1) or outgoing (-1).
Use the static constructors incoming() and outgoing() rather than
instantiating directly.
Examples:
>>> import yuzuha
>>> d = yuzuha.Direction.incoming()
>>> print(d.sign())
1
>>> print(d.flip())
Direction.outgoing
incoming
staticmethod
¶
Create an incoming Direction (sign = +1).
Returns:
| Type | Description |
|---|---|
Direction
|
An incoming direction. |
outgoing
staticmethod
¶
Create an outgoing Direction (sign = -1).
Returns:
| Type | Description |
|---|---|
Direction
|
An outgoing direction. |
from_sign
staticmethod
¶
Create a Direction from its sign value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sign
|
int
|
|
required |
Returns:
| Type | Description |
|---|---|
Direction
|
The corresponding Direction. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
sign
¶
Return the numerical sign of this direction.
Returns:
| Type | Description |
|---|---|
int
|
|
flip
¶
is_incoming
¶
Return True if this direction is incoming.
Returns:
| Type | Description |
|---|---|
bool
|
True if incoming. |
is_outgoing
¶
Return True if this direction is outgoing.
Returns:
| Type | Description |
|---|---|
bool
|
True if outgoing. |
Description¶
Direction is a two-valued enum that specifies whether an external edge is incoming
(primal representation) or outgoing (dual representation). Arrow directions govern
how charges fuse and how the invariant metric is applied when reversing an arrow.
from yuzuha import Direction
d_in = Direction.Incoming # primal / ket-type index
d_out = Direction.Outgoing # dual / bra-type index
In the sign convention used throughout Yuzuha:
- An incoming edge with spin \(j\) contributes a factor of \(+1\) to the total magnetic quantum number sum.
- An outgoing edge with spin \(j\) contributes a factor of \(-1\).
Charge conservation then requires that the total signed magnetic quantum number of all edges is zero:
Arrow reversal from incoming to outgoing is implemented via the metric tensor \(g\). Arrow reversal from outgoing to incoming uses \(g^{-1} = (-1)^{2j}\, g\), which is \(+g\) for integer spins and \(-g\) for half-integer spins.
See Also¶
- Edge: Pairs
Directionwith aSpin - Metric Tensor:
use_as_incoming,use_as_outgoing - Yuzuha Protocol — Type System: Abstract
Directionenum specification - Yuzuha Protocol — Arrow Conventions: Arrow reversal conventions
Notes¶
Direction values are comparable and can be passed directly to Edge.incoming /
Edge.outgoing constructors. The .flip() method (if available on the Rust type) is
accessible from Python as Edge.with_flipped_direction().