def combine(args, part=None):
    """
    All linear combination of a list of list.

    Args:
        args (numpy.ndarray) : List of input arrays.  Components to take linear
            combination of with `args[i].shape=(N[i], M[i])` where N is to be
            taken linear combination of and M is static.  M[i] is set to 1 if
            missing.

    Returns:
        (numpy.array) : matrix of combinations with shape (numpy.prod(N),
            numpy.sum(M)).

    Examples:
        >>> A, B = [1,2], [[4,4],[5,6]]
        >>> print(chaospy.quad.combine([A, B]))
        [[1. 4. 4.]
         [1. 5. 6.]
         [2. 4. 4.]
         [2. 5. 6.]]
    """
    args = [cleanup(arg) for arg in args]

    if part is not None:
        parts, orders = part
        if numpy.array(orders).size == 1:
            orders = [int(numpy.array(orders).item())]*len(args)
        parts = numpy.array(parts).flatten()

        for i, arg in enumerate(args):
            m, n = float(parts[i]), float(orders[i])
            l = len(arg)
            args[i] = arg[int(m/n*l):int((m+1)/n*l)]

    shapes = [arg.shape for arg in args]
    size = numpy.prod(shapes, 0)[0]*numpy.sum(shapes, 0)[1]

    if size > 10**9:
        raise MemoryError("Too large sets")

    if len(args) == 1:
        out = args[0]

    elif len(args) == 2:
        out = combine_two(*args)

    else:
        arg1 = combine_two(*args[:2])
        out = combine([arg1,]+args[2:])

    return out
All linear combination of a list of list.

    Args:
        args (numpy.ndarray) : List of input arrays.  Components to take linear
            combination of with `args[i].shape=(N[i], M[i])` where N is to be
            taken linear combination of and M is static.  M[i] is set to 1 if
            missing.

    Returns:
        (numpy.array) : matrix of combinations with shape (numpy.prod(N),
            numpy.sum(M)).

    Examples:
        >>> A, B = [1,2], [[4,4],[5,6]]
        >>> print(chaospy.quad.combine([A, B]))
        [[1. 4. 4.]
         [1. 5. 6.]
         [2. 4. 4.]
         [2. 5. 6.]]