Output file as input

473 views
Skip to first unread message

Bart Snapp

unread,
Jul 7, 2010, 8:07:49 PM7/7/10
to maca...@googlegroups.com
Hi,

I would like to have M2 check a large list of ideas for certain
properties (e.g. projective dim of R/I)

The problem is that my list is going to be very large -- and checking
these ideals will take a long time.

One possible way to go would be to have M2 produce a list of ideals in
a file, then I could have M2 check parts of this list at a time.

Is this possible? At the moment, I do not know how to have M2 create
an output file that it can read at a later date.

Thanks!

René Birkner

unread,
Jul 8, 2010, 2:47:22 AM7/8/10
to Macaulay2
Hi Bart,

Here is what you do basically:

F := openOut "myIdeals.m2"; -- Create your output file
F << toExternalString L; -- Write your ideal to the file
close F; -- close the file

To read it, do:

F = openIn "myIdeals.m2";
L = value get F;

IF you want to write your ideals to the file one at a time, you can
try the following:

F := openOut "myIdeals.m2";
F << "{";
close F; -- Generates your file with
the opening parantheses of your list

Whenever you generate one of your ideals you can now write it to the
file like this

F = openOutAppend "myIdeals.m2";
F << toExternalString I << ",";
close F;

There is just one small problem: The list now ends with a comma. But
for example when reading your file you can now do the following:

F = openIn "myIdeals.m2";
L = get F; -- Now you just read the string in the
file, so L is the string of your list
L = value(L | "}"); -- L is now your list,with an
empty entry at the end
L = drop(L,-1);

I hope this helps. It might not be the best solution, but for it works
fine.

René

Dimitri M

unread,
Jul 8, 2010, 3:22:55 AM7/8/10
to maca...@googlegroups.com
Hi,

to save a list of ideals P to the file Pfile.m2, you can use

"Pfile.m2"<<toString P<<close;

To restore it from the disc use

P=value get "Pfile.m2";

> Hi,
>
> I would like to have M2 check a large list of ideas for certain
> properties (e.g. projective dim of R/I)
>
> The problem is that my list is going to be very large -- and checking
> these ideals will take a long time.
>
> One possible way to go would be to have M2 produce a list of ideals in
> a file, then I could have M2 check parts of this list at a time.
>
> Is this possible? At the moment, I do not know how to have M2 create
> an output file that it can read at a later date.
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Macaulay2" group.
> To post to this group, send email to maca...@googlegroups.com.
> To unsubscribe from this group, send email to
> macaulay2+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/macaulay2?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages