コード例 #1
0
def standard_pade_approximants(pols, sols, idx=1, numdeg=2, dendeg=2, \
    nbr=4, verbose=True):
    r"""
    Computes Pade approximants based on the series in standard 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_standard_solutions
    from phcpy.interface import store_standard_system, load_standard_system
    from phcpy.phcpy2c3 \
        import py2c_standard_Pade_approximant as Pade_approximants
    from phcpy.phcpy2c3 import py2c_syspool_standard_size as poolsize
    from phcpy.phcpy2c3 import py2c_syspool_copy_to_standard_container
    from phcpy.phcpy2c3 import py2c_syspool_standard_clear
    nbsym = number_of_symbols(pols)
    if verbose:
        print("the polynomials :")
        for pol in pols:
            print(pol)
        print("Number of variables :", nbsym)
    store_standard_system(pols, nbvar=nbsym)
    store_standard_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_standard_container(k)
        sersol = load_standard_system()
        substsersol = substitute_symbol(sersol, idx)
        result.append(make_fractions(substsersol))
    py2c_syspool_standard_clear()
    return result
コード例 #2
0
ファイル: solver.py プロジェクト: d-torrance/PHCpack
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.
    """
    dim = number_of_symbols(system)
    if (precision == 'd'):
        from phcpy.interface import store_standard_system
        from phcpy.interface import store_standard_solutions
        from phcpy.interface import load_standard_solutions
        store_standard_system(system, nbvar=dim)
        store_standard_solutions(dim, solutions)
        from phcpy.phcpy2c3 import py2c_standard_Newton_step
        py2c_standard_Newton_step()
        result = load_standard_solutions()
    elif (precision == 'dd'):
        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, nbvar=dim)
        store_dobldobl_solutions(dim, solutions)
        from phcpy.phcpy2c3 import py2c_dobldobl_Newton_step
        py2c_dobldobl_Newton_step()
        result = load_dobldobl_solutions()
    elif (precision == 'qd'):
        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, nbvar=dim)
        store_quaddobl_solutions(dim, solutions)
        from phcpy.phcpy2c3 import py2c_quaddobl_Newton_step
        py2c_quaddobl_Newton_step()
        result = load_quaddobl_solutions()
    elif (precision == 'mp'):
        from phcpy.interface import store_multprec_system
        from phcpy.interface import store_multprec_solutions
        from phcpy.interface import load_multprec_solutions
        store_multprec_system(system, decimals, nbvar=dim)
        store_multprec_solutions(dim, solutions)
        from phcpy.phcpy2c3 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
コード例 #3
0
ファイル: solver.py プロジェクト: callmetaste/PHCpack
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 phcpy.interface import store_standard_system
        from phcpy.interface import store_standard_solutions
        from phcpy.interface import load_standard_solutions
        store_standard_system(system)
        store_standard_solutions(len(system), solutions)
        from phcpy.phcpy2c3 import py2c_standard_Newton_step
        py2c_standard_Newton_step()
        result = load_standard_solutions()
    elif(precision == 'dd'):
        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)
        from phcpy.phcpy2c3 import py2c_dobldobl_Newton_step
        py2c_dobldobl_Newton_step()
        result = load_dobldobl_solutions()
    elif(precision == 'qd'):
        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)
        from phcpy.phcpy2c3 import py2c_quaddobl_Newton_step
        py2c_quaddobl_Newton_step()
        result = load_quaddobl_solutions()
    elif(precision == 'mp'):
        from phcpy.interface import store_multprec_system
        from phcpy.interface import store_multprec_solutions
        from phcpy.interface import load_multprec_solutions
        store_multprec_system(system, decimals)
        store_multprec_solutions(len(system), solutions)
        from phcpy.phcpy2c3 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
コード例 #4
0
ファイル: solver.py プロジェクト: callmetaste/PHCpack
def total_degree(pols):
    """
    Given in pols a list of string representations of polynomials,
    returns the product of the degrees of the polynomials,
    the so-called total degree which bounds the number of
    isolated solutions of the polynomial system.
    """
    from phcpy.phcpy2c3 import py2c_syscon_total_degree
    from phcpy.interface import store_standard_system
    store_standard_system(pols)
    return py2c_syscon_total_degree()
コード例 #5
0
ファイル: solver.py プロジェクト: callmetaste/PHCpack
def permute_standard_system(pols):
    """
    Permutes the equations in the list of polynomials in pols
    with coefficients in standard double precision,
    along the permutation used in the mixed volume computation.
    """
    from phcpy.phcpy2c3 import py2c_celcon_permute_standard_system
    from phcpy.interface import store_standard_system, load_standard_system
    store_standard_system(pols)
    py2c_celcon_permute_standard_system()
    return load_standard_system()
コード例 #6
0
ファイル: solver.py プロジェクト: d-torrance/PHCpack
def total_degree(pols):
    """
    Given in pols a list of string representations of polynomials,
    returns the product of the degrees of the polynomials,
    the so-called total degree which bounds the number of
    isolated solutions of the polynomial system.
    """
    from phcpy.phcpy2c3 import py2c_syscon_total_degree
    from phcpy.interface import store_standard_system
    store_standard_system(pols)
    return py2c_syscon_total_degree()
コード例 #7
0
ファイル: solver.py プロジェクト: d-torrance/PHCpack
def permute_standard_system(pols):
    """
    Permutes the equations in the list of polynomials in pols
    with coefficients in standard double precision,
    along the permutation used in the mixed volume computation.
    """
    from phcpy.phcpy2c3 import py2c_celcon_permute_standard_system
    from phcpy.interface import store_standard_system, load_standard_system
    store_standard_system(pols)
    py2c_celcon_permute_standard_system()
    return load_standard_system()
