def testsolvebutton(): """ Solves the cyclic 5-roots problems and launches the solve button. """ from phcpy.families import cyclic cyc5 = cyclic(5) launchsolver(cyc5)
def testsolvebutton(): """ Solves the cyclic 5-roots problem and launches the solve button. """ from phcpy.families import cyclic cyc5 = cyclic(5) launchsolver(cyc5)
def testscroller(): """ Solves the cyclic 5-roots problems and launches the scroller. """ from phcpy.families import cyclic from phcpy.solver import solve cyc5 = cyclic(5) sols = solve(cyc5, silent=True) scrollsols(sols)
def testcoordinateplot(): """ Solves the cyclic 5-roots problem, prompts the user for an index of a coordinate, and launches the plotcoordinate function. """ from phcpy.families import cyclic from phcpy.solver import solve print('solving the cyclic 5-roots problem ...') cyc5 = cyclic(5) sols = solve(cyc5, silent=True) idx = int(input('Give an index : ')) plotcoordinate(sols, idx)
def testcoordinateplot(): """ Solves the cyclic 5-roots problem, prompts the user for an index of a coordinate, and launches the plotcoordinate function. """ from phcpy.families import cyclic from phcpy.solver import solve print 'solving the cyclic 5-roots problem ...' cyc5 = cyclic(5) sols = solve(cyc5, silent=True) idx = int(input('Give an index : ')) plotcoordinate(sols, idx)
def embedpoint(dim, point, addslack=True): """ Embeds the point in a witness set representation for a cyclic n-roots solution set of dimension dim. If addslack, then slack variables will be added to square the embedded system. """ from phcpy.families import cyclic nvr = len(point) sys = cyclic(nvr) emb = embedsys(dim, sys, addslack) for p in point: print p for k in range(dim): hyp = hyperplane(dim, point, addslack) emb.append(hyp) return emb
def evaluate(point): """ Evaluates the point in the cyclic n-roots problem, where n = len(point). """ from phcpy.families import cyclic n = len(point) f = cyclic(n) d = globals() for k in range(n): var = 'x' + str(k) d[var] = point[k] for k in range(n): var = 'x' + str(k) print var, '=', d[var] result = [] for r in f: result.append(eval(r[0:-1])) return result
""" Demonstration of the multitasked blackbox solver. Run this at the command line as time python d1.py. """ from phcpy.families import cyclic from phcpy.solver import solve c7 = cyclic(7) s = solve(c7, tasks=4) print 'number of solutions :', len(s)
""" Illustration of the witness set computation of the cyclic 4-roots system. """ from phcpy.families import cyclic c4 = cyclic(4) from phcpy.sets import embed c4e1 = embed(4, 1, c4) print 'the embedded cyclic 4-roots problem :' for pol in c4e1: print pol from phcpy.solver import solve sols = solve(c4e1) print 'computed', len(sols), 'solutions' from phcpy.solutions import filter_zero_coordinates as filter genpts = filter(sols, 'zz1', 1.0e-8, 'select') print 'generic points :' for sol in genpts: print sol from phcpy.sets import membertest sdpoint = [-1, 0, -1, 0, 1, 0, 1, 0] print 'testing in standard double precision ...' print membertest(c4e1, genpts, 1, sdpoint, verbose=True, precision='d') raw_input('*** hit enter to continue ***') print 'testing in double double precision ...' ddpoint = [-1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0] print membertest(c4e1, genpts, 1, ddpoint, verbose=True, precision='dd') raw_input('*** hit enter to continue ***') print 'testing in quad double precision ...' ddpoint = [-1, 0, 0, 0, 0, 0, 0, 0, \ -1, 0, 0, 0, 0, 0, 0, 0, \ 1, 0, 0, 0, 0, 0, 0, 0, \