Beispiel #1
0
def test_vec_solve():
    mu_12 = Tensor('mu_12', rank=0)
    p_1, p_2 = map(lambda x: Tensor(x, rank=1), ['p_1', 'p_2'])
    A = Tensor('A', rank=2)
    print solve_vec_eqn(
        -mu_12 * (T(p_1) * A * p_2) - mu_12 * (T(p_2) * A * p_1) +
        (T(p_2) * A * p_1), mu_12)
Beispiel #2
0
def test_0():
    A = Tensor('A', rank=2, has_inv=True)
    x = Tensor('x', rank=1)
    y = Tensor('y', rank=1)
    alpha = Tensor('alpha', rank=0)
    beta = Tensor('beta', rank=0)
    eqn = alpha * A * x + beta * y
    print eqn, "rank:", expr_rank(eqn)
    print "solution for y", solve_vec_eqn(eqn, y)
    print "solution for x", solve_vec_eqn(eqn, x)
def test_0 ():
    A = Tensor('A', rank=2, has_inv=True)
    x = Tensor('x', rank=1)
    y = Tensor('y', rank=1)
    alpha = Tensor('alpha', rank=0)
    beta = Tensor('beta', rank=0)
    eqn = alpha * A * x + beta * y
    print eqn, "rank:", expr_rank(eqn)
    print "solution for y", solve_vec_eqn(eqn, y)
    print "solution for x", solve_vec_eqn(eqn, x)
def test_vec_solve():
    mu_12 = Tensor('mu_12', rank=0)
    p_1, p_2 = map(lambda x: Tensor(x, rank=1), ['p_1', 'p_2'])
    A = Tensor('A', rank=2)
    print solve_vec_eqn(-mu_12 * (T(p_1) * A * p_2) - mu_12 * (T(p_2) * A * p_1) + (T(p_2) * A * p_1) , mu_12)
Beispiel #5
0
def test_numerator():
    a, b, c = map(lambda x: Tensor(x, rank=0), 'abc')
    expr = (a + b) / c
    sol = solve_vec_eqn(expr, a)
    assert (sol == -b)
def test_numerator ():
    a, b, c = map(lambda x: Tensor(x, rank=0), 'abc')
    expr = (a + b) / c
    sol = solve_vec_eqn(expr, a)
    assert(sol == -b)