コード例 #8
0
ファイル: solver.py プロジェクト: d-torrance/PHCpack
def standard_scale_system(pols):
    """
    Applies equation and variable scaling in standard 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_standard_system, load_standard_system
    from phcpy.phcpy2c3 import py2c_scale_standard_system
    store_standard_system(pols)
    cffs = py2c_scale_standard_system(2)
    spol = load_standard_system()
    return (spol, cffs)
コード例 #9
0
ファイル: solver.py プロジェクト: callmetaste/PHCpack
def standard_scale_system(pols):
    """
    Applies equation and variable scaling in standard 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_standard_system, load_standard_system
    from phcpy.phcpy2c3 import py2c_scale_standard_system
    store_standard_system(pols)
    cffs = py2c_scale_standard_system(2)
    spol = load_standard_system()
    return (spol, cffs)
コード例 #10
0
ファイル: solver.py プロジェクト: d-torrance/PHCpack
def standard_usolve(pol, mxi, eps):
    """
    Applies the method of Durand-Kerner (aka Weierstrass)
    to the polynomial in the string pol, in standard double precision
    The maximum number of iterations is in mxi,
    the requirement on the accuracy in eps.
    """
    from phcpy.phcpy2c3 import py2c_usolve_standard
    from phcpy.interface import store_standard_system, load_standard_solutions
    store_standard_system([pol])
    nit = py2c_usolve_standard(mxi, eps)
    rts = load_standard_solutions()
    return (nit, rts)
コード例 #11
0
ファイル: solver.py プロジェクト: d-torrance/PHCpack
def m_partition_bezout_number(pols, partition):
    """
    There are as many m-homogeneous Bezout numbers as there are
    partitions of the set of unknowns of a polynomial system.
    Given in pols the string representations of a polynomial system
    in as many variables as equations, and a string representation of
    a partition of the set of unknowns, this function returns the
    m-homogeneous Bezout number corresponding to the given partition.
    """
    from phcpy.phcpy2c3 import py2c_product_m_partition_Bezout_number
    from phcpy.interface import store_standard_system
    store_standard_system(pols)
    return py2c_product_m_partition_Bezout_number(len(partition), partition)
コード例 #12
0
ファイル: solver.py プロジェクト: callmetaste/PHCpack
def m_partition_bezout_number(pols, partition):
    """
    There are as many m-homogeneous Bezout numbers as there are
    partitions of the set of unknowns of a polynomial system.
    Given in pols the string representations of a polynomial system
    in as many variables as equations, and a string representation of
    a partition of the set of unknowns, this function returns the
    m-homogeneous Bezout number corresponding to the given partition.
    """
    from phcpy.phcpy2c3 import py2c_product_m_partition_Bezout_number
    from phcpy.interface import store_standard_system
    store_standard_system(pols)
    return py2c_product_m_partition_Bezout_number(len(partition), partition)
コード例 #13
0
ファイル: solver.py プロジェクト: callmetaste/PHCpack
def standard_usolve(pol, mxi, eps):
    """
    Applies the method of Durand-Kerner (aka Weierstrass)
    to the polynomial in the string pol, in standard double precision
    The maximum number of iterations is in mxi,
    the requirement on the accuracy in eps.
    """
    from phcpy.phcpy2c3 import py2c_usolve_standard
    from phcpy.interface import store_standard_system, load_standard_solutions
    store_standard_system([pol])
    nit = py2c_usolve_standard(mxi, eps)
    rts = load_standard_solutions()
    return (nit, rts)
コード例 #14
0
ファイル: series.py プロジェクト: sommars/PHCpack
def standard_newton_power_series(pols, lser, idx=1, nbr=4, verbose=True):
    r"""
    Computes series in standard 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_standard_system, load_standard_system
    from phcpy.phcpy2c2 import py2c_standard_Newton_power_series as newton
    from phcpy.phcpy2c2 import py2c_syspool_standard_init
    from phcpy.phcpy2c2 import py2c_syspool_standard_create
    from phcpy.phcpy2c2 import py2c_syspool_standard_size as poolsize
    from phcpy.phcpy2c2 import py2c_syspool_copy_to_standard_container
    from phcpy.phcpy2c2 import py2c_syspool_standard_clear
    nbsym = number_of_symbols(pols)
    if verbose:
        print "the polynomials :"
        for pol in pols:
            print pol
        print "Number of variables :", nbsym
    store_standard_system(lser, nbvar=1)
    py2c_syspool_standard_init(1);
    py2c_syspool_standard_create(1);
    store_standard_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_standard_container(1)
    result = load_standard_system()
    result = substitute_symbol(result, idx)
    py2c_syspool_standard_clear()
    return result
コード例 #15
0
def standard_newton_power_series(pols, lser, idx=1, nbr=4, verbose=True):
    r"""
    Computes series in standard 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_standard_system, load_standard_system
    from phcpy.phcpy2c3 import py2c_standard_Newton_power_series as newton
    from phcpy.phcpy2c3 import py2c_syspool_standard_init
    from phcpy.phcpy2c3 import py2c_syspool_standard_create
    from phcpy.phcpy2c3 import py2c_syspool_standard_size as poolsize
    from phcpy.phcpy2c3 import py2c_syspool_copy_to_standard_container
    from phcpy.phcpy2c3 import py2c_syspool_standard_clear
    nbsym = number_of_symbols(pols)
    if verbose:
        print("the polynomials :")
        for pol in pols:
            print(pol)
        print("Number of variables :", nbsym)
    store_standard_system(lser, nbvar=1)
    py2c_syspool_standard_init(1)
    py2c_syspool_standard_create(1)
    store_standard_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_standard_container(1)
    result = load_standard_system()
    result = substitute_symbol(result, idx)
    py2c_syspool_standard_clear()
    return result
