def embed(x, y, mask):
    """Embed a square matrix x with y where mask is true.

    Args:
        x <np.array>: to be embedded matrix
        y <np.array>: elements that are embedded into x. Same size as x.
        mask <np.array<bool>>: marks where to embed. Same size as x and y.
    """

    p = x.copy()
    p[mask] = (y.copy())[mask]
    return p