def monomial_map_strings(dim, ind, nbvar): r""" Returns the list of strings representing the components of the monomial map of dimension *dim*, with index *ind*, and where the number of variables equals *nbvar*. """ from phcpy.phcpy2c3 import py2c_mapcon_coefficients_of_map from phcpy.phcpy2c3 import py2c_mapcon_exponents_of_map from phcpy.phcpy2c3 import py2c_syscon_string_of_symbols sym = py2c_syscon_string_of_symbols() symvars = sym.split(' ') # py2c_mapcon_write_maps may have inserted t-varables thevars = symvars[-nbvar:] # print '-> the variables', symvars, thevars cff = py2c_mapcon_coefficients_of_map(dim, ind, nbvar) # print '-> coefficients of map', ind, ':', cff exp = py2c_mapcon_exponents_of_map(dim, ind, nbvar) # print '-> exponents of map', ind, ':', exp result = [] exp_ind = 0 for i in range(0, nbvar): str_var = thevars[i] if(cff[i] == 0): str_var = str_var + ' - 0' exp_ind = exp_ind + dim else: str_var = str_var + ' - ' + str(cff[i]) for j in range(0, dim): pwr = exp[exp_ind] if(pwr != 0): str_var = str_var + '*' + 't' + str(j+1) + '**' + str(pwr) exp_ind = exp_ind + 1 result.append(str_var) return result
def monomial_map_strings(dim, ind, nbvar): r""" Returns the list of strings representing the components of the monomial map of dimension *dim*, with index *ind*, and where the number of variables equals *nbvar*. """ from phcpy.phcpy2c3 import py2c_mapcon_coefficients_of_map from phcpy.phcpy2c3 import py2c_mapcon_exponents_of_map from phcpy.phcpy2c3 import py2c_syscon_string_of_symbols sym = py2c_syscon_string_of_symbols() symvars = sym.split(' ') # py2c_mapcon_write_maps may have inserted t-varables thevars = symvars[-nbvar:] # print '-> the variables', symvars, thevars cff = py2c_mapcon_coefficients_of_map(dim, ind, nbvar) # print '-> coefficients of map', ind, ':', cff exp = py2c_mapcon_exponents_of_map(dim, ind, nbvar) # print '-> exponents of map', ind, ':', exp result = [] exp_ind = 0 for i in range(0, nbvar): str_var = thevars[i] if (cff[i] == 0): str_var = str_var + ' - 0' exp_ind = exp_ind + dim else: str_var = str_var + ' - ' + str(cff[i]) for j in range(0, dim): pwr = exp[exp_ind] if (pwr != 0): str_var = str_var + '*' + 't' + str(j + 1) + '**' + str(pwr) exp_ind = exp_ind + 1 result.append(str_var) return result
def replace_symbol(pol, idx): """ In the polynomial pol, replaces the first symbol by the symbol at place idx. """ from phcpy.phcpy2c3 import py2c_syscon_string_of_symbols sbl = py2c_syscon_string_of_symbols() var = sbl.split(' ') result = pol.replace(var[0], var[idx - 1]) return result
def total_degree_start_system(pols): """ Returns the system and solutions of the total degree start system for the polynomials represented by the strings in the list pols. """ from phcpy.phcpy2c3 import py2c_syscon_number_of_standard_polynomials from phcpy.phcpy2c3 import py2c_syscon_string_of_symbols from phcpy.phcpy2c3 import py2c_syscon_degree_of_standard_polynomial from phcpy.interface import store_standard_system store_standard_system(pols) dim = py2c_syscon_number_of_standard_polynomials() svars = py2c_syscon_string_of_symbols() nvars = svars.split(' ') degrees = [py2c_syscon_degree_of_standard_polynomial(k+1) \ for k in range(dim)] result = [] for ind in range(dim): result.append(nvars[ind]+'^'+str(degrees[ind])+' - 1;') return (result, solve(result))
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.phcpy2c3 import py2c_copy_dobldobl_container_to_target_system from phcpy.phcpy2c3 import py2c_copy_dobldobl_container_to_target_solutions from phcpy.phcpy2c3 import py2c_copy_dobldobl_container_to_start_system from phcpy.phcpy2c3 import py2c_copy_dobldobl_container_to_start_solutions from phcpy.phcpy2c3 import py2c_dobldobl_diagonal_homotopy from phcpy.phcpy2c3 import py2c_syscon_number_of_symbols from phcpy.phcpy2c3 import py2c_syscon_string_of_symbols from phcpy.phcpy2c3 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 total_degree_start_system(pols): """ Returns the system and solutions of the total degree start system for the polynomials represented by the strings in the list pols. """ from phcpy.phcpy2c3 import py2c_syscon_number_of_standard_polynomials from phcpy.phcpy2c3 import py2c_syscon_string_of_symbols from phcpy.phcpy2c3 import py2c_syscon_degree_of_standard_polynomial from phcpy.interface import store_standard_system store_standard_system(pols) dim = py2c_syscon_number_of_standard_polynomials() svars = py2c_syscon_string_of_symbols() nvars = svars.split(' ') degrees = [py2c_syscon_degree_of_standard_polynomial(k+1) \ for k in range(dim)] result = [] for ind in range(dim): result.append(nvars[ind] + '^' + str(degrees[ind]) + ' - 1;') return (result, solve(result))