コード例 #16
0
def standard_newton_series(pols, sols, idx=1, maxdeg=4, nbr=4, verbose=True):
    r"""
    Computes series in standard 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_standard_solutions
    from phcpy.interface import store_standard_system, load_standard_system
    from phcpy.phcpy2c2 import py2c_standard_Newton_series as newton
    from phcpy.phcpy2c2 import py2c_syspool_standard_size as poolsize
    from phcpy.phcpy2c2 import py2c_syspool_copy_to_standard_container
    from phcpy.phcpy2c2 import py2c_syspool_standard_clear
    nbsym = number_of_symbols(pols)
    if verbose:
        print "the polynomials :"
        for pol in pols:
            print pol
        print "Number of variables :", nbsym
    store_standard_system(pols, nbvar=nbsym)
    store_standard_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_standard_container(k)
        sersol = load_standard_system()
        result.append(substitute_symbol(sersol, idx))
    py2c_syspool_standard_clear()
    return result
コード例 #17
0
ファイル: series.py プロジェクト: sommars/PHCpack
def standard_newton_series(pols, sols, idx=1, nbr=4, verbose=True):
    r"""
    Computes series in standard 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_standard_solutions
    from phcpy.interface import store_standard_system, load_standard_system
    from phcpy.phcpy2c2 import py2c_standard_Newton_series as newton
    from phcpy.phcpy2c2 import py2c_syspool_standard_size as poolsize
    from phcpy.phcpy2c2 import py2c_syspool_copy_to_standard_container
    from phcpy.phcpy2c2 import py2c_syspool_standard_clear
    nbsym = number_of_symbols(pols)
    if verbose:
        print "the polynomials :"
        for pol in pols:
            print pol
        print "Number of variables :", nbsym
    store_standard_system(pols, nbvar=nbsym)
    store_standard_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_standard_container(k)
        sersol = load_standard_system()
        result.append(substitute_symbol(sersol, idx))
    py2c_syspool_standard_clear()
    return result
コード例 #18
0
ファイル: solver.py プロジェクト: callmetaste/PHCpack
def m_homogeneous_bezout_number(pols):
    """
    Given in pols a list of string representations of polynomials,
    in as many variables as the elements in the list,
    this function applies a heuristic to generate a partition of the
    set of unknowns to exploit the product structure of the system.
    On return are the m-homogeneous Bezout number and the partition
    of the set of unknowns.  If the partition equals the entire
    set of unknowns, then the 1-homogeneous Bezout number equals
    the total degree of the system.
    """
    from phcpy.phcpy2c3 import py2c_product_m_homogeneous_Bezout_number
    from phcpy.interface import store_standard_system
    store_standard_system(pols)
    result = py2c_product_m_homogeneous_Bezout_number()
    return result
コード例 #19
0
ファイル: solver.py プロジェクト: callmetaste/PHCpack
def mixed_volume(pols, stable=False):
    """
    Given in pols a list of string representations of polynomials,
    this function returns the mixed volume of the system.
    This is an interface to Algorithm 846: MixedVol of ACM TOMS,
    developed by Tangan Gao, T.Y. Li, Mengnien Wu, and Li Xing.
    If the option stable is set to True, then on return is a tuple
    containing the mixed volume and the stable mixed volume.
    The mixed volume counts the solutions with all their coordinates
    nonzero, the stable mixed volume counts all affine roots.
    Note that the stable mixed volume does not apply to systems
    with negative exponents.
    Incorrectly parsed strings will result in a negative value on return.
    """
    from phcpy.phcpy2c3 import py2c_celcon_clear_container
    from phcpy.phcpy2c3 import py2c_mixed_volume
    from phcpy.interface import store_standard_system
    from phcpy.interface import store_standard_laurent_system
    py2c_celcon_clear_container()
    if stable:
        fail = store_standard_system(pols)
    else:
        fail = store_standard_laurent_system(pols)
    if(fail != 0):
        return -fail  # a negative number is clearly wrong
    else:
        return py2c_mixed_volume(stable)
コード例 #20
0
ファイル: solver.py プロジェクト: d-torrance/PHCpack
def m_homogeneous_bezout_number(pols):
    """
    Given in pols a list of string representations of polynomials,
    in as many variables as the elements in the list,
    this function applies a heuristic to generate a partition of the
    set of unknowns to exploit the product structure of the system.
    On return are the m-homogeneous Bezout number and the partition
    of the set of unknowns.  If the partition equals the entire
    set of unknowns, then the 1-homogeneous Bezout number equals
    the total degree of the system.
    """
    from phcpy.phcpy2c3 import py2c_product_m_homogeneous_Bezout_number
    from phcpy.interface import store_standard_system
    store_standard_system(pols)
    result = py2c_product_m_homogeneous_Bezout_number()
    return result
コード例 #21
0
ファイル: solver.py プロジェクト: d-torrance/PHCpack
def mixed_volume(pols, stable=False):
    """
    Given in pols a list of string representations of polynomials,
    this function returns the mixed volume of the system.
    This is an interface to Algorithm 846: MixedVol of ACM TOMS,
    developed by Tangan Gao, T.Y. Li, Mengnien Wu, and Li Xing.
    If the option stable is set to True, then on return is a tuple
    containing the mixed volume and the stable mixed volume.
    The mixed volume counts the solutions with all their coordinates
    nonzero, the stable mixed volume counts all affine roots.
    Note that the stable mixed volume does not apply to systems
    with negative exponents.
    Incorrectly parsed strings will result in a negative value on return.
    """
    from phcpy.phcpy2c3 import py2c_celcon_clear_container
    from phcpy.phcpy2c3 import py2c_mixed_volume
    from phcpy.interface import store_standard_system
    from phcpy.interface import store_standard_laurent_system
    py2c_celcon_clear_container()
    if stable:
        fail = store_standard_system(pols)
    else:
        fail = store_standard_laurent_system(pols)
    if (fail != 0):
        return -fail  # a negative number is clearly wrong
    else:
        return py2c_mixed_volume(stable)
