︠58b324f6-0116-4c8b-9a4b-e0d78b8bec8ei︠ %md # Example: Macaulay2 with Matroids package ## About Macaulay2 * [Macaulay2 home](http://www2.macaulay2.com/Macaulay2/) * [sagemath interface to Macaulay2](http://doc.sagemath.org/html/en/reference/interfaces/sage/interfaces/macaulay2.html) * (old) [sagews example showing Macaulay2 mode](https://github.com/sagemathinc/cocalc-example-files/blob/master/sage/MagicCommandsDoc.sagews) ## Using the Matroids package * Matroids [package docs](http://www2.macaulay2.com/Macaulay2/doc/Macaulay2-1.11/share/doc/Macaulay2/Matroids/html/) * Matroids [github repo](https://github.com/jchen419/Matroids-M2) * Where Macaulay2 looks for packages [path](http://www2.macaulay2.com/Macaulay2/share/doc/Macaulay2/Macaulay2Doc/html/_path.html) ︡97235da6-270f-405d-8ea8-df3e4f3c27bf︡{"done":true,"md":"\n# Macaulay2 using Matroids package\n\n\n## About Macaulay2\n\n* [Macaulay2 home](http://www2.macaulay2.com/Macaulay2/)\n* [sagemath interface to Macaulay2](http://doc.sagemath.org/html/en/reference/interfaces/sage/interfaces/macaulay2.html)\n* (old) [sagews example showing Macaulay2 mode](https://github.com/sagemathinc/cocalc-example-files/blob/master/sage/MagicCommandsDoc.sagews)\n\n## Using the Matroids package\n\n* Matroids [package docs](http://www2.macaulay2.com/Macaulay2/doc/Macaulay2-1.11/share/doc/Macaulay2/Matroids/html/)\n* Matroids [github repo](https://github.com/jchen419/Matroids-M2)\n* Where Macaulay2 looks for packages [path](http://www2.macaulay2.com/Macaulay2/share/doc/Macaulay2/Macaulay2Doc/html/_path.html)"} ︠3587afce-1e24-45bd-89fa-d9897959f1fcs︠ %default_mode macaulay2 ︡ded2ff0f-8875-4241-8699-fb2d98c0d09f︡{"done":true}︡ ︠716a0b1f-5a96-4884-9c99-4327c9ff20e9s︠ -- check that we are in macaulay2 mode 22/15+1/22 ︡f2efc6c7-0191-4d6a-a9b9-69f39320fa49︡{"stdout":"499\n---\n330\n\nQQ"}︡{"done":true}︡ ︠55b39aac-da2a-418b-b228-8e50ba9a6e2fs︠ -- show where M2 packages will be found path ︡4d6a37cc-bbaa-45e0-b726-54949b8cea60︡{"stdout":"{./, .Macaulay2/code/, .Macaulay2/local/share/Macaulay2/, .Macaulay2/local/common/share/Macaulay2/, /usr/share/Macaulay2/}\n\nList"}︡{"done":true}︡ ︠4e7b659b-e263-4720-befc-db259f5f245as︠ %sh # fetch Matroids package if it's not already installed # running M2 from .term or starting sagews %macaulay2 mode creates ~/.Macaulay2/code test -f $HOME/.Macaulay2/code/Matroids.m2 || { test -d $HOME/.Macaulay2/code || M2 < /dev/null cd $HOME/.Macaulay2/code wget https://raw.githubusercontent.com/jchen419/Matroids-M2/master/Matroids.m2 } ︡94572300-1af5-4db3-9c98-9b7fed4e4f87︡{"done":true}︡ ︠850e080b-0f82-4e83-af8a-4dda0227b745s︠ -- now we are ready to use the package and run examples from package docs needsPackage "Matroids" ︡b62e2b6e-0d1a-42ef-a3ca-5ad1d3ae37b3︡{"stdout":"--loading configuration for package \"Graphs\" from file /home/user/.Macaulay2/init-Graphs.m2\n--loading configuration for package \"FourTiTwo\" from file /home/user/.Macaulay2/init-FourTiTwo.m2\n--loading configuration for package \"Posets\" from file /home/user/.Macaulay2/init-Posets.m2\n\no1000000003 = Matroids\n\no1000000003 : Package"}︡{"done":true}︡ ︠7a2bc93b-2214-4e28-a37c-26f7fbd325b6s︠ M = matroid({a, matrix{{-1.2},{3.78}}, x, set{4,6}, -9}, {{a, x}, {x, -9}}) ︡1771a4d2-5c5c-4469-a433-e64d4177908a︡{"stdout":"a matroid of rank 2 on 5 elements\n\nMatroid"}︡{"done":true}︡ ︠5b78e710-c128-4e61-aa51-a72b1995c83ds︠ peek M ︡435a7092-7761-424c-a23a-8d49e1b80bbe︡{"stdout":"Matroid{bases => {set {0, 2}, set {2, 4}}}\n cache => CacheTable{...2...}\n groundSet => set {0, 1, 2, 3, 4}\n rank => 2"}︡{"done":true}︡ ︠260ea253-908a-4235-b1f1-215a95113505s︠ M_{0,1,4} ︡8843129c-2a5c-4ed0-9293-42c42521b3f5︡{"stdout":"{a, | -1.2 |, -9}\n | 3.78 |\n\nList"}︡{"done":true}︡ ︠2f6b6f40-23f7-4947-8e9a-87178cee628b︠