symmray.bosonic_common ====================== .. py:module:: symmray.bosonic_common .. autoapi-nested-parse:: Common methods for any 'bosonic' (non-fermionic) arrays. Classes ------- .. autoapisummary:: symmray.bosonic_common.BosonicCommon Module Contents --------------- .. py:class:: BosonicCommon Mixin for bosonic (non-fermionic) arrays. .. py:method:: to_pytree() Convert this abelian array to a pytree purely of non-symmray containers and objects. .. py:method:: _binary_blockwise_op(other, fn, missing=None, inplace=False) .. py:method:: _split(*args, **kwargs) .. py:method:: transpose(axes=None, inplace=False) -> BosonicCommon Transpose this abelian array. :param axes: A permutation of the axes to transpose the array by. If None, the axes will be reversed. :type axes: tuple[int, ...] | None, optional :param inplace: Whether to perform the operation inplace or return a new array. :type inplace: bool, optional :rtype: BosonicCommon .. py:method:: conj(inplace=False) -> BosonicCommon Return the complex conjugate of this abelian array, including the indices and any subindex fusing information. :param inplace: Whether to perform the operation inplace or return a new array. :type inplace: bool, optional :rtype: BosonicCommon .. py:method:: dagger(inplace=False) -> BosonicCommon Return the adjoint of this abelian array, including the indices and any subindex fusing information. :param inplace: Whether to perform the operation inplace or return a new array. :type inplace: bool, optional :rtype: AbelianArray .. py:attribute:: dagger_project_left .. py:attribute:: dagger_project_right .. py:attribute:: dagger_compose_left .. py:attribute:: dagger_compose_right .. py:method:: _fuse_core(*axes_groups, mode='auto', inplace=False) -> BosonicCommon The core implementation of the fuse operation, which fuses multiple axes into a single group, and returns a new array with the new sectors and blocks. The new axes are inserted at the minimum axis of any of the groups. .. py:method:: unfuse(axis, inplace=False) -> BosonicCommon Unfuse the ``axis`` index, which must carry subindex information, likely generated automatically from a fusing operation. :param axis: The axis to unfuse. It must have subindex information (``.indices[axis].subinfo``), typically from a previous fusing operation. :type axis: int :param inplace: Whether to perform the operation inplace or return a new array. :type inplace: bool, optional :rtype: BosonicCommon .. py:method:: squeeze(axis=None, inplace=False) -> BosonicCommon Squeeze the abelian array, removing axes of size 1. :param axis: The axis or axes to squeeze. If None, all axes of size 1 will be removed. :type axis: int or sequence of int, optional :param inplace: Whether to perform the operation inplace or return a new array. :type inplace: bool, optional :rtype: BosonicCommon .. py:method:: einsum(eq, preserve_array=False) Einsum for abelian arrays, currently only single term. :param eq: The einsum equation, e.g. "abcb->ca". The output indices must be specified and only trace and permutations are allowed. :type eq: str :param preserve_array: If tracing to a scalar, whether to return an abelian array object with no indices, or simply the scalar itself (the default). :type preserve_array: bool, optional :rtype: BosonicCommon or scalar .. py:method:: tensordot(other, axes=2, mode='auto', preserve_array=False) Tensordot between two abelian symmetric arrays. :param other: The other array to contract with. :type other: BosonicCommon :param axes: The axes to contract. If an integer, the last ``axes`` axes of ``self`` will be contracted with the first ``axes`` axes of ``other``. If a tuple, the axes to contract in ``self`` and ``other`` respectively. :type axes: int or tuple[int] :param mode: The mode to use for the contraction. If "auto", it will choose between "fused" and "blockwise" based on the number of axes to contract. :type mode: {"auto", "fused", "blockwise"} :param preserve_array: Whether to return a scalar if the result is a scalar. :type preserve_array: bool, optional .. py:method:: __matmul__(other, preserve_array=False) .. py:method:: trace() Compute the trace of the abelian array, assuming it is a square matrix. .. py:method:: to_dense() Convert this abelian array to a dense array, by combining all the blocks into a single large array, filling in zeros where necessary. :returns: A dense array with the same shape as this abelian array. :rtype: array_like .. py:method:: allclose(other, **allclose_opts) Test whether this abelian array is close to another, that is, has all the same sectors, and the corresponding arrays are close. :param other: The other array to compare to. :type other: BosonicCommon :param allclose_opts: Keyword arguments to pass to ``allclose``. :rtype: bool .. py:method:: test_allclose(other, **allclose_opts) Assert that this abelian array is close to another, that is, has all the same sectors, and the corresponding arrays are close. Unlike ``allclose``, this raises an AssertionError with details if not. :param other: The other array to compare to. :type other: BosonicCommon :param allclose_opts: Keyword arguments to pass to ``allclose``. :raises AssertionError: If the arrays are not close. .. py:method:: eigh(**kwargs) Eigenvalue decomposition of this assumed Hermitian abelian array. :returns: * **w** (*vector*) -- The eigenvalues as a vector. * **u** (*BosonicCommon*) -- The array of eigenvectors. .. py:method:: cholesky(*, upper=False) -> BosonicCommon Cholesky decomposition of this assumed positive-definite array. :param upper: Whether to return the upper triangular Cholesky factor. Default is False, returning the lower triangular factor. :type upper: bool, optional :returns: **l_or_r** -- The Cholesky factor. Lower triangular if ``upper=False``, upper triangular if ``upper=True``. :rtype: BosonicCommon .. py:method:: cholesky_regularized(absorb=0, shift=True) Cholesky decomposition with optional diagonal regularization, returning results in an SVD-like ``(left, None, right)`` format for compatibility with tensor network split drivers. :param absorb: How to return the factors: - ``0`` (``'both'``): return ``(L, None, L^H)``. - ``-12`` (``'lsqrt'``): return ``(L, None, None)``. - ``12`` (``'rsqrt'``): return ``(None, None, L^H)``. :type absorb: {-12, 0, 12}, optional :param shift: Diagonal regularization shift. If True or negative, auto-compute from dtype machine epsilon. The shift is always applied as a relative shift scaled by the trace of each block. Default is True. :type shift: float, optional :returns: * **left** (*BosonicCommon or None*) -- The lower Cholesky factor, or None. * **s** (*None*) -- Always None (no singular values). * **right** (*BosonicCommon or None*) -- The conjugate transpose of the Cholesky factor, or None.