Example #1
0
def start_pieri_system(rows, cols, pivots, planes, linear=False):
    """
    Generates a Pieri system where the last equation
    is for a special plane.  For all other equations,
    the planes in the list planes will be used.
    If linear, then variables in the matrix are named with 
    a strict linear index instead of a double index.
    """
    newpiv = update_pivots(rows, pivots)
    mat = variables(rows, cols, newpiv, linear)
    nvr = number_of_variables(pivots)
    dim = rows - cols
    result = []
    for k in range(nvr):
        cff = planes[k]
        equ = all_terms(mat, rows, cols, cff)
        print '-> number of terms in equation %d : %d' % (k+1, len(equ))
        pol = sum_terms(equ)
        result.append(pol + ';')
    lastcff = special_plane(rows, newpiv)
    print '-> the special plane :'
    print lastcff
    lastequ = all_terms(mat, rows, cols, lastcff)
    lastpol = sum_terms(lastequ)
    result.append(lastpol + ';')
    return result
Example #2
0
def start_pieri_system(rows, cols, pivots, planes, linear=False):
    """
    Generates a Pieri system where the last equation
    is for a special plane.  For all other equations,
    the planes in the list planes will be used.
    If linear, then variables in the matrix are named with 
    a strict linear index instead of a double index.
    """
    newpiv = update_pivots(rows, pivots)
    mat = variables(rows, cols, newpiv, linear)
    nvr = number_of_variables(pivots)
    dim = rows - cols
    result = []
    for k in range(nvr):
        cff = planes[k]
        equ = all_terms(mat, rows, cols, cff)
        print '-> number of terms in equation %d : %d' % (k + 1, len(equ))
        pol = sum_terms(equ)
        result.append(pol + ';')
    lastcff = special_plane(rows, newpiv)
    print '-> the special plane :'
    print lastcff
    lastequ = all_terms(mat, rows, cols, lastcff)
    lastpol = sum_terms(lastequ)
    result.append(lastpol + ';')
    return result
Example #3
0
def run_tracker(start, sols, target, sol_num, gamma, min_step, max_step,
                num_steps):
    set_homotopy_continuation_gamma(gamma.real, gamma.imag)
    set_homotopy_continuation_parameter(5, min_step)
    set_homotopy_continuation_parameter(4, max_step)
    set_homotopy_continuation_parameter(12, num_steps)
    dim = number_of_symbols(start)
    result = [[], [], [], [], [], [], []]
    for i in range(dim):
        result[2].append([])
    standard_set_homotopy(target, start, False)
    idx = 0
    choice_sol = sol_num
    solution = sols[choice_sol - 1]
    idx = idx + 1
    standard_set_solution(dim, solution, False)
    solution = standard_get_solution(False)
    solution_dict = strsol2dict(solution)
    var_names = variables(solution_dict)
    var_names.sort()
    result[0].append(standard_t_value())
    result[1].append(standard_step_size())
    for i in range(len(var_names)):
        result[2][i].append(solution_dict[var_names[i]])
    result[3].append(standard_closest_pole())
    result[4].append(standard_pole_radius())
    result[5].append(standard_series_coefficients(dim))
    result[6].append(standard_pade_vector(dim))
    for i in range(num_steps):
        standard_predict_correct(False)
        solution = standard_get_solution(False)
        solution_dict = strsol2dict(solution)
        result[0].append(standard_t_value())
        result[1].append(standard_step_size())
        for j in range(len(var_names)):
            result[2][j].append(solution_dict[var_names[j]])
        result[3].append(standard_closest_pole())
        result[4].append(standard_pole_radius())
        result[5].append(standard_series_coefficients(dim))
        result[6].append(standard_pade_vector(dim))
    for i in range(len(result[2])):
        for j in range(len(result[2][i])):
            result[2][i][j] = (result[2][i][j].real, result[2][i][j].imag)
    return result
Example #4
0
def show_variable_matrix():
    """
    Prompts the user for the number of rows and columns,
    the pivot information of the matrix of variables.
    Then shows the variable matrix and all its minors,
    along with the equation for a random coefficient matrix.
    """
    rows, cols, pvts = ask_inputs()
    answer = raw_input('Double indexing of variables ? (y/n) ')
    linear = (answer != 'y')
    varmat = variables(rows, cols, pvts, linear)
    print '-> the matrix of variables :'
    print varmat
    answer = raw_input('Enumerate all minors ? (y/n) ')
    if (answer == 'y'):
        all_minors(varmat, rows, cols)
    answer = raw_input('Enumerate all terms ? (y/n) ')
    dim = rows - cols
    cff = random_matrix(rows, dim)
    equ = all_terms(varmat, rows, cols, cff)
    print '-> all terms in the Pieri condition :'
    print sum_terms(equ)
