def double_double_cascade_step(dim, embsys, esols, tasks=0): r""" Given in *embsys* an embedded polynomial system and solutions with nonzero slack variables in *esols*, does one step in the homotopy cascade, with double double precision arithmetic. The dimension of the solution set represented by *embsys* and *esols* is the value of *dim*. The number of tasks in multithreaded path tracking is given by *tasks*. The default zero value of *tasks* indicates no multithreading. The list on return contains witness points on lower dimensional solution components. """ from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_start_system from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_start_solutions from phcpy.phcpy2c2 import py2c_dobldobl_cascade_homotopy from phcpy.phcpy2c2 import py2c_solve_by_dobldobl_homotopy_continuation from phcpy.phcpy2c2 import py2c_solcon_clear_dobldobl_solutions from phcpy.phcpy2c2 import py2c_copy_dobldobl_target_solutions_to_container from phcpy.interface import store_dobldobl_witness_set from phcpy.interface import load_dobldobl_solutions store_dobldobl_witness_set(len(embsys), dim, embsys, esols) py2c_copy_dobldobl_container_to_start_system() py2c_copy_dobldobl_container_to_start_solutions() py2c_dobldobl_cascade_homotopy() py2c_solve_by_dobldobl_homotopy_continuation(tasks) py2c_solcon_clear_dobldobl_solutions() py2c_copy_dobldobl_target_solutions_to_container() return load_dobldobl_solutions()
def double_double_cascade_step(dim, embsys, esols, tasks=0): r""" Given in *embsys* an embedded polynomial system and solutions with nonzero slack variables in *esols*, does one step in the homotopy cascade, with double double precision arithmetic. The dimension of the solution set represented by *embsys* and *esols* is the value of *dim*. The number of tasks in multithreaded path tracking is given by *tasks*. The default zero value of *tasks* indicates no multithreading. The list on return contains witness points on lower dimensional solution components. """ from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_start_system from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_start_solutions from phcpy.phcpy2c2 import py2c_dobldobl_cascade_homotopy from phcpy.phcpy2c2 import py2c_solve_by_dobldobl_homotopy_continuation from phcpy.phcpy2c2 import py2c_solcon_clear_dobldobl_solutions from phcpy.phcpy2c2 import py2c_copy_dobldobl_target_solutions_to_container from phcpy.interface import store_dobldobl_witness_set from phcpy.interface import load_dobldobl_solutions store_dobldobl_witness_set(len(embsys), dim, embsys, esols) py2c_copy_dobldobl_container_to_start_system() py2c_copy_dobldobl_container_to_start_solutions() py2c_dobldobl_cascade_homotopy() py2c_solve_by_dobldobl_homotopy_continuation(tasks) py2c_solcon_clear_dobldobl_solutions() py2c_copy_dobldobl_target_solutions_to_container() return load_dobldobl_solutions()
def double_double_track(target, start, sols, gamma=0, tasks=0): r""" Does path tracking in double double precision. On input are a target system, a start system with solutions, optionally a (random) gamma constant and the number of tasks. The default value zero for *tasks* indicates no multithreading. The number of tasks in the multithreading is given by *tasks*. The *target* is a list of strings representing the polynomials of the target system (which has to be solved). The *start* is a list of strings representing the polynomials of the start system with known solutions in *sols*. The *sols* is a list of strings representing start solutions. By default, a random *gamma* constant is generated, otherwise *gamma* must be a nonzero complex constant. On return are the string representations of the solutions computed at the end of the paths. """ from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_target_system from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_start_system from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_start_solutions from phcpy.phcpy2c2 import py2c_create_dobldobl_homotopy from phcpy.phcpy2c2 import py2c_create_dobldobl_homotopy_with_gamma from phcpy.phcpy2c2 import py2c_solve_by_dobldobl_homotopy_continuation from phcpy.phcpy2c2 import py2c_solcon_clear_dobldobl_solutions from phcpy.phcpy2c2 import py2c_copy_dobldobl_target_solutions_to_container from phcpy.interface import store_dobldobl_system from phcpy.interface import store_dobldobl_solutions from phcpy.interface import load_dobldobl_solutions from phcpy.solver import number_of_symbols dim = number_of_symbols(start) store_dobldobl_system(target, nbvar=dim) py2c_copy_dobldobl_container_to_target_system() store_dobldobl_system(start, nbvar=dim) py2c_copy_dobldobl_container_to_start_system() # py2c_clear_dobldobl_homotopy() if(gamma == 0): py2c_create_dobldobl_homotopy() else: py2c_create_dobldobl_homotopy_with_gamma(gamma.real, gamma.imag) store_dobldobl_solutions(dim, sols) py2c_copy_dobldobl_container_to_start_solutions() py2c_solve_by_dobldobl_homotopy_continuation(tasks) py2c_solcon_clear_dobldobl_solutions() py2c_copy_dobldobl_target_solutions_to_container() return load_dobldobl_solutions()
def double_double_track(target, start, sols, gamma=0, tasks=0): """ Does path tracking in double double precision. On input are a target system, a start system with solutions, optionally a (random) gamma constant and the number of tasks. The target is a list of strings representing the polynomials of the target system (which has to be solved). The start is a list of strings representing the polynomials of the start system with known solutions in sols. The sols is a list of strings representing start solutions. By default, a random gamma constant is generated, otherwise gamma must be a nonzero complex constant. On return are the string representations of the solutions computed at the end of the paths. """ from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_target_system from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_start_system from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_start_solutions from phcpy.phcpy2c2 import py2c_create_dobldobl_homotopy from phcpy.phcpy2c2 import py2c_create_dobldobl_homotopy_with_gamma from phcpy.phcpy2c2 import py2c_solve_by_dobldobl_homotopy_continuation from phcpy.phcpy2c2 import py2c_solcon_clear_dobldobl_solutions from phcpy.phcpy2c2 import py2c_copy_dobldobl_target_solutions_to_container from phcpy.interface import store_dobldobl_system from phcpy.interface import store_dobldobl_solutions from phcpy.interface import load_dobldobl_solutions from phcpy.solver import number_of_symbols dim = number_of_symbols(start) store_dobldobl_system(target, nbvar=dim) py2c_copy_dobldobl_container_to_target_system() store_dobldobl_system(start, nbvar=dim) py2c_copy_dobldobl_container_to_start_system() # py2c_clear_dobldobl_homotopy() if(gamma == 0): py2c_create_dobldobl_homotopy() else: py2c_create_dobldobl_homotopy_with_gamma(gamma.real, gamma.imag) store_dobldobl_solutions(dim, sols) py2c_copy_dobldobl_container_to_start_solutions() py2c_solve_by_dobldobl_homotopy_continuation(tasks) py2c_solcon_clear_dobldobl_solutions() py2c_copy_dobldobl_target_solutions_to_container() return load_dobldobl_solutions()
def dobldobl_diagonal_homotopy(dim1, sys1, esols1, dim2, sys2, esols2): r""" Defines a diagonal homotopy to intersect the witness sets defined by (*sys1*, *esols1*) and (*sys2*, *esols2*), respectively of dimensions *dim1* and *dim2*. The systems *sys1* and *sys2* are assumed to be square and with as many slack variables as the dimension of the solution sets. The data is stored in double double precision. """ from phcpy.interface import store_dobldobl_system as storesys from phcpy.interface import store_dobldobl_solutions as storesols from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_target_system from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_target_solutions from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_start_system from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_start_solutions from phcpy.phcpy2c2 import py2c_dobldobl_diagonal_homotopy from phcpy.phcpy2c2 import py2c_syscon_number_of_symbols from phcpy.phcpy2c2 import py2c_syscon_string_of_symbols from phcpy.phcpy2c2 import py2c_diagonal_symbols_doubler storesys(sys1) symbols = py2c_syscon_string_of_symbols() nbsymbs = py2c_syscon_number_of_symbols() print 'number of symbols :', nbsymbs print 'names of variables :', symbols storesols(len(sys1), esols1) if (dim1 >= dim2): py2c_copy_dobldobl_container_to_target_system() py2c_copy_dobldobl_container_to_target_solutions() else: py2c_copy_dobldobl_container_to_start_system() py2c_copy_dobldobl_container_to_start_solutions() storesys(sys2) storesols(len(sys2), esols2) if (dim1 >= dim2): py2c_copy_dobldobl_container_to_start_system() py2c_copy_dobldobl_container_to_start_solutions() else: py2c_copy_dobldobl_container_to_target_system() py2c_copy_dobldobl_container_to_target_solutions() if (dim1 >= dim2): py2c_dobldobl_diagonal_homotopy(dim1, dim2) else: py2c_dobldobl_diagonal_homotopy(dim2, dim1) py2c_diagonal_symbols_doubler(nbsymbs - dim1, dim1, len(symbols), symbols)
def dobldobl_diagonal_homotopy(dim1, sys1, esols1, dim2, sys2, esols2): r""" Defines a diagonal homotopy to intersect the witness sets defined by (*sys1*, *esols1*) and (*sys2*, *esols2*), respectively of dimensions *dim1* and *dim2*. The systems *sys1* and *sys2* are assumed to be square and with as many slack variables as the dimension of the solution sets. The data is stored in double double precision. """ from phcpy.interface import store_dobldobl_system as storesys from phcpy.interface import store_dobldobl_solutions as storesols from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_target_system from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_target_solutions from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_start_system from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_start_solutions from phcpy.phcpy2c2 import py2c_dobldobl_diagonal_homotopy from phcpy.phcpy2c2 import py2c_syscon_number_of_symbols from phcpy.phcpy2c2 import py2c_syscon_string_of_symbols from phcpy.phcpy2c2 import py2c_diagonal_symbols_doubler storesys(sys1) symbols = py2c_syscon_string_of_symbols() nbsymbs = py2c_syscon_number_of_symbols() print 'number of symbols :', nbsymbs print 'names of variables :', symbols storesols(len(sys1), esols1) if(dim1 >= dim2): py2c_copy_dobldobl_container_to_target_system() py2c_copy_dobldobl_container_to_target_solutions() else: py2c_copy_dobldobl_container_to_start_system() py2c_copy_dobldobl_container_to_start_solutions() storesys(sys2) storesols(len(sys2), esols2) if(dim1 >= dim2): py2c_copy_dobldobl_container_to_start_system() py2c_copy_dobldobl_container_to_start_solutions() else: py2c_copy_dobldobl_container_to_target_system() py2c_copy_dobldobl_container_to_target_solutions() if(dim1 >= dim2): py2c_dobldobl_diagonal_homotopy(dim1, dim2) else: py2c_dobldobl_diagonal_homotopy(dim2, dim1) py2c_diagonal_symbols_doubler(nbsymbs-dim1, dim1, len(symbols), symbols)
def dobldobl_track(target, start, sols, filename="", verbose=False): """ Wraps the tracker for Pade continuation in double double precision. On input are a target system, a start system with solutions, optionally: a string *filename* and the *verbose* flag. The *target* is a list of strings representing the polynomials of the target system (which has to be solved). The *start* is a list of strings representing the polynomials of the start system, with known solutions in *sols*. The *sols* is a list of strings representing start solutions. On return are the string representations of the solutions computed at the end of the paths. """ from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_target_system from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_start_system from phcpy.phcpy2c2 import py2c_copy_dobldobl_container_to_start_solutions from phcpy.phcpy2c2 import py2c_create_dobldobl_homotopy_with_gamma from phcpy.phcpy2c2 import py2c_clear_dobldobl_homotopy from phcpy.phcpy2c2 import py2c_clear_dobldobl_operations_data from phcpy.interface import store_dobldobl_system from phcpy.interface import store_dobldobl_solutions from phcpy.interface import load_dobldobl_solutions from phcpy.solver import number_of_symbols from phcpy.phcpy2c2 import py2c_padcon_dobldobl_track dim = number_of_symbols(start) store_dobldobl_system(target, nbvar=dim) py2c_copy_dobldobl_container_to_target_system() store_dobldobl_system(start, nbvar=dim) py2c_copy_dobldobl_container_to_start_system() (regamma, imgamma) = get_homotopy_continuation_parameter(1) store_dobldobl_solutions(dim, sols) py2c_copy_dobldobl_container_to_start_solutions() nbc = len(filename) (regamma, imgamma) = get_homotopy_continuation_parameter(1) py2c_create_dobldobl_homotopy_with_gamma(regamma, imgamma) fail = py2c_padcon_dobldobl_track(nbc, filename, int(verbose)) # py2c_clear_dobldobl_homotopy() # py2c_clear_dobldobl_operations_data() return load_dobldobl_solutions()