# Path: qmeq/indexing.py
# def empty_szlst(nsingle, noneq=False):
#     """
#     Make an empty list of lists corresponding to different charges and :math:`S_{z}` values.
# 
#     Parameters
#     ----------
#     nsingle : int
#         Number of single particle states.
#     noneq : bool
#         If True the list contains None objects.
#         If False the list contains empty lists [].
# 
#     Returns
#     -------
#     list of lists
#         Contains None objects or [].
#     """
#     ncharge = nsingle+1
#     if noneq:
#         return [[None for _ in szrange(i, nsingle)] for i in range(ncharge)]
#     else:
#         return [[[] for _ in szrange(i, nsingle)] for i in range(ncharge)]
# 
# Path: qmeq/indexing.py
# def empty_ssqlst(nsingle, noneq=False):
#     """
#     Make an empty list of lists of lists corresponding to
#     different charge, :math:`S_{z}`, :math:`S^{2}` values.
# 
#     Parameters
#     ----------
#     nsingle : int
#         Number of single particle states.
#     noneq : bool
#         If True the list contains None objects.
#         If False the list contains empty lists [].
# 
#     Returns
#     -------
#     list of lists of lists
#         Contains None objects or [].
#     """
#     ncharge = nsingle+1
#     if noneq:
#         return [[[None for _ in ssqrange(i, j, nsingle)] for j in szrange(i, nsingle)] for i in range(ncharge)]
#     else:
#         return [[[[] for _ in ssqrange(i, j, nsingle)] for j in szrange(i, nsingle)] for i in range(ncharge)]
# 
# Path: qmeq/indexing.py
# def szrange(charge, nsingle):
#     """
#     Make a list giving :math:`S_{z}` values for given charge.
# 
#     Parameters
#     ----------
#     charge : int
#         Value of the charge.
#     nsingle : int
#         Number of single particle states.
# 
#     Returns
#     -------
#     list
#         List containing :math:`S_{z}` values for given charge.
#     """
#     szmax = min(charge, nsingle-charge)
#     return list(range(-szmax, szmax+1, +2))
#     # return range(szmax, -szmax-1, -2)
# 
# Path: qmeq/indexing.py
# def ssqrange(charge, sz, nsingle):
#     """
#     Make a list giving all possible :math:`S^{2}` values for given charge and :math:`S_{z}`.
# 
#     Parameters
#     ----------
#     charge : int
#         Value of the charge.
#     sz : int
#         Value of sz.
#     nsingle : int
#         Number of single particle states.
# 
#     Returns
#     -------
#     list
#         List of all possible :math:`S^{2}` values for given charge and :math:`S_{z}`.
#     """
#     szmax = min(charge, nsingle-charge)
#     return list(range(abs(sz), szmax+1, +2))
# 
# Path: qmeq/indexing.py
# def sz_to_ind(sz, charge, nsingle):
#     """
#     Converts :math:`S_{z}` to a list index.
# 
#     Parameters
#     ----------
#     sz : int
#         Value :math:`S_{z}` of a spin projection in the z direction.
#     charge : int
#         Value of the charge.
#     nsingle : int
#         Number of single particle states.
# 
#     Returns
#     -------
#     int
#         Value of the list index corresponding to sz.
#     """
#     szmax = min(charge, nsingle-charge)
#     return int((szmax+sz)/2)
# 
# Path: qmeq/indexing.py
# def ssq_to_ind(ssq, sz):
#     """
#     Convert the value of :math:`S^{2}` for a given :math:`S_{z}` to an index.
# 
#     Parameters
#     ----------
#     ssq : int
#         Value of :math:`S^{2}`.
#     sz : int
#         Value of :math:`S_{z}`.
# 
#     Returns
#     -------
#     int
#         An index corresponding to given :math:`S^{2}` and :math:`S_{z}`.
#     """
#     return int((ssq-abs(sz))/2)


