allclose¶
allclose
¶
Return True if two tensors are numerically equal within the given tolerances.
For Abelian tensors, compares each dense block with torch.allclose.
For generic tensors, compares the physical tensors R @ W block-by-block,
which is gauge-invariant with respect to the reduced representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Tensor
|
First tensor. |
required |
B
|
Tensor
|
Second tensor. |
required |
rtol
|
float
|
Relative tolerance passed to |
1e-05
|
atol
|
float
|
Absolute tolerance passed to |
1e-08
|
Returns:
| Type | Description |
|---|---|
bool
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If either argument is not a |
ValueError
|
If the tensors have incompatible index structures. |
Notes¶
- For Abelian tensors, each dense block is compared directly with
torch.allclose. - For non-Abelian (SU(2)) tensors, the physical tensor
R @ Wis compared block-by-block, making the check invariant to the gauge freedom in the reduced representation. Two tensors that represent the same physical content but differ in their internal(R, W)factorization will still compare as equal. - Structural mismatches (different tensor order, incompatible groups or directions)
raise
ValueError. Differing block keys returnFalsewithout raising.
See Also¶
- Basic Operations:
+,-,*,/ - Tensor:
Tensor.__eq__for exact equality - Bridge: SU(2) intertwiner container