Last active
April 18, 2019 13:24
-
-
Save saschatimme/02faf68103d639eb31f5706760b974d4 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
parsePolynomial = p -> replace("ii","im",replace("p[0-9]+","0",toExternalString p)) | |
writeSystem = method(Options=>{}) | |
writeSystem (List, File) := o -> (P,f) -> ( | |
R := ring first P; | |
vars := apply(gens R, toString); | |
concatenate(mingle(vars, (#vars-1):1)); | |
f << "# This file was auto generated from Macaulay2.\n"; | |
f << "# For more information about HomotopyContinuation.jl visit:\n"; | |
f << "# https://www.JuliaHomotopyContinuation.org\n"; | |
f << "using HomotopyContinuation"; | |
f << "\n\n"; | |
f << "@polyvar " | concatenate(mingle(vars, #vars:1)); | |
eqnCommas:=(#P-1):", "; | |
f << "\n"; | |
f <<"f = [" | concatenate mingle( | |
apply(P,e->parsePolynomial e), eqnCommas)| "];\n"; | |
f << "\n"; | |
f << "result = solve(f)"; | |
) | |
writeSystem (List, String) :=o -> (P,filename) -> ( | |
f := openOut filename; | |
writeSystem(P,f); | |
close f; | |
) | |
writeSystem (Ideal, String) := o -> (I,f) -> ( | |
writeSystem(first entries gens I, f) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment