def roc_hint(matrix_string, i, matrix): error_string = "There must have been a mistake. Try again.\n" pc.print_matrix(matrix_string, i, "", matrix) while True: try: roc = eval(raw_input("Please enter " + str(matrix_string) + str(i) + "_roc or \"auto\":\n")) if roc==auto: roc = al.right_ortho_complement(matrix) try: if al.is_zero_matrix(matrix*roc): pc.print_matrix(matrix_string, i, "_roc", roc) return roc else: print error_string except: print error_string except Exception as exc: print exc print error_string
def roc_hint(matrix_string, i, matrix): error_string = "There must have been a mistake. Try again.\n" pc.print_matrix(matrix_string, i, "", matrix) while True: try: roc = eval( input("Please enter " + str(matrix_string) + str(i) + "_roc or \"auto\":\n")) if roc == auto: roc = al.right_ortho_complement(matrix) try: if al.is_zero_matrix(matrix * roc): pc.print_matrix(matrix_string, i, "_roc", roc) return roc else: print(error_string) except: print(error_string) except Exception as exc: print(exc) print(error_string)
def main(): P1i, P0i = tangent_system() global mode mode = raw_input("Enter \"manual\" for manual mode or hit enter:\n") ##################################################################### i = 0 while 1: # new iteration_stack myIteration = mc.IterationStack(i, P1i, P0i) assert al.has_full_row_rank(P1i), "P10 does not have full row rank. There \ must be algebraic equations." Bi = reduction(myIteration) assert not al.is_zero_matrix(Bi), "System ist not flat!" if is_special_case(Bi): # special case Bi = fourseven(myIteration) if end_condition(Bi): # flag myIteration.last_iter_step = True # add to system stack + print myStack.add_iteration(myIteration) break P1i, P0i = elimination(myIteration) if mode=="manual": pc.print_line() # add to system stack + print iteration myStack.add_iteration(myIteration) i += 1 # create transformation and calculate H and G(d/dt) myStack.transformation = tr.Transformation(myStack) # store results of the algorithm in pickled data container data = st.Container() data.F_eq = nct.make_all_symbols_noncommutative(example.F_eq, "")[0] data.vec_x = nct.make_all_symbols_noncommutative(example.vec_x, "")[0] data.vec_xdot = nct.make_all_symbols_noncommutative(example.vec_xdot, "")[0] if hasattr(example, 'diff_symbols'): data.diff_symbols = nct.make_all_symbols_noncommutative(example.diff_symbols, "")[0] if hasattr(example, 'user_data'): data.user_data = example.user_data # add data to be stored here: # make symbols in P10 and P00 noncommutative P1 = nct.make_all_symbols_noncommutative(myStack.transformation.P10, "")[0] P0 = nct.make_all_symbols_noncommutative(myStack.transformation.P00, "")[0] s = sp.Symbol('s', commutative=False) data.P = P1*s+P0 data.P1 = P1 data.P0 = P0 data.H = nct.make_all_symbols_noncommutative(myStack.transformation.H, "")[0] fname = path.replace(".py",".pcl") st.pickle_full_dump(data, fname) # for testing try: import pycartan as ct global w myIntegrabilityCheck = ic.IntegrabilityCheck(myStack) w = myStack.transformation.w except Exception as exc: print exc print "Data saved to ", fname, "\n" pc.print_line()
def main(): P1i, P0i = tangent_system() global mode # raw_input was removed in python3 if sys.version_info[0] == 2: mode = raw_input("Enter \"manual\" for manual mode or hit enter:\n") elif sys.version_info[0] == 3: mode = input("Enter \"manual\" for manual mode or hit enter:\n") ##################################################################### i = 0 while 1: # new iteration_stack myIteration = mc.IterationStack(i, P1i, P0i) assert al.has_full_row_rank( P1i), "P10 does not have full row rank. There \ must be algebraic equations." Bi = reduction(myIteration) assert not al.is_zero_matrix(Bi), "System ist not flat!" if is_special_case(Bi): # special case Bi = fourseven(myIteration) if end_condition(Bi): # flag myIteration.last_iter_step = True # add to system stack + print myStack.add_iteration(myIteration) break P1i, P0i = elimination(myIteration) if mode == "manual": pc.print_line() # add to system stack + print iteration myStack.add_iteration(myIteration) i += 1 # create transformation and calculate H and G(d/dt) myStack.transformation = tr.Transformation(myStack) # store results of the algorithm in pickled data container data = st.Container() data.F_eq = nct.make_all_symbols_noncommutative(example.F_eq, "")[0] data.vec_x = nct.make_all_symbols_noncommutative(example.vec_x, "")[0] data.vec_xdot = nct.make_all_symbols_noncommutative(example.vec_xdot, "")[0] if hasattr(example, 'diff_symbols'): data.diff_symbols = nct.make_all_symbols_noncommutative( example.diff_symbols, "")[0] if hasattr(example, 'user_data'): data.user_data = example.user_data # add data to be stored here: # make symbols in P10 and P00 noncommutative P1 = nct.make_all_symbols_noncommutative(myStack.transformation.P10, "")[0] P0 = nct.make_all_symbols_noncommutative(myStack.transformation.P00, "")[0] s = sp.Symbol('s', commutative=False) data.P = P1 * s + P0 data.P1 = P1 data.P0 = P0 data.H = nct.make_all_symbols_noncommutative(myStack.transformation.H, "")[0] fname = path.replace(".py", ".pcl") st.pickle_full_dump(data, fname) # for testing try: import pycartan as ct import core.integrability as ic global w myIntegrabilityCheck = ic.IntegrabilityCheck(myStack) w = myStack.transformation.w except Exception as exc: print(exc) print("Data saved to ", fname, "\n") pc.print_line()