Example #1
0
def permute_dobldobl_system(pols):
    """
    Permutes the equations in the list of polynomials in pols
    with coefficients in double double precision,
    along the permutation used in the mixed volume computation.
    """
    from phcpy.phcpy2c2 import py2c_celcon_permute_dobldobl_system
    from phcpy.interface import store_dobldobl_system, load_dobldobl_system
    store_dobldobl_system(pols)
    py2c_celcon_permute_dobldobl_system()
    return load_dobldobl_system()
Example #2
0
def dobldobl_scale_system(pols):
    """
    Applies equation and variable scaling in double double precision
    to the polynomials in the list pols.
    On return is the list of scaled polynomials and the scaling coefficients.
    """
    from phcpy.interface import store_dobldobl_system, load_dobldobl_system
    from phcpy.phcpy2c2 import py2c_scale_dobldobl_system
    store_dobldobl_system(pols)
    cffs = py2c_scale_dobldobl_system(2)
    spol = load_dobldobl_system()
    return (spol, cffs)
Example #3
0
def dobldobl_usolve(pol, mxi, eps):
    """
    Applies the method of Durand-Kerner (aka Weierstrass)
    to the polynomial in the string pol, in double double precision
    The maximum number of iterations is in mxi,
    the requirement on the accuracy in eps.
    """
    from phcpy.phcpy2c2 import py2c_usolve_dobldobl
    from phcpy.interface import store_dobldobl_system, load_dobldobl_solutions
    store_dobldobl_system([pol])
    nit = py2c_usolve_dobldobl(mxi, eps)
    rts = load_dobldobl_solutions()
    return (nit, rts)
Example #4
0
def newton_step(system, solutions, precision='d', decimals=100):
    """
    Applies one Newton step to the solutions of the 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_system
        from interface import store_standard_solutions, load_standard_solutions
        store_standard_system(system)
        store_standard_solutions(len(system), solutions)
        from phcpy.phcpy2c2 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 phcpy.phcpy2c2 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 phcpy.phcpy2c2 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 phcpy.phcpy2c2 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
Example #5
0
def dobldobl_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 double double precision.
    After application of deflation with default settings,
    the new approximate solutions are returned.
    """
    from phcpy.phcpy2c2 import py2c_dobldobl_deflate
    from phcpy.interface import store_dobldobl_system
    from phcpy.interface import store_dobldobl_solutions
    from phcpy.interface import load_dobldobl_solutions
    store_dobldobl_system(system)
    store_dobldobl_solutions(len(system), solutions)
    py2c_dobldobl_deflate()
    result = load_dobldobl_solutions()
    return result