Esempio n. 1
0
def run_mathematica():
    from sympy import sin, cos
    P0, P1, P2 = projections_2d(x, y)

    P1_d = {}
    for f in (
        (1, 0),
        (0, 1),
        (sin(x), 0),
        (sin(y), 0),
        (-sin(y), sin(x)),
        (sin(x), sin(y)),
        (sin(x), cos(2 * y)),
    ):
        P1_d[repr(f)] = repr(P1(f))
        print()
        print(f)
        print(P1_d[repr(f)])

    P2_d = {}
    for f in (
            1,
            sin(x),
            sin(y),
            cos(x),
            cos(y),
            sin(x + y),
            sin(x + 2 * y),
            x,
            y,
            x**2,
            y**2,
            x * y,
            x**3,
            x**2 * y,
            x * y**2,
            y**3,
    ):
        P2_d[repr((f, ))] = repr(P2((f, )))
        print()
        print(f)
        print(P2_d[repr((f, ))])

    dataname = 'memoize/projections.json'
    import dec
    dec.store_data(dataname, {1: P1_d, 2: P2_d})
    return
Esempio n. 2
0
def run_mathematica():
    from sympy import sin, cos
    P0, P1, P2 = projections_2d(x, y)

    P1_d = {}    
    for f in ((1,0),
              (0,1),
              (sin(x),0),
              (sin(y),0),
              (-sin(y), sin(x)),
              (sin(x), sin(y)),
              (sin(x), cos(2*y)),
              ):
        P1_d[repr(f)] = repr(P1(f))
        print()
        print(f)
        print(P1_d[repr(f)])
        
    P2_d = {}    
    for f in (1,
              sin(x),
              sin(y),
              cos(x),
              cos(y),
              sin(x+y),
              sin(x+2*y),
              x, y, x**2, y**2, x*y, 
              x**3, x**2*y, x*y**2, y**3,
              ):
        P2_d[repr((f,))] = repr(P2((f,)))
        print()
        print(f)
        print(P2_d[repr((f,))])
    
    dataname = 'memoize/projections.json'
    import dec
    dec.store_data(dataname, {1:P1_d, 2:P2_d})
    return
Esempio n. 3
0
        p = to_matrix(laplace_d, N)
        one = zeros(N)
        one[0] = 1
        p = vstack((one, p))

        z = dot(linalg.pinv(p), concatenate(([f(g.verts_dual[0])], P0d(q))))

        err = linalg.norm(P0d(f) - z, inf)
        L[1].append(err)

    return size, L


dataname = "converge/poisson1d_periodic.json"
dec.store_data(dataname, run())

import matplotlib
matplotlib.rcParams['legend.fancybox'] = True
import matplotlib.pyplot as plt
fontsize = 20
labelsize = 13.5


def fix_axis_labels(plt):
    plt.tick_params(labelsize=labelsize)
    plt.xticks((1, 10, 100), ('1', '10', '100'))
    plt.yticks((1, 1e-4, 1e-8, 1e-12), ('1e0', '1e-4', '1e-8', '1e-12'))
    plt.axis([.9, 111, 1e-15, 10])

Esempio n. 4
0
        L[0].append( err )

        #######################

        p = to_matrix(laplace_d, N)
        one = zeros(N); one[0] = 1
        p = vstack((one, p))

        z = dot(linalg.pinv(p), concatenate(( [f(g.verts_dual[0])], P0d(q) )) )

        err = linalg.norm(P0d(f) - z, inf)
        L[1].append( err )

    return size, L
dataname = "converge/poisson1d_periodic.json"
dec.store_data(dataname, run())

import matplotlib
matplotlib.rcParams['legend.fancybox'] = True
import matplotlib.pyplot as plt
fontsize = 20
labelsize = 13.5

def fix_axis_labels(plt):
    plt.tick_params(labelsize=labelsize)
    plt.xticks((1, 10, 100), ('1', '10', '100'))
    plt.yticks((1, 1e-4, 1e-8, 1e-12),
               ('1e0', '1e-4', '1e-8', '1e-12'))
    plt.axis([.9, 111, 1e-15, 10])

size, L = dec.get_data(dataname)