Esempio n. 1
0
def store_standard_system(polsys, **nbvar):
    r"""
    Stores the polynomials represented by the list of strings in *polsys* into
    the container for systems with coefficients in standard double precision.
    The number of variables is an optional argument given in *nbvar*.
    If *nbvar* is omitted, then the system is assumed to be square.
    Otherwise, suppose the number of variables equals 2 and pols is the list
    of polynomials, then the call **store_standard_system(pols, nbvar=2)**
    will store the polynomials in pols in the standard systems container.
    """
    from phcpy.phcpy2c3 import py2c_syscon_clear_standard_system
    from phcpy.phcpy2c3 \
        import py2c_syscon_initialize_number_of_standard_polynomials
    from phcpy.phcpy2c3 import py2c_syscon_store_standard_polynomial
    py2c_syscon_clear_standard_system()
    dim = len(polsys)
    fail = 0
    py2c_syscon_initialize_number_of_standard_polynomials(dim)
    for cnt in range(0, dim):
        pol = polsys[cnt]
        nchar = len(pol)
        if (len(nbvar) == 0):
            fail = py2c_syscon_store_standard_polynomial(
                nchar, dim, cnt + 1, pol)
        else:
            nvr = list(nbvar.values())[0]
            fail = py2c_syscon_store_standard_polynomial(
                nchar, nvr, cnt + 1, pol)
        if (fail != 0):
            break
    return fail
Esempio n. 2
0
def store_standard_system(polsys, **nbvar):
    r"""
    Stores the polynomials represented by the list of strings in *polsys* into
    the container for systems with coefficients in standard double precision.
    The number of variables is an optional argument given in *nbvar*.
    If *nbvar* is omitted, then the system is assumed to be square.
    Otherwise, suppose the number of variables equals 2 and pols is the list
    of polynomials, then the call **store_standard_system(pols, nbvar=2)**
    will store the polynomials in pols in the standard systems container.
    """
    from phcpy.phcpy2c3 import py2c_syscon_clear_standard_system
    from phcpy.phcpy2c3 \
        import py2c_syscon_initialize_number_of_standard_polynomials
    from phcpy.phcpy2c3 import py2c_syscon_store_standard_polynomial
    py2c_syscon_clear_standard_system()
    dim = len(polsys)
    py2c_syscon_initialize_number_of_standard_polynomials(dim)
    for cnt in range(0, dim):
        pol = polsys[cnt]
        nchar = len(pol)
        if(len(nbvar) == 0):
            fail = py2c_syscon_store_standard_polynomial(nchar, dim, cnt+1, pol)
        else:
            nvr = list(nbvar.values())[0]
            fail = py2c_syscon_store_standard_polynomial(nchar, nvr, cnt+1, pol)
        if(fail != 0):
            break
    return fail
Esempio n. 3
0
def standard_start_diagonal_cascade(gamma=0, tasks=0):
    r"""
    Does the path tracking to start a diagonal cascade in standard double
    precision.  For this to work, the functions standard_diagonal_homotopy
    and standard_diagonal_cascade_solutions must be executed successfully.
    If *gamma* equals 0 on input, then a random gamma constant is generated,
    otherwise, the given complex gamma will be used in the homotopy.
    Multitasking is available, and activated by the *tasks* parameter.
    Returns the target (system and its corresponding) 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_syscon_clear_standard_system
    from phcpy.phcpy2c3 import py2c_copy_standard_target_solutions_to_container
    from phcpy.phcpy2c3 import py2c_copy_standard_target_system_to_container
    from phcpy.interface import load_standard_solutions
    from phcpy.interface import load_standard_system
    if(gamma == 0):
        py2c_create_standard_homotopy()
    else:
        py2c_create_standard_homotopy_with_gamma(gamma.real, gamma.imag)
    py2c_solve_by_standard_homotopy_continuation(tasks)
    py2c_solcon_clear_standard_solutions()
    py2c_syscon_clear_standard_system()
    py2c_copy_standard_target_solutions_to_container()
    # from phcpy.phcpy2c3 import py2c_write_standard_target_system
    # print 'the standard target system :'
    # py2c_write_standard_target_system()
    py2c_copy_standard_target_system_to_container()
    tsys = load_standard_system()
    sols = load_standard_solutions()
    return (tsys, sols)
Esempio n. 4
0
def test_tableau():
    """
    Tests on storing and loading of a tableau.
    """
    from phcpy.phcpy2c3 import py2c_syscon_random_system
    from phcpy.phcpy2c3 import py2c_syscon_clear_standard_system
    dim, nbrmon, deg, cff = 2, 4, 3, 0
    py2c_syscon_random_system(dim, nbrmon, deg, cff)
    pols = load_standard_system()
    print('a random polynomial system :\n', pols)
    neq, nvr, ptab = load_standard_tableau()
    print('its tableau form :\n', ptab)
    py2c_syscon_clear_standard_system()
    store_standard_tableau(ptab)
    storedpols = load_standard_system()
    print('after clearing the container :\n', storedpols)
Esempio n. 5
0
def test_standard_polyhedral_homotopy():
    """
    Test on jumpstarting a polyhedral homotopy
    in standard precision.
    """
    from phcpy.phcpy2c3 import py2c_syscon_clear_standard_system
    from phcpy.phcpy2c3 import py2c_syscon_clear_standard_Laurent_system
    from phcpy.trackers import track
    py2c_syscon_clear_standard_system()
    py2c_syscon_clear_standard_Laurent_system()
    qrt = random_trinomials()
    mixvol = mixed_volume(qrt)
    print('the mixed volume is', mixvol)
    (rqs, rsols) = random_coefficient_system()
    print('found %d solutions' % len(rsols))
    newton_step(rqs, rsols)
    print('tracking to target...')
    pqr = permute_standard_system(qrt)
    qsols = track(pqr, rqs, rsols)
    newton_step(qrt, qsols)
Esempio n. 6
0
def test_standard_polyhedral_homotopy():
    """
    Test on jumpstarting a polyhedral homotopy
    in standard precision.
    """
    from phcpy.phcpy2c3 import py2c_syscon_clear_standard_system
    from phcpy.phcpy2c3 import py2c_syscon_clear_standard_Laurent_system
    from phcpy.trackers import track
    py2c_syscon_clear_standard_system()
    py2c_syscon_clear_standard_Laurent_system()
    qrt = random_trinomials()
    mixvol = mixed_volume(qrt)
    print('the mixed volume is', mixvol)
    (rqs, rsols) = random_coefficient_system()
    print('found %d solutions' % len(rsols))
    newton_step(rqs, rsols)
    print('tracking to target...')
    pqr = permute_standard_system(qrt)
    qsols = track(pqr, rqs, rsols)
    newton_step(qrt, qsols)