Пример #1
0
    def __init__(self, m, x_grid, lmax, compress=True):
        P = compute_normalized_associated_legendre(m,
                                                   np.arccos(x_grid),
                                                   lmax,
                                                   epsilon=1e-30)
        assert x_grid[-1] == 0

        self.P_even_arr = P_even_arr = P[:-1, ::2]  # drop equator
        self.P_odd_arr = P_odd_arr = P[:-1, 1::2]
        if compress:
            self.P_even = butterfly_compress(P_even_arr, min_rows=limit)
            self.P_odd = butterfly_compress(P_odd_arr, min_rows=limit)
            print 'Compression:', (
                (self.P_even.size() + self.P_odd.size()) /
                (prod(P_even_arr.shape) + prod(P_odd_arr.shape)))
            print 'Ratio in final blocks:', (
                (self.P_even.S_node.size() + self.P_odd.S_node.size()) /
                (self.P_even.size() + self.P_odd.size()))
            1 / 0  #TODO: Below uses old API
            self.P_even = serialize_butterfly_matrix(self.P_even)
            self.P_odd = serialize_butterfly_matrix(self.P_odd)
        else:
            self.P_even = DenseMatrix(P_even_arr)
            self.P_odd = DenseMatrix(P_odd_arr)
        # Treat equator seperately, as we cannot interpolate to it from
        # samples in (0, 1). Only need even part, as odd part will be 0.
        self.P_equator = DenseMatrix(P[-1:, ::2])
Пример #2
0
def doit(thetas, m, lmax):
    P = compute_normalized_associated_legendre(m, thetas, lmax, epsilon=1e-30)[:, odd::2]
    compressed = butterfly_compress(P, min_rows=min_rows, eps=1e-14)
    raw_size = compressed.nrows * compressed.ncols * 8
    comp_size = compressed.size()
#    print format_numbytes(raw_size), format_numbytes(comp_size)
    return raw_size, comp_size
Пример #3
0
def doit(thetas, m, lmax):
    P = compute_normalized_associated_legendre(m, thetas, lmax,
                                               epsilon=1e-30)[:, odd::2]
    compressed = butterfly_compress(P, min_rows=min_rows, eps=1e-14)
    raw_size = compressed.nrows * compressed.ncols * 8
    comp_size = compressed.size()
    #    print format_numbytes(raw_size), format_numbytes(comp_size)
    return raw_size, comp_size
Пример #4
0
def doit(m, chunk_size):
    P = compute_normalized_associated_legendre(m, nodes, lmax, epsilon=epsilon_legendre)
    P = P[:, odd::2].T
    x = butterfly_compress(P, chunk_size, eps=epsilon_butterfly)

    stats_list = []
    for level in range(x.get_max_depth()):
        flop_stats = x.get_stats(level, residual_flop_func)
        mem_stats = x.get_stats(level, residual_size_func)
        stats_list.append(flop_stats + mem_stats[1:])
        print 'm=%d,l=%d %s' % (m, level, x.format_stats(level, residual_size_func))
    return np.asarray(stats_list)
Пример #5
0
    def __init__(self, m, x_grid, lmax, compress=True):
        P = compute_normalized_associated_legendre(m, np.arccos(x_grid), lmax, epsilon=1e-30)
        assert x_grid[-1] == 0

        self.P_even_arr = P_even_arr = P[:-1, ::2] # drop equator
        self.P_odd_arr = P_odd_arr = P[:-1, 1::2]
        if compress:
            self.P_even = butterfly_compress(P_even_arr, min_rows=limit)
            self.P_odd = butterfly_compress(P_odd_arr, min_rows=limit)
            print 'Compression:', ((self.P_even.size() + self.P_odd.size()) / 
                (prod(P_even_arr.shape) + prod(P_odd_arr.shape)))
            print 'Ratio in final blocks:', (
                (self.P_even.S_node.size() + self.P_odd.S_node.size()) /
                (self.P_even.size() + self.P_odd.size()))
            1/0 #TODO: Below uses old API
            self.P_even = serialize_butterfly_matrix(self.P_even)
            self.P_odd = serialize_butterfly_matrix(self.P_odd)
        else:
            self.P_even = DenseMatrix(P_even_arr)
            self.P_odd = DenseMatrix(P_odd_arr)
        # Treat equator seperately, as we cannot interpolate to it from
        # samples in (0, 1). Only need even part, as odd part will be 0.
        self.P_equator = DenseMatrix(P[-1:, ::2])
