Skip to content

Commit

Permalink
abstract some SU related functionality (for block/fermionic)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmgray committed Jun 12, 2024
1 parent 0224a68 commit 847e0e9
Show file tree
Hide file tree
Showing 8 changed files with 224 additions and 195 deletions.
7 changes: 5 additions & 2 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Release notes for `quimb`.

(whats-new-1-8-2)=
## v1.8.2 (unreleased)
## v1.8.2 (2024-06-12)

**Enhancements:**

Expand All @@ -13,7 +13,10 @@ Release notes for `quimb`.
- Update generic TN optimizer docs.
- add [`tn.gen_inds_loops`](quimb.tensor.tensor_core.TensorNetwork.gen_inds_loops) for generating all loops of indices in a TN.
- add [`tn.gen_inds_connected`](quimb.tensor.tensor_core.TensorNetwork.gen_inds_connected) for generating all connected sets of indices in a TN.

- make SVD fallback error catching more generic ({pull}`#238`)
- fix some windows + numba CI issues.
- [`approx_spectral_function`](quimb.linalg.approx_spectral.approx_spectral_function) add plotting and tracking
- add dispatching to various tensor primitives to allow overriding

(whats-new-1-8-1)=
## v1.8.1 (2024-05-06)
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ write_to = "quimb/_version.py"

[tool.pytest.ini_options]
testpaths = "tests"
addopts = "--cov=quimb --cov-report term-missing --cov-report xml:coverage.xml --verbose --durations=10"
filterwarnings = "once"

[tool.coverage.run]
Expand Down
25 changes: 24 additions & 1 deletion quimb/tensor/array_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,25 @@ def ndim(array):
return len(array.shape)


@compose
def multiply_diagonal(x, v, axis, backend=None):
"""Multiply v into x as if contracting in a diagonal matrix."""
newshape = tuple((-1 if i == axis else 1) for i in range(ndim(x)))
v_broadcast = do("reshape", v, newshape, like=backend)
return x * v_broadcast


@compose
def align_axes(*arrays, axes, backend=None):
"""Prepare a set of arrays that should be contractible along ``axes``.
For example, block symmetric arrays need to have aligned sectors prior to
fusing.
"""
# default implementation is nothing
return arrays


# ------------- miscelleneous other backend agnostic functions -------------- #


Expand Down Expand Up @@ -281,7 +300,11 @@ def find_diag_axes(x, atol=1e-12):
if shape[i] != shape[j]:
continue
if do(
"allclose", x[indxrs[i] != indxrs[j]], zero, atol=atol, like=backend
"allclose",
x[indxrs[i] != indxrs[j]],
zero,
atol=atol,
like=backend,
):
return (i, j)
return None
Expand Down
Loading

0 comments on commit 847e0e9

Please sign in to comment.