# Path: EMpy/utils.py
# def snell(theta_inc, n):
#     """Snell law.
# 
#     INPUT
#     theta_inc = angle of incidence.
#     n = 1D numpy.array of refractive indices.
# 
#     OUTPUT
#     theta = 1D numpy.array.
#     """
# 
#     theta = numpy.zeros_like(n)
#     theta[0] = theta_inc
#     for i in range(1, n.size):
#         theta[i] = numpy.arcsin(n[i - 1] / n[i] * numpy.sin(theta[i - 1]))
#     return theta
# 
# def norm(x):
#     """Return the norm of a 1D vector."""
#     return numpy.sqrt(numpy.vdot(x, x))
# 
# Path: EMpy/constants.py



from builtins import zip
from builtins import range
from builtins import object
from scipy.linalg import inv
from EMpy.utils import snell, norm
from EMpy.constants import c, mu0
import scipy as S
        """

        self.wls = S.asarray(wls)

        multilayer = self.multilayer
        theta_inc = self.theta_inc

        nlayers = len(multilayer)
        d = S.array([l.thickness for l in multilayer]).ravel()

        Rs = S.zeros_like(self.wls)
        Ts = S.zeros_like(self.wls)
        Rp = S.zeros_like(self.wls)
        Tp = S.zeros_like(self.wls)

        Dp = S.zeros((2, 2), dtype=complex)
        Ds = S.zeros((2, 2), dtype=complex)
        P = S.zeros((2, 2), dtype=complex)
        Ms = S.zeros((2, 2), dtype=complex)
        Mp = S.zeros((2, 2), dtype=complex)
        k = S.zeros((nlayers, 2), dtype=complex)

        ntot = S.zeros((self.wls.size, nlayers), dtype=complex)
        for i, l in enumerate(multilayer):
            #            ntot[:,i] = l.mat.n(self.wls,l.mat.T0)
            ntot[:, i] = l.mat.n(self.wls, l.mat.toc.T0)

        for iwl, wl in enumerate(self.wls):

            n = ntot[iwl, :]

# Path: EMpy/utils.py
# def snell(theta_inc, n):
#     """Snell law.
# 
#     INPUT
#     theta_inc = angle of incidence.
#     n = 1D numpy.array of refractive indices.
# 
#     OUTPUT
#     theta = 1D numpy.array.
#     """
# 
#     theta = numpy.zeros_like(n)
#     theta[0] = theta_inc
#     for i in range(1, n.size):
#         theta[i] = numpy.arcsin(n[i - 1] / n[i] * numpy.sin(theta[i - 1]))
#     return theta
# 
# def norm(x):
#     """Return the norm of a 1D vector."""
#     return numpy.sqrt(numpy.vdot(x, x))
# 
# Path: EMpy/constants.py



# Path: EMpy/transfer_matrix.py
from builtins import zip
from builtins import range
from builtins import object
from scipy.linalg import inv
from EMpy.utils import snell, norm
from EMpy.constants import c, mu0
import scipy as S

        """

        self.wls = S.asarray(wls)

        multilayer = self.multilayer
        theta_inc = self.theta_inc

        nlayers = len(multilayer)
        d = S.array([l.thickness for l in multilayer]).ravel()

        Rs = S.zeros_like(self.wls)
        Ts = S.zeros_like(self.wls)
        Rp = S.zeros_like(self.wls)
        Tp = S.zeros_like(self.wls)

        Dp = S.zeros((2, 2), dtype=complex)
        Ds = S.zeros((2, 2), dtype=complex)
        P = S.zeros((2, 2), dtype=complex)
        Ms = S.zeros((2, 2), dtype=complex)
        Mp = S.zeros((2, 2), dtype=complex)
        k = S.zeros((nlayers, 2), dtype=complex)

        ntot = S.zeros((self.wls.size, nlayers), dtype=complex)
        for i, l in enumerate(multilayer):
            #            ntot[:,i] = l.mat.n(self.wls,l.mat.T0)
            ntot[:, i] = l.mat.n(self.wls, l.mat.toc.T0)

        for iwl, wl in enumerate(self.wls):

            n = ntot[iwl, :]

            theta = snell(theta_inc, n)