Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()
elif(precision == 'mp'):
from interface import store_multprec_system
from interface import store_multprec_solutions, load_multprec_solutions
store_multprec_system(system, decimals)
store_multprec_solutions(len(system), solutions)
from phcpy2c import py2c_multprec_Newton_step
py2c_multprec_Newton_step(decimals)
result = load_multprec_solutions()
else:
print 'wrong argument for precision'
return None
for sol in result:
strsol = sol.split('\n')
print strsol[-1]
return result
elif(precision == 'dd'):
from interface import store_dobldobl_laurent_system
from interface import store_dobldobl_solutions, load_dobldobl_solutions
store_dobldobl_laurent_system(system)
store_dobldobl_solutions(len(system), solutions)
from phcpy2c import py2c_dobldobl_Newton_Laurent_step
py2c_dobldobl_Newton_Laurent_step()
result = load_dobldobl_solutions()
elif(precision == 'qd'):
from interface import store_quaddobl_laurent_system
from interface import store_quaddobl_solutions, load_quaddobl_solutions
store_quaddobl_laurent_system(system)
store_quaddobl_solutions(len(system), solutions)
from phcpy2c import py2c_quaddobl_Newton_Laurent_step
py2c_quaddobl_Newton_Laurent_step()
result = load_quaddobl_solutions()
elif(precision == 'mp'):
from interface import store_multprec_laurent_system
from interface import store_multprec_solutions, load_multprec_solutions
store_multprec_laurent_system(system, decimals)
store_multprec_solutions(len(system), solutions)
from phcpy2c import py2c_multprec_Newton_Laurent_step
py2c_multprec_Newton_Laurent_step(decimals)
result = load_multprec_solutions()
else:
print 'wrong argument for precision'
return None
for sol in result:
strsol = sol.split('\n')
print strsol[-1]
return result
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()
elif(precision == 'mp'):
from interface import store_multprec_system
from interface import store_multprec_solutions, load_multprec_solutions
store_multprec_system(system, decimals)
store_multprec_solutions(len(system), solutions)
from phcpy2c import py2c_multprec_Newton_step
py2c_multprec_Newton_step(decimals)
result = load_multprec_solutions()
else:
print 'wrong argument for precision'
return None
for sol in result:
strsol = sol.split('\n')
print strsol[-1]
return result
def quaddobl_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 quad double precision.
After application of deflation with default settings,
the new approximate solutions are returned.
"""
from phcpy2c import py2c_quaddobl_deflate
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)
py2c_quaddobl_deflate()
result = load_quaddobl_solutions()
return result
def quaddobl_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 quad double precision.
After application of deflation with default settings,
the new approximate solutions are returned.
"""
from phcpy2c import py2c_quaddobl_deflate
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)
py2c_quaddobl_deflate()
result = load_quaddobl_solutions()
return result
def quaddobl_usolve(pol, mxi, eps):
"""
Applies the method of Durand-Kerner (aka Weierstrass)
to the polynomial in the string pol, in quad double precision
The maximum number of iterations is in mxi,
the requirement on the accuracy in eps.
"""
from phcpy2c import py2c_usolve_quaddobl
from interface import store_quaddobl_system, load_quaddobl_solutions
store_quaddobl_system([pol])
nit = py2c_usolve_quaddobl(mxi, eps)
rts = load_quaddobl_solutions()
return (nit, rts)
from phcpy2c import py2c_copy_quaddobl_container_to_start_solutions
from phcpy2c import py2c_quaddobl_cascade_homotopy
from phcpy2c import py2c_solve_by_quaddobl_homotopy_continuation
from phcpy2c import py2c_solcon_clear_quaddobl_solutions
from phcpy2c import py2c_copy_quaddobl_target_solutions_to_container
from interface import store_quaddobl_system
from interface import store_quaddobl_solutions, load_quaddobl_solutions
store_quaddobl_system(embsys)
py2c_copy_quaddobl_container_to_start_system()
store_quaddobl_solutions(len(embsys), esols)
py2c_copy_quaddobl_container_to_start_solutions()
py2c_quaddobl_cascade_homotopy()
py2c_solve_by_quaddobl_homotopy_continuation()
py2c_solcon_clear_quaddobl_solutions()
py2c_copy_quaddobl_target_solutions_to_container()
return load_quaddobl_solutions()
# py2c_syscon_write_dobldobl_system()
result = load_quaddobl_system()
# print result
py2c_celcon_quaddobl_polyhedral_homotopy()
nbcells = py2c_celcon_number_of_cells()
py2c_solcon_clear_quaddobl_solutions()
for cell in range(1, nbcells+1):
mixvol = py2c_celcon_solve_quaddobl_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_quaddobl_solution_path(cell, j, 0)
py2c_celcon_copy_target_quaddobl_solution_to_container(cell, j)
sols = load_quaddobl_solutions()
# print sols
# newton_step(result, sols)
return (result, sols)
store_quaddobl_system(target)
py2c_copy_quaddobl_container_to_target_system()
store_quaddobl_system(start)
py2c_copy_quaddobl_container_to_start_system()
# py2c_clear_quaddobl_homotopy()
if(gamma == 0):
py2c_create_quaddobl_homotopy()
else:
py2c_create_quaddobl_homotopy_with_gamma(gamma.real, gamma.imag)
dim = len(start)
store_quaddobl_solutions(dim, sols)
py2c_copy_quaddobl_container_to_start_solutions()
py2c_solve_by_quaddobl_homotopy_continuation(tasks)
py2c_solcon_clear_quaddobl_solutions()
py2c_copy_quaddobl_target_solutions_to_container()
return load_quaddobl_solutions()