Пример #1
0
def step(context):
    from dcprogs.likelihood import find_root_intervals
    try:
        find_root_intervals(context.determinant, **context.parameters)
    except:
        context.noerror = False
    else:
        context.noerror = True
Пример #2
0
def step(context, resolution):
  from numpy import min
  from dcprogs.likelihood import find_root_intervals_brute_force, find_root_intervals
  if hasattr(context, "exception"): raise context.exception
  roots = find_root_intervals(context.equation)
  mini = min([r[0] for r in roots])
  context.intervals_brute_force = find_root_intervals_brute_force(context.equation, resolution, 2*mini)
  context.resolution = resolution
Пример #3
0
def step(context, resolution):
    from numpy import min
    from dcprogs.likelihood import find_root_intervals_brute_force, find_root_intervals
    if hasattr(context, "exception"): raise context.exception
    roots = find_root_intervals(context.equation)
    mini = min([r[0] for r in roots])
    context.intervals_brute_force = find_root_intervals_brute_force(
        context.equation, resolution, 2 * mini)
    context.resolution = resolution
Пример #4
0
def step(context):
  from dcprogs.likelihood import find_root_intervals
  if hasattr(context, "exception"): raise context.exception
  context.intervals = find_root_intervals(context.equation)
Пример #5
0
def step(context):
  from dcprogs.likelihood import find_root_intervals
  try: find_root_intervals(context.determinant, **context.parameters)
  except: context.noerror = False
  else: context.noerror = True
Пример #6
0
                    [    0,         0,    10,      0,  -10] ], 2)
det = DeterminantEq(qmatrix, 1e-4);


upper_bound = find_upper_bound_for_roots(det);
lower_bound = find_lower_bound_for_roots(det);

get_eigenvalues = lambda s: eig(det.H(s))[0].T
assert all(get_eigenvalues(lower_bound) > lower_bound) 
assert all(get_eigenvalues(upper_bound) < upper_bound) 


print("Root Determination\n"                                         \
      "==================\n\n"                                       \
      "  * Interval containing roots: {lower}, {upper}\n"            \
      "  * Eigenvalues of H at lower bound: {eiglow}\n"              \
      "  * Eigenvalues of H at upper bound: {eigup}\n"               \
      .format( lower=lower_bound, upper=upper_bound,
               eiglow = get_eigenvalues(lower_bound),
               eigup  = get_eigenvalues(upper_bound) ))

intervals = find_root_intervals(det, lower_bound, upper_bound)
for (start, end), multiplicity in intervals:
  root, iterations, function_calls = brentq(det, start, end)
  print("  * Root interval: [{0}, {1}]\n"
        "    Corresponding root: {2}\n".format(start, end, root))


roots = find_roots(det);
print("  * All roots: {0}\n".format([root for root, multiplicity in roots]))
Пример #7
0
def step(context):
    from dcprogs.likelihood import find_root_intervals
    if hasattr(context, "exception"): raise context.exception
    context.intervals = find_root_intervals(context.equation)