commit 807d7f936edfc705ba524e318bff149e092b9e4a Author: Mickaël Montessinos Date: Mon Feb 26 18:48:12 2024 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..80411db --- /dev/null +++ b/.gitignore @@ -0,0 +1,93 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# IPython Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# dotenv +.env + +# virtualenv +venv/ +ENV/ + +# Spyder project settings +.spyderproject + +# Rope project settings +.ropeproject + +/.travis_ci_gh_pages_deploy_key +/.travis_ci_gh_pages_deploy_key.pub +/gh-pages diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..29918e9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +# Dockerfile for binder +# Reference: https://mybinder.readthedocs.io/en/latest/dockerfile.html#preparing-your-dockerfile + +FROM sagemath/sagemath:latest + +# Copy the contents of the repo in ${HOME} +COPY --chown=sage:sage . ${HOME} + +# Install this package and dependencies +RUN sage -pip install . diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..7853561 --- /dev/null +++ b/README.rst @@ -0,0 +1,64 @@ +============== +Vector Bundles +============== + +This is a `SageMath `_ implementing algorithms for creating and +manipulating Vector Bundles over algebraic curves on finite field. All manipulations are +done using algebra on function fields. + +Installation +------------ + +Local install from source +^^^^^^^^^^^^^^^^^^^^^^^^^ + +Download the source from the git repository:: + + $ git clone https://github.com/sagemath/sage_sample.git + +Change to the root directory and run:: + + $ sage -pip install --upgrade --no-index -v . + +For convenience this package contains a `makefile `_ with this +and other often used commands. Should you wish too, you can use the +shorthand:: + + $ make install + +Usage +----- + + +Once the package is installed, you can use it in Sage with:: + + sage: from vector_bundle import * + +See also the `demo notebook `_ and the documentation. + +Documentation +------------- + +The documentation of the package can be generated using Sage's +``Sphinx`` installation:: + + $ cd docs + $ sage -sh -c "make html" + +Shorthand:: + + $ make doc + +TEST +---- + +To run the test suite of the package, simply run the command:: + + $make test + +from the root of the repository. + +CONTACT +------- + +Mickaël Montessinos: mickael.montessinos@mif.vu.lt diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0 diff --git a/demo.ipynb b/demo.ipynb new file mode 100644 index 0000000..74f1539 --- /dev/null +++ b/demo.ipynb @@ -0,0 +1,234 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# A demo of the vector_bundle package." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "from vector_bundle import *\n", + "F. = FunctionField(GF(101))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Constructing an indecomposable bundle on an elliptic curve\n", + "We construct an indecomposable vector bundle of rank 5 and degree 3 on a function field of genus 1. \n", + "This construction may be done automatically using the ```atiyah_bundle``` function but we break it down step by step." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[Ideal (1) of Maximal order of Function field in y defined by y^2 + 100*x^3 + 100*x]\n", + "[(1)]\n", + "[((x/(x^2 + 1))*y)]\n" + ] + } + ], + "source": [ + "R. = F[]\n", + "K. = F.extension(y^2 - x^3 - x)\n", + "deg_1_bundle = VectorBundle(K, K.places_infinite()[0].divisor())\n", + "E = deg_1_bundle\n", + "print(E.coefficient_ideals())\n", + "print(E.basis_finite())\n", + "print(E.basis_infinite())" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[Ideal (x^2/(x^2 + 3)) of Maximal order of Function field in y defined by y^2 + 100*x^3 + 100*x, Ideal (1) of Maximal order of Function field in y defined by y^2 + 100*x^3 + 100*x]\n", + "[(1, 0), (0, 1)]\n", + "[(1, 0), (100*x^3/(x^2 + 1), (x/(x^2 + 1))*y)]\n" + ] + } + ], + "source": [ + "E = E.extension_by_global_sections()\n", + "print(E.coefficient_ideals())\n", + "print(E.basis_finite())\n", + "print(E.basis_infinite())" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[Ideal (x^2/(x^2 + 3)) of Maximal order of Function field in y defined by y^2 + 100*x^3 + 100*x, Ideal (1) of Maximal order of Function field in y defined by y^2 + 100*x^3 + 100*x]\n", + "[(1, 0), (0, 1)]\n", + "[((x/(x^2 + 1))*y, 0), ((100*x^4/(x^4 + 2*x^2 + 1))*y, x^3/(x^2 + 1))]\n" + ] + } + ], + "source": [ + "E = E.tensor_product(deg_1_bundle)\n", + "print(E.coefficient_ideals())\n", + "print(E.basis_finite())\n", + "print(E.basis_infinite())" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[Ideal (x^2/(x^2 + 3)) of Maximal order of Function field in y defined by y^2 + 100*x^3 + 100*x, Ideal (x^2/(x^2 + 3)) of Maximal order of Function field in y defined by y^2 + 100*x^3 + 100*x, Ideal (x^2/(x^2 + 3)) of Maximal order of Function field in y defined by y^2 + 100*x^3 + 100*x, Ideal (x^2/(x^2 + 3)) of Maximal order of Function field in y defined by y^2 + 100*x^3 + 100*x, Ideal (1) of Maximal order of Function field in y defined by y^2 + 100*x^3 + 100*x]\n", + "[(1, 0, 0, 0, 0), (0, 1, 0, 0, 0), (0, 0, 1, 0, 0), (0, 0, 0, 1, 0), (0, 0, 0, 0, 1)]\n", + "[(1, 0, 0, 0, 0), (0, 1, 0, 0, 0), (0, 0, 1, 0, 0), (100*x^3/(x^2 + 1), 0, 100/x^2*y, (x/(x^2 + 1))*y, 0), (x^6/(x^4 + 2*x^2 + 1), (100*x^4/(x^4 + 2*x^2 + 1))*y, (x/(x^2 + 1))*y, (100*x^4/(x^4 + 2*x^2 + 1))*y, x^3/(x^2 + 1))]\n" + ] + } + ], + "source": [ + "E = E.extension_by_global_sections()\n", + "print(E.coefficient_ideals())\n", + "print(E.basis_finite())\n", + "print(E.basis_infinite())" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "5\n", + "3\n" + ] + } + ], + "source": [ + "print(E.rank())\n", + "print(E.degree())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We check the algebra of global endomorphisms of E to ensure that it is indecomposable." + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[\n", + "[1 0 0 0 0]\n", + "[0 1 0 0 0]\n", + "[0 0 1 0 0]\n", + "[0 0 0 1 0]\n", + "[0 0 0 0 1]\n", + "]" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "E.end().h0()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Constructing a weakly stable vector bundle following Savin's method\n", + "We construct a weakly stable vector bundle of rank 3 and degree 5 by successive extensions by line bundles. \n", + "See [Sav07] in the references for details. \n", + "This, again, may be achieved directly using the ```savin_bundle``` function." + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n", + "5\n", + "[Ideal (1, 1/x*y) of Maximal order of Function field in y defined by y^2 + 100*x^3 + 100*x, Ideal (1) of Maximal order of Function field in y defined by y^2 + 100*x^3 + 100*x, Ideal (1) of Maximal order of Function field in y defined by y^2 + 100*x^3 + 100*x]\n", + "[(1, 0, 0), (0, 1, 0), (0, 0, 1)]\n", + "[(1, 0, 0), ((100*x/(x^2 + 1))*y, x^3/(x^2 + 1), 0), (0, (100*x^4/(x^4 + 2*x^2 + 1))*y, x^3/(x^2 + 1))]\n" + ] + } + ], + "source": [ + "F = VectorBundle(K, 2*K.places_infinite()[0].divisor())\n", + "F1 = VectorBundle(K, K.places_finite()[0].divisor())\n", + "E1 = F1\n", + "E2 = F.non_trivial_extension(E1)\n", + "E3 = F.non_trivial_extension(E2)\n", + "print(E3.rank())\n", + "print(E3.degree())\n", + "print(E3.coefficient_ideals())\n", + "print(E3.basis_finite())\n", + "print(E3.basis_infinite())" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SageMath 10.3.beta8", + "language": "sage", + "name": "sagemath" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.2" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..e949e5c --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,177 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = build + +# User-friendly check for sphinx-build +ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) +$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) +endif + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " xml to make Docutils-native XML files" + @echo " pseudoxml to make pseudoxml-XML files for display purposes" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/slabbe.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/slabbe.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/slabbe" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/slabbe" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +latexpdfja: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through platex and dvipdfmx..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +xml: + $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml + @echo + @echo "Build finished. The XML files are in $(BUILDDIR)/xml." + +pseudoxml: + $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml + @echo + @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..481730a --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,445 @@ +# -*- coding: utf-8 -*- +# +# sample documentation build configuration file, +# inspried by slabbe configuration file created sphinx-quickstart +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +# General information about the project. +project = u"A SageMath package implementing vector bundles on algebraic curves using only function fields" +copyright = u'2024, Mickaël Montessinos' +package_name = 'vector_bundle' +package_folder = "../../" +authors = u"Mickaël Montessinos" + +import six +import sys +import os +from sage.env import SAGE_DOC_SRC, SAGE_DOC, SAGE_SRC + +try: + import sage.all +except ImportError: + raise RuntimeError("to build the documentation you need to be inside a Sage shell (run first the command 'sage -sh' in a shell") + + + + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath(package_folder)) +#sys.path.append(os.path.join(SAGE_SRC, "sage_setup", "docbuild", "ext")) + + +print("Using sys.path = {}".format(sys.path)) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + #'sage_autodoc', ## Not available on conda-forge sage! + #'sage_package.sphinx', + 'sphinx.ext.doctest', + 'sphinx.ext.coverage', + 'sphinx.ext.extlinks', + 'matplotlib.sphinxext.plot_directive', + #'sphinxcontrib.bibtex' +] + +### from Sage src/doc/common/conf.py +# This code is executed before each ".. PLOT::" directive in the Sphinx +# documentation. It defines a 'sphinx_plot' function that displays a Sage object +# through matplotlib, so that it will be displayed in the HTML doc. +plot_html_show_source_link = False +plot_pre_code = """ +def sphinx_plot(graphics, **kwds): + import matplotlib.image as mpimg + from sage.misc.temporary_file import tmp_filename + import matplotlib.pyplot as plt + ## Option handling is taken from Graphics.save + try: + from sage.plot.multigraphics import GraphicsArray + except ImportError: + from sage.plot.graphics import GraphicsArray + options = dict() + if not isinstance(graphics, GraphicsArray): + options.update(graphics.SHOW_OPTIONS) + options.update(graphics._extra_kwds) + options.update(kwds) + dpi = options.pop('dpi', None) + transparent = options.pop('transparent', None) + fig_tight = options.pop('fig_tight', None) + figsize = options.pop('figsize', None) + ## figsize handling is taken from Graphics.matplotlib() + if figsize is not None and not isinstance(figsize, (list, tuple)): + # in this case, figsize is a number and should be positive + try: + figsize = float(figsize) # to pass to mpl + except TypeError: + raise TypeError("figsize should be a positive number, not {0}".format(figsize)) + if figsize > 0: + default_width, default_height=rcParams['figure.figsize'] + figsize=(figsize, default_height*figsize/default_width) + else: + raise ValueError("figsize should be positive, not {0}".format(figsize)) + + if figsize is not None: + # then the figsize should be two positive numbers + if len(figsize) != 2: + raise ValueError("figsize should be a positive number " + "or a list of two positive numbers, not {0}".format(figsize)) + figsize = (float(figsize[0]),float(figsize[1])) # floats for mpl + if not (figsize[0] > 0 and figsize[1] > 0): + raise ValueError("figsize should be positive numbers, " + "not {0} and {1}".format(figsize[0],figsize[1])) + + plt.figure(figsize=figsize) + if isinstance(graphics, GraphicsArray): + ## from GraphicsArray.save + figure = plt.gcf() + rows = graphics.nrows() + cols = graphics.ncols() + for i, g in enumerate(graphics): + subplot = figure.add_subplot(rows, cols, i + 1) + g_options = copy(options) + g_options.update(g.SHOW_OPTIONS) + g_options.update(g._extra_kwds) + g_options.pop('dpi', None) + g_options.pop('transparent', None) + g_options.pop('fig_tight', None) + g.matplotlib(figure=figure, sub=subplot, **g_options) + else: + figure = graphics.matplotlib(figure=plt.gcf(), figsize=figsize, **options) + plt.tight_layout(pad=0) + plt.margins(0) + plt.show() + +from sage.all_cmdline import * +""" + +plot_html_show_formats = False +plot_formats = ['svg', 'pdf', 'png'] + +# Add any paths that contain templates here, relative to this directory. +# templates_path = ['_templates'] +templates_path = [os.path.join(SAGE_DOC_SRC, 'common', 'templates'), '_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + + + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +from pkg_resources import get_distribution, DistributionNotFound +# The full version, including alpha/beta/rc tags. +try: + release = get_distribution('sage-numerical-interactive-mip').version +except DistributionNotFound: + release = "0.2" +#print("############# release reported: {} ##################".format(release)) +# The short X.Y version. +version = '.'.join(release.split('.')[:2]) + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = [] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +default_role = 'math' + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'sage-classic' +html_theme_path = ['../themes'] + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +html_theme_options = {} + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = [] #['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = package_name + "doc" + + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ('index', package_name + '.tex', u'Documentation of ' + six.text_type(package_name), + authors, 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', package_name, six.text_type(package_name) + u" documentation", + [authors], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', package_name, six.text_type(package_name) + u" documentation", + authors, package_name, project, + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False + +# -- Options copied from Sagemath conf.py file ------------------------------- + +# We use MathJax to build the documentation unless the environment +# variable SAGE_DOC_MATHJAX is set to "no" or "False". (Note that if +# the user does not set this variable, then the script sage-env sets +# it to "True".) + +if (os.environ.get('SAGE_DOC_MATHJAX', 'no') != 'no' + and os.environ.get('SAGE_DOC_MATHJAX', 'no') != 'False'): + + extensions.append('sphinx.ext.mathjax') + mathjax_path = 'MathJax.js?config=TeX-AMS_HTML-full,../mathjax_sage.js' + + from sage.misc.latex_macros import sage_mathjax_macros + # this is broken for now + # html_theme_options['mathjax_macros'] = sage_mathjax_macros() + + ## from pkg_resources import Requirement, working_set + ## sagenb_path = working_set.find(Requirement.parse('sagenb')).location + ## mathjax_relative = os.path.join('sagenb','data','mathjax') + + ## # It would be really nice if sphinx would copy the entire mathjax directory, + ## # (so we could have a _static/mathjax directory), rather than the contents of the directory + + ## mathjax_static = os.path.join(sagenb_path, mathjax_relative) + ## html_static_path.append(mathjax_static) + ## exclude_patterns=['**/'+os.path.join(mathjax_relative, i) for i in ('docs', 'README*', 'test', + ## 'unpacked', 'LICENSE')] + from sage.env import SAGE_LOCAL, SAGE_SHARE + html_static_path.append(SAGE_LOCAL + "/lib/mathjax") # conda + html_static_path.append(SAGE_SHARE + "/mathjax") # sage distribution +else: + extensions.append('sphinx.ext.imgmath') + +# This is to make the verbatim font smaller; +# Verbatim environment is not breaking long lines +from sphinx.highlighting import PygmentsBridge +from pygments.formatters.latex import LatexFormatter + +class CustomLatexFormatter(LatexFormatter): + def __init__(self, **options): + super(CustomLatexFormatter, self).__init__(**options) + self.verboptions = r"formatcom=\footnotesize" + +PygmentsBridge.latex_formatter = CustomLatexFormatter + +latex_elements['preamble'] += r''' +% One-column index +\makeatletter +\renewenvironment{theindex}{ + \chapter*{\indexname} + \markboth{\MakeUppercase\indexname}{\MakeUppercase\indexname} + \setlength{\parskip}{0.1em} + \relax + \let\item\@idxitem +}{} +\makeatother +\renewcommand{\ttdefault}{txtt} +''' + +##################################################### +# add LaTeX macros for Sage + +from sage.misc.latex_macros import sage_latex_macros + +try: + pngmath_latex_preamble # check whether this is already defined +except NameError: + pngmath_latex_preamble = "" + +for macro in sage_latex_macros(): + # used when building latex and pdf versions + latex_elements['preamble'] += macro + '\n' + # used when building html version + pngmath_latex_preamble += macro + '\n' + + +## The following is needed on conda-forge sagemath +from sage.repl.user_globals import initialize_globals +import sage.all +my_globs = dict() +initialize_globals(sage.all, my_globs) diff --git a/docs/source/constructions.rst b/docs/source/constructions.rst new file mode 100644 index 0000000..bcbd2b7 --- /dev/null +++ b/docs/source/constructions.rst @@ -0,0 +1,10 @@ +.. nodoctest + +Constructions +============= + +.. automodule:: vector_bundle.constructions + :members: + :undoc-members: + :show-inheritance: + diff --git a/docs/source/ext_group.rst b/docs/source/ext_group.rst new file mode 100644 index 0000000..45c7cba --- /dev/null +++ b/docs/source/ext_group.rst @@ -0,0 +1,10 @@ +.. nodoctest + +Ext group +========= + +.. automodule:: vector_bundle.ext_group + :members: + :undoc-members: + :show-inheritance: + diff --git a/docs/source/hom_bundle.rst b/docs/source/hom_bundle.rst new file mode 100644 index 0000000..6fce05c --- /dev/null +++ b/docs/source/hom_bundle.rst @@ -0,0 +1,9 @@ +.. nodoctest + +Hom bundle +========== + +.. automodule:: vector_bundle.hom_bundle + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 0000000..1f21713 --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,36 @@ +========================== +Sage Vector Bundle Package +========================== + +This is a SageMath package implementing vector bundles on algebraic curves + +To use this module, you need to import it:: + + from vector_bundle import * + +This work is licensed under a `Creative Commons Attribution-Share Alike +3.0 License`__. + +The source code for building this documentation and its theme are taken from +the `sage_sample`__ github repository. + +__ https://creativecommons.org/licenses/by-sa/3.0/ +__ https://github.com/sagemath/sage_sample + +Vector Bundle +============= + +.. toctree:: + :maxdepth: 1 + + vector_bundle + hom_bundle + ext_group + constructions + +Indices and Tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/source/vector_bundle.rst b/docs/source/vector_bundle.rst new file mode 100644 index 0000000..0354eeb --- /dev/null +++ b/docs/source/vector_bundle.rst @@ -0,0 +1,9 @@ +.. nodoctest + +Vector bundle +================= + +.. automodule:: vector_bundle.vector_bundle + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/themes/sage-classic/genindex-single.html b/docs/themes/sage-classic/genindex-single.html new file mode 100644 index 0000000..d65ebd9 --- /dev/null +++ b/docs/themes/sage-classic/genindex-single.html @@ -0,0 +1,69 @@ +{# + This is a customized version for Sage documentation theme. + + Changes: at line 42, "slice(2)" -> "slice(1)" +#} + +{# + basic/genindex-single.html + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + + Template for a "single" page of a split index. + + :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +#} +{% macro indexentries(firstname, links) %} + {%- if links -%} + + {%- if links[0][0] %}{% endif -%} + {{ firstname|e }} + {%- if links[0][0] %}{% endif -%} + + + {%- for ismain, link in links[1:] -%} + , {% if ismain %}{% endif -%} + [{{ loop.index }}] + {%- if ismain %}{% endif -%} + + {%- endfor %} + {%- else %} + {{ firstname|e }} + {%- endif %} +{% endmacro %} + +{%- extends "layout.html" %} +{% set title = _('Index') %} +{% block body %} + +

