Ask Your Question
1

Can I import M2 matrices into sage?

asked 2016-02-01 22:26:18 -0500

done_with_fish gravatar image

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?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-02-02 05:14:14 -0500

Nathann gravatar image

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 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 ?

Nathann

edit flag offensive delete link more

Comments

Yes thank you!

done_with_fish gravatar imagedone_with_fish ( 2016-02-02 12:07:26 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-02-01 22:26:18 -0500

Seen: 65 times

Last updated: Feb 02 '16