# 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/wrappers/mytypes.py



import itertools
import numbers
import numpy as np
from .indexing import szrange
from .indexing import ssqrange
from .indexing import sz_to_ind
from .indexing import ssq_to_ind
from .wrappers.mytypes import doublenp
    si : StateIndexing
        StateIndexing or StateIndexingDM object.
    mtype : type
        Defines type of pmtr matrix. For example, float, complex, etc.

    Returns
    -------
    pmtr : ndarray
        nmany by nmany numpy array containing many-body eigenvectors.
    """
    pmtr = np.zeros((si.nmany, si.nmany), dtype=mtype)
    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):
                szind = sz_to_ind(sz, charge, si.nsingle)
                # Iterate over many-body states for given charge
                for j1, j2 in itertools.product(range(len(si.szlst[charge][szind])),
                                                range(len(si.szlst[charge][szind]))):
                    (pmtr[si.szlst[charge][szind][j1], si.szlst[charge][szind][j2]]) = (
                        vecslst[charge][szind][j1, j2])
    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):

# 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/wrappers/mytypes.py



# Path: qmeq/leadstun.py
import itertools
import numbers
import numpy as np
from .indexing import szrange
from .indexing import ssqrange
from .indexing import sz_to_ind
from .indexing import ssq_to_ind
from .wrappers.mytypes import doublenp

    si : StateIndexing
        StateIndexing or StateIndexingDM object.
    mtype : type
        Defines type of pmtr matrix. For example, float, complex, etc.

    Returns
    -------
    pmtr : ndarray
        nmany by nmany numpy array containing many-body eigenvectors.
    """
    pmtr = np.zeros((si.nmany, si.nmany), dtype=mtype)
    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):
                szind = sz_to_ind(sz, charge, si.nsingle)
                # Iterate over many-body states for given charge
                for j1, j2 in itertools.product(range(len(si.szlst[charge][szind])),
                                                range(len(si.szlst[charge][szind]))):
                    (pmtr[si.szlst[charge][szind][j1], si.szlst[charge][szind][j2]]) = (
                        vecslst[charge][szind][j1, j2])
    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):

                    ssqind = ssq_to_ind(ssq, sz)