Created
September 13, 2016 12:46
-
-
Save cthoyt/2077166fd57c4dd3583499f5ef40d5f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def parse_bertini_main_data(fl): | |
""" | |
Parses main_data output from Bertini 1.5.1 | |
:param fl: file object for main_data | |
:type f1: file-like object | |
:return: list of solutions | |
""" | |
it = (line.strip() for line in fl) | |
number_variables = next(it) | |
solution_dimension = int(number_variables[21:]) | |
print(solution_dimension) | |
variables = next(it) | |
rank = next(it) | |
_ = next(it) | |
dimension_title = next(it) | |
_ = next(it) | |
non_singular_title = next(it) | |
line = next(it) | |
solns = [] | |
while line == '---------------': | |
path_number = next(it) | |
component_number = next(it) | |
estimated_condition_number = next(it) | |
components = [] | |
for i in range(solution_dimension): | |
component = next(it) | |
re, im = component.split(' ') | |
component = float(re) + 1j * float(im) | |
components.append(component) | |
solns.append(components) | |
multiplicity = next(it) | |
deflations = next(it) | |
line = next(it) | |
return solns |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment