# Passing ideals between Macaulay and Sage

During some sage code, I'd like to take an ideal, send it to Macaulay2, do some computations with it, and then continue to use the new ideal in sage.

Are there smart ways to do this? I'm currently doing it by converting all variables/equations to strings, and using string maniuplations to produce valid macaulay2 commands. More concretely:

1.) Define the same ring in Macaulay2 via:

(my rings are Z-algebras):
l = R.cover_ring().variable_names(); #variable names
m = R.defining_ideal().gens(); #generators of ideal
T = "R = ZZ[" + ", ".join(str(z) for z in l) + "]/("+ ",".join(str(z) for z in m)  +")" ;
macaulay2(T);


2.) Then, I can define an ideal I and do some computations with it.

3.) Question: I can print the generators of I via

macaulay2("toString gens I");

and then, again using string maniuplations remove the "matrix {{" and "}}" from Macaulay2's output, split the string to get a list which can be then be interpreted as generators of an ideal in sage.

Is there a better way to do any of these steps?

edit retag close merge delete