{% trans key=key %}Index – {{ key }}{% endtrans %}

+ + + {%- for column in entries|slice(1) if column %} + + {%- endfor %} +
    + {%- for entryname, (links, subitems, _) in column %} +
  • {{ indexentries(entryname, links) }} + {%- if subitems %} +
      + {%- for subentryname, subentrylinks in subitems %} +
    • {{ indexentries(subentryname, subentrylinks) }}
    • + {%- endfor %} +
    + {%- endif -%}
  • + {%- endfor %} +
+ +{% endblock %} + +{% block sidebarrel %} +

{{ _('Index') }}

+

{% for key, dummy in genindexentries -%} + {{ key }} + {% if not loop.last %}| {% endif %} + {%- endfor %}

+ +

{{ _('Full index on one page') }}

+ {{ super() }} +{% endblock %} diff --git a/docs/themes/sage-classic/genindex-split.html b/docs/themes/sage-classic/genindex-split.html new file mode 100644 index 0000000..ec87558 --- /dev/null +++ b/docs/themes/sage-classic/genindex-split.html @@ -0,0 +1,47 @@ +{# + This is a customized version for Sage documentation theme. + + Changes: no change +#} + +{# + basic/genindex-split.html + ~~~~~~~~~~~~~~~~~~~~~~~~~ + + Template for a "split" index overview page. + + :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +#} +{%- extends "layout.html" %} +{% set title = _('Index') %} +{% block body %} + +

{{ _('Index') }}

+ +

{{ _('Index pages by letter') }}:

+ +
+

{% for key, dummy in genindexentries -%} + {{ key }} + {% if not loop.last %}| {% endif %} + {%- endfor %}

+ +

{{ _('Full index on one page') }} + ({{ _('can be huge') }})

+
+ +{% endblock %} + +{% block sidebarrel %} +{% if split_index %} +

Index

+

{% for key, dummy in genindexentries -%} + {{ key }} + {% if not loop.last %}| {% endif %} + {%- endfor %}

+ +

{{ _('Full index on one page') }}

+{% endif %} + {{ super() }} +{% endblock %} diff --git a/docs/themes/sage-classic/genindex.html b/docs/themes/sage-classic/genindex.html new file mode 100644 index 0000000..6ea56b6 --- /dev/null +++ b/docs/themes/sage-classic/genindex.html @@ -0,0 +1,82 @@ +{# + This is a customized version for Sage documentation theme. + + Changes: at line 52, "slice(2)" -> "slice(1)" +#} + +{# + basic/genindex.html + ~~~~~~~~~~~~~~~~~~~ + + Template for an "all-in-one" index. + + :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +#} +{%- extends "layout.html" %} +{% set title = _('Index') %} + +{% macro indexentries(firstname, links) %} + {%- if links -%} + + {%- if links[0][0] %}{% endif -%} + {{ firstname|e }} + {%- if links[0][0] %}{% endif -%} + + + {%- for ismain, link in links[1:] -%} + , {% if ismain %}{% endif -%} + [{{ loop.index }}] + {%- if ismain %}{% endif -%} + + {%- endfor %} + {%- else %} + {{ firstname|e }} + {%- endif %} +{% endmacro %} + +{% block body %} + +

{{ _('Index') }}

+ +
+ {% for key, dummy in genindexentries -%} + {{ key }} + {% if not loop.last %}| {% endif %} + {%- endfor %} +
+ +{%- for key, entries in genindexentries %} +

{{ key }}

+ + {%- for column in entries|slice_index(1) if column %} + + {%- endfor %} +
    + {%- for entryname, (links, subitems, _) in column %} +
  • {{ indexentries(entryname, links) }} + {%- if subitems %} +
      + {%- for subentryname, subentrylinks in subitems %} +
    • {{ indexentries(subentryname, subentrylinks) }}
    • + {%- endfor %} +
    + {%- endif -%}
  • + {%- endfor %} +
+{% endfor %} + +{% endblock %} + +{% block sidebarrel %} +{% if split_index %} +

{{ _('Index') }}

+

{% for key, dummy in genindexentries -%} + {{ key }} + {% if not loop.last %}| {% endif %} + {%- endfor %}

+ +

{{ _('Full index on one page') }}

+{% endif %} + {{ super() }} +{% endblock %} diff --git a/docs/themes/sage-classic/layout.html b/docs/themes/sage-classic/layout.html new file mode 100644 index 0000000..1cea7f1 --- /dev/null +++ b/docs/themes/sage-classic/layout.html @@ -0,0 +1,181 @@ +{% extends "classic/layout.html" %} + +{% block rootrellink %} + +{% endblock %} + +{% block extrahead %} + +{% endblock %} + +{%- block footer %} + {{ super() }} + + +{%- endblock %} + + + + +{%- macro sidebar() %} + {%- if not embedded %}{% if not theme_nosidebar|tobool %} +
+
+ {%- block sidebarlogo %} + {%- if logo %} + + {%- endif %} + {%- endblock %} + {%- block sidebartoc %} + {%- if display_toc %} +

{{ _('Table Of Contents') }}

+ {{ toc }} + {%- endif %} + {%- endblock %} + {%- block sidebarrel %} + {%- if prev %} +

{{ _('Previous topic') }}

+

{{ prev.title }}

+ {%- endif %} + {%- if next %} +

{{ _('Next topic') }}

+

{{ next.title }}

+ {%- endif %} + {%- endblock %} + {%- block sidebarsourcelink %} + {%- if show_source and has_source and sourcename %} +

{{ _('This Page') }}

+ + {%- endif %} + {%- endblock %} + {%- if customsidebar %} + {% include customsidebar %} + {%- endif %} + {%- block sidebarsearch %} + {%- if pagename != "search" and builder != "singlehtml" %} + + + {%- endif %} + {%- endblock %} +
+
+ {%- endif %}{% endif %} +{%- endmacro %} diff --git a/docs/themes/sage-classic/search.html b/docs/themes/sage-classic/search.html new file mode 100644 index 0000000..ba8b035 --- /dev/null +++ b/docs/themes/sage-classic/search.html @@ -0,0 +1,70 @@ +{# + basic/search.html + ~~~~~~~~~~~~~~~~~ + + Template for the search page. + + :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +#} +{%- extends "layout.html" %} +{% set title = _('Search') %} +{%- block scripts %} + {{ super() }} + + +{%- endblock %} +{% block extrahead %} + + {{ super() }} +{% endblock %} +{% block body %} +

{{ _('Search') }}

+ {% block scriptwarning %} + + {% endblock %} + {% block searchtext %} +

+ {% trans %}Searching for multiple words only shows matches that contain + all words.{% endtrans %} +

+

+ {% trans %}Note also that you can also call "search_src(...)" + while running Sage to search Sage's source code.{% endtrans %} +

+ {% endblock %} + {% block searchbox %} +
+ + + +
+ {% endblock %} + {% block searchresults %} + {% if search_performed %} +

{{ _('Search Results') }}

+ {% if not search_results %} +

{{ _('Your search did not match any documents.') }}

+ {% endif %} + {% endif %} +
+ {% if search_results %} +
    + {% for href, caption, context in search_results %} +
  • {{ caption }} +
    {{ context|e }}
    +
  • + {% endfor %} +
+ {% endif %} +
+ {% endblock %} +{% endblock %} + diff --git a/docs/themes/sage-classic/static/check-solid.svg b/docs/themes/sage-classic/static/check-solid.svg new file mode 100644 index 0000000..92fad4b --- /dev/null +++ b/docs/themes/sage-classic/static/check-solid.svg @@ -0,0 +1,4 @@ + + + + diff --git a/docs/themes/sage-classic/static/copy-button.svg b/docs/themes/sage-classic/static/copy-button.svg new file mode 100644 index 0000000..9c074da --- /dev/null +++ b/docs/themes/sage-classic/static/copy-button.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/docs/themes/sage-classic/static/file.png b/docs/themes/sage-classic/static/file.png new file mode 100644 index 0000000..a858a41 Binary files /dev/null and b/docs/themes/sage-classic/static/file.png differ diff --git a/docs/themes/sage-classic/static/logo_sagemath_black.svg b/docs/themes/sage-classic/static/logo_sagemath_black.svg new file mode 100644 index 0000000..fe39d8d --- /dev/null +++ b/docs/themes/sage-classic/static/logo_sagemath_black.svg @@ -0,0 +1 @@ + diff --git a/docs/themes/sage-classic/static/logo_sagemath_white.svg b/docs/themes/sage-classic/static/logo_sagemath_white.svg new file mode 100644 index 0000000..347ed0f --- /dev/null +++ b/docs/themes/sage-classic/static/logo_sagemath_white.svg @@ -0,0 +1 @@ + diff --git a/docs/themes/sage-classic/static/minus.png b/docs/themes/sage-classic/static/minus.png new file mode 100644 index 0000000..d96755f Binary files /dev/null and b/docs/themes/sage-classic/static/minus.png differ diff --git a/docs/themes/sage-classic/static/pdf.png b/docs/themes/sage-classic/static/pdf.png new file mode 100644 index 0000000..8fc8340 Binary files /dev/null and b/docs/themes/sage-classic/static/pdf.png differ diff --git a/docs/themes/sage-classic/static/plus.png b/docs/themes/sage-classic/static/plus.png new file mode 100644 index 0000000..7107cec Binary files /dev/null and b/docs/themes/sage-classic/static/plus.png differ diff --git a/docs/themes/sage-classic/static/sage.css_t b/docs/themes/sage-classic/static/sage.css_t new file mode 100644 index 0000000..38b6159 --- /dev/null +++ b/docs/themes/sage-classic/static/sage.css_t @@ -0,0 +1,382 @@ +/* + * This style sheet is borrowed from the Sphinx classic theme style sheet + * distributed as the file themes/classic/static/classic.css_t in Sphinx 4.4.0. + * + * Customizations for Sage follow from the end of the original style sheet. + * + */ + +@import url("basic.css"); + +/* -- page layout ----------------------------------------------------------- */ + +html { + /* CSS hack for macOS's scrollbar */ + background-color: #FFFFFF; +} + +body { + font-family: {{ theme_bodyfont }}; + font-size: 100%; + background-color: {{ theme_footerbgcolor }}; + color: #000; + margin: 0; + padding: 0; +} + +div.document { + background-color: {{ theme_sidebarbgcolor }}; +} + +div.documentwrapper { + float: left; + width: 100%; +} + +div.bodywrapper { + margin: 0 0 0 {{ theme_sidebarwidth|todim }}; +} + +div.body { + background-color: {{ theme_bgcolor }}; + color: {{ theme_textcolor }}; + padding: 0 20px 30px 20px; +} + +{%- if theme_rightsidebar|tobool %} +div.bodywrapper { + margin: 0 {{ theme_sidebarwidth|todim }} 0 0; +} +{%- endif %} + +div.footer { + color: {{ theme_footertextcolor }}; + width: 100%; + padding: 9px 0 9px 0; + text-align: center; + font-size: 75%; +} + +div.footer a { + color: {{ theme_footertextcolor }}; + text-decoration: underline; +} + +div.related { + background-color: {{ theme_relbarbgcolor }}; + line-height: 30px; + color: {{ theme_relbartextcolor }}; +} + +div.related a { + color: {{ theme_relbarlinkcolor }}; +} + +div.sphinxsidebar { + {%- if theme_stickysidebar|tobool %} + top: 30px; + bottom: 0; + margin: 0; + position: fixed; + overflow: auto; + height: auto; + {%- endif %} + {%- if theme_rightsidebar|tobool %} + float: right; + {%- if theme_stickysidebar|tobool %} + right: 0; + {%- endif %} + {%- endif %} +} + +{%- if theme_stickysidebar|tobool %} +/* this is nice, but it leads to hidden headings when jumping + to an anchor */ +/* +div.related { + position: fixed; +} + +div.documentwrapper { + margin-top: 30px; +} +*/ +{%- endif %} + +div.sphinxsidebar h3 { + font-family: {{ theme_headfont }}; + color: {{ theme_sidebartextcolor }}; + font-size: 1.4em; + font-weight: normal; + margin: 0; + padding: 0; +} + +div.sphinxsidebar h3 a { + color: {{ theme_sidebartextcolor }}; +} + +div.sphinxsidebar h4 { + font-family: {{ theme_headfont }}; + color: {{ theme_sidebartextcolor }}; + font-size: 1.3em; + font-weight: normal; + margin: 5px 0 0 0; + padding: 0; +} + +div.sphinxsidebar p { + color: {{ theme_sidebartextcolor }}; +} + +div.sphinxsidebar p.topless { + margin: 5px 10px 10px 10px; +} + +div.sphinxsidebar ul { + margin: 10px; + padding: 0; + color: {{ theme_sidebartextcolor }}; +} + +div.sphinxsidebar a { + color: {{ theme_sidebarlinkcolor }}; +} + +div.sphinxsidebar input { + border: 1px solid {{ theme_sidebarlinkcolor }}; + font-family: sans-serif; + font-size: 1em; +} + +{% if theme_collapsiblesidebar|tobool %} +/* for collapsible sidebar */ +div#sidebarbutton { + background-color: {{ theme_sidebarbtncolor }}; +} +{% endif %} + +/* -- hyperlink styles ------------------------------------------------------ */ + +a { + color: {{ theme_linkcolor }}; + text-decoration: none; +} + +a:visited { + color: {{ theme_visitedlinkcolor }}; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +{% if theme_externalrefs|tobool %} +a.external { + text-decoration: none; + border-bottom: 1px dashed {{ theme_linkcolor }}; +} + +a.external:hover { + text-decoration: none; + border-bottom: none; +} + +a.external:visited { + text-decoration: none; + border-bottom: 1px dashed {{ theme_visitedlinkcolor }}; +} +{% endif %} + +/* -- body styles ----------------------------------------------------------- */ + +div.body h1, +div.body h2, +div.body h3, +div.body h4, +div.body h5, +div.body h6 { + font-family: {{ theme_headfont }}; + background-color: {{ theme_headbgcolor }}; + font-weight: normal; + color: {{ theme_headtextcolor }}; + border-bottom: 1px solid #ccc; + margin: 20px -20px 10px -20px; + padding: 3px 0 3px 10px; +} + +div.body h1 { margin-top: 0; font-size: 200%; } +div.body h2 { font-size: 160%; } +div.body h3 { font-size: 140%; } +div.body h4 { font-size: 120%; } +div.body h5 { font-size: 110%; } +div.body h6 { font-size: 100%; } + +a.headerlink { + color: {{ theme_headlinkcolor }}; + font-size: 0.8em; + padding: 0 4px 0 4px; + text-decoration: none; +} + +a.headerlink:hover { + background-color: {{ theme_headlinkcolor }}; + color: white; +} + +div.body p, div.body dd, div.body li, div.body blockquote { + text-align: justify; + line-height: 130%; +} + +div.admonition p.admonition-title + p { + display: inline; +} + +div.admonition p { + margin-bottom: 5px; +} + +div.admonition pre { + margin-bottom: 5px; +} + +div.admonition ul, div.admonition ol { + margin-bottom: 5px; +} + +div.note { + background-color: #eee; + border: 1px solid #ccc; +} + +div.seealso { + background-color: #ffc; + border: 1px solid #ff6; +} + +div.topic { + background-color: #eee; +} + +div.warning { + background-color: #ffe4e4; + border: 1px solid #f66; +} + +p.admonition-title { + display: inline; +} + +p.admonition-title:after { + content: ":"; +} + +pre { + padding: 5px; + background-color: {{ theme_codebgcolor }}; + color: {{ theme_codetextcolor }}; + line-height: 120%; + border: 1px solid #ac9; + border-left: none; + border-right: none; +} + +code { + background-color: #ecf0f3; + padding: 0 1px 0 1px; + font-size: 0.95em; +} + +th, dl.field-list > dt { + background-color: #ede; +} + +.warning code { + background: #efc2c2; +} + +.note code { + background: #d6d6d6; +} + +.viewcode-back { + font-family: {{ theme_bodyfont }}; +} + +div.viewcode-block:target { + background-color: #f4debf; + border-top: 1px solid #ac9; + border-bottom: 1px solid #ac9; +} + +div.code-block-caption { + color: #efefef; + background-color: #1c4e63; +} + +/* + * Customizations for Sage + * + */ + +/* -- sage logo -------------------------- */ + +img.sage-logo { + height: 28px; + vertical-align: middle; +} + +/* -- hyperlink styles ------------------- */ + +a, +a:visited { + color: {{ theme_linkcolor }}; + text-decoration: none; +} + +/* -- commands or code within text ------- */ + +tt { + background-color: #EAEAF8; + padding: 0 1px 0 1px; + font-size: 0.95em; +} + +/* -- class and method headlines --------- */ + +dl.py.class > dt, +dl.py.method > dt { + overflow-x: scroll; + text-align: left; +} + +dl.py.class > dd > p:first-child { + overflow-x: scroll; + white-space: nowrap; +} + +/* -- search page ------------------------ */ + +ul.search li { + text-align: left; +} + +/* -- references ------------------------- */ + +dl.citation p { + text-align: left; +} + +/* -- jupyter-sphinx ------------------------------------------------------ */ + +#thebelab-activate-button { + position: fixed; + right: 10px; + bottom: 10px; +} + +.jupyter_cell .thebelab-input { + display: none; +} diff --git a/docs/themes/sage-classic/static/sageicon.png b/docs/themes/sage-classic/static/sageicon.png new file mode 100644 index 0000000..1ee5781 Binary files /dev/null and b/docs/themes/sage-classic/static/sageicon.png differ diff --git a/docs/themes/sage-classic/static/sagelogo.png b/docs/themes/sage-classic/static/sagelogo.png new file mode 100644 index 0000000..286be5a Binary files /dev/null and b/docs/themes/sage-classic/static/sagelogo.png differ diff --git a/docs/themes/sage-classic/theme.conf b/docs/themes/sage-classic/theme.conf new file mode 100644 index 0000000..fbde86a --- /dev/null +++ b/docs/themes/sage-classic/theme.conf @@ -0,0 +1,42 @@ +[theme] +inherit = classic +stylesheet = sage.css +pygments_style = sphinx + +[options] +# Background color for the footer line: dark blue +footerbgcolor = #8C8DE6 + +# Text color for the footer line: white +footertextcolor = #FFFFFF + +# Background color for the sidebar: light bluish gray +sidebarbgcolor = #EAEAF8 + +# Text color for the sidebar: black +sidebartextcolor = #000000 + +# Link color for the sidebar: light dark blue +sidebarlinkcolor = #090999 + +# Background color for the relation bar: light grayish blue +relbarbgcolor = #B8B9F6 + +# Text color for the relation bar: light dark blue +relbartextcolor = #090999 + +# Link color for the relation bar: light dark blue +relbarlinkcolor = #090999 + +# Body text color: black +textcolor = #000000 + +# Background color for headings: light gray +headbgcolor = #F2F2F2 + +# Body link color: dark greenish blue +linkcolor = #45529B + +# Background color for code blocks: very pale yellow +codebgcolor = #FFFFE5 + diff --git a/makefile b/makefile new file mode 100644 index 0000000..146fd76 --- /dev/null +++ b/makefile @@ -0,0 +1,37 @@ +# This Makefile is for convenience as a reminder and shortcut for the most used commands + +# Package folder +PACKAGE = vector_bundle + +# change to your sage command if needed +SAGE = sage + +all: install test + +install: + $(SAGE) -pip install --upgrade -v . + +uninstall: + $(SAGE) -pip uninstall $(PACKAGE) + +develop: + $(SAGE) -pip install --upgrade -e . + +test: + $(SAGE) setup.py test + +coverage: + $(SAGE) -coverage $(PACKAGE)/* + +doc: + cd docs && $(SAGE) -sh -c "make html" + +doc-pdf: + cd docs && $(SAGE) -sh -c "make latexpdf" + +clean: clean-doc + +clean-doc: + cd docs && $(SAGE) -sh -c "make clean" + +.PHONY: all install develop test coverage clean clean-doc doc doc-pdf diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..f20e898 --- /dev/null +++ b/setup.py @@ -0,0 +1,50 @@ +## -*- encoding: utf-8 -*- +import os +import sys +from setuptools import setup +from codecs import open # To open the README file with proper encoding +from setuptools.command.test import test as TestCommand # for tests + + +# Get information from separate files (README, VERSION) +def readfile(filename): + with open(filename, encoding='utf-8') as f: + return f.read() + +# For the tests +class SageTest(TestCommand): + def run_tests(self): + errno = os.system("sage -t --force-lib vector_bundle") + if errno != 0: + sys.exit(1) + +setup( + name = "vector_bundle", + version = readfile("VERSION").strip(), # the VERSION file is shared with the documentation + description='A sage package implementing vector bundles on algebraic curves using only function fields', + long_description = readfile("README.rst"), # get the long description from the README + # For a Markdown README replace the above line by the following two lines: + # long_description = readfile("README.md"), + # long_description_content_type="text/markdown", + # url='https://github.com/sagemath/sage_sample', + author='Mickaël Montessinos', + author_email='mickael.montessinos@mif.vu.lt', # choose a main contact email + license='GPLv2+', # This should be consistent with the LICENCE file + classifiers=[ + # How mature is this project? Common values are + # 3 - Alpha + # 4 - Beta + # 5 - Production/Stable + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Science/Research', + 'Topic :: Software Development :: Build Tools', + 'Topic :: Scientific/Engineering :: Mathematics', + 'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)', + 'Programming Language :: Python :: 3.7', + ], # classifiers list: https://pypi.python.org/pypi?%3Aaction=list_classifiers + keywords = "Algebraic Geometry Number Theory Curves Vector Bundles", + packages = ['vector_bundle'], + cmdclass = {'test': SageTest}, # adding a special setup command for tests + setup_requires = ['sage-package'], + install_requires = ['sage-package', 'sphinx'], +) diff --git a/vector_bundle/__init__.py b/vector_bundle/__init__.py new file mode 100644 index 0000000..6153417 --- /dev/null +++ b/vector_bundle/__init__.py @@ -0,0 +1,4 @@ +from __future__ import absolute_import +# Add the import for which you want to give a direct access +from .vector_bundle import VectorBundle +from .constructions import * diff --git a/vector_bundle/constructions.py b/vector_bundle/constructions.py new file mode 100644 index 0000000..3279d54 --- /dev/null +++ b/vector_bundle/constructions.py @@ -0,0 +1,229 @@ +r""" +This module provides functions for various interesting constructions of vector bundles. + +AUTHORS: + +_Mickaël Montessinos: initial implementation +""" + +########################################################################### +# Copyright (C) 2024 Mickaël Montessinos (mickael.montessinos@mif.vu.lt),# +# # +# Distributed under the terms of the GNU General Public License (GPL) # +# either version 3, or (at your option) any later version # +# # +# http://www.gnu.org/licenses/ # +########################################################################### + +from sage.matrix.constructor import matrix +from vector_bundle import VectorBundle +from . import function_field_utility + +def trivial_bundle(K): + r""" + Return the structure sheaf of the algebraic curve with function field K. + + EXAMPLES :: + + sage: from vector_bundle import trivial_bundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: O = K.maximal_order() + sage: V = trivial_bundle(K) + sage: V._ideals + [Ideal (1) of Maximal order of Function field in y defined by y^2 + x + 2] + sage: V._g_finite + [1] + sage: V._g_infinite + [1] + """ + return VectorBundle(K, K.one().divisor()) + +def canonical_bundle(K): + r""" + Return a canonical line bundle over K suitable for explicit Serre duality. + + EXAMPLES :: + + sage: from vector_bundle import canonical_bundle, trivial_bundle + sage: F. = FunctionField(GF(3)) + sage: canonical_bundle(F).degree() + -2 + sage: R. = F[] + sage: K. = F.extension(y^2 - x^3 - x) + sage: L = canonical_bundle(K); L + Vector bundle of rank 1 over Function field in y defined by y^2 + 2*x^3 + 2*x + sage: L == trivial_bundle(K) + True + """ + pi,_ = function_field_utility.safe_uniformizer(K) + return VectorBundle(K, pi.differential().divisor()) + +def _euclid(a,b): + r""" + The Euclidian algorithm in `N` but outputs intermediate steps. + """ + u1 = a + u2 = b + res = [] + while u2 != 0: + q, r = u1.quo_rem(u2) + res.append((u1, u2, q, r)) + u1 = u2 + u2 = r + return res + + +def atiyah_bundle(field, rank, degree, base=None): + r""" + Return `\alpha_{r,d}(F_r \otimes base)` in the notation of Theorem 6 [At57]_ + , where `r` is ``rank`` and `d` is ``degree``. + + INPUT: + + - ``field`` - FunctionField; of genus 1 with an infinite place of degree 1 + - ``rank`` - integer + - ``degree`` - integer + - ``base`` - line bundle of degree 0 over field ; (default = ``trivial_bundle(field)``) + + EXAMPLES :: + + sage: from vector_bundle import atiyah_bundle + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(11)) + sage: R. = F[] + sage: K. = F.extension(y^2 - x^3 - x) + sage: base = VectorBundle(K, K.places_finite()[0].divisor()) + sage: E = atiyah_bundle(K, 5, 3, base) + sage: E.rank() + 5 + sage: E.degree() + 3 + sage: E.hom(E).h0() + [ + [1 0 0 0 0] + [0 1 0 0 0] + [0 0 1 0 0] + [0 0 0 1 0] + [0 0 0 0 1] + ] + """ + if base is None: + base = trivial_bundle(field) + if rank <= 0 : + raise ValueError('rank must be positive') + if field.genus() != 1: + raise ValueError('field must have genus 1') + if base.function_field() != field: + raise ValueError('base must have field as its function_field.') + if degree < 0: + return atiyah_bundle(field, rank, -degree, base).dual() + divisor = field.places_infinite()[0].divisor() + gcd = _euclid(rank, degree) + plan = [(i % 2,q) for i,(_, _, q, _) in enumerate(gcd)] + a, b = plan[-1] + plan[-1] = (a, b - 1) + starting_rank = gcd[-1][1] + result = trivial_bundle(field) + line_bundle = VectorBundle(field, divisor) + for _ in range(starting_rank - 1): + result = result.extension_by_global_sections() + result = result.tensor_product(line_bundle) + for move, reps in reversed(plan): + for _ in range(reps): + if move == 0: + result = result.extension_by_global_sections() + else: + result = result.tensor_product(line_bundle) + return result + + +def savin_bundle(field, rank, degree, line, line_1, line_2): + r""" + Return a weakly stable bundle over field of rank ``rank`` and degree + ``degree`` + + ALGORITHM: + + Section V of [Sav08]_ + + INPUT: + + - ``field`` -- FunctionField: the base of the bundle. Must have genus at least 2. + + - ``rank`` -- Integer: the rank of the output bundle + + - ``degree`` -- Integer: the degree of the output bundle + + - ``line`` -- VectorBundle: line bundle of degree ``degree//rank + 1`` plays the role of `F` in the algorithm + + - ``line_1`` -- VectorBundle: line bundle of degree ``degree // rank`` plays the role of `F_1` in the algorithm + + - ``line_2`` -- VectorBundle: line bundle of degree ``degree // rank`` plays the role of `F_2` in the algorithm + + EXAMPLE :: + + sage: from vector_bundle import VectorBundle, savin_bundle + sage: F. = FunctionField(GF(11)) + sage: R. = F[] + sage: K. = F.extension(y^2 - x^5 + x) + sage: line = VectorBundle(K, 3 * K.places_infinite()[0].divisor()) + sage: line_1 = VectorBundle(K, 2 * K.places_finite()[0].divisor()) + sage: line_2 = VectorBundle(K, 2 * K.places_finite()[1].divisor()) + sage: E = savin_bundle(K, 3, 7, line, line_1, line_2) + sage: E.rank() + 3 + sage: E.degree() + 7 + """ + if degree < 0: + return savin_bundle(field, rank, -degree, line, line_1, line_2).dual() + q, r = degree.quo_rem(rank) + if line.rank() != 1 or line_1.rank() != 1 or line_2.rank() != 1: + raise ValueError('The input bundles must have rank 1') + if line_1.degree() != q or line_1.degree() != q or line.degree() != q+1: + raise ValueError('At least one of the input line bundles has' + + 'invalid degree') + E = line_1 + for _ in range(rank - r - 1): + E = line_2.non_trivial_extension(E) + for _ in range(r): + E = line.non_trivial_extension(E) + return E + +def rank_2_trivial_determinant_semistable_bundle(ksi, ext=None): + r""" + Construct the semi-stable vector bundle of rank 2 and trivial determinant + defined by the extension of ``ksi`` by ``ksi.dual()`` and nonzero extension + class ``ext``. + + The fact that this vector bundle is semi-stable is Lemma 5.1 in [NR69]_. + If ``ext`` is None, we default to a default nonzero extension class. + + INPUT: + + - ``ksi`` -- a degree 1 line bundle over a function field of genus at least 2 + - ``ext`` -- an object representing a class of extensions of ``ksi`` by ``ksi.dual()``. (Default: None) + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle, trivial_bundle, rank_2_trivial_determinant_semistable_bundle + sage: F. = FunctionField(GF(11)) + sage: R. = F[] + sage: K. = F.extension(y^2 - x^5 - 1) + sage: ksi = VectorBundle(K, K.places_finite()[0].divisor()) + sage: V = rank_2_trivial_determinant_semistable_bundle(ksi) + sage: V.rank() + 2 + sage: V.determinant() == trivial_bundle(K) + True + """ + if ksi.rank() != 1: + raise ValueError('ksi must have rank one') + if ksi.degree() != 1: + raise ValueError('ksi must have degree one') + if ksi.function_field().genus() < 2: + raise ValueError('The function field of ksi must have genus at least 2') + ext_group = ksi.extension_group(ksi.dual()) + return ext_group.extension(ext) diff --git a/vector_bundle/ext_group.py b/vector_bundle/ext_group.py new file mode 100644 index 0000000..0798b7c --- /dev/null +++ b/vector_bundle/ext_group.py @@ -0,0 +1,252 @@ +r""" +This module implements the ExtGroup and ExtGroupElement classes used for +building extensions of vector bundles. + +AUTHORS: + +_Mickaël Montessinos: initial implementation +""" + +########################################################################### +# Copyright (C) 2024 Mickaël Montessinos (mickael.montessinos@mif.vu.lt),# +# # +# Distributed under the terms of the GNU General Public License (GPL) # +# either version 3, or (at your option) any later version # +# # +# http://www.gnu.org/licenses/ # +########################################################################### + +from sage.structure.sage_object import SageObject +from sage.structure.element import is_Matrix +from sage.matrix.special import block_matrix +from sage.modules.free_module_element import vector + +class ExtGroup(SageObject): + r""" + The group of extensions of ``left`` by ``right``. + + The group `Ext^1(\mathrm{left},\mathrm{right})` is + `H^1(\mathrm{left}^\vee \otimes \mathrm{right})`. + Its elements may be represented as matrices of infinite répartitions + lying in `M_{\mathrm{right}.rank(),\mathrm{left}.rank()}(R)` or as + vectors of length ``self.dim()`` with coefficients in the coefficient + field, representing linear forms on + `H^0(\omega \otimes \mathrm{right}^\vee \otimes \mathrm{left})`, where + `\omega` is the canonical bundle of the function field of ``left`` and + ``right`` + The two representations are related via Serre duality. + + If ``precompute_basis`` is set to ``True``, a basis of répartition + matrices is computed. Its element represent the linear forms + ``vector([0,...,0,1,0,...,0])``. Otherwise, linear forms are converted + to elements of the `H^1` on the fly. You should set ``precompute_basis`` + to ``True`` only if you plan to create several extensions with this group. + + INPUT: + + - ``left`` -- VectorBundle + - ``right`` -- VectorBundle; must have the same function field as left + - ``precompute_basis`` -- boolean + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle, trivial_bundle + sage: F. = FunctionField(GF(3)) + sage: triv = trivial_bundle(F) + sage: triv.extension_group(triv) + Extension group of Vector bundle of rank 1 over Rational function field in x over Finite Field of size 3 by Vector bundle of rank 1 over Rational function field in x over Finite Field of size 3. + """ + def __init__(self, left, right, precompute_basis=False): + if not left._function_field == right._function_field: + raise ValueError('left and right should have the same function' + + 'field') + self._left = left + self._right = right + self._hom = left.hom(right) + self._ext_dual_basis, self._ext_dual_bundle = self._hom.h1_dual() + self._s = len(self._ext_dual_basis) + if precompute_basis: + self._compute_basis() + else: + self._basis = None + + def __hash__(self): + return hash((self._left, self._right)) + + def __eq__(self, other): + return self._left == other._left and self._right == other._right + + def _repr_(self): + return "Extension group of %s by %s." % (self._left, self._right) + + def _compute_basis(self): + r""" + Compute the representation of basis elements of ``self`` as elements of the `H^1` + """ + if self._basis is None: + self._basis = [self._hom.h1_element( + vector([0] * i + [1] + [0] * (self._s-i-1))) + for i in range(self._s)] + + def dim(self): + r""" + Return the dimension of the extension group as a vector space over the + base coefficient field + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(11)) + sage: R. = F[] + sage: K. = F.extension(y^2 - x^5 - 1) + sage: ksi = VectorBundle(K, K.places_finite()[0].divisor()) + sage: ext = ksi.extension_group(ksi.dual()); ext.dim() + 3 + """ + return self._s + + def left(self): + r""" + Return the left vector bundle of ``self``. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: L1 = VectorBundle(F, x.zeros()[0].divisor()) + sage: L2 = VectorBundle(F, x.poles()[0].divisor()) + sage: ext = L1.extension_group(L2); ext.left() == L1 + True + """ + return self._left + + def right(self): + r""" + Return the right vector bundle of ``self``. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: L1 = VectorBundle(F, x.zeros()[0].divisor()) + sage: L2 = VectorBundle(F, x.poles()[0].divisor()) + sage: ext = L1.extension_group(L2); ext.right() == L2 + True + """ + return self._right + + def dual_basis(self): + r""" + Return a basis of the dual of the `Ext^1` group. This is a basis of + `H^0(\omega \otimes \mathrm{right}^\vee \otimes \mathrm{left})`, where + `\omega` is a canonical line bundle. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(11)) + sage: R. = F[] + sage: K. = F.extension(y^2 - x^5 - 1) + sage: ksi = VectorBundle(K, K.places_finite()[0].divisor()) + sage: ext = ksi.extension_group(ksi.dual()); ext.dual_basis() + [[x^4/(x^5 + 6)], [x^5/(x^5 + 6)], [(x^2/(x^5 + 6))*y + 10*x^2/(x^5 + 6)]] + """ + return self._ext_dual_basis + + def basis(self): + r"""Return a basis of `Ext^1` group. Its element are matrices of + infinite répartitions represented by field elements. + + Computes and stores the basis if it was not precomputed yet. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(11)) + sage: R. = F[] + sage: K. = F.extension(y^2 - x^5 - 1) + sage: ksi = VectorBundle(K, K.places_finite()[0].divisor()) + sage: ext = ksi.extension_group(ksi.dual()); ext.basis() + [[(x^9/(x^10 + 2*x^5 + 1))*y], [(x^3/(x^5 + 1))*y], [x^6/(x^5 + 1)]] + """ + self._compute_basis() + return self._basis + + def _extension_from_ext_element(self, ext): + r""" + Return the extension of ``self.left() by ``self.right()`` encoded by + ``ext``. + + ``ext`` is a matrix of elements of ``self._function_field`` which + represents the constant value over the infinite places of a répartition + matrix with support at infinity representing an element of + `H^1(\mathrm{hom}(\mathrm{left},\mathrm{right}))`. + Such an element encodes an extension `V`: + `0 \to \mathrm{other} \to V \to \mathrm{self} \to 0` + + INPUT: + + - ``ext`` -- a matrix of dimension ``right.rank(),left.rank()`` + """ + from vector_bundle import VectorBundle + function_field = self._left._function_field + ideals = self._right._ideals + self._left._ideals + g_finite = block_matrix([[self._right._g_finite, 0], + [0, self._left._g_finite]]) + g_infinite = block_matrix([[self._right._g_infinite, + -ext * self._left._g_infinite], + [0, self._left._g_infinite]]) + return VectorBundle(function_field, ideals, g_finite, g_infinite) + + def _extension_from_linear_form(self, form): + if self._basis is None: + ext = self._hom.h1_element(form) + ext = self._ext_dual_bundle._vector_to_matrix(ext).transpose() + else: + ext = sum([coeff * e for coeff, e in zip(form, self._basis)]) + return self._extension_from_ext_element(ext) + + def extension(self, ext=None): + r""" + Return the extension of ``self.left()`` by ``self.right()`` encoded by + ``ext``. + + ``ext`` can be a matrix of elements of ``self._function_field`` + which represents the constant value over the infinite places of a + répartition matrix with support at infinity representing an element of + `H^1(\mathrm{hom}(\mathrm{left},\mathrm{right}))`. + Such an element encodes an extension `V`: + `0 \to \mathrm{other} \to V \to \mathrm{self} \to 0` + + ``ext`` can also be a vector of length `self.dim()` representing an + extension in the basis of the Ext vector space. + + By default, ``ext`` is chosen as any non trivial extension. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle, trivial_bundle + sage: F. = FunctionField(GF(11)) + sage: R. = F[] + sage: K. = F.extension(y^2 - x^3 - x) + sage: triv = trivial_bundle(K) + sage: ext = triv.extension_group(triv) + sage: V = ext.extension() + sage: V.rank() + 2 + sage: V.determinant() == triv + True + sage: V.h0() + [(1, 0)] + sage: V.end().h0() + [ + [0 1] [1 0] + [0 0], [0 1] + ] + """ + if ext is None: + ext = vector([1] + [0]*(self._s-1)) + if is_Matrix(ext): + return self._extension_from_ext_element(ext) + else: + return self._extension_from_linear_form(ext) diff --git a/vector_bundle/function_field_utility.py b/vector_bundle/function_field_utility.py new file mode 100644 index 0000000..3089556 --- /dev/null +++ b/vector_bundle/function_field_utility.py @@ -0,0 +1,466 @@ +########################################################################### +# Copyright (C) 2024 Mickaël Montessinos (mickael.montessinos@mif.vu.lt),# +# # +# Distributed under the terms of the GNU General Public License (GPL) # +# either version 3, or (at your option) any later version # +# # +# http://www.gnu.org/licenses/ # +########################################################################### + +from sage.matrix.constructor import matrix +from sage.rings.infinity import Infinity +from copy import copy +from sage.misc.cachefunc import cached_function +from sage.misc.misc_c import prod +from sage.matrix.constructor import matrix +from sage.matrix.special import block_matrix, elementary_matrix,\ + identity_matrix +from sage.rings.function_field.function_field_rational\ + import RationalFunctionField +from sage.rings.function_field.order_rational\ + import FunctionFieldMaximalOrderInfinite_rational + +@cached_function +def all_infinite_places(K): + r""" + Return a list of the infinite places of K of all degrees + + INPUT: + - ``K`` -- FunctionField + """ + if isinstance(K,RationalFunctionField): + return [K.gen().poles()[0]] + deg = K.degree() + return sum([K.places_infinite(degree = deg) for deg in range(1, deg + 1)], + []) + + +def infinite_valuation(a): + r""" + Returns the valuation -deg of an element of a rational function field + + The degree method returns the "height" of the element. + + EXAMPLES: + + sage: from vector_bundle.function_field_utility import infinite_valuation + sage: F. = FunctionField(GF(3)) + sage: infinite_valuation(x**-1 + x**-2) + 1 + """ + if a == 0: + return Infinity + return a.denominator().degree() - a.numerator().degree() + + +def infinite_mod(a,i): + r""" + Returns a mod x**-i + + EXAMPLES: + + sage: from vector_bundle.function_field_utility import infinite_mod + sage: K. = FunctionField(GF(3)) + sage: infinite_mod(x**-1 + x**-3,2) + 1/x + """ + x = a.parent().gen() + b = a * x**(i-1) + return x**(1-i) * (b.numerator() // b.denominator()) + + +def infinite_integral_matrix(mat): + r""" + Return an matrix with coefficient in the infinite maximal order and its denominator. + + INPUT: + + - ``mat`` -- Matrix with coefficients in a rational function field K + + OUTPUT: + + - ``int_mat`` -- Matrix with coefficients in K.maximal_order_infinite() + - ``den`` -- Element of K.maximal_order_infinite such that mat = int_mat/den + + EXAMPLES: + + sage: from vector_bundle.function_field_utility import infinite_integral_matrix + sage: F. = FunctionField(GF(11)) + sage: mat = matrix([[x, 1], [x**-1, 2]]) + sage: infinite_integral_matrix(mat) + ( + [ 1 1/x] + [1/x^2 2/x], 1/x + ) + """ + K = mat[0,0].parent() + if isinstance(K,FunctionFieldMaximalOrderInfinite_rational): + return mat,1 + if not isinstance(K,RationalFunctionField): + raise ValueError('mat must have coefficients in a rational function' + + 'field or its infinite maximal order') + x = K.gen() + R = K.maximal_order_infinite() + den = x**min([infinite_valuation(e) for e in mat.list()]) + int_mat = matrix(R,mat.nrows(),mat.ncols(),(den*mat).list()) + return int_mat, den + + +def infinite_hermite_form(mat,include_zero_cols=True,transformation=False): + r""" + Return the hermite form of a matrix with coefficient in a rational infinite maximal order. + + EXAMPLE: + + sage: from vector_bundle.function_field_utility import infinite_hermite_form + sage: K. = FunctionField(GF(3)) + sage: R = K.maximal_order_infinite() + sage: mat = matrix(R,[[1, x**-1, x**-2, (x**3+1) / x**3], [(2*x+2) / (x**3+2), x**-2, (x**2+2) / (x**4+1), 1]]) + sage: H,T = infinite_hermite_form(mat,transformation=True); H + [0 0 1 0] + [0 0 0 1] + sage: mat*T == H + True + + TESTS: + + sage: F. = FunctionField(GF(3)) + sage: R = F.maximal_order_infinite() + sage: mat = matrix(R,[[x**-1, 0, 2, 1], [0, x**-1, 1, 1], [0, 0, 1, 0], [0, 0, 0, 1]]) + sage: infinite_hermite_form(mat) == mat + True + """ + R = mat.base_ring() + if not isinstance(R,FunctionFieldMaximalOrderInfinite_rational): + raise ValueError('mat must have base ring a rational infinite maximal' + + ' order.') + n = mat.nrows() + r = mat.ncols() + x = R.function_field().gen() + H = copy(mat) + T = identity_matrix(R,r) + #First, make mat upper triangular with diagonal coefficient of the form + #x**-k. + for i in range(1,n+1): + degs = [infinite_valuation(H[-i,j]) for j in range(r+1-i)] + d0 = min(degs) + j0 = degs.index(d0) + E = elementary_matrix(R,r,row1=j0,row2=r-i) + T *= E + H *= E + E = elementary_matrix(R,r,row1=r-i,scale=(x**d0 * H[-i,-i])**-1) + T *= E + H *= E + for j in range(r-i): + E = elementary_matrix(R,r,row1=r-i,row2=j,scale=-H[-i,j]/H[-i,-i]) + T *= E + H *= E + for i in range(2,n+1): + d = infinite_valuation(H[-i,-i]) + for j in range(1,i): + E = elementary_matrix( + R,r,row1=r-i,row2=r-j, + scale=(infinite_mod(H[-i,-j],d)-H[-i,-j])/H[-i,-i]) + T *= E + H *= E + if not include_zero_cols: + H = H[:,r-n:] + if transformation: + return H,T + return H + + +def infinite_ideal_hnf(I,transformation=False): + r""" + Return the Hermite form of an ideal of the infinite maximal order. + """ + O = I.ring() + K = O.function_field() + x = K.gen() + F = K.base_field() + R = F.maximal_order_infinite() + n = K.degree() + order_basis = O.basis() + order_matrix = matrix(R,[gen.list() for gen in O.basis()]).transpose() + ideal_basis = I.gens_over_base(); + ideal_matrix = order_matrix**-1 * matrix(F,[gen.list() + for gen in ideal_basis]).transpose() + mat,den = infinite_integral_matrix(ideal_matrix) + #This is awkward but if transformation is False, hnf,U = ().hermite_form() + #will unpack the matrix. + if transformation: + hnf,U = infinite_hermite_form(mat, transformation=True) + return hnf/den,U + hnf = infinite_hermite_form(mat) + return hnf/den + +def infinite_order_xgcd(ideals): + r""" + Performs the extended gcd algorithm for ideals in the infinite order. + + INPUT: + + - ``ideals`` -- list of ideals over the infinite maximal order of a function field + + OUTPUT: + + - ``coeffs`` --- list of elements of the function field such that as[i] in ideals[i] and sum(as) = 1 + + ALGORITHM: + + Proposition 1.3.7 from [Coh00] + + EXAMPLES: + + sage: from vector_bundle.function_field_utility import infinite_order_xgcd + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y**2 - x**-5 - 1) + sage: primes = [p.prime_ideal() for p in K.places_infinite()]; len(primes) + 2 + sage: a = infinite_order_xgcd(primes); a + [2*y + 2, y + 2] + sage: sum(a) + 1 + sage: all([a[i] in primes[i] for i in range(2)]) + True + """ + order_basis = ideals[0].ring().basis() + if order_basis[0] != 1: + raise ValueError('The first element of the basis of the order should' + + ' be 1.') + n = len(order_basis) + k = len(ideals) + y = ideals[0].ring().function_field().gen() + ideals_hnf = [infinite_ideal_hnf(I) for I in ideals] + ideals_bases = [[sum([order_basis[i]*mat[i,j] for i in range(n)]) + for j in range(n)] + for mat in ideals_hnf] + C = block_matrix([ideals_hnf]) + C, den = infinite_integral_matrix(C) + H,U = infinite_hermite_form(C, include_zero_cols=False, transformation=True) + if not (H/den).is_one(): + raise ValueError("The ideals should be coprime.") + v = U[:,-n].list() + return [sum([ideals_bases[i][j]*v[n*i+j] for j in range(n)]) for i in range(k)] + + +def infinite_approximation(places,valuations,residues): + r""" + Return a in the function field of places such that + (a - residues[i]) has valuation at least valuations[i] at places[i]. + + INPUT: + + - ``places`` -- list of FunctionFieldPlace. Infinite places only. + - ``valuations`` -- list of integers of same length as places. + - ``residues`` -- list of elements of the function field. + + ALGORITHM: + + Proposition 1.3.11 from [Coh00] + """ + if len(places) == 1: + return residues[0] + valuations = [max(0,val) for val in valuations] + primes = [place.prime_ideal() for place in places] + I = prod([prime**(val+1) for prime, val in zip(primes, valuations)]) + ideals = [I * prime**(-val-1) + for prime, val in zip(primes, valuations)] + coefficients = infinite_order_xgcd(ideals) + return sum([c * res for c,res in zip(coefficients,residues)]) + + +@cached_function +def safe_uniformizer(K): + r""" + Return a safe uniformizer and an infinite place of self._function_field + A uniformizer is safe if its valuation at other infinite places is 0. + + EXAMPLES: + + sage: from vector_bundle.function_field_utility import safe_uniformizer + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 - x**-5 - 1) + sage: places = K.places_infinite() + sage: pi, place = safe_uniformizer(K); pi + ((2*x + 1)/x)*y + (2*x + 2)/x + sage: place == places[0] + True + sage: pi.valuation(place) + 1 + sage: pi.valuation(places[1]) + 0 + + TESTS: + + sage: from vector_bundle.function_field_utility import all_infinite_places + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: places = K.places_infinite() + sage: pi, place = safe_uniformizer(K); pi + 1/x*y + sage: place == places[0] + True + sage: pi.valuation(place) + 1 + sage: R. = F[] + sage: K. = F.extension(y^4 + (2*x^2 + 2)/x^2) + sage: pi, _ = safe_uniformizer(K) + sage: [pi.valuation(place) for place in all_infinite_places(K)] + [1, 0, 0] + sage: safe_uniformizer(F) + (1/x, Place (1/x)) + """ + places = all_infinite_places(K) + n = len(places) + return (infinite_approximation( + places, + [2] + ([1]*(n-1)), + [places[0].local_uniformizer()] + ([1]*(n-1))), + places[0]) + +def local_expansion(place,pi,f): + r""" + Return a function giving the i-th coefficient of the expansion of f. + + This uses code from sage.rings.function_field.maps.FunctionFieldCompletion. + While somewhat redundant, it adds the possibility to chose the uniformizer + with respect to which the expansion is computed. + + INPUT: + + - ``place`` -- FunctionFieldPlace; the place at which to expand + - ``pi`` -- The uniformizer giving variable for the power series + - ``f`` -- The function to expand + + OUTPUT: + + - a function taking as input an integer i and returning the coefficient of degree i + + EXAMPLES: + + sage: from vector_bundle.function_field_utility import local_expansion + sage: from vector_bundle.function_field_utility import safe_uniformizer + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 - x**-5 - 1) + sage: pi, place = safe_uniformizer(K) + sage: f = 1 / (1-pi) + sage: exp = local_expansion(place, pi, f) + sage: all([exp(i) == 1 for i in range(20)]) + True + """ + if f == 0: + return lambda i : 0 + K = place.function_field() + der = K.higher_derivation() + k, _, to_k = place.residue_field() + val = f.valuation(place) + e = f * pi**(-val) + return lambda i : to_k(der._derive(e, i - val, pi)) if i >= val else 0 + +def residue(place,pi,f): + r""" + Return the residue of constant répartition f at place with respect + to local uniformizer pi. + """ + if pi.valuation(place) != 1: + raise ValueError('pi must be a local uniformizer at place') + k, _, _ = place.residue_field() + kc = place.function_field().constant_base_field() + exp = local_expansion(place,pi,f) + high_res = exp(-1) + return k.over(kc)(high_res).trace() + + +def invert_trace(field,base,target): + r""" + Find an element of trace 1 over base in field. + + EXAMPLES: + sage: from vector_bundle.function_field_utility import invert_trace + sage: base = GF(9) + sage: field = GF(9**3) + sage: a = invert_trace(field, base, 1); a + 2*z6^4 + 2*z6^3 + z6 + 1 + sage: field.over(base)(a).trace() + 1 + """ + if field == base: + if target not in field: + raise ValueError('Since field = base, target should be an element' + + ' of field') + return target + as_ext = field.over(base) + d = as_ext.degree(base) + t = as_ext.gen() + i = [(t**j).trace() != 0 for j in range(d)].index(True) + return field(target * t**i/((t**i).trace())) + +def insert_row(mat,i,row): + r""" + Return matrix mat with row inserted in ith position. + + EXAMPLES: + sage: from vector_bundle.function_field_utility import insert_row + sage: mat = matrix(GF(3), 2, 2, [1, 2, 2, 1]) + sage: insert_row(mat, 1, [0, 1]) + [1 2] + [0 1] + [2 1] + """ + return matrix([mat[j] for j in range(i)] + + [row] + + [mat[j] for j in range(i,mat.nrows())]) + + +def norm(v): + r""" + Return the norm of vector v: the maximal degree of its coefficients. + + Input: + + - v -- vector with coefficients in a RationalFunctionField + + EXAMPLES: + + sage: from vector_bundle.function_field_utility import norm + sage: R. = GF(3)[] + sage: v = vector([x^3 + 3 + 1, x^2]) + sage: norm(v) + 3 + """ + return max([c.degree() for c in v.list()]) + +def smallest_norm_first(mat,i = 0,norms=[]): + r""" + Swap rows of M so that the i-th row has smaller norm than rows below. + + INPUT: + + ``mat`` -- matrix with coefficients in a RationalFunctionField + ``i`` -- integer (default: `0`) + + EXAMPLES: + + sage: from vector_bundle.function_field_utility import smallest_norm_first + sage: R. = GF(3)[] + sage: mat = matrix([[1, 1], [x^2, x^3], [1, x]]) + sage: smallest_norm_first(mat, 1) + [0, 1, 3] + sage: mat + [ 1 1] + [ 1 x] + [x^2 x^3] + """ + if norms == []: + norms = [norm(row) for row in mat] + j = norms[i:].index(min(norms[i:])) + mat.swap_rows(i,i+j) + n = norms[i] + norms[i] = norms[j+i] + norms[j+i] = n + return norms diff --git a/vector_bundle/hom_bundle.py b/vector_bundle/hom_bundle.py new file mode 100644 index 0000000..fb4b12b --- /dev/null +++ b/vector_bundle/hom_bundle.py @@ -0,0 +1,305 @@ +r""" +This module implements the HomBundle class, for vector bundles constructed +as homomorphism sheaves between two vector bundles. + +The class inherits from the VectorBundle class, but sections, either local +or global, are displayed as matrices. + +EXAMPLES :: + + sage: from vector_bundle import VectorBundle, trivial_bundle, savin_bundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 - x^5 - 1) + +We construct a vector bundle of rank 2 and degree 4:: + + sage: F = VectorBundle(K, 3 * K.places_infinite()[0].divisor()) + sage: F1 = VectorBundle(K, 2 * K.places_finite()[0].divisor()) + sage: F2 = VectorBundle(K, 2 * K.places_finite()[1].divisor()) + sage: V = savin_bundle(K, 2, 4, F, F1, F2); V.h0() + [(1, 0), (2*x, 1)] + +We construct the ``HomBundle`` from `\mathcal{O}_X^2` to ``V``. Its global +sections should represent linear maps from `k^2` to `H^0(V)`, where `k` +is the constant field of `K`:: + + sage: domain = trivial_bundle(K).direct_sum_repeat(2) + sage: hom_bundle = domain.hom(V); hom_bundle.h0() + [ + [1 0] [0 1] [2*x 0] [ 0 2*x] + [0 0], [0 0], [ 1 0], [ 0 1] + ] +""" +########################################################################### +# Copyright (C) 2024 Mickaël Montessinos (mickael.montessinos@mif.vu.lt),# +# # +# Distributed under the terms of the GNU General Public License (GPL) # +# either version 3, or (at your option) any later version # +# # +# http://www.gnu.org/licenses/ # +########################################################################### + +from sage.matrix.constructor import matrix +from sage.modules.free_module_element import vector +from vector_bundle import VectorBundle + +class HomBundle(VectorBundle): + r""" + Vector bundles representing homomorphism sheaves of vector bundles. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: ideals = [P.prime_ideal() for P in K.places_finite()[:2]] + sage: g_finite = matrix([[1, x], [2, y]]) + sage: g_infinite = matrix([[x, 1], [2, y]]) + sage: V1 = VectorBundle(K, ideals, g_finite, g_infinite) + sage: V2 = VectorBundle(K, K.places_infinite()[0].divisor()) + sage: V = V1.hom(V2); V + Homomorphism bundle from Vector bundle of rank 2 over Function field in y defined by y^2 + x + 2 to Vector bundle of rank 1 over Function field in y defined by y^2 + x + 2 + """ + def __init__(self,domain,codomain): + if (not isinstance(domain,VectorBundle) or + not isinstance(codomain,VectorBundle)): + raise TypeError + if domain._function_field != codomain._function_field: + raise ValueError + self._domain = domain + self._codomain = codomain + ideals = [ideal_domain**-1 * ideal_codomain + for ideal_domain in domain._ideals + for ideal_codomain in codomain._ideals] + g_finite = (domain._g_finite.transpose()**-1)\ + .tensor_product(codomain._g_finite) + g_infinite = (domain._g_infinite.transpose()**-1)\ + .tensor_product(codomain._g_infinite) + super().__init__(domain._function_field, ideals,g_finite,g_infinite) + + def __hash__(self): + return hash((self._domain, self._codomain)) + + def __eq__(self,other): + return (super().__eq__(other) + and self._domain == other._domain + and self._codomain == other._codomain) + + def _repr_(self): + return "Homomorphism bundle from %s to %s" % ( + self._domain, + self._codomain, + ) + + def domain(self): + r""" + Return the domain of self + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: L1 = VectorBundle(F, x.poles()[0].divisor()) + sage: L2 = VectorBundle(F, x.zeros()[0].divisor()) + sage: V = L1.hom(L2); V.domain() == L1 + True + """ + return self._domain + + def codomain(self): + r""" + Return the codomain of self + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: L1 = VectorBundle(F, x.poles()[0].divisor()) + sage: L2 = VectorBundle(F, x.zeros()[0].divisor()) + sage: V = L1.hom(L2); V.codomain() == L2 + True + """ + return self._codomain + + def _vector_to_matrix(self,vec): + r""" + Return the matrix of the homomorphism encoded by vector vec. + """ + return matrix(self._domain.rank(),self._codomain.rank(),vec).transpose() + + def _matrix_to_vector(self,mat): + r""" + Inverse operation of _vector_to_matrix() + """ + return vector(mat.transpose().list()) + + def basis_finite(self): + r""" + Return basis of the finite lattice of the hom bundle. + + OUTPUT: + + - The basis elements are represented as matrices. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: ideals = [P.prime_ideal() for P in K.places_finite()[:2]] + sage: g_finite = matrix([[1, x], [2, y]]) + sage: g_infinite = matrix([[x, 1], [2, y]]) + sage: V1 = VectorBundle(K, ideals, g_finite, g_infinite) + sage: O = K.maximal_order() + sage: V2 = VectorBundle(K, K.places_finite()[2].prime_ideal(),1,x^2) + sage: V = V1.hom(V2) + sage: V.basis_finite() + [[(x/(x^2 + x + 2))*y + (x + 2)/(x^2 + x + 2) (x/(x^2 + x + 2))*y + 2*x^2/(x^2 + x + 2)], + [(2/(x^2 + x + 2))*y + x/(x^2 + x + 2) (2/(x^2 + x + 2))*y + x/(x^2 + x + 2)]] + """ + basis = super().basis_finite() + return [self._vector_to_matrix(v) for v in basis] + + def basis_infinite(self): + r""" + Return basis of the infinite lattice of the hom bundle. + + OUTPUT: + + - The basis elements are represented as matrices. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: ideals = [P.prime_ideal() for P in K.places_finite()[:2]] + sage: g_finite = matrix([[1, x], [2, y]]) + sage: g_infinite = matrix([[x, 1],[2, y]]) + sage: V1 = VectorBundle(K, ideals,g_finite,g_infinite) + sage: O = K.maximal_order() + sage: V2 = VectorBundle(K, K.places_finite()[2].prime_ideal(),1,x^2) + sage: V = V1.hom(V2) + sage: V.basis_infinite() + [[(x^2/(x^3 + 2*x^2 + 1))*y + (x^4 + 2*x^3)/(x^3 + 2*x^2 + 1) (x^3/(x^3 + 2*x^2 + 1))*y + 2*x^2/(x^3 + 2*x^2 + 1)], + [(2*x^3/(x^3 + 2*x^2 + 1))*y + x^2/(x^3 + 2*x^2 + 1) (2*x^4/(x^3 + 2*x^2 + 1))*y + x^3/(x^3 + 2*x^2 + 1)]] + """ + basis = super().basis_infinite() + return [self._vector_to_matrix(v) for v in basis] + + def basis_local(self,place): + r""" + Return basis of the infinite lattice of the hom bundle. + + OUTPUT: + + - The basis elements are represented as matrices. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: ideals = [P.prime_ideal() for P in K.places_finite()[:2]] + sage: g_finite = matrix([[1,x],[2,y]]) + sage: g_infinite = matrix([[x,1],[2,y]]) + sage: V1 = VectorBundle(K, ideals,g_finite,g_infinite) + sage: O = K.maximal_order() + sage: V2 = VectorBundle(K, K.places_finite()[2].prime_ideal(),1,x^2) + sage: V = V1.hom(V2) + sage: place = K.places_finite()[0] + sage: V.basis_local(place) + [[(1/(x^2 + x + 2))*y + (x + 2)/(x^3 + x^2 + 2*x) (1/(x^2 + x + 2))*y + 2*x/(x^2 + x + 2)], + [(2/(x^2 + x + 2))*y + x/(x^2 + x + 2) (2/(x^2 + x + 2))*y + x/(x^2 + x + 2)]] + sage: all([all([(mat * g_finite)[0, j].valuation(place) >= (V2._ideals[0] * V1._ideals[j]**-1).divisor().valuation(place) for j in range(2)]) for mat in V.basis_local(place)]) + True + """ + basis = super().basis_local(place) + return [self._vector_to_matrix(v) for v in basis] + + def hom(self, other): + r""" + Return the Hom bundle from self to other. + + If other is a vector bundle, this is the hom bundle from ``self._codomain`` + to ``self._domain.tensor_product(other)``. + If other is also a hom bundle, this is the hom bundle from + ``self.codomain().tensor_product(other.domain())`` + to ``self.domain().tensor_product(other.codomain()`` + """ + if isinstance(other, HomBundle): + return self._codomain.tensor_product(other._domain)\ + .hom(self._domain.tensor_product(other._codomain)) + return self._codomain.hom(self._domain.tensor_product(other)) + + def tensor_product(self,other): + r""" + Return the tensor product of a hom bundle and a vector bundle. + This is the same thing as + ``self._domain.hom(self._codomain.tensor_product(other))`` + """ + return self._domain.hom(self._codomain.tensor_product(other)) + + def conorm(self,K): + r""" + Return the conorm of a hom bundle. + + It is the same thing as the hom bundle of the conorms of its domain and + codomain. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: ideals = [P.prime_ideal() for P in F.places_finite()[:2]] + sage: g_finite = matrix([[1, x], [2, x]]) + sage: g_infinite = matrix([[x, 1], [2, x]]) + sage: V1 = VectorBundle(F, ideals, g_finite, g_infinite) + sage: ideals = [P.prime_ideal() for P in F.places_finite()[1:3]] + sage: g_finite = matrix([[0, x], [1, 1/x]]) + sage: g_infinite = matrix([[x, 2*x^2], [2, 1]]) + sage: V2 = VectorBundle(F, ideals, g_finite, g_infinite) + sage: V1.conorm(K).hom(V2.conorm(K)) == V1.hom(V2).conorm(K) + True + """ + + return self._domain.conorm(K).hom(self._codomain.conorm(K)) + + def h0(self): + r""" + Returns the 0th cohomology group of the hom bundle. + The global sections are output in matrix form, they are the global + homomorphisms from ``self._domain`` to ``self._codomain``. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: ideals = [P.prime_ideal() for P in K.places_finite()[:2]] + sage: g_finite = matrix([[1, x], [2, y]]) + sage: g_infinite = matrix([[x, 1], [2, y]]) + sage: V1 = VectorBundle(K, ideals, g_finite, g_infinite) + sage: O = K.maximal_order() + sage: V2 = VectorBundle(K, K.places_finite()[2].prime_ideal(),1,x^2) + sage: V = V1.hom(V2) + sage: h0 = V.h0(); len(h0) == V.degree() + (1-K.genus())*V.rank() + True + sage: all([all([(mat * g_finite)[0, j] in V2._ideals[0] * V1._ideals[j]**-1 for j in range(2)]) for mat in h0]) + True + sage: O_infinity = K.maximal_order_infinite() + sage: all([all([a in O_infinity for a in (x**-2 * mat * g_infinite).list()]) for mat in h0]) + True + """ + h0 = super().h0() + return [self._vector_to_matrix(v) for v in h0] + + diff --git a/vector_bundle/vector_bundle.py b/vector_bundle/vector_bundle.py new file mode 100644 index 0000000..b18ee57 --- /dev/null +++ b/vector_bundle/vector_bundle.py @@ -0,0 +1,1075 @@ +r""" +This module implements algebraic algorithms for manipulating vector bundles +as pairs of lattices over its function field. Follows the algorithmic methods +discussed in [Mon24]_ + +EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 - x^3 - x) + sage: order = K.maximal_order() + sage: ideals = [K.places_finite()[0].prime_ideal()^-1, order.ideal(1)] + sage: g_finite = identity_matrix(K,2) + sage: g_infinite = matrix(K,[[1, 0], [0, 1/x^2*y]]) + sage: V = VectorBundle(K, ideals, g_finite, g_infinite); V + Vector bundle of rank 2 over Function field in y defined by y^2 + 2*x^3 + 2*x + +We can compute a basis of the space of global sections of ``V``:: + + sage: h0 = V.h0(); h0 + [(1, 0)] + +We can also compute a basis of the `H^1` group of ``V``. First, a basis of its +dual is computed:: + + sage: h1_dual, _ = V.h1_dual(); h1_dual + [[0 1]] + +Then, we compute a representent of a linear form over ``h1_dual``:: + + sage: V.h1_element([1]) + [0, (x/(x^2 + 1))*y] + +We can verify the Riemann-Roch theorem:: + + sage: len(h0) - len(h1_dual) == V.degree() + V.rank()*(1 - K.genus()) + True + +REFERENCES: + +.. [At57] M. F. Atiyah + *Vector Bundles on Elliptic Curves* + Proc. Lond. Math. Soc. + 3(1):414-452, 1957 + +.. [Mon24] M. Montessinos + *Algebraic algorithms for vector bundles over algebraic curves* + In preparation + +.. [Sav08] V. Savin + *Algebraic-Geometric Codes from Vector Bundles and their Decoding* + +.. [NR69] M. S. Narasimhan and S. Ramanan + *Moduli of vector bundles on a compact Riemann surface* + Ann. of Math. 89(1):14-51, 1969 + +AUTHORS: + +_Mickaël Montessinos: initial implementation +""" + +########################################################################### +# Copyright (C) 2024 Mickaël Montessinos (mickael.montessinos@mif.vu.lt),# +# # +# Distributed under the terms of the GNU General Public License (GPL) # +# either version 3, or (at your option) any later version # +# # +# http://www.gnu.org/licenses/ # +########################################################################### + +from copy import copy +from sage.misc.cachefunc import cached_method +from sage.structure.element import is_Matrix +from sage.structure.sage_object import SageObject +from sage.misc.misc_c import prod +from sage.arith.functions import lcm +from sage.arith.misc import integer_ceil +from sage.functions.log import logb +from sage.matrix.constructor import matrix +from sage.matrix.special import block_matrix, elementary_matrix\ + , identity_matrix +from sage.matrix.matrix_space import MatrixSpace +from sage.rings.function_field.ideal import FunctionFieldIdeal +from sage.rings.function_field.function_field_rational\ + import RationalFunctionField +from sage.rings.function_field.order_rational\ + import FunctionFieldMaximalOrderInfinite_rational +from sage.modules.free_module_element import vector +from sage.schemes.projective.projective_space import ProjectiveSpace +from . import function_field_utility +from . import ext_group + + +class VectorBundle(SageObject): + r""" + A vector bundle defined over a normal curve with function field K. + + If ``g_finite`` and ``g_infinite`` are None and ideals is a divisor, the line + bundle `L(D)` is returned. + + If the constructed vector bundle is to have rank one, ``ideals`` may be an + ideal instead of a list. Likewise, ``g_finite`` and ``g_infinite`` can be + elements of `K` rather that matrices of size `1 \times 1`. + + INPUT: + + - ``function_field`` -- FunctionField; the function field of the bundle + + - ``ideals`` -- list of coefficient ideals of the finite part of the bundle + + - ``g_finite`` -- matrix; a basis of the finite part of the bundle + + - ``g_infinite`` -- matrix; a basis of the infinite part of the bundle + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: VectorBundle(F,x.poles()[0].divisor()) + Vector bundle of rank 1 over Rational function field in x over Finite Field of size 3 + sage: R. = F[] + sage: K. = F.extension(y^2 - x^3 - x) + sage: ideals = [P.prime_ideal() for P in K.places_finite()[:2]] + sage: g_finite = matrix([[1, x], [y, 2]]) + sage: g_infinite = matrix([[x, y], [x + y, 1]]) + sage: VectorBundle(K, ideals, g_finite, g_infinite) + Vector bundle of rank 2 over Function field in y defined by y^2 + 2*x^3 + 2*x + + A line bundle may be defined without using lists and matrices:: + + sage: VectorBundle(K, K.maximal_order().ideal(1), 1, 1) + Vector bundle of rank 1 over Function field in y defined by y^2 + 2*x^3 + 2*x + + It may also be defined using a divisor:: + + sage: VectorBundle(K, K.one().divisor()) + Vector bundle of rank 1 over Function field in y defined by y^2 + 2*x^3 + 2*x + """ + + def __init__(self,function_field, ideals,g_finite=None,g_infinite=None): + if g_finite is None or g_infinite is None: + self._line_bundle_from_divisor(function_field, ideals) + else: + self._vector_bundle_from_data(function_field, ideals, + g_finite,g_infinite) + + def __hash__(self): + return hash((tuple(self._ideals), + tuple(self._g_finite.list()), + tuple(self._g_infinite.list()))) + + def __eq__(self,other): + return (self._ideals == other._ideals + and self._g_finite == other._g_finite + and self._g_infinite == other._g_infinite) + + def _neq_(self, other): + return not self == other + + def _repr_(self): + return "Vector bundle of rank %s over %s" % ( + self.rank(), + self._function_field, + ) + + def _line_bundle_from_divisor(self,function_field,divisor): + r""" + Build a line bundle from a divisor + """ + if not function_field == divisor.parent().function_field(): + raise ValueError('The divisor should be defined over the ' + + 'function field.') + self._function_field = function_field + couples = divisor.list() + finite_part = [c for c in couples if not c[0].is_infinite_place()] + self._ideals = [prod([place.prime_ideal()**-mult + for place,mult in finite_part], + self._function_field.maximal_order().ideal(1))] + self._g_finite = matrix(function_field,[[1]]) + infinite_places = function_field_utility.all_infinite_places( + function_field) + pi = function_field_utility.infinite_approximation( + infinite_places, + [1-divisor.multiplicity(place) for place in infinite_places], + [place.local_uniformizer()**-divisor.multiplicity(place) + for place in infinite_places]) + self._g_infinite = matrix(function_field,[[pi]]) + + def _vector_bundle_from_data(self,function_field, + ideals,g_finite,g_infinite): + r""" + Construct a vector bundle from data. + """ + if not isinstance(ideals,list): + ideals=[ideals] + if not is_Matrix(g_finite): + if isinstance(g_finite,list): + g_finite = matrix(g_finite).transpose() + else: + g_finite = matrix([[g_finite]]) + if not is_Matrix(g_infinite): + if isinstance(g_finite,list): + g_infinite = matrix(g_infinite).transpose() + else: + g_infinite = matrix([[g_infinite]]) + g_finite.change_ring(function_field) + g_infinite.change_ring(function_field) + r = len(ideals) + if (g_finite.nrows() != r + or g_finite.ncols() != r + or g_infinite.nrows() != r + or g_infinite.ncols() != r): + raise ValueError('The length of the ideal list must equal the \ + size of the basis matrices') + if not g_finite.is_invertible() or not g_infinite.is_invertible(): + raise ValueError('The basis matrices must be invertible') + if not all([isinstance(I,FunctionFieldIdeal) + for I in ideals]): + raise TypeError('The second argument must be a list of \ + FunctionFieldIdeals.') + if not all([I.base_ring() == function_field.maximal_order() + for I in ideals]): + raise ValueError('All ideals must have the maximal order of\ + function_field as base ring.') + self._function_field = function_field + self._ideals = ideals + self._g_finite = g_finite + self._g_infinite = g_infinite + + def function_field(self): + r""" + Return the function field of the vector bundle + + EXAMPLES :: + + sage: from vector_bundle import trivial_bundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 - x^3 - x) + sage: V = trivial_bundle(K) + sage: V.function_field() + Function field in y defined by y^2 + 2*x^3 + 2*x + """ + return self._function_field + + def coefficient_ideals(self): + r""" + Return the coefficient ideals of the finite part of self. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: ideals = [P.prime_ideal() for P in K.places_finite()[:2]] + sage: g_finite = matrix([[1, x], [2, y]]) + sage: g_infinite = matrix([[x, 1], [2, y]]) + sage: V = VectorBundle(K, ideals, g_finite, g_infinite) + sage: Is = V.coefficient_ideals() + sage: Is == [P.prime_ideal() for P in K.places_finite()[:2]] + True + """ + return copy(self._ideals) + + def basis_finite(self): + r""" + Return the basis vectors of the finite part of self. + + The basis elements may not be in the corresponding lattice over the + finite maximal order: the lattice may not be free and one must account + for the coefficient ideals. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: ideals = [P.prime_ideal() for P in K.places_finite()[:2]] + sage: g_finite = matrix([[1, x], [2, y]]) + sage: g_infinite = matrix([[x, 1], [2, y]]) + sage: V = VectorBundle(K, ideals, g_finite, g_infinite) + sage: V.basis_finite() + [(1, 2), (x, y)] + """ + return [vector(self._g_finite[:, j]) for j in range(self.rank())] + + def basis_infinite(self): + r""" + Return the basis vectors of the infinite part of self. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: ideals = [P.prime_ideal() for P in K.places_finite()[:2]] + sage: g_finite = matrix([[1, x], [2, y]]) + sage: g_infinite = matrix([[x, 1], [2, y]]) + sage: V = VectorBundle(K, ideals, g_finite, g_infinite) + sage: V.basis_infinite() + [(x, 2), (1, y)] + """ + return [vector(self._g_infinite[:, j]) for j in range(self.rank())] + + def basis_local(self,place): + r""" + Return a local basis of self at prime. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: ideals = [P.prime_ideal() for P in K.places_finite()[:2]] + sage: g_finite = matrix([[1, x], [2, y]]) + sage: g_infinite = matrix([[x, 1], [2, y]]) + sage: V = VectorBundle(K, ideals, g_finite, g_infinite) + sage: V.basis_local(K.places_finite()[0]) + [(x, 2*x), (x, y)] + """ + if place.is_infinite_place(): + return self._g_infinite + pi = place.local_uniformizer() + return [(pi**self._ideals[j].divisor().valuation(place)) + * vector(self._g_finite[:, j]) + for j in range(self.rank())] + + def rank(self): + r""" + Return the rank of a vector bundle. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: O = K.maximal_order() + sage: V = VectorBundle(K, O.ideal(1), x, y) + sage: V.rank() + 1 + """ + return len(self._ideals) + + @cached_method + def determinant(self): + r""" + Return the determinant bundle. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: ideals = [P.prime_ideal() for P in K.places_finite()[:2]] + sage: g_finite = matrix([[1, x], [2, y]]) + sage: g_infinite = matrix([[x, 1], [2, y]]) + sage: V = VectorBundle(K, ideals, g_finite, g_infinite) + sage: d = V.determinant() + sage: d._ideals + [Ideal (x) of Maximal order of Function field in y defined by y^2 + x + 2] + sage: d._g_finite + [y + x] + sage: d._g_infinite + [x*y + 1] + """ + if self.rank() == 1: + return self + O = self._function_field.maximal_order() + I = prod(self._ideals) + determinant_finite = self._g_finite.determinant() + determinant_infinite = self._g_infinite.determinant() + return VectorBundle(self._function_field + ,I + ,determinant_finite + ,determinant_infinite) + + def degree(self): + r""" + Returns the degree of the vector bundle. + + This is defined as the degree of the divisor of the determinant bundle. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: ideals = [P.prime_ideal() for P in K.places_finite()[:2]] + sage: g_finite = matrix([[1, x], [2, y]]) + sage: g_infinite = matrix([[x, 1], [2, y]]) + sage: V = VectorBundle(K, ideals, g_finite, g_infinite) + sage: V.degree() + -1 + """ + if self.rank() > 1: + return self.determinant().degree() + degree_ideal = self._ideals[0].divisor().degree() + order_finite = self._function_field.maximal_order() + order_infinite = self._function_field.maximal_order_infinite() + divisor_finite = order_finite.ideal(self._g_finite[0,0]).divisor() + divisor_infinite = order_infinite.ideal(self._g_infinite[0,0]).divisor() + return -(degree_ideal + + divisor_finite.degree() + + divisor_infinite.degree()) + + def slope(self): + r""" + Return the slop of the vector bundle. + + The slope is the ratio rank/degree + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: from vector_bundle import trivial_bundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2-x^3-x) + sage: E = VectorBundle(K, K.places_infinite()[0].divisor()) + sage: V = E.non_trivial_extension(trivial_bundle(K)) + sage: V.slope() + 1/2 + """ + return self.degree()/self.rank() + + def is_locally_trivial(self,place): + r""" + Check if the vector bundle is the trivial lattice at place ``place`` + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(7)) + sage: R. = F[] + sage: K. = F.extension(y^2 - x^3 - x) + sage: L1 = VectorBundle(K, K.places_finite()[0].divisor()) + sage: L2 = VectorBundle(K, K.places_finite()[1].divisor()) + sage: V = L1.direct_sum(L2) + sage: V.is_locally_trivial(K.places_finite()[0]) + False + sage: V.is_locally_trivial(K.places_finite()[2]) + True + sage: V.is_locally_trivial(K.places_infinite()[0]) + True + sage: L = VectorBundle(K,K.places_infinite()[0].divisor()) + sage: L.is_locally_trivial(K.places_infinite()[0]) + False + """ + basis = self.basis_local(place) + mat = matrix(basis) + return (all([c.valuation(place) >= 0 for c in mat.list()]) + and mat.determinant().valuation(place) == 0) + + def hom(self,other): + r""" + Returns the hom bundle ``Hom(self,other)`` + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: ideals = [P.prime_ideal() for P in K.places_finite()[:2]] + sage: g_finite = matrix([[1, x], [2, y]]) + sage: g_infinite = matrix([[x, 1], [2, y]]) + sage: V1 = VectorBundle(K, ideals, g_finite, g_infinite) + sage: O = K.maximal_order() + sage: V2 = VectorBundle(K, O.ideal(1), 1, x^2) + sage: V = V1.hom(V2) + sage: V.rank() == V1.rank() * V2.rank() + True + sage: V.degree() == V2.degree()*V1.rank() - V1.degree()*V2.rank() + True + """ + from . import hom_bundle + return hom_bundle.HomBundle(self,other) + + def end(self): + r""" + Return the hom bundle of endomorphisms of ``self``. + + Examples :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: L1 = VectorBundle(F, x.zeros()[0].divisor()) + sage: L2 = VectorBundle(F, x.poles()[0].divisor()) + sage: E = L1.direct_sum(L2).end(); E.h0() + [ + [1 0] [0 0] [ 0 1/x] [0 0] + [0 0], [x 0], [ 0 0], [0 1] + ] + """ + return self.hom(self) + + def dual(self): + r""" + Returns the dual vector bundle of ``self``. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: ideals = [P.prime_ideal() for P in K.places_finite()[:2]] + sage: g_finite = matrix([[1, x], [2, y]]) + sage: g_infinite = matrix([[x, 1], [2, y]]) + sage: V = VectorBundle(K, ideals, g_finite, g_infinite) + sage: Vd = V.dual() + sage: Vd.rank() == V.rank() + True + sage: Vd.degree() == -V.degree() + True + """ + from . import constructions + return self.hom(constructions.trivial_bundle(self._function_field)) + + def direct_sum(self,other): + r""" + Returns the direct sum of two vector bundles + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: ideals = [P.prime_ideal() for P in K.places_finite()[:2]] + sage: g_finite = matrix([[1, x], [2, y]]) + sage: g_infinite = matrix([[x, 1], [2, y]]) + sage: V1 = VectorBundle(K, ideals, g_finite, g_infinite) + sage: O = K.maximal_order() + sage: V2 = VectorBundle(K, O.ideal(1), 1, x^2) + sage: V = V1.direct_sum(V2) + sage: V.rank() == V1.rank() + V2.rank() + True + sage: V.degree() == V1.degree() + V2.degree() + True + """ + ideals = self._ideals + other._ideals + g_finite = block_matrix([[self._g_finite,0],[0,other._g_finite]]) + g_infinite = block_matrix([[self._g_infinite,0],[0,other._g_infinite]]) + return VectorBundle(self._function_field, ideals,g_finite,g_infinite) + + def _direct_sum_rec(self,acc,n): + r""" + Accumulator function for ``direct_sum_repeat``. + """ + if n < 0: + raise ValueError('n should be nonnegative') + elif n == 0: + return acc + return self._direct_sum_rec(self.direct_sum(acc), n-1) + + def direct_sum_repeat(self,n): + r""" + Return the direct sum of ``n`` copies of ``self``. + + EXAMPLES :: + + sage: from vector_bundle import trivial_bundle + sage: F. = FunctionField(GF(3)) + sage: L = trivial_bundle(F) + sage: V = L.direct_sum_repeat(3) + sage: V.rank() + 3 + sage: V.degree() + 0 + sage: V.h0() + [(1, 0, 0), (0, 1, 0), (0, 0, 1)] + """ + if n <= 0: + raise ValueError('n should be positive') + return self._direct_sum_rec(self,n-1) + + def tensor_product(self,other): + r""" + Returns the tensor product of two vector bundles + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: ideals = [P.prime_ideal() for P in K.places_finite()[:2]] + sage: g_finite = matrix([[1, x], [2, y]]) + sage: g_infinite = matrix([[x, 1], [2, y]]) + sage: V1 = VectorBundle(K, ideals, g_finite, g_infinite) + sage: O = K.maximal_order() + sage: V2 = VectorBundle(K, O.ideal(1), 1, x^2) + sage: V = V1.tensor_product(V2) + sage: V.rank() == V1.rank() * V2.rank() + True + sage: V.degree() == V1.degree()*V2.rank() + V2.degree()*V1.rank() + True + """ + ideals = [I * J for I in self._ideals for J in other._ideals] + g_finite = self._g_finite.tensor_product(other._g_finite) + g_infinite = self._g_infinite.tensor_product(other._g_infinite) + return VectorBundle(self._function_field, ideals,g_finite,g_infinite) + + def _tensor_power_aux(self,acc,n): + r""" + Auxiliary recursive function for ``tensor_power`` + """ + if n < 0: + raise ValueError('n should be nonnegative') + elif n == 0: + return acc + return self._tensor_power_aux(self.tensor_product(acc),n-1) + + def tensor_power(self,n): + r""" + Return the n-th tensor power of ``self`` + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: L = VectorBundle(F, x.poles()[0].divisor()) + sage: E = L.tensor_power(3) + sage: E.rank() + 1 + sage: E.degree() + 3 + sage: E.h0() + [(1), (x), (x^2), (x^3)] + """ + if n <= 0: + raise ValueError('n should be positive') + return self._tensor_power_aux(self,n-1) + + + def conorm(self,K): + r""" + Return the conorm of the vector bundle over an extension of its base + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: ideals = [P.prime_ideal() for P in F.places_finite()[:2]] + sage: g_finite = matrix([[1, x], [2, x]]) + sage: g_infinite = matrix([[x, 1], [2, x]]) + sage: V = VectorBundle(F, ideals, g_finite, g_infinite) + sage: VK = V.conorm(K) + sage: VK.rank() + 2 + sage: VK.degree() == K.degree() * V.degree() + True + """ + O = K.maximal_order() + ideals = [O.ideal(I.gens()) for I in self._ideals] + return VectorBundle(K, ideals,self._g_finite,self._g_infinite) + + def restriction(self): + r""" + Return the Weil restriction of the vector bundle over the base field of + ``self._function_field`` + + As a vector bundle is seen as a pair of lattices, the Weil restriction + of a bundle is the pair of lattices seen above the maximal orders of + the base field. Equivalently, if the field extension K in L corresponds + to a morphism of curves f from Y to X, the restriction is the direct + image under f. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 + x + 2) + sage: ideals = [P.prime_ideal() for P in K.places_finite()[:2]] + sage: g_finite = matrix([[1, x], [2, y]]) + sage: g_infinite = matrix([[x, 1], [2, y]]) + sage: V = VectorBundle(K, ideals, g_finite, g_infinite) + sage: VF = V.restriction() + sage: VF._ideals + [Ideal (1) of Maximal order of Rational function field in x over Finite Field of size 3, + Ideal (1) of Maximal order of Rational function field in x over Finite Field of size 3, + Ideal (1) of Maximal order of Rational function field in x over Finite Field of size 3, + Ideal (1) of Maximal order of Rational function field in x over Finite Field of size 3] + sage: VF._g_finite + [ x 1 x^2 2*x] + [ 0 1 0 x] + [ 2*x 2 0 2*x + 1] + [ 0 2 x 2] + sage: VF._g_infinite + [ x 0 1 0] + [ 0 1 0 1/x] + [ 2 0 0 (2*x + 1)/x] + [ 0 2/x 1 0] + """ + F = self._function_field.base_field() + trivial_ideal = F.maximal_order().ideal(1) + ideals = [trivial_ideal for _ in range(self._function_field.degree() * self.rank())] + g_finite = matrix([vector(c*self._g_finite[:, i]) for i,I in enumerate(self._ideals) + for c in I.gens_over_base()]) + g_finite = matrix([sum([a.list() for a in collumn],[]) + for collumn in g_finite]).transpose() + gen_infinite = self._function_field.maximal_order_infinite().ideal(1)\ + .gens_over_base() + g_infinite = matrix([vector(c*self._g_infinite[:, i]) for i in range(self.rank()) + for c in gen_infinite]) + g_infinite = matrix([sum([a.list() for a in collumn],[]) + for collumn in g_infinite]).transpose() + return VectorBundle(F, ideals,g_finite,g_infinite) + + def _h0_rational(self): + r""" + Returns a k-basis of self. + + self.function_field must be a rational function field. + Elements of ``self._ideals`` are assumed to be trivial. + Some lines of code are borrowed from the implementation of + ``sage.rings.function_field.divisor.FunctionFieldDivisor._basis`` + + ALGORITHM: + + The basis reduction algorithm used in [Len84] + + TODO: + + Try more recent algorithms such as [GSSV12] + Implement Popov form normalization to get a normalized h0 basis. + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: ideals = [F.maximal_order().ideal(1)] * 2 + sage: g_finite = matrix([[x^-5, x^-1], [2 + x^-2, 1]]) + sage: g_infinite = matrix([[2*x + x^-2, 2], [x^3 + 2*x^-1, 1]]) + sage: V = VectorBundle(F, ideals, g_finite, g_infinite) + sage: V.degree() + 4 + sage: h0 = V._h0_rational(); len(h0) + 6 + sage: O_finite = F.maximal_order() + sage: O_infinite = F.maximal_order_infinite() + sage: all([all([c in O_finite for c in g_finite**-1 * v]) for v in h0]) + True + sage: all([all([c in O_infinite for c in g_infinite**-1 * v]) for v in h0]) + True + """ + mat = self._g_infinite**-1 * self._g_finite + mat_0 = copy(mat) + den = lcm([e.denominator() for e in mat.list()]) + R = den.parent() + one = R.one() + mat = matrix(R,self.rank(),[e.numerator() for e in (den*mat).list()])\ + .transpose() #So we operate on rows + col_swaps = [] + norms = function_field_utility.smallest_norm_first(mat) + k=-1 + while k + 1 < self.rank(): + norms = function_field_utility.smallest_norm_first(mat,k + 1,norms) + if k >= 0: + a = matrix([[mat[i, j][norms[i]] + for j in range(k + 1)] + for i in range(k + 2)]) + target = a[k + 1, :] + a.delete_rows([k + 1]) + r = a.solve_left(target).list() + mat[k + 1, :]-= sum([r[i] + * one.shift(norms[k+1] - norms[i]) + * mat[i, :] + for i in range(k + 1)]) + new_norm = function_field_utility.norm(mat[k+1, :]) + if k < 0 or norms[k+1] == new_norm: + degs = [c.degree() for c in mat[k + 1, :].list()] + i = degs.index(max(degs)) + mat.swap_columns(k + 1, i) + col_swaps.append((k + 1, i)) + k += 1 + else: + norms[k+1] = new_norm + larger = [n > norms[k+1] for n in norms[:k+1]] + if any(larger): + k = larger.index(True) - 1 + while col_swaps: + i, j = col_swaps.pop() + mat.swap_columns(i, j) + mat /= den + basis = [] + for i in range(self.rank()): + for p in range(min([c.denominator().degree() + - c.numerator().degree() + for c in mat[i, :].list()]) + 1): + basis.append(self._g_infinite * vector(one.shift(p)*mat[i, :])) + return basis + + def h0(self): + r""" + Returns a basis of the 0th cohomology group of ``self`` + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 - x^3 - x) + sage: ideals = [P.prime_ideal() for P in K.places_finite()[:2]] + sage: g_finite = matrix([[1,1 / (x**5 + y)],[2, y]]) + sage: g_infinite = matrix([[x, 1], [2, y**3]]) + sage: V = VectorBundle(K, ideals, g_finite, g_infinite) + sage: V.degree() + 6 + sage: h0 = V.h0(); len(h0) + 6 + sage: all([all([c in ideals[i] for i,c in enumerate(list(g_finite**-1 * v))]) for v in h0]) + True + sage: O_infinity = K.maximal_order_infinite() + sage: all([all([c in O_infinity for c in g_infinite**-1 * v]) for v in h0]) + True + + TESTS :: + + sage: from vector_bundle import VectorBundle + sage: from vector_bundle import canonical_bundle + sage: F. = FunctionField(GF(3)) + sage: ideals = [F.maximal_order().ideal(x), F.maximal_order().ideal(1 / (1+x^3))] + sage: g_finite = matrix([[x^-5, x^-1], [2 + x^-2, 1]]) + sage: g_infinite = matrix([[2*x + x^-2, 2], [x^3 + 2*x^-1, 1]]) + sage: V = VectorBundle(F, ideals, g_finite, g_infinite) + sage: V.degree() + 6 + sage: h0 = V.h0(); len(h0) + 8 + sage: all([all([c in ideals[i] for i,c in enumerate(list(g_finite**-1 * v))]) for v in h0]) + True + sage: O_infinite = F.maximal_order_infinite() + sage: all([all([c in O_infinite for c in g_infinite**-1 * v]) for v in h0]) + True + sage: R. = F[] + sage: K. = F.extension(y^4 - x**-2 - 1) + sage: L = canonical_bundle(K) + sage: len(L.h0()) + 1 + """ + if isinstance(self._function_field,RationalFunctionField): + #Compute restriction to normalize the coefficient ideals. + return self.restriction()._h0_rational() + res = self.restriction() + h0_res = res.h0() + h0 = [] + y = self._function_field.gen() + deg = self._function_field.degree() + for v in h0_res: + h0.append(vector([sum([y**j * v[i*deg + j] + for j in range(deg)]) + for i in range(self.rank())])) + return h0 + + @cached_method + def h1_dual(self): + r""" + Return the dual of the 1st cohomology group of the vector bundle. + By Serre duality, this is the 0th cohomology group of + ``canonical_bundle(self._function_field).tensor_product(self.dual())`` + + OUTPUT: + + - a basis of the dual of the h1 of self + - the hom bundle whose h0 has basis the first output + + EXAMPLES :: + + sage: from vector_bundle import trivial_bundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 - x^3 - x) + sage: L = trivial_bundle(K) + sage: L.h1_dual() + ([[1]], + Homomorphism bundle from Vector bundle of rank 1 over Function field in y defined by y^2 + 2*x^3 + 2*x to Vector bundle of rank 1 over Function field in y defined by y^2 + 2*x^3 + 2*x) + """ + from . import constructions + line_bundle = constructions.canonical_bundle(self._function_field) + vector_bundle = self.hom(line_bundle) + return vector_bundle.h0(), vector_bundle + + def h1_dimension(self): + r""" + Return the dimension of the 1st cohomology group of the vector bundle. + + EXAMPLES :: + + sage: from vector_bundle import trivial_bundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 - x^3 - x) + sage: L = trivial_bundle(K) + sage: L.h1_dimension() + 1 + sage: K.genus() + 1 + """ + h1,_ = self.h1_dual() + return len(h1) + + def h1_element(self,form=None): + r""" + Represent a linear form over ``self.h1_dual()`` under Serre duality. + + INPUT: + + - ``form`` -- vector of elements of self._function_field.constant_base_field() representing a linear form over self.h1_dual(). (default: [1,0,...,0]) + + OUTPUT: + + - ''res'' -- vector of elements of K such that the corresponding infinite répartition vectorcorresponds to form under Serre duality with respect to _safe_uniformizer(self._function_field).differential(). + + EXAMPLES :: + + sage: from vector_bundle import VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^4 - x**-2 - 1) + sage: trivial_ideal = K.maximal_order().ideal(1) + sage: g_finite = identity_matrix(K, 2) + sage: pi = K.places_infinite()[0].local_uniformizer() + """ + K = self._function_field + h1_dual, h1_dual_bundle = self.h1_dual() + s = len(h1_dual) + if form is None: + form = [1] + [0] * (s-1) + r = self.rank() + places = function_field_utility.all_infinite_places(K) + pi_0, place_0 = function_field_utility.safe_uniformizer(K) + if not place_0 == places[0]: + raise ValueError('Something went wrong with the order of infinite' + + ' places of the function field') + k,from_k,to_k = place_0.residue_field() + form = vector([function_field_utility.invert_trace( + k, K.constant_base_field(), c) for c in form]) + dual_matrix = matrix([h1_dual_bundle._matrix_to_vector(mat) + for mat in h1_dual]).transpose() + zero_rows = [i for i, row in enumerate(dual_matrix) if row == 0] + exps = [[function_field_utility.local_expansion(place_0, + pi_0,dual_matrix[i, j]) + for j in range(s)] + for i in range(r)] + min_vals = [[min([dual_matrix[i, j].valuation(place) for j in range(s)]) + for i in range(r)] + for place in places] + ell = 0 + n_matrix = matrix(k,0,s,[]) + while n_matrix.rank() < s: + for i in range(r): + row = [exps[i][j](min_vals[0][i] + ell) for j in range(s)] + n_matrix = function_field_utility.insert_row( + n_matrix, (i+1)*(ell+1) - 1, row) + ell +=1 + ell_pow = k.cardinality() ** integer_ceil(logb(ell,k.cardinality())) + res = n_matrix.solve_left(form) + pi = function_field_utility.infinite_approximation( + places, + [1] + [integer_ceil(-min(min_val)/ell) for min_val in min_vals[1:]], + [1] + [0]*(len(places)-1))**ell_pow + res = [function_field_utility.infinite_approximation( + places, + [1] + [0]*(len(places)-1), + [a] + [0]*(len(places)-1))**ell_pow + for a in res] + return [pi + * pi_0**(-min_vals[0][i]-1) + * sum([pi_0**(-j) * res[i*ell + j] for j in range(ell)]) + if not i in zero_rows else 0 + for i in range(r)] + + @cached_method + def extension_group(self, other, precompute_basis=None): + return ext_group.ExtGroup(self, other, precompute_basis) + + def non_trivial_extension(self, other): + ext_group = self.extension_group(other) + return ext_group.extension() + + def extension_by_global_sections(self): + r""" + Return the canonical extension of ``self`` by `\omega^s` where `\omega` is the + canonical line bundle and `s` is `dim(H^0(\mathrm{self}))`. + + This extension is defined in [At57]_ for elliptic curves, but the + constructions generalises to arbitrary genus if one replaces the + trivial line bundle with a canonical line bundle. + + WARNING: + + The implementation is hacky at the moment and relies on the + hypothesis that ``h1_dual`` returns a good basis of the space. + A more robust implementation would either use formal power series to + do linear algebra on the global sections or rely on the ``h0`` computation + using matrices in normal Popov form to have normalized output. + + EXAMPLES :: + + sage: from vector_bundle import trivial_bundle, VectorBundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^2 - x^3 - x) + sage: T = trivial_bundle(K) + sage: E = T.extension_by_global_sections() + sage: E.rank() + 2 + sage: E.hom(E).h0() + [ + [0 1] [1 0] + [0 0], [0 1] + ] + sage: L = VectorBundle(K,K.places_infinite()[0].divisor()) + sage: E = (E.tensor_product(L)).extension_by_global_sections() + sage: E.rank() + 4 + sage: E.degree() + 2 + sage: E.hom(E).h0() + [ + [0 1 0 0] [1 0 0 0] + [0 0 0 0] [0 1 0 0] + [0 0 0 1] [0 0 1 0] + [0 0 0 0], [0 0 0 1] + ] + """ + from . import constructions + h0 = self.h0() + s = len(h0) + ohm = constructions.canonical_bundle(self._function_field)\ + .direct_sum_repeat(s) + ext_group = self.extension_group(ohm) + ext_dual = ext_group.dual_basis() + form = [1 if any([vector(mat[:, i]) == v + for i,v in enumerate(h0)]) else 0 + for mat in ext_dual] + return ext_group.extension(form) + + def is_isomorphic_to(self, other): + r""" + Checks whether self is isomorphic to other + + ALGORITHM: + + Computes the space of global homomorphisms and looks for + an invertible matrix. Can probably be improved. + + EXAMPLES :: + + sage: from vector_bundle import trivial_bundle, canonical_bundle + sage: F. = FunctionField(GF(3)) + sage: R. = F[] + sage: K. = F.extension(y^4 - x^-2 - 1) + sage: triv = trivial_bundle(K) + sage: can = canonical_bundle(K) + sage: triv.is_isomorphic_to(can) + True + """ + mat_basis = self.hom(other).h0() + k = self._function_field.constant_base_field() + return any([sum([(c*mat).is_unit() for c, mat in zip(vec, mat_basis)]) + for vec in ProjectiveSpace(len(mat_basis)-1, k)])