def DirectionalCoupler(ports):
    """DirectionalCoupler
    Directional Coupler
    @param ports integer number of ports (3 or 4)
    @return s-parameter matrix of a three or four port directional coupler
    port 1 and 2 are a thru connection.

    port 3 picks off the wave going from port 1 to 2.

    port 4 (optional) picks off the wave going from port 2 to port 1.

    @note the directional coupler is completely ideal and is not passive
    in that the picked off wave is an exact copy of the wave going between
    the ports specified above.
    """
    if ports == 3:
        return [[0, 1, 0], [1, 0, 0], [1, 0, 0]]
    elif ports == 4:
        return [[0, 1, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [0, 1, 0, 0]]
