# Path: EMpy/modesolvers/interface.py
# def interface_matrix(solver1, solver2, x=None, y=None):
# 
#     neigs = solver1.nmodes
# 
#     O11 = numpy.zeros((neigs, neigs), dtype=complex)
#     O22 = numpy.zeros((neigs, neigs), dtype=complex)
#     O12 = numpy.zeros((neigs, neigs), dtype=complex)
#     O21 = numpy.zeros((neigs, neigs), dtype=complex)
# 
#     for i in range(neigs):
#         for j in range(neigs):
# 
#             O11[i, j] = overlap(solver1.modes[i], solver1.modes[j], x, y)
#             O22[i, j] = overlap(solver2.modes[i], solver2.modes[j], x, y)
#             O12[i, j] = overlap(solver1.modes[i], solver2.modes[j], x, y)
#             O21[i, j] = overlap(solver2.modes[i], solver1.modes[j], x, y)
# 
#     return (O11, O22, O12, O21)


from builtins import zip
from builtins import object
from EMpy.modesolvers.interface import interface_matrix
import numpy
import pylab


class SimpleJoint(object):

    #    def __init__(self, cs1, cs2, solver1, solver2, inputLHS=None, inputRHS=None):
    def __init__(self, solver1, solver2, inputLHS=None, inputRHS=None):
        #        self.cs1 = cs1
        self.solver1 = solver1
        #        self.cs2 = cs2
        self.solver2 = solver2
        self.length = 0.0
        self.build_matrix()
        self.compute_output(inputLHS, inputRHS)

    def compute_output(self, inputLHS=None, inputRHS=None):
        if inputLHS is None:
            self.inputLHS = numpy.zeros(self.solver1.nmodes)
            self.inputLHS[0] = 1.0
        else:
            self.inputLHS = inputLHS
        if inputRHS is None:
            self.inputRHS = numpy.zeros(self.solver1.nmodes)
        else:
            self.inputRHS = inputRHS
        input = numpy.r_[self.inputLHS, self.inputRHS]
        output = numpy.dot(self.S, input)
        self.outputLHS = output[: self.solver1.nmodes]
        self.outputRHS = output[self.solver1.nmodes :]

    def build_matrix(self):

# Path: EMpy/modesolvers/interface.py
# def interface_matrix(solver1, solver2, x=None, y=None):
# 
#     neigs = solver1.nmodes
# 
#     O11 = numpy.zeros((neigs, neigs), dtype=complex)
#     O22 = numpy.zeros((neigs, neigs), dtype=complex)
#     O12 = numpy.zeros((neigs, neigs), dtype=complex)
#     O21 = numpy.zeros((neigs, neigs), dtype=complex)
# 
#     for i in range(neigs):
#         for j in range(neigs):
# 
#             O11[i, j] = overlap(solver1.modes[i], solver1.modes[j], x, y)
#             O22[i, j] = overlap(solver2.modes[i], solver2.modes[j], x, y)
#             O12[i, j] = overlap(solver1.modes[i], solver2.modes[j], x, y)
#             O21[i, j] = overlap(solver2.modes[i], solver1.modes[j], x, y)
# 
#     return (O11, O22, O12, O21)


# Path: EMpy/modesolvers/geometries.py
from builtins import zip
from builtins import object
from EMpy.modesolvers.interface import interface_matrix
import numpy
import pylab



class SimpleJoint(object):

    #    def __init__(self, cs1, cs2, solver1, solver2, inputLHS=None, inputRHS=None):
    def __init__(self, solver1, solver2, inputLHS=None, inputRHS=None):
        #        self.cs1 = cs1
        self.solver1 = solver1
        #        self.cs2 = cs2
        self.solver2 = solver2
        self.length = 0.0
        self.build_matrix()
        self.compute_output(inputLHS, inputRHS)

    def compute_output(self, inputLHS=None, inputRHS=None):
        if inputLHS is None:
            self.inputLHS = numpy.zeros(self.solver1.nmodes)
            self.inputLHS[0] = 1.0
        else:
            self.inputLHS = inputLHS
        if inputRHS is None:
            self.inputRHS = numpy.zeros(self.solver1.nmodes)
        else:
            self.inputRHS = inputRHS
        input = numpy.r_[self.inputLHS, self.inputRHS]
        output = numpy.dot(self.S, input)
        self.outputLHS = output[: self.solver1.nmodes]
        self.outputRHS = output[self.solver1.nmodes :]

    def build_matrix(self):

        O11, O22, O12, O21 = interface_matrix(self.solver1, self.solver2)