ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 02 Feb 2016 12:07:26 -0600Can I import M2 matrices into sage?https://ask.sagemath.org/question/32413/can-i-import-m2-matrices-into-sage/I have thousands of matrices I computed in Macaulay2. They are scattered throughout sub-directories of `~/matrices/` one example of one of these matrices is
$ cat ~/matrices/foo/001-matrix
map((ZZ)^9,(ZZ)^7,{{1, 0, -1, 0, 0, 0, 0}, {1, 0, 1, 0, 0, 0, 0}, {1, 0, 0, -1, -1, -1, -1}, {1, 0, 0, 1, 0, 0, 0}, {1, 0, 0, 0, 1, 0, 0}, {0, 1, 0, 0, 0, 1, 0}, {0, 1, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0, 0}})
I would like to write a script to convert each of these matrices into a format that sage can read. It seems like
sage: A = macaulay2(value get "~/matrices/foo/001-matrix")
should work but this returns the error `invalid syntax`. Is it possible to perform my desired conversions?Mon, 01 Feb 2016 22:26:18 -0600https://ask.sagemath.org/question/32413/can-i-import-m2-matrices-into-sage/Answer by Nathann for <p>I have thousands of matrices I computed in Macaulay2. They are scattered throughout sub-directories of <code>~/matrices/</code> one example of one of these matrices is</p>
<pre><code>$ cat ~/matrices/foo/001-matrix
map((ZZ)^9,(ZZ)^7,{{1, 0, -1, 0, 0, 0, 0}, {1, 0, 1, 0, 0, 0, 0}, {1, 0, 0, -1, -1, -1, -1}, {1, 0, 0, 1, 0, 0, 0}, {1, 0, 0, 0, 1, 0, 0}, {0, 1, 0, 0, 0, 1, 0}, {0, 1, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0, 0}})
</code></pre>
<p>I would like to write a script to convert each of these matrices into a format that sage can read. It seems like</p>
<pre><code>sage: A = macaulay2(value get "~/matrices/foo/001-matrix")
</code></pre>
<p>should work but this returns the error <code>invalid syntax</code>. Is it possible to perform my desired conversions?</p>
https://ask.sagemath.org/question/32413/can-i-import-m2-matrices-into-sage/?answer=32416#post-id-32416I don't know anything about macaulay and don't have it installed, but I suggest you try to make the content of your command *be* a string, or you will keep hitting this syntax error. What about
sage: A = macaulay2('value get "~/matrices/foo/001-matrix"')
Does it give what you want ?
NathannTue, 02 Feb 2016 05:14:14 -0600https://ask.sagemath.org/question/32413/can-i-import-m2-matrices-into-sage/?answer=32416#post-id-32416Comment by done_with_fish for <p>I don't know anything about macaulay and don't have it installed, but I suggest you try to make the content of your command <em>be</em> a string, or you will keep hitting this syntax error. What about</p>
<pre><code> sage: A = macaulay2('value get "~/matrices/foo/001-matrix"')
</code></pre>
<p>Does it give what you want ?</p>
<p>Nathann</p>
https://ask.sagemath.org/question/32413/can-i-import-m2-matrices-into-sage/?comment=32420#post-id-32420Yes thank you!Tue, 02 Feb 2016 12:07:26 -0600https://ask.sagemath.org/question/32413/can-i-import-m2-matrices-into-sage/?comment=32420#post-id-32420