Example #5
0
def show_variable_matrix():
    """
    Prompts the user for the number of rows and columns,
    the pivot information of the matrix of variables.
    Then shows the variable matrix and all its minors,
    along with the equation for a random coefficient matrix.
    """
    rows, cols, pvts = ask_inputs()
    answer = raw_input('Double indexing of variables ? (y/n) ')
    linear = (answer != 'y')
    varmat = variables(rows, cols, pvts, linear)
    print '-> the matrix of variables :'
    print varmat
    answer = raw_input('Enumerate all minors ? (y/n) ')
    if(answer == 'y'):
        all_minors(varmat, rows, cols)
    answer = raw_input('Enumerate all terms ? (y/n) ')
    dim = rows - cols
    cff = random_matrix(rows, dim)
    equ = all_terms(varmat, rows, cols, cff)
    print '-> all terms in the Pieri condition :'
    print sum_terms(equ)
Example #6
0
def pieri_system(rows, cols, pivots, planes, linear=False):
    """
    Generates a Pieri system for the numbers of rows in rows,
    the number of columns in cols, and the given pivots.
    The list planes must contain at least as many matrices
    as the number of variables in the pivots.
    The number of rows of the matrices in planes is the value
    of rows and the number of columns of the matrices in planes
    must equal to rows - cols.
    If linear, then variables in the matrix are named with 
    a strict linear index instead of a double index.
    """
    mat = variables(rows, cols, pivots, linear)
    nvr = number_of_variables(pivots)
    dim = rows - cols
    result = []
    for k in range(nvr):
        cff = planes[k]
        equ = all_terms(mat, rows, cols, cff)
        print '-> number of terms in equation %d : %d' % (k + 1, len(equ))
        pol = sum_terms(equ)
        result.append(pol + ';')
    return result
Example #7
0
def extend_solutions(sols, dim, pivots):
    """
    Adds one extra zero coordinate to all solutions in sols,
    corresponding to the rightmost nonfull pivot.
    """
    from phcpy.solutions import strsol2dict, variables, make_solution
    piv = rightmost_nonfull_pivot(dim, pivots)
    print '-> in extend_solutions, piv =', piv
    if (piv < 0):
        result = sols
    else:
        rown = pivots[piv] + 1  # row number of new variable
        name = 'x_' + str(rown + 1) + '_' + str(piv + 1)
        print '-> the name of the new variable :', name
        result = []
        for sol in sols:
            dicsol = strsol2dict(sol)
            solvar = variables(dicsol)
            solval = [dicsol[var] for var in solvar]
            solvar.append(name)
            solval.append(complex(0.0))
            result.append(make_solution(solvar, solval))
    return result
Example #8
0
def pieri_system(rows, cols, pivots, planes, linear=False):
    """
    Generates a Pieri system for the numbers of rows in rows,
    the number of columns in cols, and the given pivots.
    The list planes must contain at least as many matrices
    as the number of variables in the pivots.
    The number of rows of the matrices in planes is the value
    of rows and the number of columns of the matrices in planes
    must equal to rows - cols.
    If linear, then variables in the matrix are named with 
    a strict linear index instead of a double index.
    """
    mat = variables(rows, cols, pivots, linear)
    nvr = number_of_variables(pivots)
    dim = rows - cols
    result = []
    for k in range(nvr):
        cff = planes[k]
        equ = all_terms(mat, rows, cols, cff)
        print '-> number of terms in equation %d : %d' % (k+1, len(equ))
        pol = sum_terms(equ)
        result.append(pol + ';')
    return result
Example #9
0
def extend_solutions(sols, dim, pivots):
    """
    Adds one extra zero coordinate to all solutions in sols,
    corresponding to the rightmost nonfull pivot.
    """
    from phcpy.solutions import strsol2dict, variables, make_solution
    piv = rightmost_nonfull_pivot(dim, pivots)
    print '-> in extend_solutions, piv =', piv
    if(piv < 0):
        result = sols
    else:
        rown = pivots[piv] + 1  # row number of new variable 
        name = 'x_' + str(rown+1) + '_' + str(piv+1)
        print '-> the name of the new variable :', name
        result = []
        for sol in sols:
            dicsol = strsol2dict(sol)
            solvar = variables(dicsol)
            solval = [dicsol[var] for var in solvar] 
            solvar.append(name)
            solval.append(complex(0.0))
            result.append(make_solution(solvar, solval))
    return result