示例#1
0
#    print "R_l:", R_l
#    print  "P_l * I_U_tl - R_l", pprint.pformat(P_l * I_tl - R_l)
    def unroll_mats(acc, eqn):
        if isinstance(eqn, matrix):
            return acc + flatten_list(eqn.tolist())
        else:
            return acc + [eqn]

    eqns = reduce(unroll_mats, eqns, [])
    return eqns, reduce(unroll_mats, known, [])

# Hold your nose
from ignition.flame.tensors.basic_operators import add_invertible
A = Tensor("A", rank=2)
P_0 = Tensor("P_0", rank=2)
add_invertible(T(P_0) * A * P_0)
add_invertible(T(P_0) * A ** 2 * P_0)


# Define the Partition Objs
A = iterative_arg("A", rank=2, part_suffix="1x1")
X = iterative_arg ("X", rank=2, part_suffix="1x3", arg_src="Overwrite")
P = iterative_arg ("P", rank=2, part_suffix="1x3", arg_src="Computed")
I = iterative_arg ("I", rank=2, part_suffix="I_3x3", arg_src="Computed")
U = iterative_arg ("U", rank=2, part_suffix="Upper_Bidiag_3x3", arg_src="Computed")
J = iterative_arg ("J", rank=2, part_suffix="J_3x3", arg_src="Computed")
D = iterative_arg ("D", rank=2, part_suffix="Diag_3x3", arg_src="Computed")
R = iterative_arg ("R", rank=2, part_suffix="1x3", arg_src="Computed")
O = iterative_arg ("O", rank=2, part_suffix="1x3", arg_src="Computed")

示例#2
0
        print "H_tl and Th_ml:", H_tl, Th_ml
        eqns.append(matrix([[T(e), one]]) * H_tl + matrix([[one]]) * Th_ml)
    if H_tl.shape == (1, 1) and Th_ml.shape == (1, 1):
        print "H_tl and Th_ml:", H_tl, Th_ml
        eqns.append(matrix([[T(e)]]) * H_tl + matrix([[one]]) * Th_ml)
    def unroll_mats(acc, eqn):
        if isinstance(eqn, matrix):
            return acc + flatten_list(eqn.tolist())
        else:
            return acc + [eqn]
    eqns = reduce(unroll_mats, eqns, [])
    return eqns, [e]

from ignition.flame.tensors.basic_operators import add_invertible
O_00 = Tensor("O_00", rank=2)
add_invertible(O_00)

def victor_solver(b4_eqns, aft_eqns, e_knowns):
    added = []
    A = Tensor("A", 2)
    R_0 = Tensor("R_0", 2)
    r_1 = Tensor("r_1", 1)
    O_00 = Tensor("O_00", 2)
    w_11 = Tensor("omicron_11", 0)
    for eqn in aft_eqns:
        if A in eqn:
            added.append((T(R_0) * eqn).expand().subs(T(R_0) * R_0, O_00))
            added.append((T(r_1) * eqn).expand().subs(T(r_1) * r_1, w_11))
    aft_eqns.extend(added)
    return tensor_solver(b4_eqns, aft_eqns, e_knowns)
示例#3
0
from ignition.dsl.flame.tensors.solvers import backward_sub

SHOW_NUM_SOLS = 10

# First define the variables
delta_1, omega_2, pi_1, pi_2, gamma_2, mu_12 = \
    map(lambda x: Tensor(x, rank=0),
        ['delta_1', 'omega_2', 'pi_1', 'pi_2', 'gamma_2', 'mu_12'])
r_1, r_2, q_1, q_2, p_1, p_2, s_1, s_2, u_02, x_1, x_2 = \
    map(lambda x: Tensor(x, rank=1),
        ['r_1', 'r_2', 'q_1', 'q_2', 'p_1', 'p_2', 's_1', 's_2', 'u_02',
         'x_1', 'x_2'])
A, R_0, P_0 = map(lambda x: Tensor(x, rank=2), ['A', 'R_0', 'P_0'])

from ignition.flame.tensors.basic_operators import add_invertible
add_invertible(T(P_0) * A * P_0)
add_invertible(T(P_0) * A**2 * P_0)

# Specify which variables are known
knowns = [p_1, r_1, q_1, x_1, pi_1, A, R_0, P_0]


def cg():
    # Specify the CG eqns (coming from a 4x4 PME)
    cg_eqns = [
        delta_1 * A * p_1 - r_1 + r_2,
        p_2 - r_2 + p_1 * mu_12,
        x_2 - x_1 - delta_1 * p_1,
        T(r_1) * r_2,
        T(p_1) * A * p_2,
    ]
示例#4
0
        print "H_tl and Th_ml:", H_tl, Th_ml
        eqns.append(matrix([[T(e)]]) * H_tl + matrix([[one]]) * Th_ml)

    def unroll_mats(acc, eqn):
        if isinstance(eqn, matrix):
            return acc + flatten_list(eqn.tolist())
        else:
            return acc + [eqn]

    eqns = reduce(unroll_mats, eqns, [])
    return eqns, [e]


from ignition.flame.tensors.basic_operators import add_invertible
O_00 = Tensor("O_00", rank=2)
add_invertible(O_00)


def victor_solver(b4_eqns, aft_eqns, e_knowns):
    added = []
    A = Tensor("A", 2)
    R_0 = Tensor("R_0", 2)
    r_1 = Tensor("r_1", 1)
    O_00 = Tensor("O_00", 2)
    w_11 = Tensor("omicron_11", 0)
    for eqn in aft_eqns:
        if A in eqn:
            added.append((T(R_0) * eqn).expand().subs(T(R_0) * R_0, O_00))
            added.append((T(r_1) * eqn).expand().subs(T(r_1) * r_1, w_11))
    aft_eqns.extend(added)
    return tensor_solver(b4_eqns, aft_eqns, e_knowns)