コード例 #22
0
ファイル: trackers.py プロジェクト: sommars/PHCpack
def ade_tuned_double_track(target, start, sols, pars, gamma=0, verbose=1):
    r"""
    Does path tracking with algorithm differentiation,
    in standard double precision, with tuned parameters in pars.
    On input are a target system, a start system with solutions.
    The *target* is a list of strings representing the polynomials
    of the target system (which has to be solved).
    The *start* is a list of strings representing the polynomials
    of the start system, with known solutions in *sols*.
    The *sols* is a list of strings representing start solutions.
    The *pars* is a tuple of 14 values for the path parameters.
    On return are the string representations of the solutions
    computed at the end of the paths.
    If *gamma* on input equals zero, then a random complex number is generated,
    otherwise the real and imaginary parts of *gamma* are used.
    """
    from phcpy.phcpy2c3 import py2c_copy_standard_container_to_target_system
    from phcpy.phcpy2c3 import py2c_copy_standard_container_to_start_system
    from phcpy.phcpy2c3 import py2c_ade_manypaths_d_pars
    from phcpy.interface import store_standard_system
    from phcpy.interface import store_standard_solutions
    from phcpy.interface import load_standard_solutions
    store_standard_system(target)
    py2c_copy_standard_container_to_target_system()
    store_standard_system(start)
    py2c_copy_standard_container_to_start_system()
    dim = len(start)
    store_standard_solutions(dim, sols)
    if(gamma == 0):
        from random import uniform
        from cmath import exp, pi
        angle = uniform(0, 2*pi)
        gamma = exp(angle*complex(0, 1))
        if(verbose > 0):
            print('random gamma constant :', gamma)
    if(verbose > 0):
        print('the path parameters :\n', pars)
    fail = py2c_ade_manypaths_d_pars(verbose, gamma.real, gamma.imag, \
        pars[0], pars[1], pars[2], pars[3], pars[4], pars[5], pars[6], \
        pars[7], pars[8], pars[9], pars[10], pars[11], pars[12], pars[13])
    if(fail == 0):
        if(verbose > 0):
            print('Path tracking with AD was a success!')
    else:
        print('Path tracking with AD failed!')
    return load_standard_solutions()
コード例 #23
0
def standard_double_track(target, start, sols, gamma=0, tasks=0):
    r"""
    Does path tracking with standard double precision.
    On input are a target system, a start system with solutions,
    optionally: a (random) gamma constant and the number of tasks.
    The *target* is a list of strings representing the polynomials
    of the target system (which has to be solved).
    The *start* is a list of strings representing the polynomials
    of the start system, with known solutions in sols.
    The *sols* is a list of strings representing start solutions.
    By default, a random *gamma* constant is generated,
    otherwise *gamma* must be a nonzero complex constant.
    The number of tasks in the multithreading is defined by *tasks*.
    The default zero value for *tasks* indicates no multithreading.
    On return are the string representations of the solutions
    computed at the end of the paths.
    """
    from phcpy.phcpy2c3 import py2c_copy_standard_container_to_target_system
    from phcpy.phcpy2c3 import py2c_copy_standard_container_to_start_system
    from phcpy.phcpy2c3 import py2c_copy_standard_container_to_start_solutions
    from phcpy.phcpy2c3 import py2c_create_standard_homotopy
    from phcpy.phcpy2c3 import py2c_create_standard_homotopy_with_gamma
    from phcpy.phcpy2c3 import py2c_solve_by_standard_homotopy_continuation
    from phcpy.phcpy2c3 import py2c_solcon_clear_standard_solutions
    from phcpy.phcpy2c3 import py2c_copy_standard_target_solutions_to_container
    from phcpy.interface import store_standard_system
    from phcpy.interface import store_standard_solutions
    from phcpy.interface import load_standard_solutions
    from phcpy.solver import number_of_symbols
    dim = number_of_symbols(start)
    store_standard_system(target, nbvar=dim)
    py2c_copy_standard_container_to_target_system()
    store_standard_system(start, nbvar=dim)
    py2c_copy_standard_container_to_start_system()
    # py2c_clear_standard_homotopy()
    if(gamma == 0):
        py2c_create_standard_homotopy()
    else:
        py2c_create_standard_homotopy_with_gamma(gamma.real, gamma.imag)
    store_standard_solutions(dim, sols)
    py2c_copy_standard_container_to_start_solutions()
    py2c_solve_by_standard_homotopy_continuation(tasks)
    py2c_solcon_clear_standard_solutions()
    py2c_copy_standard_target_solutions_to_container()
    return load_standard_solutions()
