Exemplo n.º 1
0
def fht(shapein, **kargs):
    """
    Fast Hadamard transform LinearOperator
    """

    def matvec(arr):
        return fht_mod.fht(arr, **kargs)

    return lo.ndoperator(shapein, shapein, matvec=matvec, rmatvec=matvec, dtype=np.float64)
Exemplo n.º 2
0
def fht(shapein, **kargs):
    """
    Fast Hadamard transform LinearOperator
    """
    def matvec(arr):
        return fht_mod.fht(arr, **kargs)

    return lo.ndoperator(shapein,
                         shapein,
                         matvec=matvec,
                         rmatvec=matvec,
                         dtype=np.float64)
Exemplo n.º 3
0
def group_sum(ind, cube, data):
    from lo import ndsubclass
    # shapes
    shapein = cube.shape + (data.shape[-1],)
    shapeout = cube.shape + (len(ind),)
    # slicing indexes
    ind1 = ind
    ind2 = ind1[1:] + [None,]
    axis = -1
    def matvec(x):
        out = np.zeros(shapeout)
        for i, j, k in zip(ind1, ind2, np.arange(len(ind1))):
            out[..., k] = x[..., i:j].sum(axis=-1)
        return out
    def rmatvec(x):
        out = np.zeros(shapein)
        for i, j, k in zip(ind1, ind2, np.arange(len(ind1))):
            tmp_shape = out[..., i:j].shape
            out[..., i:j] = x[..., k].repeat(tmp_shape[-1]).reshape(tmp_shape)
        return out
    return lo.ndoperator(shapein, shapeout, matvec, rmatvec, dtype=np.float64)