symmray.sparse.sparse_fermionic_array ===================================== .. py:module:: symmray.sparse.sparse_fermionic_array .. autoapi-nested-parse:: Fermionic symmetric arrays with block sparse backend. Classes ------- .. autoapisummary:: symmray.sparse.sparse_fermionic_array.FermionicArray symmray.sparse.sparse_fermionic_array.Z2FermionicArray symmray.sparse.sparse_fermionic_array.U1FermionicArray symmray.sparse.sparse_fermionic_array.Z2Z2FermionicArray symmray.sparse.sparse_fermionic_array.U1U1FermionicArray Functions --------- .. autoapisummary:: symmray.sparse.sparse_fermionic_array.argsort Module Contents --------------- .. py:function:: argsort(seq) .. py:class:: FermionicArray(indices, charge=None, blocks=(), phases=(), label=None, dummy_modes=None, symmetry=None) Bases: :py:obj:`symmray.fermionic_common.FermionicCommon`, :py:obj:`symmray.sparse.sparse_array_common.SparseArrayCommon`, :py:obj:`symmray.sparse.sparse_data_common.BlockCommon`, :py:obj:`symmray.array_common.ArrayCommon`, :py:obj:`symmray.common.SymmrayCommon` A fermionic block symmetry array. :param indices: The indices of the array. :type indices: tuple of Index :param charge: The total charge of the array, if not given it will be inferred from either the first sector or set to the identity charge, if no sectors are given. :type charge: hashable, optionals :param blocks: The blocks of the array, by default empty. :type blocks: dict, optional :param phases: The lazy phases of each block, by default empty. :type phases: dict, optional :param label: An optional label for the array, potentially needed for ordering dummy odd fermionic modes. :type label: hashable, optional :param symmetry: The symmetry of the array, if not using a specific symmetry class. :type symmetry: str or Symmetry, optional .. py:attribute:: __slots__ :value: ('_blocks', '_charge', '_dummy_modes', '_indices', '_label', '_phases', '_symmetry') .. py:attribute:: fermionic :value: True .. py:attribute:: static_symmetry :value: None .. py:attribute:: _phases .. py:attribute:: _dummy_modes :value: () .. py:method:: to_pytree() Convert this sparse fermionic array to a pytree purely of non-symmray containers and objects. .. py:method:: from_pytree(data) :classmethod: Create a sparse fermionic array from a pytree purely of non-symmray containers and objects. .. py:property:: parity The parity of the total charge. .. py:property:: phases The lazy phases of each sector. Trivial phases are not necessarily stored. .. py:method:: copy() Create a copy of this fermionic array. :returns: The copied array. :rtype: FermionicArray .. py:method:: new_with(indices, charge, blocks, label=None) Create a new block sparse fermionic array of the same class as this one. Unlike `copy`, this does not copy over any existing data and drops by default `label`, `phases`, and `dummy_modes`. .. py:method:: copy_with(indices=None, blocks=None, charge=None, phases=None) Create a copy of this fermionic array with some attributes replaced. :param indices: The new indices, if None, the original indices are used. :type indices: tuple of Index, optional :param blocks: The new blocks, if None, the original blocks are used. :type blocks: dict, optional :param charge: The new total charge, if None, the original charge is used. :type charge: int, optional :param phases: The new phases, if None, the original phases are used. :type phases: dict, optional .. py:method:: modify(indices=None, blocks=None, charge=None, phases=None, dummy_modes=None) Modify this fermionic array inplace. This is for internal use, and does not perform any checks on the updated attributes. :param indices: The new indices, if None, the original indices are used. :type indices: tuple of Index, optional :param blocks: The new blocks, if None, the original blocks are used. :type blocks: dict, optional :param charge: The new total charge, if None, the original charge is used. :type charge: int, optional :param phases: The new phases, if None, the original phases are used. :type phases: dict, optional :param dummy_modes: The new dummy_modes, if None, the original dummy_modes are used. :type dummy_modes: object or FermionicOperator, optional .. py:method:: randomize_phases(seed=None, inplace=False) -> FermionicArray Randomize the phases of each sector to either +1 or -1. This is useful for testing. :param seed: The random seed or generator, by default None. :type seed: int or numpy.random.Generator, optional :param inplace: Whether to perform the operation in place. :type inplace: bool, optional :returns: The phase randomized array. :rtype: FermionicArray .. py:method:: phase_sync(inplace=False) -> FermionicArray Multiply all lazy phases into the block arrays. :param inplace: Whether to perform the operation in place. :type inplace: bool, optional :returns: The resolved array, which now has no lazy phases. :rtype: FermionicArray .. py:method:: phase_flip(*axs, inplace=False) -> FermionicArray Flip the phase of all sectors with odd parity at the given axis. :param ax: The axis along which to flip the phase. :type ax: int :param inplace: Whether to perform the operation in place. :type inplace: bool, optional :returns: The phase-flipped array. :rtype: FermionicArray .. py:method:: phase_transpose(axes=None, inplace=False) Phase this fermionic array as if it were transposed virtually, i.e. the actual arrays are not transposed. Useful when one wants the actual data layout to differ from the required fermionic mode layout. :param axes: The permutation of axes, by default None. :type axes: tuple of int, optional :param inplace: Whether to perform the operation in place. :type inplace: bool, optional :rtype: FermionicArray .. py:method:: phase_sector(sector, inplace=False) Flip the phase of a specific sector. :param sector: The sector to flip the phase of. :type sector: tuple of hashable :param inplace: Whether to perform the operation in place. :type inplace: bool, optional :rtype: FermionicArray .. py:method:: phase_global(inplace=False) Flip the global phase of the array. :param inplace: Whether to perform the operation in place. :type inplace: bool, optional :rtype: FermionicArray .. py:method:: _map_blocks(fn_block=None, fn_sector=None, fn_filter=None) Map the blocks and their keys (sectors) of the array inplace. .. py:method:: _resolve_dummy_modes_conj(phase_permutation=True) Assuming we have effectively taken the conjugate of a fermionic array with dummy modes, get their new order and compute any phase changes coming from moving back to the beginning of the index order. .. py:method:: _resolve_dummy_modes_combine(left, right) Calculate the new combined dummy odd modes and any associated global phases combing from contracting two fermionic arrays `a` and `b`. This modifies this array in place. .. py:method:: _resolve_dummy_modes_squeeze(axes_squeeze) Assuming we are about to squeeze away `axes_squeeze`, compute the phases associated with moving them to the beginning of the array, and then turn them into dummy modes. .. py:method:: transpose(axes=None, phase=True, inplace=False) Transpose the fermionic array, by default accounting for the phases accumulated from swapping odd charges. :param axes: The permutation of axes, by default None. :type axes: tuple of int, optional :param phase: Whether to flip the phase of sectors whose odd charges undergo a odd permutation. By default True. :type phase: bool, optional :param inplace: Whether to perform the operation in place. :type inplace: bool, optional :returns: The transposed array. :rtype: FermionicArray .. py:method:: conj(phase_permutation=True, phase_dual=False, inplace=False) Conjugate this fermionic array. By default this include phases from both the virtual flipping of all axes, but *not* the conjugation of dual indices, such that:: ( tensordot_fermionic(x.conj(), x, ndim) == tensordot_fermionic(x, x.conj(), ndim) ) If all indices have matching dualness (i.e. all bra or all ket), *or* you set `phase_dual=True` then the above contractions will also be equal to ``x.norm() ** 2``. :param phase_permutation: Whether to flip the phase of sectors whose odd charges undergo a odd permutation due to *virtually* flipping the order of axes, by default True. :type phase_permutation: bool, optional :param phase_dual: Whether to flip the phase of dual indices, by default False. If a FermionicArray has a mix of dual and non-dual indices, and you are explicitly forming the norm, you may want to set this to True. But if it is part of a large tensor network you only need to flip the phase of true 'outer' dual indices. :type phase_dual: bool, optional :rtype: FermionicArray .. py:method:: dagger(phase_dual=False, inplace=False) Fermionic adjoint, implements `.H` attribute. :param phase_dual: Whether to flip the phase of dual indices, by default False. If a FermionicArray has a mix of dual and non-dual indices, and you are explicitly forming the norm, you may want to set this to True. But if it is part of a large tensor network you only need to flip the phase of 'outer' dual indices. :type phase_dual: bool, optional :param inplace: Whether to perform the operation in place. :type inplace: bool, optional :returns: The conjugate transposed array. :rtype: FermionicArray .. py:method:: eigh(phase_eigenvalues=True, **kwargs) -> tuple[symmray.sparse.sparse_vector.BlockVector, FermionicArray] Eigenvalue decomposition of this assumed Hermitian block sparse fermionic array. :param phase_eigenvalues: If True, any local phase will be absorbed into the eigenvalues, such that `U @ diag(w) @ U.H == a` always holds. By default True. If `False` then one of `U` or `U.H` should be phased individually to account for local phasesin the above expression. :type phase_eigenvalues: bool, optional :returns: * **w** (*BlockVector*) -- The eigenvalues as a vector. If `phase_eigenvalues` is True, then eigenvalues corresponding to odd parity sectors will be negated depending of the inner index dualness. * **U** (*FermionicArray*) -- The array of eigenvectors. .. py:class:: Z2FermionicArray(indices, charge=None, blocks=(), phases=(), label=None, dummy_modes=None, symmetry=None) Bases: :py:obj:`FermionicArray` A fermionic block array with Z2 symmetry. .. py:attribute:: static_symmetry .. py:method:: to_pyblock3(flat=False) .. py:class:: U1FermionicArray(indices, charge=None, blocks=(), phases=(), label=None, dummy_modes=None, symmetry=None) Bases: :py:obj:`FermionicArray` A fermionic block array with U1 symmetry. .. py:attribute:: static_symmetry .. py:method:: to_pyblock3(flat=False) .. py:class:: Z2Z2FermionicArray(indices, charge=None, blocks=(), phases=(), label=None, dummy_modes=None, symmetry=None) Bases: :py:obj:`FermionicArray` A fermionic block array with Z2 x Z2 symmetry. .. py:attribute:: static_symmetry .. py:class:: U1U1FermionicArray(indices, charge=None, blocks=(), phases=(), label=None, dummy_modes=None, symmetry=None) Bases: :py:obj:`FermionicArray` A fermionic block array with U1 x U1 symmetry. .. py:attribute:: static_symmetry