def newton_laurent_step(system, solutions, precision='d', decimals=100): """ Applies one Newton step to the solutions of the Laurent system. 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_laurent_system from interface import store_standard_solutions, load_standard_solutions store_standard_laurent_system(system) store_standard_solutions(len(system), solutions) from phcpy.phcpy2c2 import py2c_standard_Newton_Laurent_step py2c_standard_Newton_Laurent_step() result = load_standard_solutions() 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 phcpy.phcpy2c2 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 phcpy.phcpy2c2 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 phcpy.phcpy2c2 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
def quaddobl_scale_solutions(nvar, sols, cffs): """ Scales the solutions in the list sols using the coefficients in cffs, using quad 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 quaddobl_scale_system(pols), then the solutions on return will be solutions of the original polynomials in the list pols. """ from phcpy.interface import store_quaddobl_solutions from phcpy.interface import load_quaddobl_solutions from phcpy.phcpy2c2 import py2c_scale_quaddobl_solutions store_quaddobl_solutions(nvar, sols) py2c_scale_quaddobl_solutions(len(cffs), str(cffs)) 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 phcpy.phcpy2c2 import py2c_quaddobl_deflate from phcpy.interface import store_quaddobl_system from phcpy.interface import store_quaddobl_solutions from phcpy.interface import load_quaddobl_solutions store_quaddobl_system(system) store_quaddobl_solutions(len(system), solutions) py2c_quaddobl_deflate() result = load_quaddobl_solutions() return result