Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions quimb/tensor/decomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,18 @@ def _trim_and_renorm_svd_result(
return U, None, VH


@compose
def identity(x, **kwargs):
"""
No-op "decomposition" that leaves the input unchanged. Can be useful to quickly build a tensor network representing a given tensor "as is".
"""

if x.shape[0] < x.shape[1]:
return do("eye", x.shape[0], like=x), None, x
else:
return x, None, do("eye", x.shape[1], like=x)


@compose
def svd_truncated(
x,
Expand Down
1 change: 1 addition & 0 deletions quimb/tensor/tensor_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def rand_uuid(base=""):

_VALID_SPLIT_GET = {None, "arrays", "tensors", "values"}
_SPLIT_FNS = {
"identity": decomp.identity,
"svd": decomp.svd_truncated,
"eig": decomp.svd_via_eig_truncated,
"lu": decomp.lu_truncated,
Expand Down