pax_global_header 0000666 0000000 0000000 00000000064 15136200257 0014513 g ustar 00root root 0000000 0000000 52 comment=e78cd796f8e750d0c526425034fcecc0f12942bc Macaulay2-Jupyter-Kernel-0.8.0/ 0000775 0000000 0000000 00000000000 15136200257 0016214 5 ustar 00root root 0000000 0000000 Macaulay2-Jupyter-Kernel-0.8.0/.github/ 0000775 0000000 0000000 00000000000 15136200257 0017554 5 ustar 00root root 0000000 0000000 Macaulay2-Jupyter-Kernel-0.8.0/.github/workflows/ 0000775 0000000 0000000 00000000000 15136200257 0021611 5 ustar 00root root 0000000 0000000 Macaulay2-Jupyter-Kernel-0.8.0/.github/workflows/test.yml 0000664 0000000 0000000 00000001044 15136200257 0023312 0 ustar 00root root 0000000 0000000 name: Test on: workflow_dispatch: pull_request: jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: actions/setup-python@v6 with: cache: pip - name: Install Macaulay2 run: sudo apt-get install -y macaulay2 --no-install-recommends - name: Build kernel run: pip install . - name: Install kernel run: python3 -m m2_kernel install --user - name: Test kernel run: | pip install .[test] python3 -m unittest Macaulay2-Jupyter-Kernel-0.8.0/CHANGELOG.md 0000664 0000000 0000000 00000011070 15136200257 0020024 0 ustar 00root root 0000000 0000000 ## [0.8.0] - Now uses [Metakernel](https://github.com/Calysto/metakernel), adding a wide variety of new features. For example, there are quite a few new [magics](https://metakernel.readthedocs.io/en/latest/source/README.html). - Mode magics have a slightly different syntax, e.g., use `%mode texmacs` instead of `--%mode=texmacs`. - The mode magics have been updated. The only three options are `webapp` (the new default), `texmacs`, and `standard`. - There is no more `timeout` magic. Instead, the kernel may be interrupted at any time by the client, e.g., by pressing the ■ button in Jupyter Lab. - The installation step is slightly different. Use `python3 -m m2_kernel install` (likely with the `--user` option) instead of `python3 -m m2_kernel.install`. - In `webapp` mode, links in `help`, `locate`, `code`, etc. output now point to the Macaulay2 webpage. - The `9,0` keyboard shortcut for restarting the kernel and clearing has been removed. However, this operation is still available under the "Kernel" menu in Jupyter Lab. - When `show` is used to show a local image (e.g., when using `displayGraph` in the *Graphs* package), the image now appears in an output cell. - Simple unit tests have been added, using [jupyter_kernel_test](https://github.com/jupyter/jupyter_kernel_test). ## [0.7.0] - Now maintained by the Macaulay2 organization. - Update to work with Notebook 7. - Add "webapp" mode. - Syntax highlighting in code cells in Notebook & JupyterLab has been moved to [codemirror-lang-macaulay2](https://github.com/d-torrance/codemirror-lang-macaulay2) and [jupyterlab-macaulay2](https://github.com/d-torrance/jupyterlab-macaulay2). ## [0.6.7] - Bug fixes ## [0.6.6] - Clean up asset installation - codemirror and kernel spec. - Add custom shortcuts. - Add custom help link. ## [0.6.5] - Guard against echo in pexpect. - Added `9,0` as a kernel-restart-and-clear keyboard shortcut. - Added `debug` interpreter option. - Added `original` display mode, returning the same output as M2's interactive session, making it easy to copy output in text-only context. - Other small tweaks. ## [0.6.0] Major changes addressing stability and performance - Rewrote the REPL part: * It no longer uses regexes (except for inferring the input \#). This had a tremendous effect on stability and speed. * Added finer timeout control. Now if a statement timeouts, then whole cell execution is interrupted, and this is clearly reported to the client. * Macaulay2 exceptions and stdout are always printed to the cell's stdout. I removed stderr formatting, since it did not fit nicely with the rest. * Decoupled the REPL from the kernel-proper class. It can now be used directly in Python3. Will add demo later. ## [0.5.2] - Put codemirror mode in the correct place. This fixes GET 404 error that prevented syntax highlighting when running remotely. This isn't documented at all but the fix works fine. - Add comment in Macaulay2 using Cmd-/ or Ctrl-/. ## [0.5.1] - Add the nbextension to the distribution. ## [0.5.0] - Capture TIMEOUT exceptions. - Send ^C control to proc when needed. - Redirect M2 errors to stderr always. - Added raw mode. ## [0.4.0] - Client-side syntax highlighting. ## [0.3.2] - Added `pretty` display mode. ## [0.3.0] - Add robust cell magic support. - Minor syntax highlighting changes. ## [0.2.3] - Bug fixes. - Changed mode `normal` to `default`. - Syntax hightlight changes. ## [0.2.0] - 2019-01-18 - Stable IO processing. Not aware of bugs or caveats. - In normal mode, code in cells evaluates the same way as in M2 interactive mode. - Output now is only presented for the last statement in a block. This is intentional and parallels IPython. M2 errors still need to be propagated though. See TODO. - Implements basic cell magic (as IPython does) and configuration. - Can provide configuration script using `$M2JK_CONFIG`. - Two output modes: *normal* and *texmacs*. Another one, *pretty*, is commented out. See TODO. - Modes can be specified in config file at start up, or during execution. - *normal* is exactly the same as M2 interactive mode. - *texmacs* prints and renders the output value the way your browser does. - Timeouts can be set for the allowed delay for a block calculation (plus transport). They can be set in a configure script or interactively. - Profiling didn't show any speed up using byte-strings over regular strings for both matching and transport, so kept current set up. ## [Unreleased] - Basic implementation. Many bugs. - Code organized properly as a pip3 module. - Some highlighting on the client side. Macaulay2-Jupyter-Kernel-0.8.0/LICENSE 0000664 0000000 0000000 00000002065 15136200257 0017224 0 ustar 00root root 0000000 0000000 MIT License Copyright (c) 2018-2019 Radoslav Zlatev Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Macaulay2-Jupyter-Kernel-0.8.0/MANIFEST.in 0000664 0000000 0000000 00000000056 15136200257 0017753 0 ustar 00root root 0000000 0000000 graft m2_kernel/assets graft m2_kernel/images Macaulay2-Jupyter-Kernel-0.8.0/README.md 0000664 0000000 0000000 00000005447 15136200257 0017505 0 ustar 00root root 0000000 0000000 # M2JK — Jupyter kernel for Macaulay2 [](https://pypi.org/project/macaulay2-jupyter-kernel/) [](#) > Beta Testing! You can now use [Jupyter](http://www.jupyter.org) (Notebook or Lab) as a front-end for [Macaulay2](https://macaulay2.com). See the [demo][demo] for sample use and an outline of the kernel-specific features. For bugs or requests, open an issue. For recent changes, see the [changelog](CHANGELOG.md).  ## Requirements You need a recent version of Python and `pip`. Python 3 is recommended for build installs and necessary for source installs. You can install Jupyter directly from PyPI by ```bash pip3 install --upgrade pip pip3 install jupyter ``` Macaulay2 needs to be installed and on your path. If you are using Emacs as your front-end, it already is, but you can test it by `which M2`. Otherwise, you can achieve that by running `setup()` from within an M2 session. Alternatively, you can configure M2JK to use a specific binary. ## Installation You can install the latest development version from source by ```bash $ pip3 install git+https://github.com/Macaulay2/Macaulay2-Jupyter-Kernel $ python3 -m m2_kernel install ``` ## Docker A docker image packing `v0.6.7-beta` and Macaulay2 version `1.18` is available as `rzlatev/m2jk`. To run locally, you need to map port `8890`. ```bash $ docker run -p 8890:8890 rzlatev/m2jk & ``` ## Running the notebook Once the installation is complete, you need to start (or restart) Jupyter by ```bash $ jupyter notebook & ``` This shoud fire up a browser for you. If not, copy the output URL into one. Then select File ⇨ New Notebook ⇨ M2 from the main menu. ## License This software is not part of Macaulay2 and is released under the MIT License. [demo]: https://nbviewer.jupyter.org/github/Macaulay2/Macaulay2-Jupyter-Kernel/blob/master/demo/demo.ipynb [features]: https://nbviewer.jupyter.org/github/Macaulay2/Macaulay2-Jupyter-Kernel/blob/master/demo/features.ipynb [m2book]: https://nbviewer.jupyter.org/github/Macaulay2/Macaulay2-Jupyter-Kernel/blob/master/demo/m2book.ipynb Macaulay2-Jupyter-Kernel-0.8.0/TODO 0000664 0000000 0000000 00000002243 15136200257 0016705 0 ustar 00root root 0000000 0000000 Next Release: ☐ add line number in `original` ☐ keep no more than a single blank line at a time ✔ add kernel.js to the kernelspec and move shortcuts code there @done(19-01-30 20:00) ✔ fix install locations for codemirror @done(19-01-30 19:59) ☐ add kernel uninstall ☐ add actual M2 version to banner @started(19-01-30 21:18) ☐ improve client-side syntax indentation ✔ fix parsing input lines that are longer than 80 (printWidth) chars @done(19-01-30 10:51) Testing: ✔ macOS @done(19-01-30 20:22) ✔ Linux x64_86 @done(19-01-30 20:22) ☐ Linux armv7/8 @started(19-01-30 21:19) ✔ Docker x64_86 @done(19-02-01 10:28) ☐ write unit tests ☐ better testing on travis-ci Remote Server: ✔ write a docker file for M2JK + Jupyter Notebook + M2 @started(19-01-30 20:23) @done(19-02-01 10:28) @lasted(1d14h5m13s) ✔ try it on AWS or DO @done(19-02-01 10:28) ☐ wiki docs Client-side JavaScript and CSS: ☐ add ^C trigger making this work in the REPL would take a litte work ☐ add an emacs-like colors theme ☐ may be look into https://github.com/marks1024/language-macaulay2 Macaulay2-Jupyter-Kernel-0.8.0/demo/ 0000775 0000000 0000000 00000000000 15136200257 0017140 5 ustar 00root root 0000000 0000000 Macaulay2-Jupyter-Kernel-0.8.0/demo/demo.ipynb 0000664 0000000 0000000 00000043172 15136200257 0021136 0 ustar 00root root 0000000 0000000 { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Demo" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can write Macaulay2 code as is.\n", "This includes comments, whitespaces, semicolons (or lack thereof), multiple-line statements, loading packages, printing to stdout, handling exceptions, etc." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Syntax highlighting and code completion is available. Use `0,0` to quickly restart the kernel." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/html": [ "
o1 = $\\left\\{1,\\:9,\\:25,\\:49,\\:81,\\:121,\\:169,\\:225,\\:289\\right\\}$
\n", "o1 : List
\n" ], "text/plain": [ "o1 = $\\left\\\\{1,\\:9,\\:25,\\:49,\\:81,\\:121,\\:169,\\:225,\\:289\\right\\\\}$\n", "\n", "o1 : List\n", "\n" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "for i from 1 to random(20) list if i%2==1 then i*i else continue" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can write text and mathematics directly along your code.\n", "Jupyter supports Markdown fully and $\\TeX$ to a degree.\n", "For example:\n", "\n", "The cell below defines the twisted cubic $C$ over the rationals in two ways —\n", "as $\\text{Proj}~\\mathbb{Q}[s^3, s^2t, st^2, t^3]$, and as the ideal of maximal minors of\n", "$\n", "g=\n", "\\begin{bmatrix}\n", "x_0& x_1& x_2\\\\\n", "x_1& x_2& x_3\n", "\\end{bmatrix}\n", "$.\n", "It then checks that the two definitions agree using Macaulay2's `assert`." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "o2 = $S$
\n", "o2 : PolynomialRing
\n", "o3 = $R$
\n", "o3 : PolynomialRing
\n", "o4 = $\\texttt{map}{}\\left(R,\\,S,\\,\\left\\{s^{3},\\:s^{2}t,\\:s\\,t^{2},\\:t^{3}\\right\\}\\right)$
\n", "o4 : RingMap $R\\,\\longleftarrow \\,S$
\n", "o5 = $\\left(\\!\\begin{array}{ccc}\r\n", "x_{0}&x_{1}&x_{2}\\\\\r\n", "x_{1}&x_{2}&x_{3}\r\n", "\\end{array}\\!\\right)$
\n", "o5 : Matrix $S^{2}\\,\\longleftarrow \\,S^{3}$
\n", "o6 = $\\texttt{ideal}{}\\left(x_{2}^{2}-x_{1}x_{3},\\,x_{1}x_{2}-x_{0}x_{3},\\,x_{1}^{2}-x_{0}x_{2}\\right)$
\n", "o6 : Ideal of $S$
\n" ], "text/plain": [ "o2 = $S$\n", "\n", "o2 : PolynomialRing\n", "\n", "o3 = $R$\n", "\n", "o3 : PolynomialRing\n", "\n", "o4 =\n", "$\\texttt{map}{}\\left(R,\\,S,\\,\\left\\\\{s^{3},\\:s^{2}t,\\:s\\,t^{2},\\:t^{3}\\right\\\\}\\right)$\n", "\n", "o4 : RingMap $R\\,\\longleftarrow \\,S$\n", "\n", "o5 = $\\left(\\\\!\\begin{array}{ccc} x_{0}&x_{1}&x_{2}\\\\\\ x_{1}&x_{2}&x_{3}\n", "\\end{array}\\\\!\\right)$\n", "\n", "o5 : Matrix $S^{2}\\,\\longleftarrow \\,S^{3}$\n", "\n", "o6 =\n", "$\\texttt{ideal}{}\\left(x_{2}^{2}-x_{1}x_{3},\\,x_{1}x_{2}-x_{0}x_{3},\\,x_{1}^{2}-x_{0}x_{2}\\right)$\n", "\n", "o6 : Ideal of $S$\n", "\n" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "S = QQ[x_0..x_3] -- the embedding space\n", "R = QQ[s,t] -- PP^1 \n", "f = map(R,S,{s^3, s^2*t, s*t^2, t^3})\n", "g = matrix({{x_0,x_1,x_2},{x_1,x_2,x_3}})\n", "C = ker f\n", "assert(C == minors(2, g))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that failed assertions do propagate to stdout." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "stdio:8:6:(3): error: assertion failed\n", "
o9 = $-2\\,\\texttt{P}_{0}+3\\,\\texttt{P}_{1}$
\n", "o9 : ProjectiveHilbertPolynomial
\n" ], "text/plain": [ "\n", " stdio:8:6:(3): error: assertion failed\n", "\n", "o9 = $-2\\,\\texttt{P}_{0}+3\\,\\texttt{P}_{1}$\n", "\n", "o9 : ProjectiveHilbertPolynomial\n", "\n" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "assert(false)\n", "hilbertPolynomial C" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Long input is OK. " ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "o10 = $20\\,s^{501}t^{501}$
\n", "o10 : $R$
\n" ], "text/plain": [ "o10 = $20\\,s^{501}t^{501}$\n", "\n", "o10 : $R$\n", "\n" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "q = poly \"s501t501+s501t501+s501t501+s501t501+s501t501+s501t501+s501t501+s501t501+s501t501+s501t501+s501t501+s501t501+s501t501+s501t501+s501t501+s501t501+s501t501+s501t501+s501t501+s501t501\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Output can be suppressed as usual." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\n", "\n" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "degree C;" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "M2JK implements a set of *magic* commands. The name is borrowed from IPython.\n", "It can be added as `%o12 = $\\underset{\\vphantom{\\Big|}0}{S^{1}}\\,\\xleftarrow{\\left(\\!\\begin{array}{ccc}\r\n", "x_{1}^{2}-x_{0}x_{2}&x_{1}x_{2}-x_{0}x_{3}&x_{2}^{2}-x_{1}x_{3}\r\n", "\\end{array}\\!\\right)}\\,\\underset{\\vphantom{\\Big|}1}{S^{3}}\\,\\xleftarrow{\\left(\\!\\begin{array}{cc}\r\n", "-x_{2}&x_{3}\\\\\r\n", "x_{1}&-x_{2}\\\\\r\n", "-x_{0}&x_{1}\r\n", "\\end{array}\\!\\right)}\\,\\underset{\\vphantom{\\Big|}2}{S^{2}}\\,\\xleftarrow{0}\\,\\underset{\\vphantom{\\Big|}3}{0}$
\n", "o12 : ChainComplex
\n", "o13 = $\\left(\\!\\begin{array}{ccc}\r\n", "x_{0}&x_{1}&x_{2}\\\\\r\n", "x_{1}&x_{2}&x_{3}\r\n", "\\end{array}\\!\\right)$
\n", "o13 : Matrix $S^{2}\\,\\longleftarrow \\,S^{3}$
\n" ], "text/plain": [ "o12 =\n", "$\\underset{\\vphantom{\\Big|}0}{S^{1}}\\,\\xleftarrow{\\left(\\\\!\\begin{array}{ccc}\n", "x_{1}^{2}-x_{0}x_{2}&x_{1}x_{2}-x_{0}x_{3}&x_{2}^{2}-x_{1}x_{3}\n", "\\end{array}\\\\!\\right)}\\,\\underset{\\vphantom{\\Big|}1}{S^{3}}\\,\\xleftarrow{\\left(\\\\!\\begin{array}{cc}\n", "-x_{2}&x_{3}\\\\\\ x_{1}&-x_{2}\\\\\\ -x_{0}&x_{1}\n", "\\end{array}\\\\!\\right)}\\,\\underset{\\vphantom{\\Big|}2}{S^{2}}\\,\\xleftarrow{0}\\,\\underset{\\vphantom{\\Big|}3}{0}$\n", "\n", "o12 : ChainComplex\n", "\n", "o13 = $\\left(\\\\!\\begin{array}{ccc} x_{0}&x_{1}&x_{2}\\\\\\ x_{1}&x_{2}&x_{3}\n", "\\end{array}\\\\!\\right)$\n", "\n", "o13 : Matrix $S^{2}\\,\\longleftarrow \\,S^{3}$\n", "\n" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%mode webapp\n", "res C\n", "g" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n" ], "text/plain": [ "o14 = S1<-S3<-S2<-S00123\n", "\n", "o14 : ChainComplex\n", "\n", "o15 = (x0x1x2x1x2x3)\n", "\n", "o15 : Matrix S2<-S3\n", "\n" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%mode texmacs\n", "res C\n", "g" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\r\n", " 1 3 2\r\n", "o16 = S <-- S <-- S <-- 0\r\n", " \r\n", " 0 1 2 3\r\n", "\r\n", "o16 : ChainComplex\r\n", "\r\n", "\r\n", "o17 = | x_0 x_1 x_2 |\r\n", " | x_1 x_2 x_3 |\r\n", "\r\n", " 2 3\r\n", "o17 : Matrix S <-- S\r\n", "\r\n" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%mode standard\n", "res C\n", "g" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can preset `mode`, as well as the M2-executable path.\n", "This is done by creating an INI file like so:\n", "```\n", "[magic]\n", "execpath = .../usr-dist/x86_64-Darwin-MacOS-10.14.1/bin/M2-binary\n", "mode = standard\n", "```\n", "You can then tell M2JK to use it by setting the environment variable `$M2JK_CONFIG`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Many more magic command are available. See https://github.com/calysto/metakernel/blob/main/metakernel/magics/README.md." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, more complex language tools are available in the same way they are in an interactive session.\n", "Note, however, that there are limits to the number of character you can transmit.\n", "Additionally, printing to file (including STDOUT, STDERR) is an extremely costly operation,\n", "so timeouts may occur." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\r\n", "o18 = SchurRings\r\n", "\r\n", "o18 : Package\r\n", "\r\n", "\r\n", "o19 = S\r\n", "\r\n", "o19 : SchurRing\r\n", "\r\n", "\r\n", "o20 = s\r\n", " 2,1,1\r\n", "\r\n", "o20 : S\r\n", "\r\n", "\r\n", "\r\n", "\r\n", "o23 = /usr/share/Macaulay2/Core/option.m2:15:14-18:8: --source code:\r\n", " (opts,f) -> args -> (\r\n", " -- Common code for functions created with >> to process options and arguments.\r\n", " uncurry(f, override (opts,args))\r\n", " )\r\n", " | symbol class value location of symbol\r\n", " | ------ ----- ----- ------------------ \r\n", " | f FunctionClosure FunctionClosure[/usr/share/Macaulay2/Core/methods.m2:1. /usr/share/Macaulay2/Core/option.m2:15:8-15:9\r\n", " | opts OptionTable OptionTable{EHPVariables => (e, h, p)} /usr/share/Macaulay2/Core/option.m2:15:3-15:7\r\n", " | GroupActing => GL \r\n", " | SVariable => s \r\n", " | -- function f:\r\n", " | /usr/share/Macaulay2/Core/methods.m2:154:67-154:105: --source code:\r\n", " | methodFunction := new MethodFunctionWithOptions from (opts >> o -> arg -> innerMethodFunction(o,arg));\r\n", " | | symbol class value location of symbol\r\n", " | | ------ ----- ----- ------------------ \r\n", " | | opts OptionTable OptionTable{EHPVariables => (e, h, p)} /usr/share/Macaulay2/Core/methods.m2:151:37-151:41\r\n", " | | GroupActing => GL \r\n", " | | SVariable => s \r\n", " | | innerMethodFunction CompiledFunctionClosure CompiledFunctionClosure[] /usr/share/Macaulay2/Core/methods.m2:153:11-153:30\r\n", " | | outputs List {false, false, false, false} /usr/share/Macaulay2/Core/methods.m2:151:42-151:49\r\n", " | | methopts OptionTable OptionTable{Binary => false . /usr/share/Macaulay2/Core/methods.m2:151:28-151:36\r\n", " | | Dispatch => {Thing, Thing, Thing, Thing} . \r\n", " | | Options => {EHPVariables => (e, h, p), SVa. \r\n", " | | TypicalValue => Thing . \r\n", " | | methodFunction MethodFunctionWithOptions schurRing /usr/share/Macaulay2/Core/methods.m2:154:5-154:19 \r\n", " | -- option table opts:\r\n", " | OptionTable{EHPVariables => (e, h, p)}\r\n", " | GroupActing => GL\r\n", " | SVariable => s\r\n", "\r\n" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "loadPackage(\"SchurRings\")\n", "S = schurRing(QQ,s,4)\n", "p = S_(2,1,1)\n", "debug Core\n", "assert(rawCompare(raw p, raw p)==0)\n", "code schurRing" ] } ], "metadata": { "kernelspec": { "display_name": "Macaulay2", "language": "", "name": "m2" }, "language_info": { "file_extension": ".m2", "mimetype": "text/x-macaulay2", "name": "Macaulay2" } }, "nbformat": 4, "nbformat_minor": 4 } Macaulay2-Jupyter-Kernel-0.8.0/demo/m2book.ipynb 0000664 0000000 0000000 00000027056 15136200257 0021406 0 ustar 00root root 0000000 0000000 { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "*Macaulay2* is a software system for research in algebraic geometry by Daniel R. Grayson and Michael E. Stillman.\n", "It is available online in source code form and compiled for various architectures at https://macaulay2.com/.\n", "\n", "What follows is a reproduction of the code (and some text) from the preface to\n", "\n", "> “Computations in algebraic geometry with *Macaulay 2*”,\n", "David Eisenbud,\n", "Daniel R. Grayson,\n", "Michael Stillman, and\n", "Bernd Sturmfels (Eds.) (2002) (DOI: 10.1007/978-3-662-04851-1)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "o1 = $\\frac{68}{55}$
\n", "o1 : ${\\mathbb Q}$
\n" ], "text/plain": [ "o1 = $\\frac{68}{55}$\n", "\n", "o1 : ${\\mathbb Q}$\n", "\n" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "3/5 + 7/11" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "o2 = $93\\,326\\,215\\,443\\,944\\,152\\,681\\,699\\,238\\,856\\,266\\,700\\,490\\,715\\,968\\,264\\,381\\,621\\,468\\,592\\,963\\,895\\,217\\,599\\,993\\,229\\,915\\,608\\,941\\,463\\,976\\,156\\,518\\,286\\,253\\,697\\,920\\,827\\,223\\,758\\,251\\,185\\,210\\,916\\,864\\,000\\,000\\,000\\,000\\,000\\,000\\,000\\,000$
\n" ], "text/plain": [ "o2 =\n", "$93\\,326\\,215\\,443\\,944\\,152\\,681\\,699\\,238\\,856\\,266\\,700\\,490\\,715\\,968\\,264\\,381\\,621\\,468\\,592\\,963\\,895\\,217\\,599\\,993\\,229\\,915\\,608\\,941\\,463\\,976\\,156\\,518\\,286\\,253\\,697\\,920\\,827\\,223\\,758\\,251\\,185\\,210\\,916\\,864\\,000\\,000\\,000\\,000\\,000\\,000\\,000\\,000$\n", "\n" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "100!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let’s give a hint of the breadth of types of mathematical objects available in *Macaulay2* with some examples. In *Macaulay2* one defines a quotient ring of a polynomial ring $R$ over the rational numbers by entering a command such as the one below." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "o3 = $R$
\n", "o3 : QuotientRing
\n" ], "text/plain": [ "o3 = $R$\n", "\n", "o3 : QuotientRing\n", "\n" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "R = QQ[x,y,z]/(x^3-y^3-z^3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Having done that, we can compute in the ring." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "o4 = $3\\,x^{2}y+3\\,x\\,y^{2}+2\\,y^{3}+3\\,x^{2}z+6\\,x\\,y\\,z+3\\,y^{2}z+3\\,x\\,z^{2}+3\\,y\\,z^{2}+2\\,z^{3}$
\n", "o4 : $R$
\n" ], "text/plain": [ "o4 =\n", "$3\\,x^{2}y+3\\,x\\,y^{2}+2\\,y^{3}+3\\,x^{2}z+6\\,x\\,y\\,z+3\\,y^{2}z+3\\,x\\,z^{2}+3\\,y\\,z^{2}+2\\,z^{3}$\n", "\n", "o4 : $R$\n", "\n" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(x+y+z)^3" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can make matrices over the ring." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "o5 = $\\left(\\!\\begin{array}{ccc}\r\n", "x&y&z\r\n", "\\end{array}\\!\\right)$
\n", "o5 : Matrix $R^{1}\\,\\longleftarrow \\,R^{3}$
\n" ], "text/plain": [ "o5 = $\\left(\\\\!\\begin{array}{ccc} x&y&z \\end{array}\\\\!\\right)$\n", "\n", "o5 : Matrix $R^{1}\\,\\longleftarrow \\,R^{3}$\n", "\n" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b = vars R" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "o6 = $\\left(\\!\\begin{array}{ccc}\r\n", "x^{2}&y^{2}&z^{2}\r\n", "\\end{array}\\!\\right)$
\n", "o6 : Matrix $R^{1}\\,\\longleftarrow \\,R^{3}$
\n" ], "text/plain": [ "o6 = $\\left(\\\\!\\begin{array}{ccc} x^{2}&y^{2}&z^{2} \\end{array}\\\\!\\right)$\n", "\n", "o6 : Matrix $R^{1}\\,\\longleftarrow \\,R^{3}$\n", "\n" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "c = matrix {{x^2,y^2,z^2}}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can make modules over the ring." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "o7 = $\\texttt{cokernel}\\ \\left(\\!\\begin{array}{ccc}\r\n", "x&y&z\r\n", "\\end{array}\\!\\right)$
\n", "o7 : $R$-module, quotient of $R^{1}$
\n" ], "text/plain": [ "o7 = $\\texttt{cokernel}\\ \\left(\\\\!\\begin{array}{ccc} x&y&z\n", "\\end{array}\\\\!\\right)$\n", "\n", "o7 : $R$-module, quotient of $R^{1}$\n", "\n" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M = coker b" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/html": [ "o8 = $\\texttt{image}\\ \\begin{array}{l}\\left\\{2\\right\\}\\vphantom{x-y^{2}0-z^{2}}\\\\\\left\\{2\\right\\}\\vphantom{-yx^{2}-z^{2}0}\\\\\\left\\{2\\right\\}\\vphantom{-z0y^{2}x^{2}}\\end{array}\\left(\\!\\begin{array}{cccc}\r\n", "\\vphantom{\\left\\{2\\right\\}}x&-y^{2}&0&-z^{2}\\\\\r\n", "\\vphantom{\\left\\{2\\right\\}}-y&x^{2}&-z^{2}&0\\\\\r\n", "\\vphantom{\\left\\{2\\right\\}}-z&0&y^{2}&x^{2}\r\n", "\\end{array}\\!\\right)$
\n", "o8 : $R$-module, submodule of $R^{3}$
\n" ], "text/plain": [ "o8 = $\\texttt{image}\\\n", "\\begin{array}{l}\\left\\\\{2\\right\\\\}\\vphantom{x-y^{2}0-z^{2}}\\\\\\\\\\left\\\\{2\\right\\\\}\\vphantom{-yx^{2}-z^{2}0}\\\\\\\\\\left\\\\{2\\right\\\\}\\vphantom{-z0y^{2}x^{2}}\\end{array}\\left(\\\\!\\begin{array}{cccc}\n", "\\vphantom{\\left\\\\{2\\right\\\\}}x&-y^{2}&0&-z^{2}\\\\\\\n", "\\vphantom{\\left\\\\{2\\right\\\\}}-y&x^{2}&-z^{2}&0\\\\\\\n", "\\vphantom{\\left\\\\{2\\right\\\\}}-z&0&y^{2}&x^{2} \\end{array}\\\\!\\right)$\n", "\n", "o8 : $R$-module, submodule of $R^{3}$\n", "\n" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "N = ker c" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can make projective resolutions of modules." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "o9 = $\\underset{\\vphantom{\\Big|}0}{R^{1}}\\,\\xleftarrow{\\left(\\!\\begin{array}{ccc}\r\n", "x&y&z\r\n", "\\end{array}\\!\\right)}\\,\\underset{\\vphantom{\\Big|}1}{R^{3}}\\,\\xleftarrow{\\left(\\!\\begin{array}{cccc}\r\n", "0&-z&-y&x^{2}\\\\\r\n", "-z&0&x&-y^{2}\\\\\r\n", "y&x&0&-z^{2}\r\n", "\\end{array}\\!\\right)}\\,\\underset{\\vphantom{\\Big|}2}{R^{4}}\\,\\xleftarrow{\\left(\\!\\begin{array}{cccc}\r\n", "x&-y^{2}&z^{2}&0\\\\\r\n", "-y&x^{2}&0&z^{2}\\\\\r\n", "z&0&x^{2}&y^{2}\\\\\r\n", "0&z&y&x\r\n", "\\end{array}\\!\\right)}\\,\\underset{\\vphantom{\\Big|}3}{R^{4}}\\,\\xleftarrow{\\left(\\!\\begin{array}{cccc}\r\n", "-x^{2}&-y^{2}&z^{2}&0\\\\\r\n", "-y&-x&0&-z^{2}\\\\\r\n", "z&0&-x&-y^{2}\\\\\r\n", "0&z&y&x^{2}\r\n", "\\end{array}\\!\\right)}\\,\\underset{\\vphantom{\\Big|}4}{R^{4}}$
\n", "o9 : ChainComplex
\n" ], "text/plain": [ "o9 =\n", "$\\underset{\\vphantom{\\Big|}0}{R^{1}}\\,\\xleftarrow{\\left(\\\\!\\begin{array}{ccc}\n", "x&y&z\n", "\\end{array}\\\\!\\right)}\\,\\underset{\\vphantom{\\Big|}1}{R^{3}}\\,\\xleftarrow{\\left(\\\\!\\begin{array}{cccc}\n", "0&-z&-y&x^{2}\\\\\\ -z&0&x&-y^{2}\\\\\\ y&x&0&-z^{2}\n", "\\end{array}\\\\!\\right)}\\,\\underset{\\vphantom{\\Big|}2}{R^{4}}\\,\\xleftarrow{\\left(\\\\!\\begin{array}{cccc}\n", "x&-y^{2}&z^{2}&0\\\\\\ -y&x^{2}&0&z^{2}\\\\\\ z&0&x^{2}&y^{2}\\\\\\ 0&z&y&x\n", "\\end{array}\\\\!\\right)}\\,\\underset{\\vphantom{\\Big|}3}{R^{4}}\\,\\xleftarrow{\\left(\\\\!\\begin{array}{cccc}\n", "-x^{2}&-y^{2}&z^{2}&0\\\\\\ -y&-x&0&-z^{2}\\\\\\ z&0&-x&-y^{2}\\\\\\ 0&z&y&x^{2}\n", "\\end{array}\\\\!\\right)}\\,\\underset{\\vphantom{\\Big|}4}{R^{4}}$\n", "\n", "o9 : ChainComplex\n", "\n" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "res M" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can make projective varieties." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "o10 = $X$
\n", "o10 : ProjectiveVariety
\n" ], "text/plain": [ "o10 = $X$\n", "\n", "o10 : ProjectiveVariety\n", "\n" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "X = Proj R" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can make coherent sheaves and compute their cohomology." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "o11 = ${\\mathbb Q}^{1}$
\n", "o11 : ${\\mathbb Q}$-module, free
\n" ], "text/plain": [ "o11 = ${\\mathbb Q}^{1}$\n", "\n", "o11 : ${\\mathbb Q}$-module, free\n", "\n" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "HH^1 cotangentSheaf X" ] } ], "metadata": { "kernelspec": { "display_name": "Macaulay2", "language": "", "name": "m2" }, "language_info": { "file_extension": ".m2", "mimetype": "text/x-macaulay2", "name": "Macaulay2" } }, "nbformat": 4, "nbformat_minor": 4 } Macaulay2-Jupyter-Kernel-0.8.0/demo/screenshot1.png 0000664 0000000 0000000 00002723355 15136200257 0022125 0 ustar 00root root 0000000 0000000 PNG IHDR L JiCCPICC Profile HWXS[RIhH RK E*I ĐD.*v*Z Y+ZZ(bʛX{;79sJ;N O*Euȓ#BXRX. &Rv\\42t\uQrs@(A! > ^ @O@XYj\j\I@ 2ǓeB~ѾD C8/ xT^%v!+qfsxYX]Jȡb47l\P;8h"Ydfط[93q$#&b}ߋ*{QHGMr*FAl q$7&Zs!+-p5 glF|ΔqLWiZ CoE)1j89bm( fS,m J"BشLYx^'[,sc4@7Y(a' 哢jCԵcBI^SZ}%͍TanRo0Acq