コード例 #24
0
ファイル: solver.py プロジェクト: callmetaste/PHCpack
def standard_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 standard double precision.
    After application of deflation with default settings,
    the new approximate solutions are returned.
    """
    from phcpy.phcpy2c3 import py2c_standard_deflate
    from phcpy.interface import store_standard_system
    from phcpy.interface import store_standard_solutions
    from phcpy.interface import load_standard_solutions
    store_standard_system(system)
    store_standard_solutions(len(system), solutions)
    py2c_standard_deflate()
    result = load_standard_solutions()
    return result
コード例 #25
0
def standard_set_homotopy(target, start, verbose=False):
    """
    Initializes the homotopy with the target and start system for a
    step-by-step run of the series-Pade tracker, in double precision.
    If verbose, then extra output is written.
    Returns the failure code of the homotopy initializer.
    """
    from phcpy.phcpy2c3 import py2c_copy_standard_container_to_target_system
    from phcpy.phcpy2c3 import py2c_copy_standard_container_to_start_system
    from phcpy.interface import store_standard_system
    from phcpy.solver import number_of_symbols
    dim = number_of_symbols(start)
    store_standard_system(target, nbvar=dim)
    py2c_copy_standard_container_to_target_system()
    store_standard_system(start, nbvar=dim)
    py2c_copy_standard_container_to_start_system()
    from phcpy.phcpy2c3 import py2c_padcon_standard_initialize_homotopy
    return py2c_padcon_standard_initialize_homotopy(int(verbose))
コード例 #26
0
ファイル: trackers.py プロジェクト: callmetaste/PHCpack
def ade_double_track(target, start, sols, gamma=0, verbose=1):
    """
    Does path tracking with algorithm differentiation,
    in standard double precision.
    On input are a target system, a start system with solutions.
    The target is a list of strings representing the polynomials
    of the target system (which has to be solved).
    The start is a list of strings representing the polynomials
    of the start system, with known solutions in sols.
    The sols is a list of strings representing start solutions.
    On return are the string representations of the solutions
    computed at the end of the paths.
    If gamma on input equals zero, then a random complex number is generated,
    otherwise the real and imaginary parts of gamma are used.
    """
    from phcpy.phcpy2c2 import py2c_copy_standard_container_to_target_system
    from phcpy.phcpy2c2 import py2c_copy_standard_container_to_start_system
    from phcpy.phcpy2c2 import py2c_ade_manypaths_d
    from phcpy.interface import store_standard_system
    from phcpy.interface import store_standard_solutions
    from phcpy.interface import load_standard_solutions

    store_standard_system(target)
    py2c_copy_standard_container_to_target_system()
    store_standard_system(start)
    py2c_copy_standard_container_to_start_system()
    dim = len(start)
    store_standard_solutions(dim, sols)
    if gamma == 0:
        from random import uniform
        from cmath import exp, pi

        angle = uniform(0, 2 * pi)
        gamma = exp(angle * complex(0, 1))
        if verbose > 0:
            print "random gamma constant :", gamma
    fail = py2c_ade_manypaths_d(verbose, gamma.real, gamma.imag)
    if fail == 0:
        if verbose > 0:
            print "Path tracking with AD was a success!"
    else:
        print "Path tracking with AD failed!"
    return load_standard_solutions()
コード例 #27
0
ファイル: solver.py プロジェクト: callmetaste/PHCpack
def total_degree_start_system(pols):
    """
    Returns the system and solutions of the total degree start system
    for the polynomials represented by the strings in the list pols.
    """
    from phcpy.phcpy2c3 import py2c_syscon_number_of_standard_polynomials
    from phcpy.phcpy2c3 import py2c_syscon_string_of_symbols
    from phcpy.phcpy2c3 import py2c_syscon_degree_of_standard_polynomial
    from phcpy.interface import store_standard_system
    store_standard_system(pols)
    dim = py2c_syscon_number_of_standard_polynomials()
    svars = py2c_syscon_string_of_symbols()
    nvars = svars.split(' ')
    degrees = [py2c_syscon_degree_of_standard_polynomial(k+1) \
               for k in range(dim)]
    result = []
    for ind in range(dim):
        result.append(nvars[ind]+'^'+str(degrees[ind])+' - 1;')
    return (result, solve(result))
コード例 #28
0
def initialize_standard_tracker(target, start, fixedgamma=True):
    r"""
    Initializes a path tracker with a generator for a *target*
    and *start* system given in standard double precision.
    If *fixedgamma*, then gamma will be a fixed default value,
    otherwise, a random complex constant for gamma is generated.
    """
    from phcpy.phcpy2c3 import py2c_copy_standard_container_to_target_system
    from phcpy.phcpy2c3 import py2c_copy_standard_container_to_start_system
    from phcpy.phcpy2c3 import py2c_initialize_standard_homotopy
    from phcpy.interface import store_standard_system
    store_standard_system(target)
    py2c_copy_standard_container_to_target_system()
    store_standard_system(start)
    py2c_copy_standard_container_to_start_system()
    if fixedgamma:
        return py2c_initialize_standard_homotopy(1)
    else:
        return py2c_initialize_standard_homotopy(0)
コード例 #29
0
def standard_set_parameter_homotopy(hom, idx, verbose=False):
    """
    Initializes the homotopy with the polynomials in hom for a
    step-by-step run of the series-Pade tracker, in double precision.
    The value idx gives the index of the continuation parameter
    and is the index of one of the variables in the homotopy hom.
    If verbose, then extra output is written.
    Returns the failure code of the homotopy initializer.
    """
    from phcpy.phcpy2c3 import py2c_copy_standard_container_to_target_system
    from phcpy.interface import store_standard_system
    from phcpy.solver import number_of_symbols
    dim = number_of_symbols(hom)
    store_standard_system(hom, nbvar=dim)
    py2c_copy_standard_container_to_target_system()
    from phcpy.phcpy2c3  \
        import py2c_padcon_standard_initialize_parameter_homotopy
    vrb = int(verbose)
    return py2c_padcon_standard_initialize_parameter_homotopy(idx, vrb)
コード例 #30
0
def standard_double_track(target, start, sols, gamma=0, tasks=0):
    """
    Does path tracking with standard double precision.
    On input are a target system, a start system with solutions,
    optionally: a (random) gamma constant and the number of tasks.
    The target is a list of strings representing the polynomials
    of the target system (which has to be solved).
    The start is a list of strings representing the polynomials
    of the start system, with known solutions in sols.
    The sols is a list of strings representing start 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 phcpy.phcpy2c2 import py2c_copy_standard_container_to_target_system
    from phcpy.phcpy2c2 import py2c_copy_standard_container_to_start_system
    from phcpy.phcpy2c2 import py2c_copy_standard_container_to_start_solutions
    from phcpy.phcpy2c2 import py2c_create_standard_homotopy
    from phcpy.phcpy2c2 import py2c_create_standard_homotopy_with_gamma
    from phcpy.phcpy2c2 import py2c_solve_by_standard_homotopy_continuation
    from phcpy.phcpy2c2 import py2c_solcon_clear_standard_solutions
    from phcpy.phcpy2c2 import py2c_copy_standard_target_solutions_to_container
    from phcpy.interface import store_standard_system
    from phcpy.interface import store_standard_solutions
    from phcpy.interface import load_standard_solutions
    from phcpy.solver import number_of_symbols
    dim = number_of_symbols(start)
    store_standard_system(target, nbvar=dim)
    py2c_copy_standard_container_to_target_system()
    store_standard_system(start, nbvar=dim)
    py2c_copy_standard_container_to_start_system()
    # py2c_clear_standard_homotopy()
    if(gamma == 0):
        py2c_create_standard_homotopy()
    else:
        py2c_create_standard_homotopy_with_gamma(gamma.real, gamma.imag)
    store_standard_solutions(dim, sols)
    py2c_copy_standard_container_to_start_solutions()
    py2c_solve_by_standard_homotopy_continuation(tasks)
    py2c_solcon_clear_standard_solutions()
    py2c_copy_standard_target_solutions_to_container()
    return load_standard_solutions()
