Example #1
0
def dobldobl_pade_approximants(pols, sols, idx=1, numdeg=2, dendeg=2, \
    nbr=4, verbose=True):
    r"""
    Computes Pade approximants based on the series in double double 
    precision for the polynomials in *pols*, where the leading 
    coefficients of the series are the solutions in *sols*.
    On entry are the following seven parameters:

    *pols*: a list of string representations of polynomials,

    *sols*: a list of solutions of the polynomials in *pols*,

    *idx*: index of the series parameter, by default equals 1,

    *numdeg*: the degree of the numerator,

    *dendeg*: the degree of the denominator,

    *nbr*: number of steps with Newton's method,

    *verbose*: whether to write intermediate output to screen or not.

    On return is a list of lists of strings.  Each lists of strings
    represents the series solution for the variables in the list *pols*.
    """
    from phcpy.solver import number_of_symbols
    from phcpy.interface import store_dobldobl_solutions
    from phcpy.interface import store_dobldobl_system, load_dobldobl_system
    from phcpy.phcpy2c2 \
        import py2c_dobldobl_Pade_approximant as Pade_approximants
    from phcpy.phcpy2c2 import py2c_syspool_dobldobl_size as poolsize
    from phcpy.phcpy2c2 import py2c_syspool_copy_to_dobldobl_container
    from phcpy.phcpy2c2 import py2c_syspool_dobldobl_clear
    nbsym = number_of_symbols(pols)
    if verbose:
        print "the polynomials :"
        for pol in pols:
            print pol
        print "Number of variables :", nbsym
    store_dobldobl_system(pols, nbvar=nbsym)
    store_dobldobl_solutions(nbsym, sols)
    fail = Pade_approximants(idx, numdeg, dendeg, nbr, int(verbose))
    size = (-1 if fail else poolsize())
    if verbose:
        if size == -1:
            print "An error occurred in the Pade constructor."
        else:
            print "Computed %d Pade approximants." % size
    result = []
    for k in range(1, size+1):
        py2c_syspool_copy_to_dobldobl_container(k)
        sersol = load_dobldobl_system()
        substsersol = substitute_symbol(sersol, idx)
        result.append(make_fractions(substsersol))
    py2c_syspool_dobldobl_clear()
    return result
Example #2
0
def dobldobl_newton_series(pols, sols, idx=1, maxdeg=4, nbr=4, verbose=True):
    r"""
    Computes series in double double precision for the polynomials
    in *pols*, where the leading coefficients are the solutions in *sols*.
    On entry are the following five parameters:

    *pols*: a list of string representations of polynomials,

    *sols*: a list of solutions of the polynomials in *pols*,

    *idx*: index of the series parameter, by default equals 1,

    *maxdeg*: maximal degree of the series,

    *nbr*: number of steps with Newton's method,

    *verbose*: whether to write intermediate output to screen or not.

    On return is a list of lists of strings.  Each lists of strings
    represents the series solution for the variables in the list *pols*.
    """
    from phcpy.solver import number_of_symbols
    from phcpy.interface import store_dobldobl_solutions
    from phcpy.interface import store_dobldobl_system, load_dobldobl_system
    from phcpy.phcpy2c2 import py2c_dobldobl_Newton_series as newton
    from phcpy.phcpy2c2 import py2c_syspool_dobldobl_size as poolsize
    from phcpy.phcpy2c2 import py2c_syspool_copy_to_dobldobl_container
    from phcpy.phcpy2c2 import py2c_syspool_dobldobl_clear
    nbsym = number_of_symbols(pols)
    if verbose:
        print "the polynomials :"
        for pol in pols:
            print pol
        print "Number of variables :", nbsym
    store_dobldobl_system(pols, nbvar=nbsym)
    store_dobldobl_solutions(nbsym, sols)
    fail = newton(idx, maxdeg, nbr, int(verbose))
    size = (-1 if fail else poolsize())
    if verbose:
        if size == -1:
            print "An error occurred in the execution of Newton's method."
        else:
            print "Computed %d series solutions." % size
    result = []
    for k in range(1, size+1):
        py2c_syspool_copy_to_dobldobl_container(k)
        sersol = load_dobldobl_system()
        result.append(substitute_symbol(sersol, idx))
    py2c_syspool_dobldobl_clear()
    return result
