示例#1
0
def split_filter(sols, dim, tol, verbose=True):
    r"""
    Given in *sols* is a list of solutions of dimension *dim*,
    which contain a variable with name 'zz' + str(*dim*),
    which is the name of the last slack variable.
    The tolerance *tol* is used to split the list of solution in two.
    On return is a tuple of two lists of solutions (possibly empty).
    The first list of solutions has the last slack variable equal
    to zero (with respect to the tolerance *tol) and the last slack
    variable of each solution in the second list has a magnitude
    larger than *tol*.
    If *verbose*, then the length of each solution list is printed.
    """
    from phcpy.solutions import filter_zero_coordinates as filter
    lastslack = 'zz' + str(dim)
    zerosols = filter(sols, lastslack, tol, 'select')
    nonzsols = filter(sols, lastslack, tol, 'remove')
    if verbose:
        print 'number of candidate generic points :', len(zerosols)
        print 'number of nonsolutions :', len(nonzsols)
    return (zerosols, nonzsols)
示例#2
0
def split_filter(sols, dim, tol, verbose=True):
    r"""
    Given in *sols* is a list of solutions of dimension *dim*,
    which contain a variable with name 'zz' + str(*dim*),
    which is the name of the last slack variable.
    The tolerance *tol* is used to split the list of solution in two.
    On return is a tuple of two lists of solutions (possibly empty).
    The first list of solutions has the last slack variable equal
    to zero (with respect to the tolerance *tol) and the last slack
    variable of each solution in the second list has a magnitude
    larger than *tol*.
    If *verbose*, then the length of each solution list is printed.
    """
    from phcpy.solutions import filter_zero_coordinates as filter
    lastslack = 'zz' + str(dim)
    zerosols = filter(sols, lastslack, tol, 'select')
    nonzsols = filter(sols, lastslack, tol, 'remove')
    if verbose:
        print 'number of candidate generic points :', len(zerosols)
        print 'number of nonsolutions :', len(nonzsols)
    return (zerosols, nonzsols)
示例#3
0
"""
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, \