Segment-wise dot product.

    This function calculates the dot product of x2d with each trial of x3d.

    Parameters
    ----------
    x2d : array, shape (p, m)
        Input argument.
    x3d : array, shape (t, m, n)
        Segmented input data with t trials, m signals, and n samples. The dot
        product with x2d is calculated for each trial.

    Returns
    -------
    out : array, shape (t, p, n)
        Dot product of x2d with each trial of x3d.

    Examples
    --------
    >>> x = np.random.randn(6, 40, 150)
    >>> a = np.ones((7, 40))
    >>> y = dot_special(a, x)
    >>> y.shape
    (6, 7, 150)

def dot_special(x2d, x3d):
    """Segment-wise dot product.

    This function calculates the dot product of x2d with each trial of x3d.

    Parameters
    ----------
    x2d : array, shape (p, m)
        Input argument.
    x3d : array, shape (t, m, n)
        Segmented input data with t trials, m signals, and n samples. The dot
        product with x2d is calculated for each trial.

    Returns
    -------
    out : array, shape (t, p, n)
        Dot product of x2d with each trial of x3d.

    Examples
    --------
    >>> x = np.random.randn(6, 40, 150)
    >>> a = np.ones((7, 40))
    >>> y = dot_special(a, x)
    >>> y.shape
    (6, 7, 150)
    """
    x3d = atleast_3d(x3d)
    x2d = np.atleast_2d(x2d)
    return np.concatenate([x2d.dot(x3d[i, ...])[np.newaxis, ...]
                           for i in range(x3d.shape[0])])