Пример #1
0
def test_evaluate_grid1():
    #Evaluate 2 + yx^2 + 3y^2 - xy on grid (0,0), (0,1), (0,2), (1,0), (1,1), (1,2), (2,0), (2,1), (2,2)
    poly = MultiPower(np.array([[2,0,3],
                                [0,-1,0],
                                [0,1,0]]))
    x = np.arange(3)
    xy = np.column_stack([x,x])
    sol = np.array([[2,5,14],
                    [2,5,14],
                    [2,7,18]])
    assert(np.all(poly.evaluate_grid(xy) == sol))
Пример #2
0
def test_evaluate_grid2():
    #Evaluate zy^2 + 3z^2 + 3x + zx^2y^2 on grid {0, 1, 2}X{0, 1, 2}X{0, 1, 2}
    poly = MultiPower(np.array([[[0,0,3],
                                [0,0,0],
                                [0,1,0]],
                                [[3,0,0],
                                [0,0,0],
                                [0,0,0]],
                                [[0,0,0],
                                [0,0,0],
                                [0,1,0]]]))
    x = np.arange(3)
    xyz = np.column_stack([x,x,x])
    sol = np.array([[[0,3,12],
                    [0,4,14],
                    [0,7,20]],
                    [[3,6,15],
                    [3,8,19],
                    [3,14,31]],
                    [[6,9,18],
                    [6,14,28],
                    [6,29,58]]])
    assert(np.all(poly.evaluate_grid(xyz) == sol))