Пример #6
0
def ringmajor_size(theta):
    P = normalized_associated_legendre_ms(ms, theta, lmax, epsilon=epsilon)
    x = butterfly_compress(P[:, ::2], min_rows=min_rows)
    print x.get_stats()
    return x.size()
Пример #7
0
def mmajor_size(m):
    P = compute_normalized_associated_legendre(m, nodes, lmax, epsilon=epsilon)
    x = butterfly_compress(P[:, ::2], min_rows=min_rows)
    print 'm=%d' % m, x.get_stats()
    return x.size()
Пример #8
0
from joblib import Memory
memory = Memory('joblib')

@memory.cache
def getroots(l, m):
    return associated_legendre_roots(lmax + 1, m)
    

if 1:
    roots = getroots(lmax + 1, m)
    
    roots = get_ring_thetas(Nside, positive_only=True)
    print roots.shape[0]
    P = compute_normalized_associated_legendre(m, roots, lmax)
    print butterfly_compress(P).get_stats()
    print butterfly_compress(P.T).get_stats()
    #SPeven = butterfly_horz(P[::2])
    #SPodd = butterfly_horz(P[1::2])
#    Peven = P[:, ::2]
#    as_matrix(np.log(np.abs(Peven))).plot()
#    SPeven = butterfly(P[:, ::2])
#    SPodd = butterfly(P[:, 1::2])
#    print 'Compression', SPeven.size() / DenseMatrix(P[:, ::2]).size()
#    print 'Compression', SPodd.size() / DenseMatrix(P[:, 1::2]).size()

if 0:
    x = np.cos(get_ring_thetas(Nside))
    x[np.abs(x) < 1e-10] = 0
    xneg = x[x < 0]
    xpos = x[x > 0]
def ringmajor_size(theta):
    P = normalized_associated_legendre_ms(ms, theta, lmax, epsilon=epsilon)
    x = butterfly_compress(P[:, ::2], min_rows=min_rows)
    print x.get_stats()
    return x.size()
def mmajor_size(m):
    P = compute_normalized_associated_legendre(m, nodes, lmax, epsilon=epsilon)
    x = butterfly_compress(P[:, ::2], min_rows=min_rows)
    print 'm=%d' % m, x.get_stats()
    return x.size()
Пример #11
0
from joblib import Memory
memory = Memory('joblib')


@memory.cache
def getroots(l, m):
    return associated_legendre_roots(lmax + 1, m)


if 1:
    roots = getroots(lmax + 1, m)

    roots = get_ring_thetas(Nside, positive_only=True)
    print roots.shape[0]
    P = compute_normalized_associated_legendre(m, roots, lmax)
    print butterfly_compress(P).get_stats()
    print butterfly_compress(P.T).get_stats()
    #SPeven = butterfly_horz(P[::2])
    #SPodd = butterfly_horz(P[1::2])
#    Peven = P[:, ::2]
#    as_matrix(np.log(np.abs(Peven))).plot()
#    SPeven = butterfly(P[:, ::2])
#    SPodd = butterfly(P[:, 1::2])
#    print 'Compression', SPeven.size() / DenseMatrix(P[:, ::2]).size()
#    print 'Compression', SPodd.size() / DenseMatrix(P[:, 1::2]).size()

if 0:
    x = np.cos(get_ring_thetas(Nside))
    x[np.abs(x) < 1e-10] = 0
    xneg = x[x < 0]
    xpos = x[x > 0]