import numpy as np
from .indexing import empty_szlst
from .indexing import empty_ssqlst
from .indexing import szrange
from .indexing import ssqrange
from .indexing import sz_to_ind
from .indexing import ssq_to_ind
    ----------
    valslst : list of ndarrays
        List containing eigenvalues. List entry valslst[charge] is an array of definite charge
        eigenvalues.
    si : StateIndexing
        StateIndexing or StateIndexingDM object.

    Returns
    -------
    Ea : ndarray
        nmany by 1 array containing eigenvalues of the Hamiltonian.
    """
    Ea = np.zeros(si.nmany, dtype=float)
    if si.indexing == 'sz':
        # Iterate over charges
        for charge in range(si.ncharge):
            # Iterate over spin projection sz
            for sz in szrange(charge, si.nsingle):
                # Iterate over many-body states for given charge and sz
                szind = sz_to_ind(sz, charge, si.nsingle)
                for ind in range(len(si.szlst[charge][szind])):
                    # The mapping of many-body states is according to szlst
                    Ea[si.szlst[charge][szind][ind]] = valslst[charge][szind][ind]
    elif si.indexing == 'ssq':
        # Iterate over charges
        for charge in range(si.ncharge):
            # Iterate over spin projection sz
            for sz in szrange(charge, si.nsingle):
                szind = sz_to_ind(sz, charge, si.nsingle)
                # Iterate over total spin ssq

# Path: qmeq/indexing.py
# def empty_szlst(nsingle, noneq=False):
#     """
#     Make an empty list of lists corresponding to different charges and :math:`S_{z}` values.
# 
#     Parameters
#     ----------
#     nsingle : int
#         Number of single particle states.
#     noneq : bool
#         If True the list contains None objects.
#         If False the list contains empty lists [].
# 
#     Returns
#     -------
#     list of lists
#         Contains None objects or [].
#     """
#     ncharge = nsingle+1
#     if noneq:
#         return [[None for _ in szrange(i, nsingle)] for i in range(ncharge)]
#     else:
#         return [[[] for _ in szrange(i, nsingle)] for i in range(ncharge)]
# 
# Path: qmeq/indexing.py
# def empty_ssqlst(nsingle, noneq=False):
#     """
#     Make an empty list of lists of lists corresponding to
#     different charge, :math:`S_{z}`, :math:`S^{2}` values.
# 
#     Parameters
#     ----------
#     nsingle : int
#         Number of single particle states.
#     noneq : bool
#         If True the list contains None objects.
#         If False the list contains empty lists [].
# 
#     Returns
#     -------
#     list of lists of lists
#         Contains None objects or [].
#     """
#     ncharge = nsingle+1
#     if noneq:
#         return [[[None for _ in ssqrange(i, j, nsingle)] for j in szrange(i, nsingle)] for i in range(ncharge)]
#     else:
#         return [[[[] for _ in ssqrange(i, j, nsingle)] for j in szrange(i, nsingle)] for i in range(ncharge)]
# 
# Path: qmeq/indexing.py
# def szrange(charge, nsingle):
#     """
#     Make a list giving :math:`S_{z}` values for given charge.
# 
#     Parameters
#     ----------
#     charge : int
#         Value of the charge.
#     nsingle : int
#         Number of single particle states.
# 
#     Returns
#     -------
#     list
#         List containing :math:`S_{z}` values for given charge.
#     """
#     szmax = min(charge, nsingle-charge)
#     return list(range(-szmax, szmax+1, +2))
#     # return range(szmax, -szmax-1, -2)
# 
# Path: qmeq/indexing.py
# def ssqrange(charge, sz, nsingle):
#     """
#     Make a list giving all possible :math:`S^{2}` values for given charge and :math:`S_{z}`.
# 
#     Parameters
#     ----------
#     charge : int
#         Value of the charge.
#     sz : int
#         Value of sz.
#     nsingle : int
#         Number of single particle states.
# 
#     Returns
#     -------
#     list
#         List of all possible :math:`S^{2}` values for given charge and :math:`S_{z}`.
#     """
#     szmax = min(charge, nsingle-charge)
#     return list(range(abs(sz), szmax+1, +2))
# 
# Path: qmeq/indexing.py
# def sz_to_ind(sz, charge, nsingle):
#     """
#     Converts :math:`S_{z}` to a list index.
# 
#     Parameters
#     ----------
#     sz : int
#         Value :math:`S_{z}` of a spin projection in the z direction.
#     charge : int
#         Value of the charge.
#     nsingle : int
#         Number of single particle states.
# 
#     Returns
#     -------
#     int
#         Value of the list index corresponding to sz.
#     """
#     szmax = min(charge, nsingle-charge)
#     return int((szmax+sz)/2)
# 
# Path: qmeq/indexing.py
# def ssq_to_ind(ssq, sz):
#     """
#     Convert the value of :math:`S^{2}` for a given :math:`S_{z}` to an index.
# 
#     Parameters
#     ----------
#     ssq : int
#         Value of :math:`S^{2}`.
#     sz : int
#         Value of :math:`S_{z}`.
# 
#     Returns
#     -------
#     int
#         An index corresponding to given :math:`S^{2}` and :math:`S_{z}`.
#     """
#     return int((ssq-abs(sz))/2)


# Path: qmeq/qdot.py
import numpy as np
from .indexing import empty_szlst
from .indexing import empty_ssqlst
from .indexing import szrange
from .indexing import ssqrange
from .indexing import sz_to_ind
from .indexing import ssq_to_ind

    ----------
    valslst : list of ndarrays
        List containing eigenvalues. List entry valslst[charge] is an array of definite charge
        eigenvalues.
    si : StateIndexing
        StateIndexing or StateIndexingDM object.

    Returns
    -------
    Ea : ndarray
        nmany by 1 array containing eigenvalues of the Hamiltonian.
    """
    Ea = np.zeros(si.nmany, dtype=float)
    if si.indexing == 'sz':
        # Iterate over charges
        for charge in range(si.ncharge):
            # Iterate over spin projection sz
            for sz in szrange(charge, si.nsingle):
                # Iterate over many-body states for given charge and sz
                szind = sz_to_ind(sz, charge, si.nsingle)
                for ind in range(len(si.szlst[charge][szind])):
                    # The mapping of many-body states is according to szlst
                    Ea[si.szlst[charge][szind][ind]] = valslst[charge][szind][ind]
    elif si.indexing == 'ssq':
        # Iterate over charges
        for charge in range(si.ncharge):
            # Iterate over spin projection sz
            for sz in szrange(charge, si.nsingle):
                szind = sz_to_ind(sz, charge, si.nsingle)
                # Iterate over total spin ssq

                for ssq in ssqrange(charge, sz, si.nsingle):