Ask Your Question
0

Can I read a Gap file into my current Gap session within Sage?

asked 2010-12-11 03:20:56 -0500

updated 2011-04-28 09:02:22 -0500

I have a collection of functions defined for Gap, and I'd like to be able to read their definitions and use them from Sage. I've noticed the load_package function, but this seems to require that my function definitions be installed as a Gap package. I'd like to be able to do something like

sage: gap('Read("gap_defs.g");')

and then

sage: X = gap('customFunction()')

to return the Sage-wrapped output of my gap function. However this doesn't seem to work, and nor do any of the (many) variants I've tried. Suggestions?

If installing the definitions as a Gap package is necessary, could someone tell me where the files should be put so that Sage's copy of Gap can find them? (i.e. what is the Gap root for Sage's Gap?)

edit retag flag offensive close delete

1 answer

Sort by » oldest newest most voted
1

answered 2010-12-11 07:40:20 -0500

You should be able to do the following:

sage: gap.Read('"gap_defs.g"') #similarly gap.eval('Read("gap_defs.g");')
sage: X = gap.customFunction() #assuming customFunction() returns an object

If that isn't working for you, you'll have to be more specific as to what the error is.

Note that doing

sage: gap('Read("gap_defs.g");')

is equivalent to doing something like

sage24 := Read("gap_defs.g");

in GAP. If you want to just evaluate a command in the session, use gap.eval('XXX').

edit flag offensive delete publish link more

Your Answer

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

Add Answer

[hide preview]

Stats

Asked: 2010-12-11 03:20:56 -0500

Seen: 178 times

Last updated: Dec 11 '10
{"cc_re__cc_re__cc_by_sa_3_0_le": ["tebook/\">Using &#39;GAP with GRAPE&#39; in SAGE notebook()?</a> </p> <p> <a href=\"/question/10025/problem-using-gap/\">Problem using GAP</a> </p> <p> <a href=\"/question/7802/sage-notebook-how-to-set-the-path-for-octave/\">Sage Notebook: how to set the path for Octave?</a> </p> <p> <a href=\"/question/10459/permutation-groups-in-gaps/\">Permutation Groups in Gaps</a> </p> </div> </div> </div> </div> <!-- template footer.html --> <div id=\"ground\"> <div class=\"content-wrapper\"> <div class=\"copyright\"> <a href=\"http://creativecommons.org/licenses/by-sa/3.0/legalcode\"> <img\n                            class=\"license-logo\"\n                            src=\"/m/default/media/images/cc-by-sa.png?v=19\"\n                            title=\"cc-by-sa\"\n                            alt=\"cc-by-sa\"\n                        /> </a>\n                \n                Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a <a href=\"http://creativecommons.org/licenses/by-sa/3.0/legalcode\">Creative Commons Attribution Share", "wrapper\"> <div class=\"copyright\"> <a href=\"http://creativecommons.org/licenses/by-sa/3.0/legalcode\"> <img\n                            class=\"license-logo\"\n                            src=\"/m/default/media/images/cc-by-sa.png?v=19\"\n                            title=\"cc-by-sa\"\n                            alt=\"cc-by-sa\"\n                        /> </a>\n                \n                Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a <a href=\"http://creativecommons.org/licenses/by-sa/3.0/legalcode\">Creative Commons Attribution Share Alike 3.0</a> license.\n\n            </div> <div class=\"footer-links\" > <a href=\"/about/\">about</a><span class=\"link-separator\"> |</span> <a href=\"/faq/\">faq</a><span class=\"link-separator\"> |</span> <a href=\"/help/\" title=\"help\">help</a> <span class=\"link-separator\"> |</span> <a href=\"/privacy/\">privacy policy</a><span class=\"link-separator\"> |</span> <a href=\n                        \n                            \"/feedback/?next=/question/7803/can-i-read-a-gap-"], "copyright__copyright__copyright": ["at the error is.\n\nNote that doing\n\nsage: gap('Read(\"gap_defs.g\");')\n\nis equivalent to doing something like\n\nsage24 := Read(\"gap_defs.g\");\n\nin GAP. If you want to just evaluate a command in the session, use gap.eval('XXX').\n\nedit flag offensive delete publish link more\n\nYour Answer\n\nPlease start posting anonymously - your entry will be published after you log in or create a new account.\n\nAdd Answer\n\n[hide preview]\n\nStats\n\nAsked: 2010-12-11 03:20:56 -0500\n\nSeen: 178 times\n\nLast updated: Dec 11 '10", "at the error is.\n\nNote that doing\n\nsage: gap('Read(\"gap_defs.g\");')\n\nis equivalent to doing something like\n\nsage24 := Read(\"gap_defs.g\");\n\nin GAP. If you want to just evaluate a command in the session, use gap.eval('XXX').\n\nedit flag offensive delete publish link more\n\nYour Answer\n\nPlease start posting anonymously - your entry will be published after you log in or create a new account.\n\nAdd Answer\n\n[hide preview]\n\nStats\n\nAsked: 2010-12-11 03:20:56 -0500\n\nSeen: 178 times\n\nLast updated: Dec 11 '10"]}