def standard_start_diagonal_cascade(gamma=0, tasks=0): r""" Does the path tracking to start a diagonal cascade in standard double precision. For this to work, the functions standard_diagonal_homotopy and standard_diagonal_cascade_solutions must be executed successfully. If *gamma* equals 0 on input, then a random gamma constant is generated, otherwise, the given complex *gamma* will be used in the homotopy. Multitasking is available, and activated by the *tasks* parameter. Returns the target (system and its corresponding) solutions. """ from phcpy.phcpy2c2 import py2c_create_standard_homotopy from phcpy.phcpy2c2 import py2c_create_standard_homotopy_with_gamma from phcpy.phcpy2c2 import py2c_solve_by_standard_homotopy_continuation from phcpy.phcpy2c2 import py2c_solcon_clear_standard_solutions from phcpy.phcpy2c2 import py2c_syscon_clear_standard_system from phcpy.phcpy2c2 import py2c_copy_standard_target_solutions_to_container from phcpy.phcpy2c2 import py2c_copy_standard_target_system_to_container from phcpy.interface import load_standard_solutions from phcpy.interface import load_standard_system if(gamma == 0): py2c_create_standard_homotopy() else: py2c_create_standard_homotopy_with_gamma(gamma.real, gamma.imag) py2c_solve_by_standard_homotopy_continuation(tasks) py2c_solcon_clear_standard_solutions() py2c_syscon_clear_standard_system() py2c_copy_standard_target_solutions_to_container() # from phcpy.phcpy2c2 import py2c_write_standard_target_system # print 'the standard target system :' # py2c_write_standard_target_system() py2c_copy_standard_target_system_to_container() tsys = load_standard_system() sols = load_standard_solutions() return (tsys, sols)
def standard_start_diagonal_cascade(gamma=0, tasks=0): r""" Does the path tracking to start a diagonal cascade in standard double precision. For this to work, the functions standard_diagonal_homotopy and standard_diagonal_cascade_solutions must be executed successfully. If *gamma* equals 0 on input, then a random gamma constant is generated, otherwise, the given complex *gamma* will be used in the homotopy. Multitasking is available, and activated by the *tasks* parameter. Returns the target (system and its corresponding) solutions. """ from phcpy.phcpy2c2 import py2c_create_standard_homotopy from phcpy.phcpy2c2 import py2c_create_standard_homotopy_with_gamma from phcpy.phcpy2c2 import py2c_solve_by_standard_homotopy_continuation from phcpy.phcpy2c2 import py2c_solcon_clear_standard_solutions from phcpy.phcpy2c2 import py2c_syscon_clear_standard_system from phcpy.phcpy2c2 import py2c_copy_standard_target_solutions_to_container from phcpy.phcpy2c2 import py2c_copy_standard_target_system_to_container from phcpy.interface import load_standard_solutions from phcpy.interface import load_standard_system if (gamma == 0): py2c_create_standard_homotopy() else: py2c_create_standard_homotopy_with_gamma(gamma.real, gamma.imag) py2c_solve_by_standard_homotopy_continuation(tasks) py2c_solcon_clear_standard_solutions() py2c_syscon_clear_standard_system() py2c_copy_standard_target_solutions_to_container() # from phcpy.phcpy2c2 import py2c_write_standard_target_system # print 'the standard target system :' # py2c_write_standard_target_system() py2c_copy_standard_target_system_to_container() tsys = load_standard_system() sols = load_standard_solutions() return (tsys, sols)
def standard_littlewood_richardson_homotopies( ndim, kdim, brackets, verbose=True, vrfcnd=False, minrep=True, tosqr=False, outputfilename="" ): r""" In n-dimensional space we consider k-dimensional planes, subject to intersection conditions represented by brackets. The parameters *ndim* and *kdim* give values for n and k respectively. The parameter *brackets* is a list of brackets. A bracket is a list of as many natural numbers (in the range 1..*ndim*) as *kdim*. The Littlewood-Richardson homotopies compute k-planes that meet the flags at spaces of dimensions prescribed by the brackets, in standard double precision. Four options are passed as Booleans: *verbose*: for adding extra output during computations, *vrfcnd*: for extra diagnostic verification of Schubert conditions, *minrep*: for a minimial representation of the problem formulation, *tosqr*: to square the overdetermined systems. On return is a 4-tuple. The first item of the tuple is the formal root count, sharp for general flags, then as second item the coordinates of the flags. The coordinates of the flags are stored row wise in a list of real and imaginary parts. The third and fourth item of the tuple on return are respectively the polynomial system that has been solved and its solutions. The length of the list of solution should match the root count. """ from phcpy.phcpy2c2 import py2c_solcon_clear_standard_solutions from phcpy.phcpy2c2 import py2c_schubert_standard_littlewood_richardson_homotopies as stlrhom from phcpy.interface import load_standard_solutions, load_standard_system py2c_solcon_clear_standard_solutions() nbc = len(brackets) cds = "" for bracket in brackets: for num in bracket: cds = cds + " " + str(num) # print 'the condition string :', cds (roco, sflags) = stlrhom( ndim, kdim, nbc, len(cds), cds, int(verbose), int(vrfcnd), int(minrep), int(tosqr), len(outputfilename), outputfilename, ) rflags = eval(sflags) flgs = [] for k in range(len(rflags) / 2): flgs.append(complex(rflags[2 * k], rflags[2 * k + 1])) fsys = load_standard_system() sols = load_standard_solutions() return (roco, flgs, fsys, sols)
def standard_pade_approximants(pols, sols, idx=1, numdeg=2, dendeg=2, \ nbr=4, verbose=True): r""" Computes Pade approximants based on the series in standard double precision for the polynomials in *pols*, where the leading coefficients of the series are the solutions in *sols*. On entry are the following seven parameters: *pols*: a list of string representations of polynomials, *sols*: a list of solutions of the polynomials in *pols*, *idx*: index of the series parameter, by default equals 1, *numdeg*: the degree of the numerator, *dendeg*: the degree of the denominator, *nbr*: number of steps with Newton's method, *verbose*: whether to write intermediate output to screen or not. On return is a list of lists of strings. Each lists of strings represents the series solution for the variables in the list *pols*. """ from phcpy.solver import number_of_symbols from phcpy.interface import store_standard_solutions from phcpy.interface import store_standard_system, load_standard_system from phcpy.phcpy2c3 \ import py2c_standard_Pade_approximant as Pade_approximants from phcpy.phcpy2c3 import py2c_syspool_standard_size as poolsize from phcpy.phcpy2c3 import py2c_syspool_copy_to_standard_container from phcpy.phcpy2c3 import py2c_syspool_standard_clear nbsym = number_of_symbols(pols) if verbose: print("the polynomials :") for pol in pols: print(pol) print("Number of variables :", nbsym) store_standard_system(pols, nbvar=nbsym) store_standard_solutions(nbsym, sols) fail = Pade_approximants(idx, numdeg, dendeg, nbr, int(verbose)) size = (-1 if fail else poolsize()) if verbose: if size == -1: print("An error occurred in the Pade constructor.") else: print("Computed %d Pade approximants." % size) result = [] for k in range(1, size + 1): py2c_syspool_copy_to_standard_container(k) sersol = load_standard_system() substsersol = substitute_symbol(sersol, idx) result.append(make_fractions(substsersol)) py2c_syspool_standard_clear() return result
def permute_standard_system(pols): """ Permutes the equations in the list of polynomials in pols with coefficients in standard double precision, along the permutation used in the mixed volume computation. """ from phcpy.phcpy2c3 import py2c_celcon_permute_standard_system from phcpy.interface import store_standard_system, load_standard_system store_standard_system(pols) py2c_celcon_permute_standard_system() return load_standard_system()
def standard_scale_system(pols): """ Applies equation and variable scaling in standard double precision to the polynomials in the list pols. On return is the list of scaled polynomials and the scaling coefficients. """ from phcpy.interface import store_standard_system, load_standard_system from phcpy.phcpy2c3 import py2c_scale_standard_system store_standard_system(pols) cffs = py2c_scale_standard_system(2) spol = load_standard_system() return (spol, cffs)
def standard_newton_power_series(pols, lser, idx=1, nbr=4, verbose=True): r""" Computes series in standard double precision for the polynomials in *pols*, where the leading terms are given in the list *lser*. On entry are the following five parameters: *pols*: a list of string representations of polynomials, *lser*: a list of polynomials in the series parameter (e.g.: t), for use as start terms in Newton's method, *idx*: index of the series parameter, by default equals 1, *nbr*: number of steps with Newton's method, *verbose*: whether to write intermediate output to screen or not. On return is a list of lists of strings. Each lists of strings represents the series solution for the variables in the list *pols*. """ from phcpy.solver import number_of_symbols from phcpy.interface import store_standard_system, load_standard_system from phcpy.phcpy2c2 import py2c_standard_Newton_power_series as newton from phcpy.phcpy2c2 import py2c_syspool_standard_init from phcpy.phcpy2c2 import py2c_syspool_standard_create from phcpy.phcpy2c2 import py2c_syspool_standard_size as poolsize from phcpy.phcpy2c2 import py2c_syspool_copy_to_standard_container from phcpy.phcpy2c2 import py2c_syspool_standard_clear nbsym = number_of_symbols(pols) if verbose: print "the polynomials :" for pol in pols: print pol print "Number of variables :", nbsym store_standard_system(lser, nbvar=1) py2c_syspool_standard_init(1); py2c_syspool_standard_create(1); store_standard_system(pols, nbvar=nbsym) fail = newton(idx, nbr, int(verbose)) size = (-1 if fail else poolsize()) if verbose: if size == -1: print "An error occurred in the execution of Newton's method." else: print "Computed one series solution." py2c_syspool_copy_to_standard_container(1) result = load_standard_system() result = substitute_symbol(result, idx) py2c_syspool_standard_clear() return result
def standard_littlewood_richardson_homotopies(ndim, kdim, brackets, \ verbose=True, vrfcnd=False, minrep=True, tosqr=False, outputfilename=''): r""" In n-dimensional space we consider k-dimensional planes, subject to intersection conditions represented by brackets. The parameters *ndim* and *kdim* give values for n and k respectively. The parameter brackets is a list of brackets. A bracket is a list of as many natural numbers (in the range 1..*ndim*) as *kdim*. The Littlewood-Richardson homotopies compute k-planes that meet the flags at spaces of dimensions prescribed by the brackets, in standard double precision. Four options are passed as Booleans: *verbose*: for adding extra output during computations, *vrfcnd*: for extra diagnostic verification of Schubert conditions, *minrep*: for a minimial representation of the problem formulation, *tosqr*: to square the overdetermined systems. On return is a 4-tuple. The first item of the tuple is the formal root count, sharp for general flags, then as second item the coordinates of the flags. The coordinates of the flags are stored row wise in a list of real and imaginary parts. The third and fourth item of the tuple on return are respectively the polynomial system that has been solved and its solutions. The length of the list of solution should match the root count. """ from phcpy.phcpy2c3 import py2c_solcon_clear_standard_solutions from phcpy.phcpy2c3 \ import py2c_schubert_standard_littlewood_richardson_homotopies \ as stlrhom from phcpy.interface import load_standard_solutions, load_standard_system py2c_solcon_clear_standard_solutions() nbc = len(brackets) cds = '' for bracket in brackets: for num in bracket: cds = cds + ' ' + str(num) # print 'the condition string :', cds (roco, sflags) = stlrhom(ndim, kdim, nbc, len(cds), cds, \ int(verbose), int(vrfcnd), int(minrep), int(tosqr), \ len(outputfilename), outputfilename) rflags = eval(sflags) flgs = [] for k in range(len(rflags)//2): flgs.append(complex(rflags[2*k], rflags[2*k+1])) fsys = load_standard_system() sols = load_standard_solutions() return (roco, flgs, fsys, sols)
def standard_newton_series(pols, sols, idx=1, maxdeg=4, nbr=4, verbose=True): r""" Computes series in standard double precision for the polynomials in *pols*, where the leading coefficients are the solutions in *sols*. On entry are the following five parameters: *pols*: a list of string representations of polynomials, *sols*: a list of solutions of the polynomials in *pols*, *idx*: index of the series parameter, by default equals 1, *maxdeg*: maximal degree of the series, *nbr*: number of steps with Newton's method, *verbose*: whether to write intermediate output to screen or not. On return is a list of lists of strings. Each lists of strings represents the series solution for the variables in the list *pols*. """ from phcpy.solver import number_of_symbols from phcpy.interface import store_standard_solutions from phcpy.interface import store_standard_system, load_standard_system from phcpy.phcpy2c2 import py2c_standard_Newton_series as newton from phcpy.phcpy2c2 import py2c_syspool_standard_size as poolsize from phcpy.phcpy2c2 import py2c_syspool_copy_to_standard_container from phcpy.phcpy2c2 import py2c_syspool_standard_clear nbsym = number_of_symbols(pols) if verbose: print "the polynomials :" for pol in pols: print pol print "Number of variables :", nbsym store_standard_system(pols, nbvar=nbsym) store_standard_solutions(nbsym, sols) fail = newton(idx, maxdeg, nbr, int(verbose)) size = (-1 if fail else poolsize()) if verbose: if size == -1: print "An error occurred in the execution of Newton's method." else: print "Computed %d series solutions." % size result = [] for k in range(1, size+1): py2c_syspool_copy_to_standard_container(k) sersol = load_standard_system() result.append(substitute_symbol(sersol, idx)) py2c_syspool_standard_clear() return result
def standard_newton_power_series(pols, lser, idx=1, nbr=4, verbose=True): r""" Computes series in standard double precision for the polynomials in *pols*, where the leading terms are given in the list *lser*. On entry are the following five parameters: *pols*: a list of string representations of polynomials, *lser*: a list of polynomials in the series parameter (e.g.: t), for use as start terms in Newton's method, *idx*: index of the series parameter, by default equals 1, *nbr*: number of steps with Newton's method, *verbose*: whether to write intermediate output to screen or not. On return is a list of lists of strings. Each lists of strings represents the series solution for the variables in the list *pols*. """ from phcpy.solver import number_of_symbols from phcpy.interface import store_standard_system, load_standard_system from phcpy.phcpy2c3 import py2c_standard_Newton_power_series as newton from phcpy.phcpy2c3 import py2c_syspool_standard_init from phcpy.phcpy2c3 import py2c_syspool_standard_create from phcpy.phcpy2c3 import py2c_syspool_standard_size as poolsize from phcpy.phcpy2c3 import py2c_syspool_copy_to_standard_container from phcpy.phcpy2c3 import py2c_syspool_standard_clear nbsym = number_of_symbols(pols) if verbose: print("the polynomials :") for pol in pols: print(pol) print("Number of variables :", nbsym) store_standard_system(lser, nbvar=1) py2c_syspool_standard_init(1) py2c_syspool_standard_create(1) store_standard_system(pols, nbvar=nbsym) fail = newton(idx, nbr, int(verbose)) size = (-1 if fail else poolsize()) if verbose: if size == -1: print("An error occurred in the execution of Newton's method.") else: print("Computed one series solution.") py2c_syspool_copy_to_standard_container(1) result = load_standard_system() result = substitute_symbol(result, idx) py2c_syspool_standard_clear() return result
def random_system(dim, nbrmon, deg, cff): """ Generates a random polynomial system based on the following: dim : number of equations and variables, nbrmon : maximum number of monomials per equation, deg : upper bound on the degree of the monomials, cff : type of coefficients, must be 0, 1, or 2, if 0, then random complex numbers on the unit circle, if 1, then coefficients are one (or integer multiples of one), if 2, then coefficients are floats in [-1,+1]. """ from phcpy.phcpy2c3 import py2c_syscon_random_system from phcpy.interface import load_standard_system py2c_syscon_random_system(dim, nbrmon, deg, cff) return load_standard_system()
def standard_newton_series(pols, sols, idx=1, nbr=4, verbose=True): r""" Computes series in standard double precision for the polynomials in *pols*, where the leading coefficients are the solutions in *sols*. On entry are the following five parameters: *pols*: a list of string representations of polynomials, *sols*: a list of solutions of the polynomials in *pols*, *idx*: index of the series parameter, by default equals 1, *nbr*: number of steps with Newton's method, *verbose*: whether to write intermediate output to screen or not. On return is a list of lists of strings. Each lists of strings represents the series solution for the variables in the list *pols*. """ from phcpy.solver import number_of_symbols from phcpy.interface import store_standard_solutions from phcpy.interface import store_standard_system, load_standard_system from phcpy.phcpy2c2 import py2c_standard_Newton_series as newton from phcpy.phcpy2c2 import py2c_syspool_standard_size as poolsize from phcpy.phcpy2c2 import py2c_syspool_copy_to_standard_container from phcpy.phcpy2c2 import py2c_syspool_standard_clear nbsym = number_of_symbols(pols) if verbose: print "the polynomials :" for pol in pols: print pol print "Number of variables :", nbsym store_standard_system(pols, nbvar=nbsym) store_standard_solutions(nbsym, sols) fail = newton(idx, nbr, int(verbose)) size = (-1 if fail else poolsize()) if verbose: if size == -1: print "An error occurred in the execution of Newton's method." else: print "Computed %d series solutions." % size result = [] for k in range(1, size+1): py2c_syspool_copy_to_standard_container(k) sersol = load_standard_system() result.append(substitute_symbol(sersol, idx)) py2c_syspool_standard_clear() return result
def random_linear_product_system(pols, tosolve=True): """ Given in pols a list of string representations of polynomials, returns a random linear-product system based on a supporting set structure and its solutions as well (if tosolve). """ from phcpy.phcpy2c3 import py2c_product_supporting_set_structure from phcpy.phcpy2c3 import py2c_product_random_linear_product_system from phcpy.phcpy2c3 import py2c_product_solve_linear_product_system from phcpy.interface import store_standard_system, load_standard_system from phcpy.interface import load_standard_solutions store_standard_system(pols) py2c_product_supporting_set_structure() py2c_product_random_linear_product_system() result = load_standard_system() if not tosolve: return result py2c_product_solve_linear_product_system() sols = load_standard_solutions() return (result, sols)
def standard_littlewood_richardson_homotopies(ndim, kdim, brackets, \ verbose=True, vrfcnd=False, outputfilename='/tmp/output'): """ In n-dimensional space we consider k-dimensional planes, subject to intersection conditions represented by brackets. The parameters ndim and kdim give values for n and k respectively. The parameter brackets is a list of brackets. A bracket is a list of as many natural numbers (in the range 1..ndim) as kdim. The Littlewood-Richardson homotopies compute k-planes that meet the flags at spaces of dimensions prescribed by the brackets, in standard double precision. On return is a 4-tuple. The first item of the tuple is the formal root count, sharp for general flags, then as second item the coordinates of the flags. The coordinates of the flags are stored row wise in a list of real and imaginary parts. The third and fourth item of the tuple on return are respectively the polynomial system that has been solved and its solutions. The length of the list of solution should match the root count. """ from phcpy.phcpy2c2 import py2c_solcon_clear_standard_solutions from phcpy.phcpy2c2 \ import py2c_schubert_standard_littlewood_richardson_homotopies \ as stlrhom from phcpy.interface import load_standard_solutions, load_standard_system py2c_solcon_clear_standard_solutions() nbc = len(brackets) cds = '' for bracket in brackets: for num in bracket: cds = cds + ' ' + str(num) # print 'the condition string :', cds (roco, sflags) = stlrhom(ndim, kdim, nbc, len(cds), cds, int(verbose), \ int(vrfcnd), len(outputfilename), outputfilename) rflags = eval(sflags) flgs = [] for k in range(len(rflags) / 2): flgs.append(complex(rflags[2 * k], rflags[2 * k + 1])) fsys = load_standard_system() sols = load_standard_solutions() return (roco, flgs, fsys, sols)
def standard_littlewood_richardson_homotopies(ndim, kdim, brackets, \ verbose=True, vrfcnd=False, outputfilename='/tmp/output'): """ In n-dimensional space we consider k-dimensional planes, subject to intersection conditions represented by brackets. The parameters ndim and kdim give values for n and k respectively. The parameter brackets is a list of brackets. A bracket is a list of as many natural numbers (in the range 1..ndim) as kdim. The Littlewood-Richardson homotopies compute k-planes that meet the flags at spaces of dimensions prescribed by the brackets, in standard double precision. On return is a 4-tuple. The first item of the tuple is the formal root count, sharp for general flags, then as second item the coordinates of the flags. The coordinates of the flags are stored row wise in a list of real and imaginary parts. The third and fourth item of the tuple on return are respectively the polynomial system that has been solved and its solutions. The length of the list of solution should match the root count. """ from phcpy.phcpy2c3 import py2c_solcon_clear_standard_solutions from phcpy.phcpy2c3 \ import py2c_schubert_standard_littlewood_richardson_homotopies \ as stlrhom from phcpy.interface import load_standard_solutions, load_standard_system py2c_solcon_clear_standard_solutions() nbc = len(brackets) cds = '' for bracket in brackets: for num in bracket: cds = cds + ' ' + str(num) # print 'the condition string :', cds (roco, sflags) = stlrhom(ndim, kdim, nbc, len(cds), cds, int(verbose), \ int(vrfcnd), len(outputfilename), outputfilename) rflags = eval(sflags) flgs = [] for k in range(len(rflags)/2): flgs.append(complex(rflags[2*k], rflags[2*k+1])) fsys = load_standard_system() sols = load_standard_solutions() return (roco, flgs, fsys, sols)
def m_homogeneous_start_system(pols, partition): """ For an m-homogeneous Bezout number of a polynomial system defined by a partition of the set of unknowns, one can define a linear-product system that has exactly as many regular solutions as the Bezount number. This linear-product system can then be used as start system in a homotopy to compute all isolated solutions of any polynomial system with the same m-homogeneous structure. This function returns a linear-product start system with random coefficients and its solutions for the given polynomials in pols and the partition. """ from phcpy.phcpy2c3 import py2c_product_m_homogeneous_start_system from phcpy.phcpy2c3 import py2c_product_solve_linear_product_system from phcpy.interface import store_standard_system, load_standard_system from phcpy.interface import load_standard_solutions store_standard_system(pols) py2c_product_m_homogeneous_start_system(len(partition), partition) result = load_standard_system() py2c_product_solve_linear_product_system() sols = load_standard_solutions() return (result, sols)
def standard_random_coefficient_system(silent=False): """ Runs the polyhedral homotopies and returns a random coefficient system based on the contents of the cell container, in standard double precision arithmetic. For this to work, the mixed_volume function must be called first. """ from phcpy.phcpy2c3 import py2c_celcon_standard_random_coefficient_system from phcpy.phcpy2c3 import py2c_celcon_copy_into_standard_systems_container from phcpy.phcpy2c3 import py2c_celcon_standard_polyhedral_homotopy from phcpy.phcpy2c3 import py2c_celcon_number_of_cells from phcpy.phcpy2c3 import py2c_solcon_clear_standard_solutions from phcpy.phcpy2c3 import py2c_celcon_solve_standard_start_system from phcpy.phcpy2c3 import py2c_celcon_track_standard_solution_path from phcpy.phcpy2c3 \ import py2c_celcon_copy_target_standard_solution_to_container py2c_celcon_standard_random_coefficient_system() py2c_celcon_copy_into_standard_systems_container() from phcpy.interface import load_standard_system, load_standard_solutions # py2c_syscon_write_system() result = load_standard_system() # print result py2c_celcon_standard_polyhedral_homotopy() nbcells = py2c_celcon_number_of_cells() py2c_solcon_clear_standard_solutions() for cell in range(1, nbcells + 1): mixvol = py2c_celcon_solve_standard_start_system(cell) if not silent: print('system %d has %d solutions' % (cell, mixvol)) for j in range(1, mixvol + 1): if not silent: print('-> tracking path %d out of %d' % (j, mixvol)) py2c_celcon_track_standard_solution_path(cell, j, 0) py2c_celcon_copy_target_standard_solution_to_container(cell, j) sols = load_standard_solutions() # print sols # newton_step(result, sols) return (result, sols)
def standard_random_coefficient_system(silent=False): """ Runs the polyhedral homotopies and returns a random coefficient system based on the contents of the cell container, in standard double precision arithmetic. For this to work, the mixed_volume function must be called first. """ from phcpy.phcpy2c3 import py2c_celcon_standard_random_coefficient_system from phcpy.phcpy2c3 import py2c_celcon_copy_into_standard_systems_container from phcpy.phcpy2c3 import py2c_celcon_standard_polyhedral_homotopy from phcpy.phcpy2c3 import py2c_celcon_number_of_cells from phcpy.phcpy2c3 import py2c_solcon_clear_standard_solutions from phcpy.phcpy2c3 import py2c_celcon_solve_standard_start_system from phcpy.phcpy2c3 import py2c_celcon_track_standard_solution_path from phcpy.phcpy2c3 \ import py2c_celcon_copy_target_standard_solution_to_container py2c_celcon_standard_random_coefficient_system() py2c_celcon_copy_into_standard_systems_container() from phcpy.interface import load_standard_system, load_standard_solutions # py2c_syscon_write_system() result = load_standard_system() # print result py2c_celcon_standard_polyhedral_homotopy() nbcells = py2c_celcon_number_of_cells() py2c_solcon_clear_standard_solutions() for cell in range(1, nbcells+1): mixvol = py2c_celcon_solve_standard_start_system(cell) if not silent: print('system %d has %d solutions' % (cell, mixvol)) for j in range(1, mixvol+1): if not silent: print('-> tracking path %d out of %d' % (j, mixvol)) py2c_celcon_track_standard_solution_path(cell, j, 0) py2c_celcon_copy_target_standard_solution_to_container(cell, j) sols = load_standard_solutions() # print sols # newton_step(result, sols) return (result, sols)
def standard_polysys_solve(pols, topdim=-1, \ filter=True, factor=True, tasks=0, verbose=True): """ Runs the cascades of homotopies on the polynomial system in pols in standard double precision. The default top dimension topdim is the number of variables in pols minus one. """ from phcpy.phcpy2c3 import py2c_standard_polysys_solve from phcpy.phcpy2c3 import py2c_copy_standard_polysys_witset from phcpy.solver import number_of_symbols from phcpy.interface import store_standard_system from phcpy.interface import load_standard_system, load_standard_solutions dim = number_of_symbols(pols) if (topdim == -1): topdim = dim - 1 fail = store_standard_system(pols, nbvar=dim) fail = py2c_standard_polysys_solve(tasks,topdim, \ int(filter),int(factor),int(verbose)) witsols = [] for soldim in range(0, topdim + 1): fail = py2c_copy_standard_polysys_witset(soldim) witset = (load_standard_system(), load_standard_solutions()) witsols.append(witset) return witsols
def standard_polysys_solve(pols, topdim=-1, \ filter=True, factor=True, tasks=0, verbose=True): """ Runs the cascades of homotopies on the polynomial system in pols in standard double precision. The default top dimension topdim is the number of variables in pols minus one. """ from phcpy.phcpy2c3 import py2c_standard_polysys_solve from phcpy.phcpy2c3 import py2c_copy_standard_polysys_witset from phcpy.solver import number_of_symbols from phcpy.interface import store_standard_system from phcpy.interface import load_standard_system, load_standard_solutions dim = number_of_symbols(pols) if(topdim == -1): topdim = dim - 1 fail = store_standard_system(pols, nbvar=dim) fail = py2c_standard_polysys_solve(tasks,topdim, \ int(filter),int(factor),int(verbose)) witsols = [] for soldim in range(0, topdim+1): fail = py2c_copy_standard_polysys_witset(soldim) witset = (load_standard_system(), load_standard_solutions()) witsols.append(witset) return witsols
def standard_newton_power_series(pols, lser, idx=1, maxdeg=4, nbr=4, \ checkin=True, verbose=True): r""" Computes series in standard double precision for the polynomials in *pols*, where the leading terms are given in the list *lser*. On entry are the following five parameters: *pols*: a list of string representations of polynomials, *lser*: a list of polynomials in the series parameter (e.g.: t), for use as start terms in Newton's method, *idx*: index of the series parameter, by default equals 1, *maxdeg*: maximal degree of the power series, *nbr*: number of steps with Newton's method, *checkin*: checks whether the number of symbols in pols matches the length of the list lser if idx == 0, or is one less than the length of the list lser if idx != 0. If the conditions are not satisfied, then an error message is printed and lser is returned. *verbose*: whether to write intermediate output to screen or not. On return is a list of lists of strings. Each lists of strings represents the series solution for the variables in the list *pols*. """ from phcpy.solver import number_of_symbols from phcpy.interface import store_standard_system, load_standard_system from phcpy.phcpy2c2 import py2c_standard_Newton_power_series as newton from phcpy.phcpy2c2 import py2c_syspool_standard_init from phcpy.phcpy2c2 import py2c_syspool_standard_create from phcpy.phcpy2c2 import py2c_syspool_standard_size as poolsize from phcpy.phcpy2c2 import py2c_syspool_copy_to_standard_container from phcpy.phcpy2c2 import py2c_syspool_standard_clear nbsym = number_of_symbols(pols) if verbose: print "the polynomials :" for pol in pols: print pol print "Number of variables :", nbsym if checkin: if not checkin_newton_power_series(nbsym, lser, idx): return lser store_standard_system(lser, nbvar=1) py2c_syspool_standard_init(1); py2c_syspool_standard_create(1); store_standard_system(pols, nbvar=nbsym) fail = newton(idx, maxdeg, nbr, int(verbose)) size = (-1 if fail else poolsize()) if verbose: if size == -1: print "An error occurred in the execution of Newton's method." else: print "Computed one series solution." py2c_syspool_copy_to_standard_container(1) result = load_standard_system() result = substitute_symbol(result, idx) py2c_syspool_standard_clear() return result