Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# 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_deflate(system, solutions):
"""
The deflation method augments the given system with
derivatives to restore the quadratic convergence of
Newton's method at isolated singular solutions,
in standard double precision.
After application of deflation with default settings,
the new approximate solutions are returned.
"""
from phcpy2c import py2c_standard_deflate
from interface import store_standard_system
from interface import store_standard_solutions, load_standard_solutions
store_standard_system(system)
store_standard_solutions(len(system), solutions)
py2c_standard_deflate()
result = load_standard_solutions()
return result
For each solution, prints its last line of diagnostics.
Four levels of precision are supported:
d : standard double precision (1.1e-15 or 2^(-53)),
dd : double double precision (4.9e-32 or 2^(-104)),
qd : quad double precision (1.2e-63 or 2^(-209)).
mp : arbitrary precision, where the number of decimal places
in the working precision is determined by decimals.
"""
if(precision == 'd'):
from interface import store_standard_system
from interface import store_standard_solutions, load_standard_solutions
store_standard_system(system)
store_standard_solutions(len(system), solutions)
from phcpy2c import py2c_standard_Newton_step
py2c_standard_Newton_step()
result = load_standard_solutions()
elif(precision == 'dd'):
from interface import store_dobldobl_system
from interface import store_dobldobl_solutions, load_dobldobl_solutions
store_dobldobl_system(system)
store_dobldobl_solutions(len(system), solutions)
from phcpy2c import py2c_dobldobl_Newton_step
py2c_dobldobl_Newton_step()
result = load_dobldobl_solutions()
elif(precision == 'qd'):
from interface import store_quaddobl_system
from interface import store_quaddobl_solutions, load_quaddobl_solutions
store_quaddobl_system(system)
store_quaddobl_solutions(len(system), solutions)
from phcpy2c import py2c_quaddobl_Newton_step
py2c_quaddobl_Newton_step()
result = load_quaddobl_solutions()
returns a random linear-product system based on a supporting
set structure and its solutions as well (if tosolve).
"""
from phcpy2c import py2c_product_supporting_set_structure
from phcpy2c import py2c_product_random_linear_product_system
from phcpy2c import py2c_product_solve_linear_product_system
from interface import store_standard_system, load_standard_system
from 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)
from 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) = lrhom(ndim, kdim, nbc, len(cds), cds, int(verbose), \
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)
from phcpy2c import py2c_syscon_clear_standard_Laurent_system
from phcpy2c import py2c_syscon_initialize_number_of_standard_Laurentials
from phcpy2c import py2c_syscon_store_standard_Laurential
from phcpy2c import py2c_solcon_clear_standard_solutions
from phcpy2c import py2c_solve_Laurent_system
from interface import load_standard_solutions
py2c_syscon_clear_standard_Laurent_system()
py2c_solcon_clear_standard_solutions()
dim = len(pols)
py2c_syscon_initialize_number_of_standard_Laurentials(dim)
for ind in range(0, dim):
pol = pols[ind]
nchar = len(pol)
py2c_syscon_store_standard_Laurential(nchar, dim, ind+1, pol)
py2c_solve_Laurent_system(silent, tasks)
return load_standard_solutions()
def standard_deflate(system, solutions):
"""
The deflation method augments the given system with
derivatives to restore the quadratic convergence of
Newton's method at isolated singular solutions,
in standard double precision.
After application of deflation with default settings,
the new approximate solutions are returned.
"""
from phcpy2c import py2c_standard_deflate
from interface import store_standard_system
from interface import store_standard_solutions, load_standard_solutions
store_standard_system(system)
store_standard_solutions(len(system), solutions)
py2c_standard_deflate()
result = load_standard_solutions()
return result
def standard_usolve(pol, mxi, eps):
"""
Applies the method of Durand-Kerner (aka Weierstrass)
to the polynomial in the string pol, in standard double precision
The maximum number of iterations is in mxi,
the requirement on the accuracy in eps.
"""
from phcpy2c import py2c_usolve_standard
from interface import store_standard_system, load_standard_solutions
store_standard_system([pol])
nit = py2c_usolve_standard(mxi, eps)
rts = load_standard_solutions()
return (nit, rts)
For each solution, prints its last line of diagnostics.
Four levels of precision are supported:
d : standard double precision (1.1e-15 or 2^(-53)),
dd : double double precision (4.9e-32 or 2^(-104)),
qd : quad double precision (1.2e-63 or 2^(-209)).
mp : arbitrary precision, where the number of decimal places
in the working precision is determined by decimals.
"""
if(precision == 'd'):
from interface import store_standard_system
from interface import store_standard_solutions, load_standard_solutions
store_standard_system(system)
store_standard_solutions(len(system), solutions)
from phcpy2c import py2c_standard_Newton_step
py2c_standard_Newton_step()
result = load_standard_solutions()
elif(precision == 'dd'):
from interface import store_dobldobl_system
from interface import store_dobldobl_solutions, load_dobldobl_solutions
store_dobldobl_system(system)
store_dobldobl_solutions(len(system), solutions)
from phcpy2c import py2c_dobldobl_Newton_step
py2c_dobldobl_Newton_step()
result = load_dobldobl_solutions()
elif(precision == 'qd'):
from interface import store_quaddobl_system
from interface import store_quaddobl_solutions, load_quaddobl_solutions
store_quaddobl_system(system)
store_quaddobl_solutions(len(system), solutions)
from phcpy2c import py2c_quaddobl_Newton_step
py2c_quaddobl_Newton_step()
result = load_quaddobl_solutions()
def standard_scale_solutions(nvar, sols, cffs):
"""
Scales the solutions in the list sols using the coefficients in cffs,
using standard double precision arithmetic.
The number of variables is given in the parameter nvar.
If the sols are the solution of the polynomials in the output of
standard_scale_system(pols), then the solutions on return will be
solutions of the original polynomials in the list pols.
"""
from interface import store_standard_solutions, load_standard_solutions
from phcpy2c import py2c_scale_standard_solutions
store_standard_solutions(nvar, sols)
py2c_scale_standard_solutions(len(cffs), str(cffs))
return load_standard_solutions()