Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Given in embsys an embedded polynomial system and
solutions with nonzero slace variables in esols,
does one step in the homotopy cascade,
with quad double precision arithmetic.
The list on return contains witness points on
lower dimensional solution components.
"""
from phcpy2c import py2c_copy_quaddobl_container_to_start_system
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()
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 phcpy2c import py2c_copy_quaddobl_container_to_target_system
from phcpy2c import py2c_copy_quaddobl_container_to_start_system
from phcpy2c import py2c_copy_quaddobl_container_to_start_solutions
from phcpy2c import py2c_create_quaddobl_homotopy
from phcpy2c import py2c_create_quaddobl_homotopy_with_gamma
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(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()
def initialize_quaddobl_tracker(target, start, fixedgamma=True):
"""
Initializes a path tracker with a generator for a target
and start system given in quad double precision.
If fixedgamma, then gamma will be a fixed default value,
otherwise, a random complex constant for gamma is generated.
"""
from phcpy2c import py2c_copy_quaddobl_container_to_target_system
from phcpy2c import py2c_copy_quaddobl_container_to_start_system
from phcpy2c import py2c_initialize_quaddobl_homotopy
from interface import store_quaddobl_system
store_quaddobl_system(target)
py2c_copy_quaddobl_container_to_target_system()
store_quaddobl_system(start)
py2c_copy_quaddobl_container_to_start_system()
if fixedgamma:
return py2c_initialize_quaddobl_homotopy(1)
else:
return py2c_initialize_quaddobl_homotopy(0)
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
On return are the string representations of the solutions
computed at the end of the paths.
"""
from phcpy2c import py2c_copy_quaddobl_container_to_target_system
from phcpy2c import py2c_copy_quaddobl_container_to_start_system
from phcpy2c import py2c_copy_quaddobl_container_to_start_solutions
from phcpy2c import py2c_create_quaddobl_homotopy
from phcpy2c import py2c_create_quaddobl_homotopy_with_gamma
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(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()
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)