コード例 #31
0
def initialize_standard_tracker(target, start, fixedgamma=True):
    """
    Initializes a path tracker with a generator for a target
    and start system given in standard double precision.
    If fixedgamma, then gamma will be a fixed default value,
    otherwise, a random complex constant for gamma is generated.
    """
    from phcpy.phcpy2c2 import py2c_copy_standard_container_to_target_system
    from phcpy.phcpy2c2 import py2c_copy_standard_container_to_start_system
    from phcpy.phcpy2c2 import py2c_initialize_standard_homotopy
    from phcpy.interface import store_standard_system
    store_standard_system(target)
    py2c_copy_standard_container_to_target_system()
    store_standard_system(start)
    py2c_copy_standard_container_to_start_system()
    if fixedgamma:
        return py2c_initialize_standard_homotopy(1)
    else:
        return py2c_initialize_standard_homotopy(0)
コード例 #32
0
ファイル: solver.py プロジェクト: d-torrance/PHCpack
def standard_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 standard double precision.
    After application of deflation with default settings,
    the new approximate solutions are returned.
    """
    from phcpy.phcpy2c3 import py2c_standard_deflate
    from phcpy.interface import store_standard_system
    from phcpy.interface import store_standard_solutions
    from phcpy.interface import load_standard_solutions
    dim = number_of_symbols(system)
    store_standard_system(system, nbvar=dim)
    store_standard_solutions(dim, solutions)
    py2c_standard_deflate()
    result = load_standard_solutions()
    return result
コード例 #33
0
ファイル: solver.py プロジェクト: d-torrance/PHCpack
def total_degree_start_system(pols):
    """
    Returns the system and solutions of the total degree start system
    for the polynomials represented by the strings in the list pols.
    """
    from phcpy.phcpy2c3 import py2c_syscon_number_of_standard_polynomials
    from phcpy.phcpy2c3 import py2c_syscon_string_of_symbols
    from phcpy.phcpy2c3 import py2c_syscon_degree_of_standard_polynomial
    from phcpy.interface import store_standard_system
    store_standard_system(pols)
    dim = py2c_syscon_number_of_standard_polynomials()
    svars = py2c_syscon_string_of_symbols()
    nvars = svars.split(' ')
    degrees = [py2c_syscon_degree_of_standard_polynomial(k+1) \
               for k in range(dim)]
    result = []
    for ind in range(dim):
        result.append(nvars[ind] + '^' + str(degrees[ind]) + ' - 1;')
    return (result, solve(result))
コード例 #34
0
ファイル: solver.py プロジェクト: d-torrance/PHCpack
def random_linear_product_system(pols, tosolve=True):
    """
    Given in pols a list of string representations of polynomials,
    returns a random linear-product system based on a supporting
    set structure and its solutions as well (if tosolve).
    """
    from phcpy.phcpy2c3 import py2c_product_supporting_set_structure
    from phcpy.phcpy2c3 import py2c_product_random_linear_product_system
    from phcpy.phcpy2c3 import py2c_product_solve_linear_product_system
    from phcpy.interface import store_standard_system, load_standard_system
    from phcpy.interface import load_standard_solutions
    store_standard_system(pols)
    py2c_product_supporting_set_structure()
    py2c_product_random_linear_product_system()
    result = load_standard_system()
    if not tosolve:
        return result
    py2c_product_solve_linear_product_system()
    sols = load_standard_solutions()
    return (result, sols)
コード例 #35
0
ファイル: solver.py プロジェクト: d-torrance/PHCpack
def linear_product_root_count(pols, silent=False):
    """
    Given in pols a list of string representations of polynomials,
    returns a linear-product root count based on a supporting
    set structure of the polynomials in pols.  This root count is
    an upper bound for the number of isolated solutions.
    """
    from phcpy.phcpy2c3 import py2c_product_supporting_set_structure
    from phcpy.phcpy2c3 import py2c_product_write_set_structure
    from phcpy.phcpy2c3 import py2c_product_linear_product_root_count
    from phcpy.interface import store_standard_system
    store_standard_system(pols)
    py2c_product_supporting_set_structure()
    if not silent:
        print('a supporting set structure :')
        py2c_product_write_set_structure()
    root_count = py2c_product_linear_product_root_count()
    if not silent:
        print('the root count :', root_count)
    return root_count
コード例 #36
0
ファイル: solver.py プロジェクト: callmetaste/PHCpack
def random_linear_product_system(pols, tosolve=True):
    """
    Given in pols a list of string representations of polynomials,
    returns a random linear-product system based on a supporting
    set structure and its solutions as well (if tosolve).
    """
    from phcpy.phcpy2c3 import py2c_product_supporting_set_structure
    from phcpy.phcpy2c3 import py2c_product_random_linear_product_system
    from phcpy.phcpy2c3 import py2c_product_solve_linear_product_system
    from phcpy.interface import store_standard_system, load_standard_system
    from phcpy.interface import load_standard_solutions
    store_standard_system(pols)
    py2c_product_supporting_set_structure()
    py2c_product_random_linear_product_system()
    result = load_standard_system()
    if not tosolve:
        return result
    py2c_product_solve_linear_product_system()
    sols = load_standard_solutions()
    return (result, sols)
コード例 #37
0
ファイル: solver.py プロジェクト: callmetaste/PHCpack
def linear_product_root_count(pols, silent=False):
    """
    Given in pols a list of string representations of polynomials,
    returns a linear-product root count based on a supporting
    set structure of the polynomials in pols.  This root count is
    an upper bound for the number of isolated solutions.
    """
    from phcpy.phcpy2c3 import py2c_product_supporting_set_structure
    from phcpy.phcpy2c3 import py2c_product_write_set_structure
    from phcpy.phcpy2c3 import py2c_product_linear_product_root_count
    from phcpy.interface import store_standard_system
    store_standard_system(pols)
    py2c_product_supporting_set_structure()
    if not silent:
        print('a supporting set structure :')
        py2c_product_write_set_structure()
    root_count = py2c_product_linear_product_root_count()
    if not silent:
        print('the root count :', root_count)
    return root_count
コード例 #38
0
def ade_double_track(target, start, sols, gamma=0, verbose=1):
    """
    Does path tracking with algorithm differentiation,
    in standard double precision.
    On input are a target system, a start system with solutions.
    The target is a list of strings representing the polynomials
    of the target system (which has to be solved).
    The start is a list of strings representing the polynomials
    of the start system, with known solutions in sols.
    The sols is a list of strings representing start solutions.
    On return are the string representations of the solutions
    computed at the end of the paths.
    If gamma on input equals zero, then a random complex number is generated,
    otherwise the real and imaginary parts of gamma are used.
    """
    from phcpy.phcpy2c2 import py2c_copy_standard_container_to_target_system
    from phcpy.phcpy2c2 import py2c_copy_standard_container_to_start_system
    from phcpy.phcpy2c2 import py2c_ade_manypaths_d
    from phcpy.interface import store_standard_system
    from phcpy.interface import store_standard_solutions
    from phcpy.interface import load_standard_solutions
    store_standard_system(target)
    py2c_copy_standard_container_to_target_system()
    store_standard_system(start)
    py2c_copy_standard_container_to_start_system()
    dim = len(start)
    store_standard_solutions(dim, sols)
    if(gamma == 0):
        from random import uniform
        from cmath import exp, pi
        angle = uniform(0, 2*pi)
        gamma = exp(angle*complex(0, 1))
        if(verbose > 0):
            print 'random gamma constant :', gamma
    fail = py2c_ade_manypaths_d(verbose, gamma.real, gamma.imag)
    if(fail == 0):
        if(verbose > 0):
            print 'Path tracking with AD was a success!'
    else:
        print 'Path tracking with AD failed!'
    return load_standard_solutions()
コード例 #39
0
def gpu_double_track(target, start, sols, gamma=0, verbose=1):
    r"""
    GPU accelerated path tracking with algorithm differentiation,
    in standard double precision.
    On input are a target system, a start system with solutions.
    The *target* is a list of strings representing the polynomials
    of the target system (which has to be solved).
    The *start* is a list of strings representing the polynomials
    of the start system, with known solutions in sols.
    The *sols* is a list of strings representing start solutions.
    On return are the string representations of the solutions
    computed at the end of the paths.
    If *gamma* on input equals zero, then a random complex number is generated,
    otherwise the real and imaginary parts of *gamma* are used.
    """
    from phcpy.phcpy2c3 import py2c_copy_standard_container_to_target_system
    from phcpy.phcpy2c3 import py2c_copy_standard_container_to_start_system
    from phcpy.phcpy2c3 import py2c_gpu_manypaths_d
    from phcpy.interface import store_standard_system
    from phcpy.interface import store_standard_solutions
    from phcpy.interface import load_standard_solutions
    store_standard_system(target)
    py2c_copy_standard_container_to_target_system()
    store_standard_system(start)
    py2c_copy_standard_container_to_start_system()
    dim = len(start)
    store_standard_solutions(dim, sols)
    if(gamma == 0):
        from random import uniform
        from cmath import exp, pi
        angle = uniform(0, 2*pi)
        gamma = exp(angle*complex(0, 1))
        if(verbose > 0):
            print('random gamma constant :', gamma)
    fail = py2c_gpu_manypaths_d(2, verbose, gamma.real, gamma.imag)
    if(fail == 0):
        if(verbose > 0):
            print('Path tracking on the GPU was a success!')
    else:
        print('Path tracking on the GPU failed!')
    return load_standard_solutions()
コード例 #40
0
ファイル: solver.py プロジェクト: d-torrance/PHCpack
def m_homogeneous_start_system(pols, partition):
    """
    For an m-homogeneous Bezout number of a polynomial system defined by
    a partition of the set of unknowns, one can define a linear-product
    system that has exactly as many regular solutions as the Bezount number.
    This linear-product system can then be used as start system in a
    homotopy to compute all isolated solutions of any polynomial system
    with the same m-homogeneous structure.
    This function returns a linear-product start system with random
    coefficients and its solutions for the given polynomials in pols
    and the partition.
    """
    from phcpy.phcpy2c3 import py2c_product_m_homogeneous_start_system
    from phcpy.phcpy2c3 import py2c_product_solve_linear_product_system
    from phcpy.interface import store_standard_system, load_standard_system
    from phcpy.interface import load_standard_solutions
    store_standard_system(pols)
    py2c_product_m_homogeneous_start_system(len(partition), partition)
    result = load_standard_system()
    py2c_product_solve_linear_product_system()
    sols = load_standard_solutions()
    return (result, sols)
コード例 #41
0
ファイル: solver.py プロジェクト: callmetaste/PHCpack
def m_homogeneous_start_system(pols, partition):
    """
    For an m-homogeneous Bezout number of a polynomial system defined by
    a partition of the set of unknowns, one can define a linear-product
    system that has exactly as many regular solutions as the Bezount number.
    This linear-product system can then be used as start system in a
    homotopy to compute all isolated solutions of any polynomial system
    with the same m-homogeneous structure.
    This function returns a linear-product start system with random
    coefficients and its solutions for the given polynomials in pols
    and the partition.
    """
    from phcpy.phcpy2c3 import py2c_product_m_homogeneous_start_system
    from phcpy.phcpy2c3 import py2c_product_solve_linear_product_system
    from phcpy.interface import store_standard_system, load_standard_system
    from phcpy.interface import load_standard_solutions
    store_standard_system(pols)
    py2c_product_m_homogeneous_start_system(len(partition), partition)
    result = load_standard_system()
    py2c_product_solve_linear_product_system()
    sols = load_standard_solutions()
    return (result, sols)
コード例 #42
0
def standard_track(target, start, sols, filename="", verbose=False):
    """
    Wraps the tracker for Pade continuation in standard double precision.
    On input are a target system, a start system with solutions,
    optionally: a string *filename* and the *verbose* flag.
    The *target* is a list of strings representing the polynomials
    of the target system (which has to be solved).
    The *start* is a list of strings representing the polynomials
    of the start system, with known solutions in *sols*.
    The *sols* is a list of strings representing start solutions.
    On return are the string representations of the solutions
    computed at the end of the paths.
    """
    from phcpy.phcpy2c2 import py2c_copy_standard_container_to_target_system
    from phcpy.phcpy2c2 import py2c_copy_standard_container_to_start_system
    from phcpy.phcpy2c2 import py2c_copy_standard_container_to_start_solutions
    from phcpy.phcpy2c2 import py2c_create_standard_homotopy_with_gamma
    from phcpy.phcpy2c2 import py2c_clear_standard_homotopy
    from phcpy.phcpy2c2 import py2c_clear_standard_operations_data
    from phcpy.interface import store_standard_system
    from phcpy.interface import store_standard_solutions
    from phcpy.interface import load_standard_solutions
    from phcpy.solver import number_of_symbols
    from phcpy.phcpy2c2 import py2c_padcon_standard_track
    dim = number_of_symbols(start)
    store_standard_system(target, nbvar=dim)
    py2c_copy_standard_container_to_target_system()
    store_standard_system(start, nbvar=dim)
    py2c_copy_standard_container_to_start_system()
    store_standard_solutions(dim, sols)
    py2c_copy_standard_container_to_start_solutions()
    (regamma, imgamma) = get_homotopy_continuation_parameter(1)
    py2c_create_standard_homotopy_with_gamma(regamma, imgamma)
    nbc = len(filename)
    fail = py2c_padcon_standard_track(nbc, filename, int(verbose))
    # py2c_clear_standard_homotopy()
    # py2c_clear_standard_operations_data()
    return load_standard_solutions()
コード例 #43
0
ファイル: factor.py プロジェクト: lailaiflow/PHCpack
def standard_polysys_solve(pols, topdim=-1, \
    filter=True, factor=True, tasks=0, verbose=True):
    """
    Runs the cascades of homotopies on the polynomial system in pols
    in standard double precision.  The default top dimension topdim
    is the number of variables in pols minus one.
    """
    from phcpy.phcpy2c3 import py2c_standard_polysys_solve
    from phcpy.phcpy2c3 import py2c_copy_standard_polysys_witset
    from phcpy.solver import number_of_symbols
    from phcpy.interface import store_standard_system
    from phcpy.interface import load_standard_system, load_standard_solutions
    dim = number_of_symbols(pols)
    if (topdim == -1):
        topdim = dim - 1
    fail = store_standard_system(pols, nbvar=dim)
    fail = py2c_standard_polysys_solve(tasks,topdim, \
        int(filter),int(factor),int(verbose))
    witsols = []
    for soldim in range(0, topdim + 1):
        fail = py2c_copy_standard_polysys_witset(soldim)
        witset = (load_standard_system(), load_standard_solutions())
        witsols.append(witset)
    return witsols
コード例 #44
0
ファイル: factor.py プロジェクト: janverschelde/PHCpack
def standard_polysys_solve(pols, topdim=-1, \
    filter=True, factor=True, tasks=0, verbose=True):
    """
    Runs the cascades of homotopies on the polynomial system in pols
    in standard double precision.  The default top dimension topdim
    is the number of variables in pols minus one.
    """
    from phcpy.phcpy2c3 import py2c_standard_polysys_solve
    from phcpy.phcpy2c3 import py2c_copy_standard_polysys_witset
    from phcpy.solver import number_of_symbols
    from phcpy.interface import store_standard_system
    from phcpy.interface import load_standard_system, load_standard_solutions
    dim = number_of_symbols(pols)
    if(topdim == -1):
        topdim = dim - 1
    fail = store_standard_system(pols, nbvar=dim)
    fail = py2c_standard_polysys_solve(tasks,topdim, \
        int(filter),int(factor),int(verbose))
    witsols = []
    for soldim in range(0, topdim+1):
        fail = py2c_copy_standard_polysys_witset(soldim)
        witset = (load_standard_system(), load_standard_solutions())
        witsols.append(witset)
    return witsols
コード例 #45
0
def standard_newton_power_series(pols, lser, idx=1, maxdeg=4, nbr=4, \
    checkin=True, verbose=True):
    r"""
    Computes series in standard 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,

    *maxdeg*: maximal degree of the power series,

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

    *checkin*: checks whether the number of symbols in pols matches
    the length of the list lser if idx == 0, or is one less than 
    the length of the list lser if idx != 0.  If the conditions are
    not satisfied, then an error message is printed and lser is returned.

    *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_standard_system, load_standard_system
    from phcpy.phcpy2c2 import py2c_standard_Newton_power_series as newton
    from phcpy.phcpy2c2 import py2c_syspool_standard_init
    from phcpy.phcpy2c2 import py2c_syspool_standard_create
    from phcpy.phcpy2c2 import py2c_syspool_standard_size as poolsize
    from phcpy.phcpy2c2 import py2c_syspool_copy_to_standard_container
    from phcpy.phcpy2c2 import py2c_syspool_standard_clear
    nbsym = number_of_symbols(pols)
    if verbose:
        print "the polynomials :"
        for pol in pols:
            print pol
        print "Number of variables :", nbsym
    if checkin:
        if not checkin_newton_power_series(nbsym, lser, idx):
            return lser
    store_standard_system(lser, nbvar=1)
    py2c_syspool_standard_init(1);
    py2c_syspool_standard_create(1);
    store_standard_system(pols, nbvar=nbsym)
    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 one series solution."
    py2c_syspool_copy_to_standard_container(1)
    result = load_standard_system()
    result = substitute_symbol(result, idx)
    py2c_syspool_standard_clear()
    return result