Example #3
0
def dobldobl_newton_power_series(pols, lser, idx=1, nbr=4, verbose=True):
    r"""
    Computes series in double double precision for the polynomials
    in *pols*, where the leading terms are given in the list *lser*.
    On entry are the following five parameters:

    *pols*: a list of string representations of polynomials,

    *lser*: a list of polynomials in the series parameter (e.g.: t),
    for use as start terms in Newton's method,

    *idx*: index of the series parameter, by default equals 1,

    *nbr*: number of steps with Newton's method,

    *verbose*: whether to write intermediate output to screen or not.

    On return is a list of lists of strings.  Each lists of strings
    represents the series solution for the variables in the list *pols*.
    """
    from phcpy.solver import number_of_symbols
    from phcpy.interface import store_dobldobl_system, load_dobldobl_system
    from phcpy.phcpy2c2 import py2c_dobldobl_Newton_power_series as newton
    from phcpy.phcpy2c2 import py2c_syspool_dobldobl_init
    from phcpy.phcpy2c2 import py2c_syspool_dobldobl_create
    from phcpy.phcpy2c2 import py2c_syspool_dobldobl_size as poolsize
    from phcpy.phcpy2c2 import py2c_syspool_copy_to_dobldobl_container
    from phcpy.phcpy2c2 import py2c_syspool_dobldobl_clear
    nbsym = number_of_symbols(pols)
    if verbose:
        print "the polynomials :"
        for pol in pols:
            print pol
        print "Number of variables :", nbsym
    store_dobldobl_system(lser, nbvar=1)
    py2c_syspool_dobldobl_init(1);
    py2c_syspool_dobldobl_create(1);
    store_dobldobl_system(pols, nbvar=nbsym)
    fail = newton(idx, nbr, int(verbose))
    size = (-1 if fail else poolsize())
    if verbose:
        if size == -1:
            print "An error occurred in the execution of Newton's method."
        else:
            print "Computed one series solution."
    py2c_syspool_copy_to_dobldobl_container(1)
    result = load_dobldobl_system()
    result = substitute_symbol(result, idx)
    py2c_syspool_dobldobl_clear()
    return result
Example #4
0
def dobldobl_newton_power_series(pols, lser, idx=1, nbr=4, verbose=True):
    r"""
    Computes series in double double precision for the polynomials
    in *pols*, where the leading terms are given in the list *lser*.
    On entry are the following five parameters:

    *pols*: a list of string representations of polynomials,

    *lser*: a list of polynomials in the series parameter (e.g.: t),
    for use as start terms in Newton's method,

    *idx*: index of the series parameter, by default equals 1,

    *nbr*: number of steps with Newton's method,

    *verbose*: whether to write intermediate output to screen or not.

    On return is a list of lists of strings.  Each lists of strings
    represents the series solution for the variables in the list *pols*.
    """
    from phcpy.solver import number_of_symbols
    from phcpy.interface import store_dobldobl_system, load_dobldobl_system
    from phcpy.phcpy2c2 import py2c_dobldobl_Newton_power_series as newton
    from phcpy.phcpy2c2 import py2c_syspool_dobldobl_init
    from phcpy.phcpy2c2 import py2c_syspool_dobldobl_create
    from phcpy.phcpy2c2 import py2c_syspool_dobldobl_size as poolsize
    from phcpy.phcpy2c2 import py2c_syspool_copy_to_dobldobl_container
    from phcpy.phcpy2c2 import py2c_syspool_dobldobl_clear
    nbsym = number_of_symbols(pols)
    if verbose:
        print "the polynomials :"
        for pol in pols:
            print pol
        print "Number of variables :", nbsym
    store_dobldobl_system(lser, nbvar=1)
    py2c_syspool_dobldobl_init(1)
    py2c_syspool_dobldobl_create(1)
    store_dobldobl_system(pols, nbvar=nbsym)
    fail = newton(idx, nbr, int(verbose))
    size = (-1 if fail else poolsize())
    if verbose:
        if size == -1:
            print "An error occurred in the execution of Newton's method."
        else:
            print "Computed one series solution."
    py2c_syspool_copy_to_dobldobl_container(1)
    result = load_dobldobl_system()
    result = substitute_symbol(result, idx)
    py2c_syspool_dobldobl_clear()
    return result
Example #5
0
def dobldobl_newton_series(pols, sols, idx=1, nbr=4, verbose=True):
    r"""
    Computes series in double double precision for the polynomials
    in *pols*, where the leading coefficients are the solutions in *sols*.
    On entry are the following five parameters:

    *pols*: a list of string representations of polynomials,

    *sols*: a list of solutions of the polynomials in *pols*,

    *idx*: index of the series parameter, by default equals 1,

    *nbr*: number of steps with Newton's method,

    *verbose*: whether to write intermediate output to screen or not.

    On return is a list of lists of strings.  Each lists of strings
    represents the series solution for the variables in the list *pols*.
    """
    from phcpy.solver import number_of_symbols
    from phcpy.interface import store_dobldobl_solutions
    from phcpy.interface import store_dobldobl_system, load_dobldobl_system
    from phcpy.phcpy2c2 import py2c_dobldobl_Newton_series as newton
    from phcpy.phcpy2c2 import py2c_syspool_dobldobl_size as poolsize
    from phcpy.phcpy2c2 import py2c_syspool_copy_to_dobldobl_container
    from phcpy.phcpy2c2 import py2c_syspool_dobldobl_clear
    nbsym = number_of_symbols(pols)
    if verbose:
        print "the polynomials :"
        for pol in pols:
            print pol
        print "Number of variables :", nbsym
    store_dobldobl_system(pols, nbvar=nbsym)
    store_dobldobl_solutions(nbsym, sols)
    fail = newton(idx, nbr, int(verbose))
    size = (-1 if fail else poolsize())
    if verbose:
        if size == -1:
            print "An error occurred in the execution of Newton's method."
        else:
            print "Computed %d series solutions." % size
    result = []
    for k in range(1, size+1):
        py2c_syspool_copy_to_dobldobl_container(k)
        sersol = load_dobldobl_system()
        result.append(substitute_symbol(sersol, idx))
    py2c_syspool_dobldobl_clear()
    return result