示例#1
0
def test_forward_solve():
    q, r, s = map(lambda x: Tensor(x, rank=1), 'qrs')
    delta = Tensor('delta', rank=0)
    eqn1 = s + q
    eqn2 = delta * r - q
    sol_dict = forward_solve([eqn1, eqn2], [delta, r])
    print "sol_dict should be: {q: delta*r, s: -q }"
    print "  actual:", sol_dict
示例#2
0
def test_overdetermined_forward_solve():
    pi_1, pi_2, mu_12 = \
        map(lambda x: Tensor(x, rank=0),
            ['pi_1', 'pi_2', 'mu_12'])
    r_2, p_1, p_2 = \
        map(lambda x: Tensor(x, rank=1),
            ['r_2', 'p_1', 'p_2'])
    A = Tensor('A', rank=2)

    eqns = [ pi_2 - T(r_2) * A * r_2 + T(mu_12) * pi_1 * mu_12,
             p_2 - r_2 + p_1 * mu_12,
             pi_2 - T(p_2) * A * p_2,
            ]
    return forward_solve(eqns, [r_2, p_1, mu_12, A, pi_1], True)
示例#3
0
def test_3 ():
    q, r, s = map(lambda x: Tensor(x, rank=1), 'qrs')
    s_t = Transpose(s)
    delta = Tensor('delta', rank=0)
    eqn1 = r - s - q * delta
    eqn2 = s_t * r

    print forward_solve([eqn1, eqn2], [r, s, q])
    print forward_solve([eqn1, eqn2], [delta, s, q])
    print forward_solve([eqn2, eqn1], [delta, s, q])