pax_global_header00006660000000000000000000000064137271675500014527gustar00rootroot0000000000000052 comment=50b1e0bd89071e19d07a4ce02eb06d5ef6d1295d libbraiding-1.1/000077500000000000000000000000001372716755000136365ustar00rootroot00000000000000libbraiding-1.1/.gitignore000066400000000000000000000001751372716755000156310ustar00rootroot00000000000000lib/.depends lib/braiding.o lib/cbraid.o lib/libcbraid.a .depends braiding braiding_main.o speedtest speedtest.o test test.o libbraiding-1.1/CHANGELOG000066400000000000000000000136731372716755000150620ustar00rootroot00000000000000Changelog for CBraid and Braiding ================================= ======================================================================== After r12 the code was moved from Googlecode/SVN to GitHub/Git, so no version numbers anymore. From here is the lightly edited svn log. ------------------------------------------------------------------------ r11 | jeanlucth@gmail.com | 2014-07-04 09:06:25 -0500 (Fri, 04 Jul 2014) | 1 line Removed some unused variables in new code. ------------------------------------------------------------------------ r10 | jeanlucth@gmail.com | 2014-07-04 09:02:38 -0500 (Fri, 04 Jul 2014) | 7 lines New code contributed by Maria Cumplido (student of Juan González-Meneses). Juan's description: The old code computed some sets called Ultra Summit Sets, while the new one computes Sets of Sliding Circuits (which are in general the same as above, but not always). ------------------------------------------------------------------------ r9 | jeanlucth@gmail.com | 2013-12-13 08:29:27 -0600 (Fri, 13 Dec 2013) | 1 line Updated CHANGELOG. ------------------------------------------------------------------------ r8 | jeanlucth@gmail.com | 2013-12-13 08:20:15 -0600 (Fri, 13 Dec 2013) | 1 line Updated CHANGELOG. ------------------------------------------------------------------------ r7 | mbudisic | 2013-09-24 11:11:11 -0500 (Tue, 24 Sep 2013) | 1 line The code wouldn't compile on Mac OS X clang XCode 5 without adding std:: namespace specifications to stdlib functions. ------------------------------------------------------------------------ r6 | jeanlucth@gmail.com | 2013-08-03 09:43:46 -0500 (Sat, 03 Aug 2013) | 1 line Remove unused variables cur, current. ------------------------------------------------------------------------ r5 | jeanlucth@gmail.com | 2011-10-18 22:23:24 -0500 (Tue, 18 Oct 2011) | 1 line Update svn:ignore. ------------------------------------------------------------------------ r4 | jeanlucth@gmail.com | 2011-10-07 15:30:32 -0500 (Fri, 07 Oct 2011) | 1 line Remove -fPIC compile flag. ------------------------------------------------------------------------ r3 | jeanlucth@gmail.com | 2011-09-19 15:20:47 -0500 (Mon, 19 Sep 2011) | 6 lines * Updated GPL (renamed LICENSE). * Improve Makefile for programs. * Moved remaining .h files to include. * Updated CHANGELOG to reflect move to Google code. * Tiny INSTALL file. ------------------------------------------------------------------------ r2 | jeanlucth@gmail.com | 2011-09-19 12:36:31 -0500 (Mon, 19 Sep 2011) | 2 lines Imported sources from jeanluc's private braid project (braid:trunk/cbraid r447). ======================================================================== From here the revision numbers refer to Jean-Luc's private braid project. ------------------------------------------------------------------------ r432 | jeanluc | 2011-09-17 15:54:24 -0500 (Sat, 17 Sep 2011) | 4 lines * Move all executables (including braiding_main.cpp) to programs folder. * Removed sample and braiding folders. * Makefile also builds braiding program. ------------------------------------------------------------------------ r431 | jeanluc | 2011-09-17 13:44:30 -0500 (Sat, 17 Sep 2011) | 1 line Removed unused vars and trailing spaces from braiding. ------------------------------------------------------------------------ r428 | jeanluc | 2011-09-16 09:36:19 -0500 (Fri, 16 Sep 2011) | 4 lines * Merged braiding into libcbraid. Updated Makefile. * The cbraid and braiding .h files are now in an include folder. * Moved braidlcf to the braidlcs Multi_Use_Code, added Makefile that should be able to build MEX files on different systems. ------------------------------------------------------------------------ r424 | jeanluc | 2011-09-14 17:46:01 -0500 (Wed, 14 Sep 2011) | 1 line Better comment for update; use flags needed for Matlab MEX-file compilation. ------------------------------------------------------------------------ r418 | jeanluc | 2011-09-13 20:48:00 -0500 (Tue, 13 Sep 2011) | 3 lines * Braiding: Wrap in Braiding namespace. * Braiding: Reformat. ------------------------------------------------------------------------ r417 | jeanluc | 2011-09-13 18:40:52 -0500 (Tue, 13 Sep 2011) | 6 lines * Include std global namespaces in braiding, since I don't include them in CBraid anymore. * For CBraid, do not include the namespace CBraid in cbraid.cpp, but rather include it in the namespace itself. ------------------------------------------------------------------------ r416 | jeanluc | 2011-09-13 18:36:00 -0500 (Tue, 13 Sep 2011) | 2 lines Added program "braiding" by Juan Gonzalez-Meneses. ------------------------------------------------------------------------ r415 | jeanluc | 2011-09-13 18:17:47 -0500 (Tue, 13 Sep 2011) | 7 lines Updated for GCC 4.4.5: * No longer allowed to use typedef A A. So instead typedef Factor

Factor now use typedef Factor

CanonicalFactor. * Various other places where the stricter template parsing made the compiler unhappy. * Changed time.h to ctime. ------------------------------------------------------------------------ r414 | jeanluc | 2011-09-13 17:53:32 -0500 (Tue, 13 Sep 2011) | 14 lines Changes to CBraid to go to gcc-3.4: * Redefined sint16 and uint16 to be int and unsigned int, rather than short and unsigned short. shorts are just too short. Redo this with explicit types. * Added typename after typedef and in external class definition. * Added std:: in many places. * Changed optarg to OptArg to avoid name clash. * Bugfix in cbraid_interface: the function Complement was using ~a (which doesn't even compile) rather than the inverse of *this. Note that these changes are no longer sufficient for the code to compile with GCC 4.4.5, but I wanted a separate commit for the old changes. ------------------------------------------------------------------------ r413 | jeanluc | 2011-09-13 17:05:20 -0500 (Tue, 13 Sep 2011) | 2 lines Added source code CBraid version 2001/12/07 by Jae Choon Cha. libbraiding-1.1/LICENSE000066400000000000000000001045131372716755000146470ustar00rootroot00000000000000 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 . libbraiding-1.1/Makefile.am000066400000000000000000000000771372716755000156760ustar00rootroot00000000000000SUBDIRS = lib ACLOCAL_AMFLAGS = -I m4 AM_LDFLAGS=-no-undefined libbraiding-1.1/README.md000066400000000000000000000020101372716755000151060ustar00rootroot00000000000000# libbraiding This is a project to expose the functionalitis of the _Braiding_ program as a shared library. The original goal is to include it as a component of [SageMath](https://www.sagemath.org), but it can be used in any other c++ program. This code is maintained by **[Miguel Marco-Buzunariz](https://riemann.unizar.es/~mmarco)**, as a fork of the one maintained by **[Jean-Luc Thiffeault](http://www.math.wisc.edu/~jeanluc)**. _CBraid_ is a C++ library originally written by **[Jae Choon Cha](http://gt.postech.ac.kr/~jccha/)**. It allows various computations on braid groups, such as normal forms. The code in this project is based on his final version of 2001/12/07 and distributed under the GPL. The library has been updated to run on modern compilers, and has been merged with _Braiding_ version v1.0 (2004/10/04) originally written by **[Juan Gonzalez-Meneses](http://personal.us.es/meneses/)** and distributed under the GPL. Maria Cumplido contributed some code for computing sets of sliding circuits. libbraiding-1.1/configure.ac000066400000000000000000000003371372716755000161270ustar00rootroot00000000000000AC_INIT([libbraiding], [1.1], [mmarco@unizar.es]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE([foreign -Wall]) AM_PROG_AR AC_PROG_CXX LT_INIT AC_CONFIG_FILES([Makefile lib/Makefile]) AC_OUTPUT libbraiding-1.1/lib/000077500000000000000000000000001372716755000144045ustar00rootroot00000000000000libbraiding-1.1/lib/Makefile.am000066400000000000000000000004001372716755000164320ustar00rootroot00000000000000lib_LTLIBRARIES = libbraiding.la libbraiding_la_SOURCES = cbraid.cpp braiding.cpp braiding.h cbraid.h cbraid_implementation.h cbraid_interface.h libbraiding_la_LDFLAGS = -lm include_HEADERS = braiding.h cbraid.h cbraid_implementation.h cbraid_interface.hlibbraiding-1.1/lib/braiding.cpp000066400000000000000000002202211372716755000166660ustar00rootroot00000000000000/* Copyright (C) 2004 Juan Gonzalez-Meneses. This file is part of Braiding. Braiding 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 2 of the License, or any later version. Braiding 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 Braiding. If not, see . */ /* braiding.cpp, v 1.0. 04/10/2004 Juan Gonzalez-Meneses */ #include "cbraid.h" #include #include #include using namespace CBraid; using namespace std; namespace Braiding { // typedef ArtinPresentation P; /////////////////////////////////////////////////////// // // CL(B) computes the Canonical length of a braid B, // given in Left Canonical Form // /////////////////////////////////////////////////////// sint16 CL(ArtinBraid B) { sint16 n=0; ArtinBraid::ConstFactorItr it; for(it=B.FactorList.begin(); it!=B.FactorList.end(); it++) n++; return n; } /////////////////////////////////////////////////////// // // Sup(B) computes the supremun of a braid B, // given in Left Canonical Form // /////////////////////////////////////////////////////// sint16 Sup(ArtinBraid B) { sint16 s; s=CL(B)+B.LeftDelta; return s; } /////////////////////////////////////////////////////// // // Cycling(B) computes the cycling of a braid B, // given in Left Canonical Form // /////////////////////////////////////////////////////// ArtinBraid Cycling(ArtinBraid B) { sint16 n; if (CL(B)==0) return B; // B.MakeLCF(); n=B.Index(); ArtinFactor F=ArtinFactor(n); F=*B.FactorList.begin(); B.FactorList.push_back(F.Flip(-B.LeftDelta)); B.FactorList.pop_front(); B.MakeLCF(); return B; } /////////////////////////////////////////////////////// // // Decycling(B) computes the decycling of a braid B, // given in Left Canonical Form // /////////////////////////////////////////////////////// ArtinBraid Decycling(ArtinBraid B) { sint16 n; if (CL(B)==0) return B; // B.MakeLCF(); n=B.Index(); ArtinFactor F=ArtinFactor(n); F=B.FactorList.back(); B.FactorList.push_front(F.Flip(B.LeftDelta)); B.FactorList.pop_back(); B.MakeLCF(); return B; } ///////////////////////////////////////////////////////////// // // WordToBraid(w,n) Transforms a word w (list of letters) // into a braid on n strands in LCF. // ///////////////////////////////////////////////////////////// ArtinBraid WordToBraid(list w, sint16 n) { ArtinBraid B=ArtinBraid(n); ArtinBraid B2=ArtinBraid(n); ArtinFactor F=ArtinFactor(n); sint16 k, sigma, i; list::iterator it; for(it=w.begin(); it!= w.end(); it++) { if(*it>0) { if(*it==n) F.Delta(); else { F.Identity(); sigma=*it; k=F[sigma]; F[sigma]=F[sigma+1]; F[sigma+1]=k; } B.RightMultiply(F); } else { if(*it==-n) { B2.Identity(); B2.LeftDelta=-1; } else { F.Identity(); i=-*it; k=F[i]; F[i]=F[i+1]; F[i+1]=k; F=(~F).Flip(); B2=(!ArtinBraid(ArtinFactor(n,1)))*ArtinBraid(F); } B.RightMultiply(B2); } } B.MakeLCF(); return B; } ///////////////////////////////////////////////////////////// // // PrintBraidWord(B) Shows on the screen the braid B // (given in left or right normal form) // written as a word in Artin generators. // ///////////////////////////////////////////////////////////// void PrintBraidWord(ArtinBraid B) { if(B.LeftDelta==1) { cout << "D"; if (CL(B)) cout << " . "; } else if(B.LeftDelta!=0) { cout << "D^(" << B.LeftDelta << ")"; if (CL(B)) cout << " . "; } sint16 i, j, k, n=B.Index(); ArtinFactor F=ArtinFactor(n); list::iterator it; for(it=B.FactorList.begin(); it!=B.FactorList.end(); it++) { if(it!=B.FactorList.begin()) cout << ". "; F=*it; for(i=2; i<=n; i++) { for(j=i; j>1 && F[j]::iterator it; for(it=B.FactorList.begin(); it!=B.FactorList.end(); it++) { if(it!=B.FactorList.begin()) f << ". "; F=*it; for(i=2; i<=n; i++) { for(j=i; j>1 && F[j] & word, sint16 n, sint16 power) { list::iterator itw; if(power!=1) cout << "( "; for(itw=word.begin(); itw!=word.end(); itw++) { if(*itw==n) cout << "D "; else if (*itw==-n) cout << "-D "; else cout << *itw << " "; } if(power!=1) cout << ")^" << power; } ///////////////////////////////////////////////////////////// // // PrintWord(word,n,power,file) Prints on "file" the braid "word" // on n strands raised to some "power". // ///////////////////////////////////////////////////////////// void PrintWord(list & word, sint16 n, sint16 power, char * file) { list::iterator itw; ofstream f(file,ios::app); if(power!=1) f << "( "; for(itw=word.begin(); itw!=word.end(); itw++) { if(*itw==n) f << "D "; else if (*itw==-n) f << "-D "; else f << *itw << " "; } if(power!=1) f << ")^" << power; f.close(); } ///////////////////////////////////////////////////////////// // // Crossing(word,n,power) Computes the crossing numbers of // the braid on n strands given by // "word" raised to "power". // ///////////////////////////////////////////////////////////// void Crossing(list word, sint16 n, sint16 power, sint16 ** cross) { sint16 i,j,k,l,m; list::iterator itw; sint16 *perm= new sint16[n]; for(i=1; i<=n; i++) perm[i]=i; for(i=1; i0) l=*itw; else l=-(*itw); if(perm[l]0) cross[i][j]++; else cross[i][j]--; k=perm[l]; perm[l]=perm[l+1]; perm[l+1]=k; } } } delete[] perm; } ///////////////////////////////////////////////////////////// // // SendToSSS(B) Computes a braid conjugate to B that // belongs to its Super Summit Set. // ///////////////////////////////////////////////////////////// ArtinBraid SendToSSS(ArtinBraid B) { sint16 n, k, j, p, l; n=B.Index(); k=n*(n-1)/2; ArtinBraid B2=ArtinBraid(n), B3=ArtinBraid(n); B.MakeLCF(); j=0; B2=B; B3=B; p=B.LeftDelta; while (j <= k) { B2=Cycling(B2); if(B2.LeftDelta==p) j++; else { B3=B2; p++; j=0; } } j=0; B2=B3; l=Sup(B2); while (j <= k) { B2=Decycling(B2); if(Sup(B2)==l) j++; else { B3=B2; l--; j=0; } } return B3; } ///////////////////////////////////////////////////////////// // // SendToSSS(B,C) Computes a braid conjugate to B that // belongs to its Super Summit Set, and a braid // C that conjugates B to the result. // ///////////////////////////////////////////////////////////// ArtinBraid SendToSSS(ArtinBraid B, ArtinBraid & C) { sint16 n, k, j, p, l; n=B.Index(); k=n*(n-1)/2; ArtinBraid B2=ArtinBraid(n), B3=ArtinBraid(n), C2=ArtinBraid(n); B.MakeLCF(); C=ArtinBraid(n); j=0; B2=B; B3=B; p=B.LeftDelta; while (j <= k) { if(CL(B2)==0) { C.MakeLCF(); return B2; } C2=C2*((*B2.FactorList.begin()).Flip(B2.LeftDelta)); B2=Cycling(B2); if(B2.LeftDelta==p) j++; else { B3=B2; p++; j=0; C=C*C2; C2=ArtinBraid(n); } } j=0; B2=B3; l=Sup(B2); C2=ArtinBraid(n); while (j <= k) { C2.LeftMultiply(B2.FactorList.back()); B2=Decycling(B2); if(Sup(B2)==l) j++; else { B3=B2; l--; j=0; C=C*(!C2); C2=ArtinBraid(n); } } C.MakeLCF(); return B3; } ///////////////////////////////////////////////////////////// // // LeftWedge(F1,F2) Given two simple factors F1 and F2, computes // their left lcm. That is, the smallest simple factor // F such that F1F1 and F>F2. // ///////////////////////////////////////////////////////////// ArtinFactor RightWedge(ArtinFactor F1, ArtinFactor F2) { return !LeftWedge(!F1,!F2); } ///////////////////////////////////////////////////////////// // // Remainder(B,F) Given a positive braid B in LCF and a simple // factor F, computes the simple factor S such // that BS=LeftWedge(B,F). // ///////////////////////////////////////////////////////////// ArtinFactor Remainder(ArtinBraid B, ArtinFactor F) { ArtinFactor Fi= F; if(B.LeftDelta!=0) { Fi.Identity(); return Fi; } list::iterator it; for(it=B.FactorList.begin(); it!=B.FactorList.end(); it++) { Fi=!(*it)*LeftWedge(*it,Fi); } return Fi; } ///////////////////////////////////////////////////////////// // // LeftMeet(B1,B2) Given two braids B1 and B2, computes // their left gcd. That is, the greatest braid // B such that B0) F1=ArtinFactor(n,1); else if(CL(B1)==0) F1=ArtinFactor(n,0); else F1=*B1.FactorList.begin(); if(B2.LeftDelta>0) F2=ArtinFactor(n,1); else if(CL(B2)==0) F2=ArtinFactor(n,0); else F2=*B2.FactorList.begin(); F=LeftMeet(F1,F2); B.RightMultiply(F); B1.LeftMultiply(!(ArtinBraid(F))); B1.MakeLCF(); B2.LeftMultiply(!(ArtinBraid(F))); B2.MakeLCF(); } B.MakeLCF(); B.LeftDelta-=shift; return B; } ///////////////////////////////////////////////////////////// // // LeftWedge(B1,B2) Given two braids B1 and B2, computes // their left lcm. That is, the smallest braid // B such that B10) F2=ArtinFactor(n,1); else if(CL(B2)==0) F2=ArtinFactor(n,0); else F2=*B2.FactorList.begin(); F=Remainder(B1,F2); B.RightMultiply(F); B1.RightMultiply(F); B1.LeftMultiply(!(ArtinBraid(F2))); B1.MakeLCF(); B2.LeftMultiply(!(ArtinBraid(F2))); B2.MakeLCF(); } B.MakeLCF(); B.LeftDelta-=shift; return B; } ///////////////////////////////////////////////////////////// // // MinSS(B,F) Given a braid B in its Summit Set (and in LCF), // computes the minimal simple factor R such that // Fcl) { R=R*(*B2.FactorList.begin()); B2=(!(ArtinBraid(R))*B*R).MakeRCF(); } return R; } ///////////////////////////////////////////////////////////// // // MinSSS(B) Given a braid B in its Super Summit Set (and in LCF), // computes the set of minimal simple factors R that // B^R is in the Super Summit Set. // ///////////////////////////////////////////////////////////// list MinSSS(ArtinBraid B) { sint16 i,j,k,test; sint16 n=B.Index(); sint16 *table=new sint16[n]; list Min; for(i=0; iF[j+1]) test=0; } for(j=i+1; jF[j+1]) test=0; } if(test) Min.push_back(F); } return Min; } ///////////////////////////////////////////////////////////// // // SSS(B) Given a braid B, computes its Super Summit Set. // ///////////////////////////////////////////////////////////// list SSS(ArtinBraid B) { ArtinBraid B2=SendToSSS(B); ArtinFactor F=ArtinFactor(B.Index()); list Min; list::iterator itf; list sss; sss.push_back(B2); list::iterator it=sss.begin(); while(it!=sss.end()) { Min=MinSSS(*it); for(itf=Min.begin(); itf!=Min.end(); itf++) { F=*itf; B2=((!ArtinBraid(F))*(*it)*F).MakeLCF(); if (find(sss.begin(),sss.end(),B2)==sss.end()) sss.push_back(B2); } it++; } return sss; } ///////////////////////////////////////////////////////////// // // Trajectory(B) Computes the trajectory of a braid B, that is, // a list containing the iterated cyclings of B, // until the first repetition. // ///////////////////////////////////////////////////////////// list Trajectory(ArtinBraid B) { list p; list::iterator it; while (find(p.begin(),p.end(),B)==p.end()) { p.push_back(B); B=Cycling(B); } return p; } ///////////////////////////////////////////////////////////// // // SendToUSS(B) Computes a braid conjugate to B that // belongs to its Ultra Summit Set. // ///////////////////////////////////////////////////////////// ArtinBraid SendToUSS(ArtinBraid B) { ArtinBraid B2=SendToSSS(B); list T=Trajectory(B2); return Cycling(T.back()); } ///////////////////////////////////////////////////////////// // // SendToUSS(B,C) Computes a braid conjugate to B that // belongs to its Ultra Summit Set, and a braid // C that conjugates B to the result. // ///////////////////////////////////////////////////////////// ArtinBraid SendToUSS(ArtinBraid B, ArtinBraid & C) { ArtinBraid B2=SendToSSS(B,C); list T=Trajectory(B2); ArtinBraid D=Cycling(T.back()); list::iterator it=T.begin(); while((*it)!=D) { C=C*((*(*it).FactorList.begin()).Flip(B2.LeftDelta)); it++; } return D; } ///////////////////////////////////////////////////////////// // // Transport(B,F) Given a braid B (in its USS and in LCF), and a simple factor // F such that B^F is in its SSS, computes the transport of F. // ///////////////////////////////////////////////////////////// ArtinFactor Transport(ArtinBraid B, ArtinFactor F) { ArtinBraid B2=((!ArtinBraid(F))*B*F).MakeLCF(); ArtinBraid B3=((!ArtinBraid(*B.FactorList.begin()))*F*(*B2.FactorList.begin())).MakeLCF(); return *B3.FactorList.begin(); } ///////////////////////////////////////////////////////////// // // Returns(B,F) Given a braid B (in its USS and in LCF), and a simple factor // F such that B^F is in its SSS, computes the iterated transports // of F that send B to an element in the trayectory of B^F, until // the first repetition. // ///////////////////////////////////////////////////////////// list Returns(ArtinBraid B, ArtinFactor F) { list ret; list::iterator it=ret.end(); sint16 n=B.Index(); ArtinBraid B1=B, C1=ArtinBraid(n), C2=ArtinBraid(n); sint16 i, N=1; ArtinFactor F1=F; C1=ArtinBraid((*B1.FactorList.begin()).Flip(B1.LeftDelta)); B1=Cycling(B1); while(B1!=B) { C1.RightMultiply((*B1.FactorList.begin()).Flip(B1.LeftDelta)); B1=Cycling(B1); N++; } while(it==ret.end()) { ret.push_back(F1); B1=((!ArtinBraid(F1))*B*F1).MakeLCF(); C2.Identity(); for(i=0; i::iterator it; for(it=B.FactorList.begin(); it!=B.FactorList.end(); it++) { if(it!=B.FactorList.begin()) bi=(!(*it))*LeftWedge(bi,*it); } ArtinFactor b=LeftWedge(b0,bi); return MinSSS(B,b); } ///////////////////////////////////////////////////////////// // // MainPullback(B,F) Given a braid B (in its USS and in LCF), and a // simple factor F, computes a suitable iterated pullback // of F (the factor p_B(F) in Gebhardt's paper). // ///////////////////////////////////////////////////////////// ArtinFactor MainPullback(ArtinBraid B, ArtinFactor F) { list ret; list::iterator it=ret.end(); ArtinBraid B2=B; sint16 i; list T=Trajectory(B); list::reverse_iterator itb; ArtinFactor F2=F; while (it==ret.end()) { ret.push_back(F2); for(itb=T.rbegin(); itb!=T.rend(); itb++) F2=Pullback(*itb,F2); it=find(ret.begin(),ret.end(),F2); } list::iterator it2=it; sint16 l=0; while(it2!=ret.end()) { it2++; l++; } sint16 test; if (it==ret.begin()) { test=0; } else test=1; it2=ret.begin(); while(test) { for(i=0; i ret=Returns(B,F2); list::iterator it; for(it=ret.begin(); it!=ret.end(); it++) { if(LeftMeet(F,*it)==F) return *it; } F2=MainPullback(B,F); ret=Returns(B,F2); for(it=ret.begin(); it!=ret.end(); it++) { if(LeftMeet(F,*it)==F) return *it; } cout << "Error in MinUSS."; exit(1); } ///////////////////////////////////////////////////////////// // // MinUSS(B) Given a braid B in its Ultra Summit Set (and in LCF), // computes the set of minimal simple factors R that // B^R is in the Ultra Summit Set. // ///////////////////////////////////////////////////////////// list MinUSS(ArtinBraid B) { sint16 i,j,k,test; sint16 n=B.Index(); sint16 *table=new sint16[n]; list Min; for(i=0; iF[j+1]) test=0; } for(j=i+1; jF[j+1]) test=0; } if(test) { Min.push_back(F); table[i-1]=1; } } delete[] table; return Min; } ///////////////////////////////////////////////////////////// // // USS(B) Given a braid B, computes its Ultra Summit Set. // ///////////////////////////////////////////////////////////// list > USS(ArtinBraid B) { list > uss; ArtinFactor F=ArtinFactor(B.Index()); list Min; list::iterator itf, itf2; list::iterator itb; ArtinBraid B2=SendToUSS(B); list T=Trajectory(B2); list::reverse_iterator rit=T.rbegin(); uss.push_back(Trajectory(Cycling(*rit))); B2=((!ArtinBraid(ArtinFactor(B.Index(),1)))*(Cycling(*rit))*ArtinFactor(B.Index(),1)).MakeLCF(); for(itb=(*uss.begin()).begin(); itb!=(*uss.begin()).end(); itb++) { if(B2==*itb) break; } if(itb==(*uss.begin()).end()) uss.push_back(Trajectory(B2)); list >::iterator it=uss.begin(), it2; while(it!=uss.end()) { Min=MinUSS(*(*it).begin()); for(itf=Min.begin(); itf!=Min.end(); itf++) { F=*itf; B2=((!ArtinBraid(F))*(*(*it).begin())*F).MakeLCF(); T=Trajectory(B2); for(itb=T.begin(); itb!=T.end(); itb++) { for(it2=uss.begin(); it2!=uss.end(); it2++) { if(*itb==*(*it2).begin()) break; } if(it2!=uss.end()) break; } if(itb==T.end()) { uss.push_back(T); B2=((!ArtinBraid(ArtinFactor(B.Index(),1)))*(*T.begin())*ArtinFactor(B.Index(),1)).MakeLCF(); for(itb=T.begin();itb!=T.end(); itb++) { if(B2==*itb) break; } if(itb==T.end()) uss.push_back(Trajectory(B2)); } } it++; } return uss; } ///////////////////////////////////////////////////////////// // // USS(B,mins,prev) Given a braid B, computes its Ultra Summit Set, // and stores in the lists 'mins' and 'prev' the following data: // for each i, the first braid of the orbit i is obtained by // conjugation of the first element of the orbit prev[i] // by the simple element mins[i]. // ///////////////////////////////////////////////////////////// list > USS(ArtinBraid B, list & mins, list & prev) { list > uss; ArtinBraid B2=SendToUSS(B); list T=Trajectory(B2); list::reverse_iterator rit=T.rbegin(); uss.push_back(Trajectory(Cycling(*rit))); ArtinFactor F=ArtinFactor(B.Index()); list Min; list::iterator itf, itf2; list::iterator itb; sint16 current=0; mins.clear(); prev.clear(); mins.push_back(ArtinFactor(B.Index(),0)); prev.push_back(1); list >::iterator it=uss.begin(), it2; while(it!=uss.end()) { current++; Min=MinUSS(*(*it).begin()); for(itf=Min.begin(); itf!=Min.end(); itf++) { F=*itf; B2=((!ArtinBraid(F))*(*(*it).begin())*F).MakeLCF(); T=Trajectory(B2); for(itb=T.begin(); itb!=T.end(); itb++) { for(it2=uss.begin(); it2!=uss.end(); it2++) { if(*itb==*(*it2).begin()) break; } if(it2!=uss.end()) break; } if(itb==T.end()) { uss.push_back(T); mins.push_back(F); prev.push_back(current); } } it++; } return uss; } ///////////////////////////////////////////////////////////// // // TreePath(B,uss,mins,prev) Computes a braid that conjugates // the first element in the Ultra Summit Set uss // to the braid B (which must be in the uss). // ///////////////////////////////////////////////////////////// ArtinBraid TreePath(ArtinBraid B, list > & uss, list & mins, list & prev) { sint16 n=B.Index(); ArtinBraid C=ArtinBraid(n); list >::iterator it; list::iterator itb, itb2; sint16 current=0; list::iterator itprev; list::iterator itmins; sint16 i; if(CL(B)==0) return ArtinBraid(n); for(it=uss.begin(); it!=uss.end(); it++) { current++; for(itb=(*it).begin(); itb!=(*it).end(); itb++) { if(*itb==B) break; } if(itb!=(*it).end()) break; } if(it==uss.end()) { cout << "Error in TreePath" << endl; return 0; } for(itb2=(*it).begin(); itb2!=itb; itb2++) C.RightMultiply((*(*itb2).FactorList.begin()).Flip(B.LeftDelta)); while(current!=1) { itprev=prev.begin(); itmins=mins.begin(); for(i=1; i mins; list prev; list > uss=USS(BT1,mins,prev); list >::iterator it; list::iterator itb; sint16 current=0; ArtinBraid D1=ArtinBraid(n), D2=ArtinBraid(n); for(it=uss.begin(); it!=uss.end(); it++) { current++; D2=ArtinBraid(n); for(itb=(*it).begin(); itb!=(*it).end(); itb++) { if(*itb==BT2) break; D2=D2*((*(*itb).FactorList.begin()).Flip((*itb).LeftDelta)); } if(itb!=(*it).end()) break; } if(it==uss.end()) return false; list::iterator itprev; list::iterator itmins; sint16 i; while(current!=1) { itprev=prev.begin(); itmins=mins.begin(); for(i=1; i Centralizer(list > & uss, list & mins, list & prev) { ArtinBraid B=*(*uss.begin()).begin(); sint16 n=B.Index(); list Cent; list >::iterator it; list::iterator itb; ArtinBraid C=ArtinBraid(n), D=ArtinBraid(n), E=ArtinBraid(n), B2=ArtinBraid(n); sint16 cl=CL(B), sup=Sup(B), i; list word; list Min; list::iterator itMin; list::iterator itprev; list::iterator itmins; if(cl==0 && sup%2==0) { word.push_back(1); C=WordToBraid(word,n); Cent.push_back(C); word.clear(); for(i=1; i Centralizer(ArtinBraid B) { sint16 n=B.Index(); list mins; list prev; list > uss=USS(B,mins,prev); list Cent=Centralizer(uss,mins,prev); ArtinBraid C=ArtinBraid(n); SendToUSS(B,C); list::iterator it; for(it=Cent.begin(); it!=Cent.end(); it++) { (*it).LeftMultiply(C); (*it).RightMultiply(!C); (*it).MakeLCF(); } return Cent; } ///////////////////////////////////////////////////////////// // // Tableau(F,tab) Computes the tableau associated to a // simple factor F, and stores it in tab. // ///////////////////////////////////////////////////////////// void Tableau(ArtinFactor F, sint16 **& tab) { sint16 i,j; sint16 n=F.Index(); for(i=0;itab[i+1][i+j]) tab[i][i+j]=tab[i][i+j-1]; else tab[i][i+j]=tab[i+1][i+j]; } } for(j=1;j<=n-1; j++) { for(i=j;i<=n-1; i++) { if(tab[i-1][i-j]::iterator it=B.FactorList.begin(); for (j=0; j=1 && d<=n && d!=k) disj[d]=0; } bk=bkmove[bk]; if (disj[bk]==0) bk=0; } } } if(itype) return true; else return false; } ///////////////////////////////////////////////////////////// // // ThurstonType(B) Determines if a braid B is periodic (1), // reducible (2) or pseudo-Anosov (3). // ///////////////////////////////////////////////////////////// int ThurstonType(ArtinBraid B) { sint16 i, n=B.Index(); sint16 somereducible=0, somePA=0; B.MakeLCF(); ArtinBraid pot=B; for(i=0;i > uss=USS(B); list >::iterator it; sint16 type=3; for(it=uss.begin(); it!=uss.end(); it++) { if(Circles(*(*it).begin())) { type=2; somereducible=1; } else { somePA=1; } } if(somereducible && somePA) cout << "Not all elements in the USS preserve a family of circles!!!"; return type; } ///////////////////////////////////////////////////////////// // // ThurstonType(uss) Determines if the braids in the Ultra // Summit Set uss are periodic (1), // reducible (2) or pseudo-Anosov (3). // ///////////////////////////////////////////////////////////// int ThurstonType(list > & uss) { ArtinBraid B=*(*uss.begin()).begin(); sint16 i, n=B.Index(); sint16 somereducible=0, somePA=0; ArtinBraid pot=B; for(i=0;i >::iterator it; sint16 type=3; for(it=uss.begin(); it!=uss.end(); it++) { if(Circles(*(*it).begin())) { type=2; somereducible=1; } else { somePA=1; } } if(somereducible && somePA) { cout << "Not all elements in the USS of the braid " << endl; PrintBraidWord(*(*uss.begin()).begin()); cout << endl << "preserve a family of circles!!!" << endl; } return type; } ///////////////////////////////////////////////////////////// // // Rigidity(B) Computes the rigidity of a braid B. // ///////////////////////////////////////////////////////////// sint16 Rigidity(ArtinBraid B) { ArtinBraid B2=B.MakeLCF(), B3=B2; sint16 cl=CL(B2), rigidity=0; if(cl==0) return rigidity; ArtinFactor F=(*B3.FactorList.begin()).Flip(B3.LeftDelta); B3=B3*F; B3.MakeLCF(); list::iterator it2, it3; it3=B3.FactorList.begin(); for(it2=B2.FactorList.begin(); it2!=B2.FactorList.end(); it2++) { if(*it2!=*it3) break; rigidity++; it3++; } return rigidity; } ///////////////////////////////////////////////////////////// // // Rigidity(uss) Computes the maximal rigidity of a braid // in the Ultra Summit Set uss. // ///////////////////////////////////////////////////////////// sint16 Rigidity(list > & uss) { list >::iterator it; sint16 rigidity=0, next, conjecture=0; for(it=uss.begin(); it!=uss.end(); it++) { if(it==uss.begin()) rigidity=Rigidity(*(*it).begin()); else { next=Rigidity(*(*it).begin()); if (next!=rigidity) { conjecture=1; if(next>rigidity) rigidity=next; } } } if (conjecture) { cout << endl << "There are elements is the USS of" << endl; PrintBraidWord(*(*uss.begin()).begin()); cout << endl << "with distinct rigidities!!!" << endl; } return rigidity; } ///////////////////////////////////////////////////////////// // // ReadIndex() Asks to type the number of strands. // ///////////////////////////////////////////////////////////// sint16 ReadIndex() { sint16 n; cout << endl << "Set the number of strands: "; cin >> n; cin.ignore(); return n; } ///////////////////////////////////////////////////////////// // // ReadWord(n) Asks to type a braid word on n strands, // and returns the braid word. // ///////////////////////////////////////////////////////////// list ReadWord(sint16 n) { list word; sint16 a; cout << endl << "Type a braid with " << n << " strands: " << "('" << n << "' = Delta)" << endl << endl; while(cin.peek()!='\n') { cin >> ws >> a; word.push_back(a); } cin.ignore(); return word; } ///////////////////////////////////////////////////////////// // // ReadPower() Asks to type the power to which the braid // will be raised. // ///////////////////////////////////////////////////////////// sint16 ReadPower() { sint16 power; cout << endl << "Raise it to power... "; cin >> power; cin.ignore(); return power; } ///////////////////////////////////////////////////////////// // // RaisePower(B,k) Raises the braid B to the power k. // ///////////////////////////////////////////////////////////// ArtinBraid RaisePower(ArtinBraid B, sint16 k) { ArtinBraid original=B; sint16 i; if(k==0) B.Identity(); else if(k>0) { for(i=1; i > & uss, list word, sint16 n, sint16 power, char * file, sint16 type, sint16 rigidity) { ofstream f(file); sint16 orbits=0; list >::iterator it; list::iterator oit, itb; ArtinBraid B2=ArtinBraid(n); for(it=uss.begin(); it!=uss.end(); it++) orbits++; sint16 *sizes=new sint16[orbits]; sint16 size; sint16 i; it=uss.begin(); for(i=0; i::iterator itw; f << "This file contains the Ultra Summit Set of the braid on " << n << " strands:" << endl << endl; if(power!=1) f << "( "; for(itw=word.begin(); itw!=word.end(); itw++) { if(*itw==n) f << "D "; else if (*itw==-n) f << "-D "; else f << *itw << " "; } if(power!=1) f << ")^" << power; sint16 total; if(orbits==1) { f << endl << endl << "It has 1 orbit, whose size is " << sizes[0] << "." << endl << endl; total=sizes[0]; } else { f << endl << endl << "It has " << orbits << " orbits, whose sizes are: "; total=0; for(i=0; i9) file[5]='M'; else file[5]='0'+orbit; file[6]='_'; sint16 digits=1; j=10; while(max_iteration/j>=1) { j=j*10; digits++; } i=1; for(j=1;jB and B2>B. // ///////////////////////////////////////////////////////////// ArtinBraid RightMeet(ArtinBraid B1, ArtinBraid B2) { return Reverse(LeftMeet(Reverse(B1),Reverse(B2))); } ///////////////////////////////////////////////////////////// // // LeftJoin(B1,B2) Given two braids B1 and B2, computes // their left lcm. That is, the smallest braid // B such that B10) F2=ArtinFactor(n,1); else if(CL(B2)==0) F2=ArtinFactor(n,0); else F2=B2.FactorList.front(); F=Remainder(B1,F2); B.RightMultiply(F); B1.RightMultiply(F); ////////////// Multiply B1 from the left by F2^{-1}. B1.LeftDelta--; B1.FactorList.push_front((~F2).Flip(B1.LeftDelta)); B1.MakeLCF(); ////////////// Multiply B2 from the left by F2^{-1}. B2.LeftDelta--; B2.FactorList.push_front((~F2).Flip(B2.LeftDelta)); B2.MakeLCF(); } B.MakeLCF(); B.LeftDelta+=shift; return B; } ///////////////////////////////////////////////////////////// // // RightJoin(B1,B2) Given two braids B1 and B2, computes // their right lcm. That is, the smallest braid // B such that B>B1 and B>B2. // ///////////////////////////////////////////////////////////// ArtinBraid RightJoin(ArtinBraid B1, ArtinBraid B2) { return Reverse(LeftJoin(Reverse(B1),Reverse(B2))); } /////////////////////////////////////////////////////// // // InitialFactor(B) computes the initial factor of a braid B, // given in Left Canonical Form // /////////////////////////////////////////////////////// ArtinFactor InitialFactor(ArtinBraid B) { sint16 n=B.Index(); ArtinFactor F=ArtinFactor(n,0); if(CL(B)>0) F=(B.FactorList.front()).Flip(-B.LeftDelta); return F; } /////////////////////////////////////////////////////// // // PreferredPrefix(B) computes the preferred prefix of a braid B, // given in Left Canonical Form // /////////////////////////////////////////////////////// ArtinFactor PreferredPrefix(ArtinBraid B) { ArtinFactor F=ArtinFactor(B.Index(),0); if(CL(B)>0) F=LeftMeet(InitialFactor(B),~B.FactorList.back()); return F; } /////////////////////////////////////////////////////// // // Sliding(B) computes the cyclic sliding of a braid B, // given in Left Canonical Form // /////////////////////////////////////////////////////// ArtinBraid Sliding(ArtinBraid B) { ArtinFactor F=ArtinFactor(B.Index()); if(CL(B)==0) return B; F=PreferredPrefix(B); B.FactorList.front()=(!(F.Flip(B.LeftDelta)))*B.FactorList.front(); B.FactorList.push_back(F); return B.MakeLCF(); } /////////////////////////////////////////////////////// // // PreferredSuffix(B) computes the preferred suffix of a braid B, // given in Left Canonical Form // /////////////////////////////////////////////////////// ArtinFactor PreferredSuffix(ArtinBraid B) { return !(PreferredPrefix(Reverse(B))); } ///////////////////////////////////////////////////////////// // // Trajectory_Sliding(B) Computes the trajectory under cyclic sliding // of a braid B, that is, a list containing eta^k(B), // for k=0,1,... until the first repetition. // ///////////////////////////////////////////////////////////// list Trajectory_Sliding(ArtinBraid B) { list p; while (find(p.begin(),p.end(),B)==p.end()) { p.push_back(B); B=Sliding(B); } return p; } ///////////////////////////////////////////////////////////// // // Trajectory_Sliding(B,C,d) Computes the trajectory of a braid B for cyclic sliding, // a braid C that conjugates B to the // first element of a closed orbit under sliding, // and the number d of slidings needed to reach that element // ///////////////////////////////////////////////////////////// list Trajectory_Sliding(ArtinBraid B, ArtinBraid & C, sint16 & d) { list p; list::iterator it; sint16 n=B.Index(); C=ArtinBraid(n); d=0; while (find(p.begin(),p.end(),B)==p.end()) { p.push_back(B); C.RightMultiply(PreferredPrefix(B)); B=Sliding(B); d++; } ArtinBraid B2=ArtinBraid(n); ArtinBraid C2=ArtinBraid(n); C2.RightMultiply(PreferredPrefix(B)); B2=Sliding(B); d--; while(B2!=B) { C2.RightMultiply(PreferredPrefix(B2)); B2=Sliding(B2); d--; } C.RightMultiply(!C2); C.MakeLCF(); return p; } ///////////////////////////////////////////////////////////// // // SendToSC(B) Computes a braid conjugate to B that // belongs to its Sliding Circuits Set. // ///////////////////////////////////////////////////////////// ArtinBraid SendToSC(ArtinBraid B) { list T=Trajectory_Sliding(B); return Sliding(T.back()); } ///////////////////////////////////////////////////////////// // // SendToSC(B,C) Computes a braid conjugate to B that // belongs to its Sliding Circuits Set, and a braid // C that conjugates B to the result. // ///////////////////////////////////////////////////////////// ArtinBraid SendToSC(ArtinBraid B, ArtinBraid & C) { sint16 d; list T=Trajectory_Sliding(B,C,d); return Sliding(T.back()); } ///////////////////////////////////////////////////////////// // // Transport_Sliding(B,F) Given a braid B (in its SC and in LCF), and a simple factor // F such that B^F is in its SSS, computes the transport of F for sliding. // ///////////////////////////////////////////////////////////// ArtinFactor Transport_Sliding(ArtinBraid B, ArtinFactor F) { ArtinBraid B2=((!ArtinBraid(F))*B*F).MakeLCF(); ArtinBraid B3=((!ArtinBraid(PreferredPrefix(B)))*F*(PreferredPrefix(B2))).MakeLCF(); ArtinFactor F2=ArtinFactor(B2.Index(),0); if(CL(B3)>0) F2=B3.FactorList.front(); else if (B3.LeftDelta==1) F2=ArtinFactor(B2.Index(),1); return F2; } ///////////////////////////////////////////////////////////// // // Returns_Sliding(B,F) Given a braid B (in its SC and in LCF), and a simple factor // F such that B^F is in its SSS, computes the iterated transports // of F for sliding that send B to an element in the circuit of B^F. // ///////////////////////////////////////////////////////////// list Returns_Sliding(ArtinBraid B, ArtinFactor F) { list ret; list::iterator it=ret.end(); ArtinBraid B1=B; sint16 i, N=1; B1=Sliding(B1); while(B1!=B) { N++; B1=Sliding(B1); } while(it==ret.end()) { ret.push_back(F); B1=B; for(i=0; i ret; list::iterator it=ret.end(); ArtinBraid B2=B; list T=Trajectory_Sliding(B); list::reverse_iterator itb; if(F.CompareWithDelta()) return F; ArtinFactor F2=F; while (it==ret.end()) { ret.push_back(F2); for(itb=T.rbegin(); itb!=T.rend(); itb++) F2=Pullback_Sliding(*itb,F2); it=find(ret.begin(),ret.end(),F2); } return *it; } // María Cumplido Cabello ///////////////////////////////////////////////////////////// // // MinSC(B,F) Given a braid B in its Set of Sliding Circuits (and in LCF), // computes the minimal simple factor R such that // F ret=Returns_Sliding(B,F2); list::iterator it; for(it=ret.begin(); it!=ret.end(); it++) { if(LeftMeet(F,*it)==F) return *it; } F2=MainPullback_Sliding(B,F); ret=Returns_Sliding(B,F2); for(it=ret.begin(); it!=ret.end(); it++) { if(LeftMeet(F,*it)==F) return *it; } return ArtinFactor(B.Index(),1); } ///////////////////////////////////////////////////////////// // // MinSC(B) Given a braid B in its Set of Sliding Circuits (and in LCF), // computes the set of minimal simple factors R that // B^R is in the Set of Sliding Circuits. // ///////////////////////////////////////////////////////////// list MinSC(ArtinBraid B) { sint16 i,j,k,test; sint16 n=B.Index(); sint16 *table=new sint16[n]; list Min; for(i=0; iF[j+1]) test=0; } for(j=i+1; jF[j+1]) test=0; } if(test) { Min.push_back(F); table[i-1]=1; } } delete[] table; return Min; } ///////////////////////////////////////////////////////////// // // SC(B) Given a braid B, computes its Set of Cyclic Slidings. // ///////////////////////////////////////////////////////////// list > SC(ArtinBraid B) { list > sc; ArtinFactor F=ArtinFactor(B.Index()); list Min; list::iterator itf, itf2; list::iterator itb; ArtinBraid B2=SendToSC(B); list T=Trajectory_Sliding(B2); sc.push_back(Trajectory_Sliding(B2)); B2=((!ArtinBraid(ArtinFactor(B.Index(),1)))*(B2)*ArtinFactor(B.Index(),1)).MakeLCF(); for(itb=(*sc.begin()).begin(); itb!=(*sc.begin()).end(); itb++) { if(B2==*itb) break; } if(itb==(*sc.begin()).end()) sc.push_back(Trajectory_Sliding(B2)); list >::iterator it=sc.begin(), it2; while(it!=sc.end()) { Min=MinSC(*(*it).begin()); for(itf=Min.begin(); itf!=Min.end(); itf++) { F=*itf; B2=((!ArtinBraid(F))*(*(*it).begin())*F).MakeLCF(); T=Trajectory_Sliding(B2); for(itb=T.begin(); itb!=T.end(); itb++) { for(it2=sc.begin(); it2!=sc.end(); it2++) { if(*itb==*(*it2).begin()) break; } if(it2!=sc.end()) break; } if(itb==T.end()) { sc.push_back(T); B2=((!ArtinBraid(ArtinFactor(B.Index(),1)))*(*T.begin())*ArtinFactor(B.Index(),1)).MakeLCF(); for(itb=T.begin();itb!=T.end(); itb++) { if(B2==*itb) break; } if(itb==T.end()) sc.push_back(Trajectory_Sliding(B2)); } } it++; } return sc; } //////////////////////////////////////////////////////////////////////////////////////// // // PrintSC(sc,word,n,power,file,type) Prints the Set of Sliding Circuits // of the braid (word)^power to "file". // //////////////////////////////////////////////////////////////////////////////////////// void PrintSC(list > & sc, list word, sint16 n, sint16 power, char * file, sint16 type) { ofstream f(file); sint16 orbits=0; list >::iterator it; list::iterator oit, itb; ArtinBraid B2=ArtinBraid(n); for(it=sc.begin(); it!=sc.end(); it++) orbits++; sint16 *sizes=new sint16[orbits]; sint16 size; sint16 i; it=sc.begin(); for(i=0; i::iterator itw; f << "This file contains the Set of Sliding Circuits of the braid on " << n << " strands:" << endl << endl; if(power!=1) f << "( "; for(itw=word.begin(); itw!=word.end(); itw++) { if(*itw==n) f << "D "; else if (*itw==-n) f << "-D "; else f << *itw << " "; } if(power!=1) f << ")^" << power; sint16 total; if(orbits==1) { f << endl << endl << "It has 1 circuit, whose size is " << sizes[0] << "." << endl << endl; total=sizes[0]; } else { f << endl << endl << "It has " << orbits << " circuits, whose sizes are: "; total=0; for(i=0; i > SC(ArtinBraid B, list & mins, list & prev) { list > sc; ArtinBraid B2=SendToSC(B); list T=Trajectory_Sliding(B2); sc.push_back(Trajectory_Sliding(B2)); ArtinFactor F=ArtinFactor(B.Index()); list Min; list::iterator itf, itf2; list::iterator itb; sint16 current=0; mins.clear(); prev.clear(); mins.push_back(ArtinFactor(B.Index(),0)); prev.push_back(1); list >::iterator it=sc.begin(), it2; while(it!=sc.end()) { current++; Min=MinSC(*(*it).begin()); for(itf=Min.begin(); itf!=Min.end(); itf++) { F=*itf; B2=((!ArtinBraid(F))*(*(*it).begin())*F).MakeLCF(); T=Trajectory_Sliding(B2); for(itb=T.begin(); itb!=T.end(); itb++) { for(it2=sc.begin(); it2!=sc.end(); it2++) { if(*itb==*(*it2).begin()) break; } if(it2!=sc.end()) break; } if(itb==T.end()) { sc.push_back(T); mins.push_back(F); prev.push_back(current); } } it++; } return sc; } //////////////////////////////////////////////////////////////////////////////////// // // AreConjugateSC(B1,B2,C) Determines if the braids B1 and B2 are // conjugate by testing their set of sliding circuits, // and computes a conjugating element C. // ////////////////////////////////////////////////////////////////////////////////// bool AreConjugateSC(ArtinBraid B1, ArtinBraid B2, ArtinBraid & C) { sint16 n=B1.Index(); ArtinBraid C1=ArtinBraid(n), C2=ArtinBraid(n); ArtinBraid BT1=SendToSC(B1,C1), BT2=SendToSC(B2,C2); if(CL(BT1)!=CL(BT2) || Sup(BT1)!=Sup(BT2)) return false; if(CL(BT1)==0) { C=(C1*(!C2)).MakeLCF(); return true; } list mins; list prev; list > sc=SC(BT1,mins,prev); list >::iterator it; list::iterator itb; sint16 current=0; ArtinBraid D1=ArtinBraid(n), D2=ArtinBraid(n); for(it=sc.begin(); it!=sc.end(); it++) { current++; D2=ArtinBraid(n); for(itb=(*it).begin(); itb!=(*it).end(); itb++) { if(*itb==BT2) break; D2=D2*PreferredPrefix(*itb); } if(itb!=(*it).end()) break; } if(it==sc.end()) return false; list::iterator itprev; list::iterator itmins; sint16 i; while(current!=1) { itprev=prev.begin(); itmins=mins.begin(); for(i=1; i > sc; sint16 n=B1.Index(); ArtinFactor F=ArtinFactor(n); list Min; list::iterator itf, itf2; list::iterator itb; ArtinBraid C1=ArtinBraid(n), C2=ArtinBraid(n); ArtinBraid BT1=SendToSC(B1,C1), BT2=SendToSC(B2,C2); ArtinBraid D1=ArtinBraid(n), D2=ArtinBraid(n); list mins; list prev; sint16 current=0; sint16 current2=0; mins.clear(); prev.clear(); list::iterator itprev; list::iterator itmins; sint16 i; mins.push_back(ArtinFactor(B1.Index(),0)); prev.push_back(1); list T=Trajectory_Sliding(BT1); sc.push_back(Trajectory_Sliding(BT1)); list >::iterator it=sc.begin(), it2; while(it!=sc.end()) { current++; current2++; D2=ArtinBraid(n); for(itb=(*it).begin(); itb!=(*it).end(); itb++) { if(*itb==BT2) { while(current2!=1) { itprev=prev.begin(); itmins=mins.begin(); for(i=1; i > BraidToList(sint16 n, ArtinBraid B) { ArtinFactor F = ArtinFactor(n); list::iterator it; list aux; list > rop; aux.push_back(B.LeftDelta); rop.push_back(aux); int i,j,k; for(it=B.FactorList.begin(); it!=B.FactorList.end(); it++) { aux.clear(); F = *it; for(i=2; i<=n; i++) { for(j=i; j>1 && F[j] > BraidToListRight(sint16 n, ArtinBraid B) { ArtinFactor F = ArtinFactor(n); list::iterator it; list aux; list > rop; int i,j,k; for(it=B.FactorList.begin(); it!=B.FactorList.end(); it++) { aux.clear(); F = *it; for(i=2; i<=n; i++) { for(j=i; j>1 && F[j] > ConjugatingBraid(sint16 n, list word, list word2) { ArtinBraid B1=ArtinBraid(n); ArtinBraid B2=ArtinBraid(n); ArtinBraid C = ArtinBraid(n); bool conj; list > rop; B1 = WordToBraid(word, n); B2 = WordToBraid(word2, n); B1.MakeLCF(); B2.MakeLCF(); C = ArtinBraid(n); conj = AreConjugate(B1,B2,C); if (conj) { return BraidToList(n, C); } else { return rop; } } list > LeftNormalForm(sint16 n, list word) { ArtinBraid B = ArtinBraid(n); B = WordToBraid(word, n); B.MakeLCF(); return BraidToList(n, B); } list > RightNormalForm(sint16 n, list word) { ArtinBraid B = ArtinBraid(n); B = WordToBraid(word, n); B.MakeRCF(); return BraidToListRight(n, B); } list > GreatestCommonDivisor(sint16 n, list word1, list word2) { ArtinBraid B1 = ArtinBraid(n); ArtinBraid B2 = ArtinBraid(n); B1 = WordToBraid(word1, n); B2 = WordToBraid(word2, n); B1.MakeLCF(); B2.MakeLCF(); ArtinBraid C = ArtinBraid(C); C = LeftMeet(B1, B2); return BraidToList(n, C); } list > LeastCommonMultiple(sint16 n, list word1, list word2) { ArtinBraid B1 = ArtinBraid(n); ArtinBraid B2 = ArtinBraid(n); B1 = WordToBraid(word1, n); B2 = WordToBraid(word2, n); B1.MakeLCF(); B2.MakeLCF(); ArtinBraid C = ArtinBraid(C); C = LeftWedge(B1, B2); return BraidToList(n, C); } list > > CentralizerGenerators(int n, list word) { ArtinBraid B = ArtinBraid(n); B = WordToBraid(word, n); B.MakeLCF(); list Cent; list::iterator it; list > > rop; Cent = Centralizer(B); for (it=Cent.begin(); it != Cent.end(); it++) { rop.push_back(BraidToList(n, *it)); } return rop; } list > > SuperSummitSet(int n, list word) { ArtinBraid B = ArtinBraid(n); B = WordToBraid(word, n); B.MakeLCF(); list sss; list::iterator it; list > > rop; sss = SSS(B); for (it=sss.begin(); it != sss.end(); it++) { rop.push_back(BraidToList(n, *it)); } return rop; } list > > > UltraSummitSet(int n, list word) // 1: periodic, 2: reducible, 3: pseudo-Anosov. { ArtinBraid B = ArtinBraid(n); B = WordToBraid(word, n); B.MakeLCF(); list > uss = USS(B); list >::iterator it; list::iterator itb; list > > > rop; list > > ropp; for(it=uss.begin(); it!=uss.end(); it++) { ropp.clear(); for(itb=(*it).begin(); itb!=(*it).end(); itb++) { ropp.push_back(BraidToList(n, *itb)); } rop.push_back(ropp); } return rop; } sint16 thurstontype(int n, list word) // 1: periodic, 2: reducible, 3: pseudo-Anosov. { ArtinBraid B = ArtinBraid(n); B = WordToBraid(word, n); B.MakeLCF(); int type = ThurstonType(B); return type; } sint16 Rigidity_ext(int n, list word) { ArtinBraid B = ArtinBraid(n); B = WordToBraid(word, n); B.MakeLCF(); int rig = Rigidity(B); return rig; } list > > > SlidingCircuits(int n, list word) { ArtinBraid B = ArtinBraid(n); B = WordToBraid(word, n); B.MakeLCF(); list > sc = SC(B); list >::iterator it; list::iterator itb; list > > > rop; list > > ropp; for(it=sc.begin(); it!=sc.end(); it++) { ropp.clear(); for(itb=(*it).begin(); itb!=(*it).end(); itb++) { ropp.push_back(BraidToList(n, *itb)); } rop.push_back(ropp); } return rop; } } libbraiding-1.1/lib/braiding.h000066400000000000000000000643711372716755000163470ustar00rootroot00000000000000/* Copyright (C) 2004 Juan Gonzalez-Meneses. This file is part of Braiding. Braiding 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 2 of the License, or any later version. Braiding 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 Braiding. If not, see . */ /* braiding.h, v 1.0. 04/10/2004 Juan Gonzalez-Meneses */ #include "cbraid.h" #include #include #include using namespace CBraid; using namespace std; namespace Braiding { /////////////////////////////////////////////////////// // // CL(B) computes the Canonical length of a braid B, // given in Left Canonical Form // /////////////////////////////////////////////////////// sint16 CL(ArtinBraid B); /////////////////////////////////////////////////////// // // Sup(B) computes the supremun of a braid B, // given in Left Canonical Form // /////////////////////////////////////////////////////// sint16 Sup(ArtinBraid B); /////////////////////////////////////////////////////// // // Cycling(B) computes the cycling of a braid B, // given in Left Canonical Form // /////////////////////////////////////////////////////// ArtinBraid Cycling(ArtinBraid B); /////////////////////////////////////////////////////// // // Decycling(B) computes the decycling of a braid B, // given in Left Canonical Form // /////////////////////////////////////////////////////// ArtinBraid Decycling(ArtinBraid B); ///////////////////////////////////////////////////////////// // // WordToBraid(w,n) Transforms a word w (list of letters) // into a braid on n strands in LCF. // ///////////////////////////////////////////////////////////// ArtinBraid WordToBraid(list w, sint16 n); ///////////////////////////////////////////////////////////// // // PrintBraidWord(B) Shows on the screen the braid B (given in LCF) // written as a word in Artin generaotrs. // ///////////////////////////////////////////////////////////// void PrintBraidWord(ArtinBraid B); ///////////////////////////////////////////////////////////// // // PrintBraidWord(B,f) Prints on the file f the braid B (given in LCF) // written as a word in Artin generaotrs. // ///////////////////////////////////////////////////////////// void PrintBraidWord(ArtinBraid B, char * file); ///////////////////////////////////////////////////////////// // // PrintWord(word,n,power) Shows on the screen the braid "word" // on n strands raised to some "power". // ///////////////////////////////////////////////////////////// void PrintWord(list & word, sint16 n, sint16 power); ///////////////////////////////////////////////////////////// // // PrintWord(word,n,power,file) Prints on "file" the braid "word" // on n strands raised to some "power". // ///////////////////////////////////////////////////////////// void PrintWord(list & word, sint16 n, sint16 power, char * file); ///////////////////////////////////////////////////////////// // // Crossing(word,n,power,cross) Computes the crossing numbers of // the braid on n strands given by // "word" raised to "power". // ///////////////////////////////////////////////////////////// sint16 ** Crossing(list word, sint16 n, sint16 power, sint16 ** cross); ///////////////////////////////////////////////////////////// // // SendToSSS(B) Computes a braid conjugate to B that // belongs to its Super Summit Set. // ///////////////////////////////////////////////////////////// ArtinBraid SendToSSS(ArtinBraid B); ///////////////////////////////////////////////////////////// // // SendToSSS(B,C) Computes a braid conjugate to B that // belongs to its Super Summit Set, and a braid // C that conjugates B to the result. // ///////////////////////////////////////////////////////////// ArtinBraid SendToSSS(ArtinBraid B, ArtinBraid & C); ///////////////////////////////////////////////////////////// // // LeftWedge(F1,F2) Given two simple factors F1 and F2, computes // their left lcm. That is, the smallest simple factor // F such that F1F1 and F>F2. // ///////////////////////////////////////////////////////////// ArtinFactor RightWedge(ArtinFactor F1, ArtinFactor F2); ///////////////////////////////////////////////////////////// // // Remainder(B,F) Given a positive braid B in LCF and a simple // factor F, computes the simple factor S such // that BS=LeftWedge(B,F). // ///////////////////////////////////////////////////////////// ArtinFactor Remainder(ArtinBraid B, ArtinFactor F); ///////////////////////////////////////////////////////////// // // LeftMeet(B1,B2) Given two braids B1 and B2, computes // their left gcd. That is, the smallest braid // B such that B MinSSS(ArtinBraid B); ///////////////////////////////////////////////////////////// // // SSS(B) Given a braid B, computes its Super Summit Set. // ///////////////////////////////////////////////////////////// list SSS(ArtinBraid B); ///////////////////////////////////////////////////////////// // // Trajectory(B) Computes the trajectory of a braid B, that is, // a list containing the iterated cyclings of B, // until the first repetition. // ///////////////////////////////////////////////////////////// list Trajectory(ArtinBraid B); ///////////////////////////////////////////////////////////// // // SendToUSS(B) Computes a braid conjugate to B that // belongs to its Ultra Summit Set. // ///////////////////////////////////////////////////////////// ArtinBraid SendToUSS(ArtinBraid B); ///////////////////////////////////////////////////////////// // // SendToUSS(B,C) Computes a braid conjugate to B that // belongs to its Ultra Summit Set, and a braid // C that conjugates B to the result. // ///////////////////////////////////////////////////////////// ArtinBraid SendToUSS(ArtinBraid B, ArtinBraid & C); ///////////////////////////////////////////////////////////// // // Transport(B,F) Given a braid B (in its USS and in LCF), // and a simple factor F such that B^F is in its SSS, // computes the transport of F. // ///////////////////////////////////////////////////////////// ArtinFactor Transport(ArtinBraid B, ArtinFactor F); ///////////////////////////////////////////////////////////// // // Returns(B,F) Given a braid B (in its USS and in LCF), and a simple factor // F such that B^F is in its SSS, computes the iterated // transports of F that send B to an element in the trajectory // of B^F, until the first repetition. // ///////////////////////////////////////////////////////////// list Returns(ArtinBraid B, ArtinFactor F); ///////////////////////////////////////////////////////////// // // Pullback(B,F) Given a braid B (in its USS and in LCF), and a // simple factor F, computes the pullback of F. // ///////////////////////////////////////////////////////////// ArtinFactor Pullback(ArtinBraid B, ArtinFactor F); ///////////////////////////////////////////////////////////// // // MainPullback(B,F) Given a braid B (in its USS and in LCF), and a // simple factor F, computes a suitable iterated pullback // of F (the factor p_B(F) in Gebhardt's paper). // ///////////////////////////////////////////////////////////// ArtinFactor MainPullback(ArtinBraid B, ArtinFactor F); ///////////////////////////////////////////////////////////// // // MinUSS(B,F) Given a braid B in its Ultra Summit Set (and in LCF), // computes the minimal simple factor R such that // F MinUSS(ArtinBraid B); ///////////////////////////////////////////////////////////// // // USS(B) Given a braid B, computes its Ultra Summit Set. // ///////////////////////////////////////////////////////////// list > USS(ArtinBraid B); ///////////////////////////////////////////////////////////// // // USS(B,mins,prev) Given a braid B, computes its Ultra Summit Set, // and stores in the lists 'mins' and 'prev' // the following data: // for each i, the first braid of the orbit i is obtained by // conjugation of the first element of the orbit prev[i] // by the simple element mins[i]. // ///////////////////////////////////////////////////////////// list > USS(ArtinBraid B, list & mins, list & prev); ///////////////////////////////////////////////////////////// // // TreePath(B,uss,mins,prev) Computes a braid that conjugates // the first element in the Ultra Summit Set uss // to the braid B (which must be in the uss). // ///////////////////////////////////////////////////////////// ArtinBraid TreePath(ArtinBraid B, list > & uss, list & mins, list & prev); ///////////////////////////////////////////////////////////// // // AreConjugate(B1,B2,C) Determines if the braids B1 and B2 are // conjugate, and computes a conjugating // element C. // ///////////////////////////////////////////////////////////// bool AreConjugate(ArtinBraid B1, ArtinBraid B2, ArtinBraid & C); ///////////////////////////////////////////////////////////// // // Centralizer(uss,mins,prev) Computes the centralizer of the first // element in the Ultra Summit Set uss. // ///////////////////////////////////////////////////////////// list Centralizer(list > & uss, list & mins, list & prev); ///////////////////////////////////////////////////////////// // // Centralizer(B) Computes the centralizer of the braid B. // ///////////////////////////////////////////////////////////// list Centralizer(ArtinBraid B); ///////////////////////////////////////////////////////////// // // Tableau(F,tab) Computes the tableau associated to a // simple factor F, and stores it in tab. // ///////////////////////////////////////////////////////////// void Tableau(ArtinFactor F, sint16 **& tab); ///////////////////////////////////////////////////////////// // // Circles(B) Determines if a braid B in LCF // preserves a family of circles. // ///////////////////////////////////////////////////////////// bool Circles(ArtinBraid B); ///////////////////////////////////////////////////////////// // // ThurstonType(B) Determines if a braid B is periodic (1), // reducible (2) or pseudo-Anosov (3). // ///////////////////////////////////////////////////////////// int ThurstonType(ArtinBraid B); ///////////////////////////////////////////////////////////// // // ThurstonType(uss) Determines if the braids in the Ultra // Summit Set uss are periodic (1), // reducible (2) or pseudo-Anosov (3). // ///////////////////////////////////////////////////////////// int ThurstonType(list > & uss); ///////////////////////////////////////////////////////////// // // Rigidity(B) Computes the rigidity of a braid B. // ///////////////////////////////////////////////////////////// sint16 Rigidity(ArtinBraid B); ///////////////////////////////////////////////////////////// // // Rigidity(uss) Computes the maximal rigidity of a braid // in the Ultra Summit Set uss. // ///////////////////////////////////////////////////////////// sint16 Rigidity(list > & uss); ///////////////////////////////////////////////////////////// // // ReadIndex() Asks to type the number of strands. // ///////////////////////////////////////////////////////////// sint16 ReadIndex(); ///////////////////////////////////////////////////////////// // // ReadWord(n) Asks to type a braid word on n strands, // and returns the braid word. // ///////////////////////////////////////////////////////////// list ReadWord(sint16 n); ///////////////////////////////////////////////////////////// // // ReadPower() Asks to type the power to which the braid // will be raised. // ///////////////////////////////////////////////////////////// sint16 ReadPower(); ///////////////////////////////////////////////////////////// // // RaisePower(B,k) Raises the braid B to the power k. // ///////////////////////////////////////////////////////////// ArtinBraid RaisePower(ArtinBraid B, sint16 k); ///////////////////////////////////////////////////////////// // // ReadFileName() Asks to type the name of a file. // ///////////////////////////////////////////////////////////// char* ReadFileName(); ///////////////////////////////////////////////////////////// // // PrintUSS(word,n,p,power,file) Prints the Ultra Summit Set // of the braid (word)^power to "file". // ///////////////////////////////////////////////////////////// void PrintUSS(list > & uss, list word, sint16 n, sint16 power, char * file, sint16 type, sint16 rigidity); ///////////////////////////////////////////////////////////// // // FileName(iteration,max_iteration,type,orbit,rigidity,cl) // Creates the file name corresponding to the given data. // ///////////////////////////////////////////////////////////// char * FileName(sint16 iteration, sint16 max_iteration, sint16 type, sint16 orbit, sint16 rigidity, sint16 cl); /////////////////////////////////////////////////////// // // Reverse(B) computes the revese of a braid B, // that is, B written backwards. // B must be given in left canonical form. // /////////////////////////////////////////////////////// ArtinBraid Reverse(ArtinBraid B); ///////////////////////////////////////////////////////////// // // RightMeet(B1,B2) Given two braids B1 and B2, computes // their right gcd. That is, the greatest braid // B such that B1>B and B2>B. // ///////////////////////////////////////////////////////////// ArtinBraid RightMeet(ArtinBraid B1, ArtinBraid B2); ///////////////////////////////////////////////////////////// // // LeftJoin(B1,B2) Given two braids B1 and B2, computes // their left lcm. That is, the smallest braid // B such that B1B1 and B>B2. // ///////////////////////////////////////////////////////////// ArtinBraid RightJoin(ArtinBraid B1, ArtinBraid B2); /////////////////////////////////////////////////////// // // InitialFactor(B) computes the initial factor of a braid B, // given in Left Canonical Form // /////////////////////////////////////////////////////// ArtinFactor InitialFactor(ArtinBraid B); /////////////////////////////////////////////////////// // // PreferredPrefix(B) computes the preferred prefix of a braid B, // given in Left Canonical Form // /////////////////////////////////////////////////////// ArtinFactor PreferredPrefix(ArtinBraid B); /////////////////////////////////////////////////////// // // Sliding(B) computes the cyclic sliding of a braid B, // given in Left Canonical Form // /////////////////////////////////////////////////////// ArtinBraid Sliding(ArtinBraid B); /////////////////////////////////////////////////////// // // PreferredSuffix(B) computes the preferred suffix of a braid B, // given in Left Canonical Form // /////////////////////////////////////////////////////// ArtinFactor PreferredSuffix(ArtinBraid B); ///////////////////////////////////////////////////////////// // // Trajectory_Sliding(B) Computes the trajectory under cyclic sliding // of a braid B, that is, a list containing eta^k(B), // for k=0,1,... until the first repetition. // ///////////////////////////////////////////////////////////// list Trajectory_Sliding(ArtinBraid B); ///////////////////////////////////////////////////////////// // // Trajectory_Sliding(B,C,d) Computes the trajectory of a braid B for cyclic sliding, // a braid C that conjugates B to the // first element of a closed orbit under sliding, // and the number d of slidings needed to reach that element // ///////////////////////////////////////////////////////////// list Trajectory_Sliding(ArtinBraid B, ArtinBraid & C, sint16 & d); ///////////////////////////////////////////////////////////// // // SendToSC(B) Computes a braid conjugate to B that // belongs to its Sliding Circuits Set. // ///////////////////////////////////////////////////////////// ArtinBraid SendToSC(ArtinBraid B); ///////////////////////////////////////////////////////////// // // SendToSC(B,C) Computes a braid conjugate to B that // belongs to its Sliding Circuits Set, and a braid // C that conjugates B to the result. // ///////////////////////////////////////////////////////////// ArtinBraid SendToSC(ArtinBraid B, ArtinBraid & C); ///////////////////////////////////////////////////////////// // // Transport_Sliding(B,F) Given a braid B (in its SC and in LCF), and a simple factor // F such that B^F is in its SSS, computes the transport of F for sliding. // ///////////////////////////////////////////////////////////// ArtinFactor Transport_Sliding(ArtinBraid B, ArtinFactor F); ///////////////////////////////////////////////////////////// // // Returns_Sliding(B,F) Given a braid B (in its SC and in LCF), and a simple factor // F such that B^F is in its SSS, computes the iterated transports // of F for sliding that send B to an element in the circuit of B^F. // ///////////////////////////////////////////////////////////// list Returns_Sliding(ArtinBraid B, ArtinFactor F); ///////////////////////////////////////////////////////////// // // Pullback_Sliding(B,F) Given a braid B (in its SC and in LCF), and a // simple factor F such that B^F is super summit, // computes the pullback of F at s(B) for sliding. // ///////////////////////////////////////////////////////////// ArtinFactor Pullback_Sliding(ArtinBraid B, ArtinFactor F); ///////////////////////////////////////////////////////////// // // MainPullback_Sliding(B,F) Given a braid B (in its SC and in LCF), and a // simple factor F, computes the first repeated iterated // pullback for cyclic sliding of F. // ///////////////////////////////////////////////////////////// ArtinFactor MainPullback_Sliding(ArtinBraid B, ArtinFactor F); // María Cumplido Cabello ///////////////////////////////////////////////////////////// // // MinSC(B,F) Given a braid B in its Set of Sliding Circuits (and in LCF), // computes the minimal simple factor R such that // F MinSC(ArtinBraid B); ///////////////////////////////////////////////////////////// // // SC(B) Given a braid B, computes its Set of Cyclic Slidings. // ///////////////////////////////////////////////////////////// list > SC(ArtinBraid B); ///////////////////////////////////////////////////////////// // // SC(B,mins,prev) Given a braid B, computes its Set of Sliding Circuits, // and stores in the lists 'mins' and 'prev' the following data: // for each i, the first braid of the orbit i is obtained by // conjugation of the first element of the orbit prev[i] // by the simple element mins[i]. // ///////////////////////////////////////////////////////////// list > SC(ArtinBraid B, list & mins, list & prev); //////////////////////////////////////////////////////////////////////////////////////// // // PrintSC(sc,word,n,power,file,type) Prints the Set of Sliding Circuits // of the braid (word)^power to "file". // //////////////////////////////////////////////////////////////////////////////////////// void PrintSC(list > & sc, list word, sint16 n, sint16 power, char * file, sint16 type); //////////////////////////////////////////////////////////////////////////////////// // // AreConjugateSC(B1,B2,C) Determines if the braids B1 and B2 are // conjugate by testing their set of sliding circuits, // and computes a conjugating element C. // ////////////////////////////////////////////////////////////////////////////////// bool AreConjugateSC(ArtinBraid B1, ArtinBraid B2, ArtinBraid & C); //////////////////////////////////////////////////////////////////////////////////// // // AreConjugateSC2(B1,B2,C) Determines if the braids B1 and B2 are // conjugate by the procedure of contruct SC(B1), // and computes a conjugating element C. // ////////////////////////////////////////////////////////////////////////////////// bool AreConjugateSC2(ArtinBraid B1, ArtinBraid B2, ArtinBraid & C); ////////////////////////////////////////////////////////////////////// // // // Functions to be called from external programs. // // // ////////////////////////////////////////////////////////////////////// list > ConjugatingBraid(sint16 n, list word, list word2); list > LeftNormalForm(sint16 n, list word); list > RightNormalForm(sint16 n, list word); list > GreatestCommonDivisor(sint16 n, list word1, list word2); list > LeastCommonMultiple(sint16 n, list word1, list word2); list > > CentralizerGenerators(int n, list word); list > > SuperSummitSet(int n, list word); list > > > UltraSummitSet(int n, list word); sint16 thurstontype(int n, list word); sint16 Rigidity_ext(int n, list word); list > > > SlidingCircuits(int n, list word); } // namespace Braiding libbraiding-1.1/lib/cbraid.cpp000066400000000000000000000124421372716755000163370ustar00rootroot00000000000000/* Copyright (C) 2000-2001 Jae Choon Cha. This file is part of CBraid. CBraid 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 2 of the License, or any later version. CBraid 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 CBraid. If not, see . */ /* Jae Choon CHA Implementation of cbraid.h. */ #include "cbraid.h" #include namespace CBraid { // A class used to feed a seed to the random number generator of C // library. class _RandomSeedInitializer { public: _RandomSeedInitializer() { std::srand(std::time(NULL)); } }; static _RandomSeedInitializer RandomSeedInitializer; void ArtinPresentation::MeetSub(const sint16* a, const sint16* b, sint16* r, sint16 s, sint16 t) { static sint16 u[MaxBraidIndex], v[MaxBraidIndex], w[MaxBraidIndex]; if (s >= t) return; sint16 m = (s+t)/2; MeetSub(a, b, r, s, m); MeetSub(a, b, r, m+1, t); u[m] = a[r[m]]; v[m] = b[r[m]]; if (s < m) { for(sint16 i = m-1; i >= s; --i) { u[i] = std::min(a[r[i]], u[i+1]); v[i] = std::min(b[r[i]], v[i+1]); } } u[m+1] = a[r[m+1]]; v[m+1] = b[r[m+1]]; if (t > m+1) { for(sint16 i = m+2; i <= t; ++i) { u[i] = std::max(a[r[i]], u[i-1]); v[i] = std::max(b[r[i]], v[i-1]); } } sint16 p = s; sint16 q = m+1; for(sint16 i = s; i <= t; ++i) w[i] = ((p > m) || (q <= t && u[p] > u[q] && v[p] > v[q])) ? r[q++] : r[p++]; for(sint16 i = s; i <= t; ++i) r[i] = w[i]; } BandBraid ToBandBraid(const ArtinBraid& a) { sint32 n = a.Index(); BandBraid b(n); sint32 l = a.LeftDelta, r = a.RightDelta; ArtinBraid::ConstFactorItr i = a.FactorList.begin(); // First reduce to the case of positive braids, using D^2 = d^n. sint32 k; k = (l >= 0) ? l/2 : -((-l)/2)-1; l -= 2*k; b.LeftDelta = n*k; k = (r >= 0) ? r/2 : -((-r)/2)-1; r -= 2*k; b.RightDelta = n*k; ArtinBraid::CanonicalFactor f(n); BandBraid::CanonicalFactor g(n); while (true) { if (l > 0) { f.Delta(1); --l; } else if (i != a.FactorList.end()) { f = *(i++); } else if (r > 0) { f.Delta(1); --r; } else break; while (true) { for(k = 1; k < n && f[k] < f[k+1]; ++k) ; if (k >= n) break; std::swap(f[k], f[k+1]); g.Identity(); g[k] = k+1; g[k+1] = k; b.FactorList.push_back(g); } } return b; } ArtinBraid ToArtinBraid(const BandBraid& b) { sint32 n = b.Index(); ArtinBraid a(n); sint32 l = b.LeftDelta, r = b.RightDelta; BandBraid::ConstFactorItr i = b.FactorList.begin(); // First reduce to the case of positive braids, using D^2 = d^n. sint32 k; k = (l > 0) ? l/n : -((-l)/n)-1; l -= n*k; a.LeftDelta = 2*k; k = (r > 0) ? r/n : -((-r)/n)-1; r -= n*k; a.RightDelta = 2*k; BandBraid::CanonicalFactor f(n); ArtinBraid::CanonicalFactor g(n); while (true) { if (l > 0) { f.Delta(1); --l; } else if (i != b.FactorList.end()) { f = *(i++); } else if (r > 0) { f.Delta(1); --r; } else break; for(k = 1; k <= n; ++k) g[k] = f[k]; a.FactorList.push_back(g); } return a; } #ifdef USE_CLN void BallotSequence(sint16 n, cln::cl_I k, sint8* s) { sint16 i; cln::cl_I r; // cout << flush << "BallotSequence: n=" << n << ", k=" << k; if (k <= (r = GetCatalanNumber(n-1)*GetCatalanNumber(0))) i = 1; else if (k > (r = GetCatalanNumber(n)-r)) { i = n; k = k-r; } else { for(i = 1; i <= n; ++i) { if (k <= (r = GetCatalanNumber(i-1)*GetCatalanNumber(n-i))) break; else k = k-r; } } // cout << ": i=" << i << endl << flush; cln::cl_I_div_t d = cln::floor2(k-1, GetCatalanNumber(n-i)); s[1] = 1; s[2*i] = -1; if (i > 1) BallotSequence(i-1, d.quotient, s+1); if (i < n) BallotSequence(n-i, d.remainder, s+2*i); } class _CatalanNumber { friend const cln::cl_I& GetCatalanNumber(sint16); public: _CatalanNumber(); private: cln::cl_I Table[MaxBraidIndex+1]; cln::cl_I& C(sint16 n) { return Table[n]; } }; static _CatalanNumber CatalanNumber; _CatalanNumber::_CatalanNumber() { C(0) = 1; for(sint16 n = 1; n < MaxBraidIndex; ++n) { C(n) = 0; for(sint16 k = 0; k < n; ++k) { C(n) = C(n)+C(k)*C(n-k-1); } } } const cln::cl_I& GetCatalanNumber(sint16 n) { return CatalanNumber.C(n); } #endif // USE_CLN } // namespace CBraid libbraiding-1.1/lib/cbraid.h000066400000000000000000000025671372716755000160130ustar00rootroot00000000000000/* Copyright (C) 2000-2001 Jae Choon Cha. This file is part of CBraid. CBraid 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 2 of the License, or any later version. CBraid 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 CBraid. If not, see . */ /* $Id: cbraid.h,v 1.17 2001/12/07 10:12:13 jccha Exp $ Jae Choon Cha Main header file of cbraid library. */ #ifndef _cbraid_h_ #define _cbraid_h_ #include #include #include #include #include #ifdef USE_CLN #include #endif namespace CBraid { // Interfaces of cbraid library. All the declarations are here. #include "cbraid_interface.h" // Implementations of inline functions. Fairly many functions are // defined as inline, because of the speed and efficiency. (Usually // compilers can optimize inline functions better.) #include "cbraid_implementation.h" } #endif // _cbraid_h_ libbraiding-1.1/lib/cbraid_implementation.h000066400000000000000000000577501372716755000211240ustar00rootroot00000000000000/* Copyright (C) 2000-2001 Jae Choon Cha. This file is part of CBraid. CBraid 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 2 of the License, or any later version. CBraid 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 CBraid. If not, see . */ /* $Id: cbraid_implementation.h,v 1.9 2001/12/07 10:12:13 jccha Exp $ Jae Choon Cha Implementation of cbraid library. */ template inline ForItr apply_binfun(ForItr first, ForItr last, BinFunc f) { ForItr i, j; if ((i = j = first) == last) return first; while (++j != last && f(*(i++), *j)) ; return j; } template inline BiItr reverse_apply_binfun(BiItr first, BiItr last, BinFunc f) { BiItr i, j; if (first == (i = j = last)) return first; --i; while ((j = i) != first && f(*--i, *j)) ; return --j; } template inline void bubble_sort(ForItr first, ForItr last, BinFun f) { ForItr i; if (first == (i = last)) return; while (i != first) apply_binfun(--i, last, f); } /* template inline void bubble_sort(ForItr first, ForItr last, BinFun f) { ForItr i, j, b; if (first == last) return; do { b = last; for(i = last, j = --i, --i; j != first; --i, --j) { if (f(*i, *j)) b = j; } first = b; } while (first != last); } */ template inline typename Seq::difference_type erase_front_if(Seq& s, UnaPre f) { typename Seq::difference_type c = 0; typename Seq::iterator i = s.begin(); while (i != s.end() && f(*(i))) { ++c; ++i; } s.erase(s.begin(), i); return c; } template inline typename Seq::difference_type erase_back_if(Seq& s, UnaPre f) { typename Seq::difference_type c = 0; typename Seq::reverse_iterator i = s.rbegin(); while (i != s.rend() && f(*i)) { ++i; ++c; } s.erase(i.base(), s.end()); return c; } inline ArtinPresentation::ArtinPresentation(sint16 n) { #ifdef DEBUG if (n <= 0) { std::cerr << "ArtinPresentation::ArtinPresentation: " "Bad argument (n <= 0).\n"; exit(1); } #endif PresentationIndex = n; } inline sint16 ArtinPresentation::Index() const { return PresentationIndex; } inline sint16 ArtinPresentation::DeltaTable(sint16 i, sint32 k) const { return (k & 1) ? Index()-i+1 : i; } inline void ArtinPresentation::Randomize(sint16* r) const { // The present implementation generates a random permutation using // rand() function of C library. A better pseudo random number // generator could be used. for(sint16 i = 1; i <= Index(); ++i) r[i] = i; for(sint16 i = 1; i < Index(); ++i) { sint16 j = i+sint16(std::rand()/(RAND_MAX+1.0)*(Index()-i+1)); sint16 z = r[i]; r[i] = r[j]; r[j] = z; } } inline void ArtinPresentation::LeftMeet( const sint16* a, const sint16* b, sint16* r) const { static sint16 s[MaxBraidIndex]; for(sint16 i = 1; i <= Index(); ++i) s[i] = i; MeetSub(a, b, s, 1, Index()); for(sint16 i = 1; i <= Index(); ++i) r[s[i]] = i; } inline void ArtinPresentation::RightMeet( const sint16* a, const sint16* b, sint16* r) const { static sint16 u[MaxBraidIndex], v[MaxBraidIndex]; for(sint16 i = 1; i <= Index(); ++i) { u[a[i]] = i; v[b[i]] = i; } for(sint16 i = 1; i <= Index(); ++i) r[i] = i; MeetSub(u, v, r, 1, Index()); } inline BandPresentation::BandPresentation(sint16 n) { #ifdef DEBUG if (n <= 0) { std::cerr << "BandPresentation::BandPresentation: " "Bad argument (n <= 0).\n"; exit(1); } #endif PresentationIndex = n; } inline sint16 BandPresentation::Index() const { return PresentationIndex; } inline sint16 BandPresentation::DeltaTable(sint16 i, sint32 k) const { // Because the bahavior of / and % operators for negative integers // is implementation dependent in C++, we use the following trick // to make k a non-negative integer with the same residue class // modulo index. if (k < 0) k = k-Index()*k; return (i+k-1)%Index()+1; } inline void BandPresentation::PTtoDCDT(const sint16* a, sint16* x) const { for(sint16 i = 1; i <= Index(); ++i) x[i] = 0; for(sint16 i = Index(); i >= 1; --i) { if (x[i] == 0) x[i] = i; if (a[i] < i) x[a[i]] = x[i]; } } inline void BandPresentation::DCDTtoPT(const sint16* x, sint16* a) const { static sint16 z[MaxBraidIndex]; for(sint16 i = 1; i <= Index(); ++i) z[i] = 0; for(sint16 i = 1; i <= Index(); ++i) { a[i] = (z[x[i]] == 0) ? x[i] : z[x[i]]; z[x[i]] = i; } } inline void BandPresentation::BStoPT(const sint8* s, sint16* a) const { static sint16 stack[MaxBraidIndex]; sint16 sp = 0; // cout << flush << "BStoPT: "; // for(sint16 i = 1; i <= 2*Index(); ++i) // cout << ((s[i] == 1) ? "+" : "-"); // cout << " -> "; for(sint16 i = 1; i <= 2*Index(); ++i) { if (s[i] == 1) { stack[sp++] = i; } else { sint16 j = stack[--sp]; if ((i/2)*2 != i) a[(i+1)/2] = j/2; else a[(j+1)/2] = i/2; } } // for(sint16 i = 1; i <= Index(); ++i) // cout << a[i] << " "; // cout << endl << flush; } inline void BandPresentation::Randomize(sint16* r) const { #ifdef USE_CLN static sint8 s[MaxBraidIndex]; static sint16 a[MaxBraidIndex]; cln::cl_I k = cln::random_I(cln::default_random_state, GetCatalanNumber(Index()))+1; BallotSequence(Index(), k, s); BStoPT(s, a); for(sint16 i = 1; i <= Index(); ++i) r[a[i]] = i; #else std::cerr << std::flush << "! BandPresentation::Randomize(): CLN is required.\n" << std::flush; exit(1); #endif } #ifdef BAND_PRESENTATION_SORT_BY_COMPARISON // A comparator class for std::sort(). class Compare { const sint16 *a, *b; public: Compare(const sint16* x, const sint16* y) : a(x), b(y) {} bool operator()(const sint16 p, const sint16 q) { return (a[p] > a[q]) || (a[p] == a[q] && b[p] > b[q]) || (a[p] == a[q] && b[p] == b[q] && p > q); } }; #endif inline void BandPresentation::LeftMeet( const sint16* a, const sint16* b, sint16* r) const { static sint16 x[MaxBraidIndex], y[MaxBraidIndex], u[MaxBraidIndex]; sint16 i, j, k; for(i = 1; i <= Index(); ++i) u[a[i]] = i; PTtoDCDT(u, x); for(i = 1; i <= Index(); ++i) u[b[i]] = i; PTtoDCDT(u, y); for(i = 1; i <= Index(); ++i) u[i] = Index()-i+1; // Here we need to sort u[i] such that (x[u[i]], y[u[i]], u[i]) is // decreasing w.r.t. the lexcographic order. In order to maximize // speed, we use a radix sorting algorithm that uses an workspace // array of size n(n+1). It would be reduced to 2n by using a // list-based radix sorting, which sacrificing speed. #ifdef BAND_PRESENTATION_SORT_BY_COMPARISON std::sort(u+1, u+Index()+1, Compare(x, y)); #else for(sint16* z = x; z; z = (z == x) ? y : 0) { static sint16 N[MaxBraidIndex], P[MaxBraidIndex][MaxBraidIndex]; for(k = 1; k <= Index(); ++k) N[k] = 0; for(i = 1; i <= Index(); ++i) { k = z[u[i]]; P[k][N[k]++] = u[i]; } i = 1; for(k = Index(); k >= 1; --k) { for(j = 0; j < N[k]; ++j) { u[i++] = P[k][j]; } } } #endif j = u[1]; r[j] = j; for(i = 2; i <= Index(); ++i) { if (x[j] != x[u[i]] || y[j] != y[u[i]]) j = u[i]; r[u[i]] = j; } DCDTtoPT(r, u); for(i = 1; i <= Index(); ++i) r[u[i]] = i; } inline void BandPresentation::RightMeet( const sint16* a, const sint16* b, sint16* r) const { LeftMeet(a, b, r); } template inline Factor

::Factor(sint16 n, sint32 k) : Pres(n) { pTable = new sint16[Index()]; #ifdef DEBUG if (pTable == 0) { std::cerr << "Factor

::Factor

(): Memory allocation error.\n"; exit(1); } #endif if ((uint32)k != Uninitialize) { Delta(k); } } template inline Factor

::Factor(const Factor& f) : Pres(f.Index()) { pTable = new sint16[Index()]; #ifdef DEBUG if (pTable == 0) { std::cerr << "Factor

::Factor

(): Memory allocation error.\n"; exit(1); } #endif Assign(f); } template inline Factor

::operator sint16*() { return pTable-1; } template inline Factor

::operator const sint16*() const { return pTable-1; } template inline Factor

::~Factor() { delete[] pTable; } template inline Factor

& Factor

::Delta(sint32 k) { for(register sint16 i = 1; i <= Index(); ++i) At(i) = Pres.DeltaTable(i, k); return *this; } template inline Factor

& Factor

::Identity() { return Delta(0); } template inline Factor

& Factor

::LowerDelta(sint32 k) { if (Index() % 2) throw OddIndexError(); sint16 n = Index()/2; Factor lf(n, k); for(sint32 i = 1; i <= n; ++i) { At(i) = lf[i]; At(i+n) = i+n; } return *this; } template inline Factor

& Factor

::UpperDelta(sint32 k) { if (Index() % 2) throw OddIndexError(); sint16 n = Index()/2; Factor lf(n, k); for(sint32 i = 1; i <= n; ++i) { At(i) = i; At(i+n) = lf[i]+n; } return *this; } template inline sint16 Factor

::Index() const { return Pres.Index(); } template inline sint16& Factor

::At(sint16 n) { return pTable[n-1]; } template inline sint16 Factor

::At(sint16 n) const { return pTable[n-1]; } template inline sint16& Factor

::operator[](sint16 n) { return At(n); } template inline sint16 Factor

::operator[](sint16 n) const { return At(n); } template inline Factor

& Factor

::Assign(const Factor

& f) { #ifdef DEBUG if (Index() != f.Index()) { std::cerr << "Factor

::Assign(): Index mismatch.\n"; exit(1); } #endif if (&f != this) { for(register sint16 i = 1; i <= Index(); ++i) { At(i) = f[i]; } } return *this; } template inline Factor

& Factor

::operator=(const Factor& f) { return Assign(f); } template inline bool Factor

::Compare(const Factor

& f) const { #ifdef DEBUG if (Index() != f.Index()) { std::cerr << "Factor

::Compare(): Index mismatch.\n"; exit(1); } #endif for(register sint16 i = 1; i <= Index(); ++i) { if (At(i) != f[i]) return false; } return true; } template inline bool Factor

::operator==(const Factor& f) const { return Compare(f); } template inline bool Factor

::operator!=(const Factor& f) const { return !Compare(f); } template inline bool Factor

::CompareWithDelta(sint32 k) const { for(register sint16 i = 1; i <= Index(); ++i) { if (At(i) != Pres.DeltaTable(i, k)) return false; } return true; } template inline bool Factor

::CompareWithIdentity() const { return CompareWithDelta(0); } template inline Factor

Factor

::Composition( const Factor

& a) const { #ifdef DEBUG if (Index() != a.Index()) { std::cerr << "Factor

::Composition(): Index mismatch.\n"; exit(1); } #endif Factor f(Index()); for(register sint16 i = 1; i <= Index(); ++i) f[i] = a[At(i)]; return f; } template inline Factor

& Factor

::AssignComposition( const Factor& a) { #ifdef DEBUG if (Index() != a.Index()) { std::cerr << "Factor

::Composition(): Index mismatch.\n"; exit(1); } #endif for(register sint16 i = 1; i <= Index(); ++i) At(i) = a[At(i)]; return *this; } template inline Factor

& Factor

::operator*=(const Factor& a) { return AssignComposition(a); } template inline Factor

Factor

::operator*(const Factor& a) const { return Composition(a); } template inline Factor

Factor

::Inverse() const { Factor f(Index()); for(register sint16 i = 1; i <= Index(); ++i) f[At(i)] = i; return f; } template inline Factor

& Factor

::AssignInverse() { return *this = Inverse(); } template inline Factor

Factor

::operator!() const { return Inverse(); } template inline Factor

Factor

::Flip(sint32 k) const { Factor f(Index()); for(register sint16 i = 1; i <= Index(); ++i) f[i] = Pres.DeltaTable(At(Pres.DeltaTable(i, -k)), k); return f; } template inline Factor

& Factor

::AssignFlip(sint32 k) { return *this = Flip(k); } template inline Factor

Factor

::LeftMeet(const Factor

& a) const { #ifdef DEBUG if (Index() != a.Index()) { std::cerr << "Factor

::LeftMeet(): Index mismatch.\n"; exit(1); } #endif Factor

r(Index()); Pres.LeftMeet(*this, a, r); return r; } template inline Factor

Factor

::RightMeet(const Factor

& a) const { #ifdef DEBUG if (Index() != a.Index()) { std::cerr << "Factor

::RightMeet(): Index mismatch.\n"; exit(1); } #endif Factor

r(Index()); Pres.RightMeet(*this, a, r); return r; } template inline Factor

& Factor

::Randomize() { Pres.Randomize(*this); return *this; } template Factor

LeftMeet(const Factor

& a, const Factor

& b) { return a.LeftMeet(b); } template Factor

RightMeet(const Factor

& a, const Factor

& b) { return a.RightMeet(b); } template inline bool MakeLeftWeighted(Factor

&a, Factor

&b) { #ifdef DEBUG if (a.Index() != b.Index()) { std::cerr << "MakeLeftWeighted(Factor

, Factor

): Index mismatch.\n"; exit(1); } #endif Factor

x = LeftMeet((!a)*Factor

(a.Index(), 1), b); if (x.CompareWithIdentity()) return false; else { a *= x; b = (!x)*b; return true; } } template inline bool MakeRightWeighted(Factor

& a, Factor

& b) { #ifdef DEBUG if (a.Index() != b.Index()) { std::cerr << "MakeRightWeighted(Factor

, Factor

): Index mismatch.\n"; exit(1); } #endif Factor

x = RightMeet(a, Factor

(b.Index(), 1)*!b); if (x.CompareWithIdentity()) return false; else { a *= !x; b = x*b; return true; } } template inline std::ostream& operator<<(std::ostream& os, const Factor

& f) { os << "["; for(sint16 i = 1; i < f.Index(); ++i) os << f[i] << " "; os << f[f.Index()] << "]"; return os; } template inline Braid

::Braid(sint16 n) : Pres(n) { Identity(); } template inline Braid

::Braid(const Braid& b) : Pres(b.Pres), LeftDelta(b.LeftDelta), RightDelta(b.RightDelta), FactorList(b.FactorList) {} template inline Braid

::Braid(const Factor

& f) : Pres(f.Index()), LeftDelta(0), RightDelta(0), FactorList(1, f) { } template inline Braid

::~Braid() { } template inline sint16 Braid

::Index() const { return Pres.Index(); } template inline Braid

& Braid

::Identity() { LeftDelta = RightDelta = 0; FactorList.clear(); return *this; } template inline Braid

& Braid

::Assign(const Braid& b) { #ifdef DEBUG if (Index() != b.Index()) { std::cerr << "Braid

::Assign(): Index mismatch.\n"; exit(1); } #endif Pres = b.Pres; LeftDelta = b.LeftDelta; RightDelta = b.RightDelta; FactorList = b.FactorList; return *this; } template inline Braid

& Braid

::operator=(const Braid& b) { return Assign(b); } template inline bool Braid

::Compare(const Braid& b) const { #ifdef DEBUG if (Index() != b.Index()) { std::cerr << "Braid

::Compare(): Index mismatch.\n"; exit(1); } #endif return (LeftDelta == b.LeftDelta && RightDelta == b.RightDelta && FactorList == b.FactorList); } template inline bool Braid

::operator==(const Braid& b) const { return Compare(b); } template inline bool Braid

::operator!=(const Braid& b) const { return !Compare(b); } template inline bool Braid

::CompareWithIdentity() const { return (LeftDelta == 0 && RightDelta == 0 && FactorList.empty()); } template inline Braid

Braid

::Inverse() const { Braid b(Index()); b.LeftDelta = -RightDelta; b.RightDelta = 0; Factor

f(Index()); for(ConstRevFactorItr it = FactorList.rbegin(); it != FactorList.rend(); ++it) { // Compute f such that (*it)*f = Delta. for(sint16 i = 1; i <= Index(); ++i) f[(*it)[i]] = Pres.DeltaTable(i, 1); // Rewrite a_1...a_k Delta^r (*it)^(-1) as // a_1...a_k (Delta^r f Delta^(-r)) Delta^(r-1) b.FactorList.push_back(f.Flip(-b.RightDelta)); --b.RightDelta; } b.RightDelta -= LeftDelta; return b; } template inline Braid

Braid

::operator!() const { return Inverse(); } template inline Braid

& Braid

::LeftMultiply(const Factor

& f) { #ifdef DEBUG if (Index() != f.Index()) { std::cerr << "Braid

::LeftMultiply(): Index mismatch.\n"; exit(1); } #endif FactorList.push_front(f.Flip(LeftDelta)); return *this; } template inline Braid

& Braid

::RightMultiply(const Factor

& f) { #ifdef DEBUG if (Index() != f.Index()) { std::cerr << "Braid

::RightMultiply(): Index mismatch.\n"; exit(1); } #endif FactorList.push_back(f.Flip(-RightDelta)); return *this; } template inline Braid

& Braid

::LeftMultiply(const Braid& a) { #ifdef DEBUG if (Index() != a.Index()) { std::cerr << "Braid

::LeftMultiply(): Index mismatch.\n"; exit(1); } #endif LeftDelta += a.RightDelta; for(ConstRevFactorItr it = a.FactorList.rbegin(); it != a.FactorList.rend(); ++it) { LeftMultiply(*it); } LeftDelta += a.LeftDelta; return *this; } template inline Braid

& Braid

::RightMultiply(const Braid& a) { #ifdef DEBUG if (Index() != a.Index()) { std::cerr << "Braid

::RightMultiply(): Index mismatch.\n"; exit(1); } #endif RightDelta += a.LeftDelta; for(ConstFactorItr it = a.FactorList.begin(); it != a.FactorList.end(); ++it) { RightMultiply(*it); } RightDelta += a.RightDelta; return *this; } template inline Braid

& Braid

::Multiply(const Braid& a, const Braid& b) { *this = a; return RightMultiply(b); } template inline Braid

Braid

::operator*(const Braid& a) const { Braid b(*this); return b.RightMultiply(a); } template inline Braid

& Braid

::operator*=(const Braid& a) { return RightMultiply(a); } template typename Braid

::CanonicalFactor Braid

::GetPerm() const { Factor

p(Index(), LeftDelta); FactorItr it = FactorList.begin(); while (it != FactorList.end()) p *= *(it++); return p *= Factor

(Index(), RightDelta); } template Braid

& Braid

::MakeLCF() { if (RightDelta != 0) { transform(FactorList.begin(), FactorList.end(), FactorList.begin(), std::bind2nd(std::mem_fun_ref(&Factor

::Flip), RightDelta)); LeftDelta += RightDelta; RightDelta = 0; } bubble_sort(FactorList.begin(), FactorList.end(), std::ptr_fun(MakeLeftWeighted

)); LeftDelta += erase_front_if( FactorList, std::bind2nd(std::mem_fun_ref(&Factor

::CompareWithDelta), 1)); erase_back_if(FactorList, std::mem_fun_ref(&Factor

::CompareWithIdentity)); return *this; } template Braid

& Braid

::MakeRCF() { if (LeftDelta != 0) { transform(FactorList.begin(), FactorList.end(), FactorList.begin(), std::bind2nd(std::mem_fun_ref(&Factor

::Flip), -LeftDelta)); RightDelta += LeftDelta; LeftDelta = 0; } bubble_sort(FactorList.begin(), FactorList.end(), std::ptr_fun(&MakeRightWeighted

)); RightDelta += erase_back_if( FactorList, std::bind2nd(std::mem_fun_ref(&Factor

::CompareWithDelta), 1)); erase_front_if(FactorList, std::mem_fun_ref(&Factor

::CompareWithIdentity)); return *this; } template Braid

Braid

::ReduceLeftLower() { return ReduceLeftSub(Factor

(Index()).LowerDelta()); } template Braid

Braid

::ReduceLeftUpper() { return ReduceLeftSub(Factor

(Index()).UpperDelta()); } template Braid

Braid

::ReduceRightLower() { return ReduceRightSub(Factor

(Index()).LowerDelta()); } template Braid

Braid

::ReduceRightUpper() { return ReduceRightSub(Factor

(Index()).UpperDelta()); } template Braid

Braid

::ReduceLeftSub(const Factor

& SmallDelta) { MakeLCF(); if (LeftDelta < 0) throw NegativeBraidError(); Braid b(Index()); while (1) { Factor

f(Index()); if (LeftDelta > 0) { --LeftDelta; f.Delta(1); } else if (FactorList.empty()) { break; } else { f = FactorList.front(); FactorList.pop_front(); } Factor

p = LeftMeet(f, SmallDelta); LeftMultiply((!p)*f); if (p.CompareWithIdentity()) break; b.RightMultiply(p); apply_binfun(FactorList.begin(), FactorList.end(), std::ptr_fun(MakeLeftWeighted

)); erase_back_if(FactorList, std::mem_fun_ref(&Factor

::CompareWithIdentity)); } return b; } template Braid

Braid

::ReduceRightSub(const Factor

& SmallDelta) { MakeRCF(); if (RightDelta < 0) throw NegativeBraidError(); Braid b(Index()); while (1) { Factor

f(Index()); if (RightDelta > 0) { --RightDelta; f.Delta(1); } else if (FactorList.empty()) { break; } else { f = FactorList.back(); FactorList.pop_back(); } Factor

p = RightMeet(f, SmallDelta); RightMultiply(f*!p); if (p.CompareWithIdentity()) break; b.LeftMultiply(p); reverse_apply_binfun(FactorList.begin(), FactorList.end(), std::ptr_fun(MakeRightWeighted

)); erase_front_if(FactorList, std::mem_fun_ref(&Factor

::CompareWithIdentity)); } return b; } template Braid

& Braid

::Randomize(sint32 cl) { #ifdef DEBUG if (cl < 0) { std::cerr << "Braid

::Randomize(): Bad argument.\n"; exit(1); } #endif Identity(); while (cl-- > 0) { FactorList.push_back(Factor

(Index()).Randomize()); } return *this; } template std::ostream& operator<<(std::ostream& os, const Braid

& b) { os << "(" << b.LeftDelta << "|"; typename Braid

::ConstFactorItr i; for(i = b.FactorList.begin(); i != b.FactorList.end(); ++i) { for(sint16 k = 1; k < b.Index(); ++k) os << i->At(k) << " "; os << i->At(b.Index()) << "|"; } os << b.RightDelta << ")"; return os; } libbraiding-1.1/lib/cbraid_interface.h000066400000000000000000000406011372716755000200220ustar00rootroot00000000000000/* Copyright (C) 2000-2001 Jae Choon Cha. This file is part of CBraid. CBraid 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 2 of the License, or any later version. CBraid 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 CBraid. If not, see . */ /* $Id: cbraid_interface.h,v 1.11 2001/12/07 10:12:13 jccha Exp $ Jae Choon CHA This is interface declarations of cbraid library. */ // For portablity, we use our own primitive types. The following // definitions may need to be modified for your compiler. typedef char sint8; typedef unsigned char uint8; /* JLT: Don't use short ints... */ // typedef short sint16; // typedef unsigned short uint16; typedef int sint16; typedef unsigned int uint16; typedef int sint32; typedef unsigned int uint32; typedef long long sint64; typedef unsigned long long uint64; // Implementation limits. // Maximum braid index. const sint16 MaxBraidIndex = 300; // Algorithms useful in managing standard containers of Factor objects. // Apply a binary function f on pairs (first,first+1), // (first+1,first+2), ... , sequentially, where f is allowed to change // the arguments. The algorithm stops if either the binary function f // returns false or (last-2,last-1) has been processed. An iterator // pointing the first untouched element is returned. For example, if // the entire [first, last[ has been processed, then last is returned. // One may easily recognize that this can be used is for the inner // loop of the bubble sort algorithm. In Cbraid, this is used to make // a given sequence of canonical factors weighted, under the // assumption that all adjancent pairs but the first one are weighted. // Obviously the execution time is linear in the length of the // sequence. template ForItr apply_binfun(ForItr first, ForItr last, BinFunc f); // The reverse version of apply_binfun. By reverse_apply_binfun, f is // applied on (last-2,last-1), (last-3,last-2), ... , sequentially. // It returns the first(leftmost) element that has been processed. template BiItr reverse_apply_binfun(BiItr first, BiItr last, BinFunc f); // A bubble sort algorithm. It executes apply_binfun for // [last-2,last[, [last-3,last[, ... , [first, last[ sequentialy. To // sort a sequence with respect to an order "<", f(x, y) should be a // function that swaps x and y and returns true if x > y, and unless // does nothing but returns false. This is an O(l^2) algorithm, where // l is the length of the range. template void bubble_sort(ForItr first, ForItr last, BinFun f); // Erase consecutive elements at the beginning of a sequence // satisfying a given predicate, and return the number of erased // elements. In order to remove elements from the sequence really, // the container must have erase() member function. template typename Seq::difference_type erase_front_if(Seq& s, UnaPre f); // Reverse version of erase_front_if. It erases consecutive elements // at the end of the sequence which satisfies a given predicate. template typename Seq::difference_type erase_back_if(Seq& s, UnaPre f); // Exception class. struct OddIndexError {}; struct NegativeBraidError {}; // Class describing the Artin presentation and the band generator // presentation. Basically they consist of the description of delta // and the meet operation. class ArtinPresentation { protected: sint16 PresentationIndex; public: ArtinPresentation(sint16 n); sint16 Index() const; // Return the i-th entry of the permutation table of delta^k. sint16 DeltaTable(sint16 i, sint32 k = 1) const; // Compute the meet r of the two factors a and b. A factor is // given as the associated permutation, which is viewed as a // bijection on the set {1,...n} and represented as an array whose // i-th entry is the image of i under the inverse of the // permutation (this convention is different from that in the // AsiaCrypt 2001 paper of the author). The range of indices is // [1,n], not [0,n[. We use a C style array of size (n+1) to // represent an n-permutation (the first entry is not used). // We define the left meet of two factors a and b to be the // longest factor r such that a=ra' and b=rb' for some factors a' // and b'. This coincides with the convention of the paper of // Birman, Ko, and Lee, but different from that of the article of // Thurston (in Epstein's book). Indeed, Thurston's is the // "right" meet in our sense. void LeftMeet(const sint16* a, const sint16* b, sint16* r) const; void RightMeet(const sint16* a, const sint16* b, sint16* r) const; // Generate a random factor. void Randomize(sint16* r) const; private: // Subroutine called by LeftMeet() and RightMeet() static void MeetSub(const sint16* a, const sint16* b, sint16* r, sint16 s, sint16 t); }; class BandPresentation { protected: sint16 PresentationIndex; public: BandPresentation(sint16 n); sint16 Index() const; // Return the i-th entry of the permutation table of delta^k. sint16 DeltaTable(sint16 i, sint32 k = 1) const; // Conversions between permutation table and disjoint cycle // decomposition table. They are those described in the AsiaCrypt // 2001 paper of the author, which uses different convention of // permutation table. (In other parts of this program, a[i] is // the inverse image of i, but in the paper and in these // conversion functions, a[i] is the image of i.) void PTtoDCDT(const sint16* a, sint16* x) const; void DCDTtoPT(const sint16* x, sint16* a) const; // Conversion of a ballot sequence into a permutation table. The // convention of the AsiaCrypt 2001 paper is also used here (see // the above remark). void BStoPT(const sint8* s, sint16* a) const; // Generate a random factor. It works properly only if USE_CLN // macro is defined at compile time. void Randomize(sint16* r) const; // Compute the meet r of two factors a and b. void LeftMeet(const sint16* a, const sint16* b, sint16* r) const; void RightMeet(const sint16* a, const sint16* b, sint16* r) const; }; // Class for a canonical factor, which is represented as a // permutation. template class Factor { private: // The presentation description. P Pres; // Permutation table. sint16* pTable; public: // Constructor. The permutation table is initialized as // delta^k. If k == Uninitialize, the table is left uninitialized. enum { Uninitialize = 0x80000000 }; Factor(sint16 n, sint32 k = Uninitialize); // Copy constructor. Factor(const Factor& f); // Conversion operator to the sint16* type. The address of the // permutation table is returned. Recall that the index range is // [1..n], not [0,n[; when the return value is r, r[1], ... , r[n] // contains the permutation table. r[0] may be an invalid memory // and must not be accessed. operator sint16*(); operator const sint16*() const; // Destructor. ~Factor(); // Initialize as a power of delta. Factor& Delta(sint32 k = 1); Factor& Identity(); // Initialize as a power of lower/upper delta. Factor& LowerDelta(sint32 k = 1); Factor& UpperDelta(sint32 k = 1); // Get the index. sint16 Index() const; // Access to the n-th element of the permutation table. We follow // the standard mathematical convention; the argument should be // between 1 and Index. sint16& At(sint16 n); sint16 At(sint16 n) const; sint16& operator[](sint16 n); sint16 operator[](sint16 n) const; // Assignment operator. Factor& Assign(const Factor& f); Factor& operator=(const Factor& f); // Comparison operator. bool Compare(const Factor& f) const; bool operator==(const Factor& f) const; bool operator!=(const Factor& f) const; // Comparison with special elements. bool CompareWithDelta(sint32 k = 1) const; bool CompareWithIdentity() const; // Composition operators, viewing factors as elements of the // permutation group. We have several variants: // b.Composition(a) return the composition of a and b // b.AssignComposition(a) assign to b the composition of b and a. // a*b the operator form of b.Composition(a). // b *= a the operator form of b.AssignComposition(a). Factor Composition(const Factor& a) const; Factor& AssignComposition(const Factor& a); Factor& operator*=(const Factor& a); Factor operator*(const Factor& a) const; // Inversion operators. We also have variants: // a.Inverse() return the inverse of a. // a.AssignInverse() invert a. // !a the operator form of a.Inverse(). Factor Inverse() const; Factor& AssignInverse(); Factor operator!() const; // Complement operations. For a factor a, ~a=a^(-1) delta is // called the complement (i.e. a(~a) = delta). We provide // variants similar to those of inversion. /* JLT: bugfix: the function Complement was using ~a (which doesn't even compile) rather than the inverse of *this. Juan Gonzales-Menenes had noticed the same thing in his "braiding" code; he had used !(*this) rather than this->Inverse(). */ /* Factor Complement() const { return ~a*Factor(Index(), -1); } */ Factor Complement() const { return this->Inverse()*Factor(Index(), 1); } Factor& AssignComplement() { return *this = Complement(); } Factor operator~() const { return Complement(); } // Flip operations (conjugation by delta^k, i,e. delta^(-k) a // delta^k). Factor Flip(sint32 k = 1) const; Factor& AssignFlip(sint32 k = 1); // Meet operations. b.LeftMeet(a) (resp. b.RightMeet(a)) returns // the left (resp. right) meet of b and a. Factor LeftMeet(const Factor& a) const; Factor RightMeet(const Factor& a) const; // Generate a random factor. Factor& Randomize(); }; // Binary function form of the meet operators. template Factor

LeftMeet(const Factor

& a, const Factor

& b); template Factor

RightMeet(const Factor

& a, const Factor

& b); // Make two factors left (or right) weighted. false is returned if // and only if they are already weighted. template bool MakeLeftWeighted(Factor

& a, Factor

& b); template bool MakeRightWeighted(Factor

& a, Factor

& b); // Output (the permutation table of) a factor through ostream. template std::ostream& operator<<(std::ostream& os, const Factor

& f); // Short type names for canonical factors in Artin's and the band // generator presentation. typedef Factor ArtinFactor; typedef Factor BandFactor; // Class for a braid. A braid is represented as a triple (l, // A_1...A_n, r), where l and r represent the powers of deltas at the // left and right ends, and A_1,...,A_n is a list of canonical // factors. template class Braid; // Friend functions. template std::ostream& operator<<(std::ostream& os, const Braid

& b); // Real declaration. template class Braid { public: // Type for canonical factors. /* JLT: the old code was typedef Factor

Factor, which is no longer legal C++. Hence, Factor had to be changed to Factor

or CanonicalFactor in many places. */ typedef Factor

CanonicalFactor; private: // Presentation description. P Pres; // We allow direct access to the internal data structure, because // their meanings are clear without any additional interfaces, and // this is efficient for time-critical jobs. public: // Powers of deltas at ends. sint32 LeftDelta, RightDelta; // Length of the canonical factor list. sint32 CLength; // List of canonical factors. According to my experiments, usual // operations on a list of pointers to objects is much faster // (about twice) than corresponding operations on a list of // objects, especially in the case of STL lists. Because of this, // the following type declaration will be changed later. std::list > FactorList; public: // Iterator types for canonical factors. typedef typename std::list >::iterator FactorItr; typedef typename std::list >::const_iterator ConstFactorItr; typedef typename std::list >::reverse_iterator RevFactorItr; typedef typename std::list >::const_reverse_iterator ConstRevFactorItr; public: // Constructor which creates a trivial braid. Braid(sint16 n); // Copy constructor. Braid(const Braid& b); // Construct from a factor. Braid(const Factor

& f); // Destructor. ~Braid(); // Get the index. sint16 Index() const; // Initialize as a trivial braid. Braid& Identity(); // Assignment operator. Braid& Assign(const Braid& b); Braid& operator=(const Braid& b); // Comparison operator. Two braids are viewed as the same ones if // and only if they have the same internal representation. Hence // braids are usually converted to canonical forms before // comparison. bool Compare(const Braid& b) const; bool operator==(const Braid& b) const; bool operator!=(const Braid& b) const; // Compare with the trivial representation of the identity braid. // true is returned iff both LeftDelta and RightDelta are zero and // FactorList is empty. bool CompareWithIdentity() const; // Inverting operators. a.Inverse() returns the inverse of // a. !a is the operator form of Inverse(). Braid Inverse() const; Braid operator!() const; // Mutiplication operators. By b.LeftMultiply(a) and // b.RightMultiply(a), b becomes a*b and b*a, respectively. a // can be either a braid or a factor. More functions are // provided for braids. c.Multiply(a,b), c becomes a*b. a*b // returns the multiplication. By a*=b, a becomes a*b. Braid& LeftMultiply(const Factor

& f); Braid& RightMultiply(const Factor

& f); Braid& LeftMultiply(const Braid& a); Braid& RightMultiply(const Braid& a); Braid& Multiply(const Braid& a, const Braid& b); Braid operator*(const Braid& a) const; Braid& operator*=(const Braid& a); // Get the permutation associated to the braid. Factor

GetPerm() const; // Convertion into canonical forms. Braid& MakeLCF(); Braid& MakeRCF(); // Reduce the maximal left/right lower/upper subbraid. By // definition, a is the maximal left lower subbraid of a // positive braid b if a is maximal among positive left lower // braids such that a^(-1) b is positive. b.MaxLeftLower() set // x to b return a. The other three are similar. Braid ReduceLeftLower(); Braid ReduceLeftUpper(); Braid ReduceRightLower(); Braid ReduceRightUpper(); private: // Subroutines used by Reduce{Left, Right}{Upper,Lower}(). Braid ReduceLeftSub(const Factor

& f); Braid ReduceRightSub(const Factor

& f); public: // Generate a random braid. The result is a braid consisting // of cl randomly chosen canonical factors with RightDelta and // LeftDelta zero. Braid& Randomize(sint32 cl = 1); // Friend functions. // Print a braid through ostream. friend std::ostream& operator<< <>(std::ostream& os, const Braid& b); }; // Short names for braid types. typedef Braid ArtinBraid; typedef Braid BandBraid; // Conversion between ArtinBraid and BandBraid. BandBraid ToBandBraid(const ArtinBraid& a); ArtinBraid ToArtinBraid(const BandBraid& b); #ifdef USE_CLN // Catalan number function. const cln::cl_I& GetCatalanNumber(sint16 n); // Generate the k-th ballot sequence of length 2n and store it in // s[1..2n] (note that s[0] is not used). It is internally used by // Randomize(), but is declared as public since it has its own worth. void BallotSequence(CBraid::sint16 n, const cln::cl_I k, CBraid::sint8* s); #endif // USE_CLN libbraiding-1.1/library.pyx000066400000000000000000000142171372716755000160510ustar00rootroot00000000000000#clang C++ #clib braiding r""" Cython wrapper for the libbraiding library. The libbraiding library is a modification of the braiding program by Juan Gonzalez-Meneses (https://github.com/jeanluct/cbraid) to expose the functions as a C++ library instead of an interactive program. Braids are returned in left normal form as a list of lists. The first list contains only an integer, representing the power of Delta. The subsequent lists are the Tietze lists of the elementary permutation braids. """ from libcpp.list cimport list cdef extern from "braiding.h" namespace "Braiding": list[list[int]] ConjugatingBraid (int n, list[int] word, list[int] word2) list[list[int]] LeftNormalForm (int n, list[int] word) list[list[int]] RightNormalForm (int n, list[int] word) list[list[int]] GreatestCommonDivisor(int n, list[int] word1, list[int] word2) list[list[int]] LeastCommonMultiple(int n, list[int] word1, list[int] word2) list[list[list[int]]] CentralizerGenerators(int n, list[int] word) list[list[list[int]]] SuperSummitSet(int n, list[int] word) list[list[list[list[int]]]] UltraSummitSet(int n, list[int] word) int thurstontype(int n, list[int] word); int Rigidity_ext(int n, list[int] word); list[list[list[list[int]]]] SlidingCircuits(int n, list[int] word) def conjugatingbraid(braid1, braid2): r""" Return a braid that conjugates braid1 to braid2, if such a braid exists. INPUT: - ``braid1`` -- the braid to be conjugated. - ``braid2`` -- the braid to conjugate to. OUTPUT: The list of lists that represent a conjugating braid. If the input braids are not conjugate, an empty list is returned. EXAMPLES:: sage: B = BraidGroup(3) sage: b = B([1,2,1,-2]) sage: c = B([1,2]) sage: conjugatingbraid(b,c) # optional - libbraiding [[0], [2]] """ nstrands = max(braid1.parent().strands(), braid2.parent().strands()) l1 = braid1.Tietze() l2 = braid2.Tietze() sig_on() cdef list[list[int]] rop = ConjugatingBraid(nstrands, l1, l2) sig_off() return rop def leftnormalform(braid): r""" Return the left normal form of a braid. INPUT: - ``braid`` -- a braid OUTPUT: A list of lists with the left normal form. The first list contains the power of delta. The subsequent lists are the elementary permutation braids. EXAMPLES:: sage: B = BraidGroup(3) sage: b = B([1,2,1,-2]) sage: leftnormalform(b) # optional - libbraiding [[0], [2, 1]] """ nstrands = braid.parent().strands() l1 = braid.Tietze() sig_on() cdef list[list[int]] rop = LeftNormalForm(nstrands, l1) sig_off() return rop def rightnormalform(braid): r""" Return the right normal form of a braid. INPUT: - ``braid`` -- a braid OUTPUT: A list of lists with the right normal form. The first list contains the power of delta. The subsequent lists are the elementary permutation braids. EXAMPLES:: sage: B = BraidGroup(3) sage: b = B([1,2,1,-2]) sage: rightnormalform(b) # optional - libbraiding [[2, 1], [0]] """ nstrands = braid.parent().strands() l1 = braid.Tietze() sig_on() cdef list[list[int]] rop = RightNormalForm(nstrands, l1) sig_off() return rop def greatestcommondivisor(braid1, braid2): r""" Return the greatest common divisor of two braids. """ nstrands = max(braid1.parent().strands(), braid2.parent().strands()) l1 = braid1.Tietze() l2 = braid2.Tietze() sig_on() cdef list[list[int]] rop = GreatestCommonDivisor(nstrands, l1, l2) sig_off() return rop def leastcommonmultiple(braid1, braid2): r""" Return the least common multiple of two braids. """ nstrands = max(braid1.parent().strands(), braid2.parent().strands()) l1 = braid1.Tietze() l2 = braid2.Tietze() sig_on() cdef list[list[int]] rop = LeastCommonMultiple(nstrands, l1, l2) sig_off() return rop def centralizer(braid): r""" Return a list of generators of the centralizer of a braid. """ nstrands = braid.parent().strands() lnf = leftnormalform(braid) if len(lnf) == 1: # (lib)braiding crashes when the input is a power of Delta. if lnf[0][0] % 2 == 0: return [[[0], [i+1]] for i in range(nstrands)] elif nstrands % 2: return [[[0], [i+1, nstrands - i -1]] for i in range(nstrands/2)] else: return [[[0], [i+1, nstrands - i -1]] for i in range(nstrands/2-1)] + [[[0], [nstrands/2]]] l = braid.Tietze() sig_on() cdef list[list[list[int]]] rop = CentralizerGenerators(nstrands, l) sig_off() return rop def supersummitset(braid): r""" Return a list with the super-summit-set of a braid. """ nstrands = braid.parent().strands() l = braid.Tietze() sig_on() cdef list[list[list[int]]] rop = SuperSummitSet(nstrands, l) sig_off() return rop def ultrasummitset(braid): r""" Return a list with the ultra-summit-set of the braid. """ nstrands = braid.parent().strands() l = braid.Tietze() sig_on() cdef list[list[list[list[int]]]] rop = UltraSummitSet(nstrands, l) sig_off() return rop def thurston_type(braid): r""" Return the Thurston type of the braid """ nstrands = braid.parent().strands() l = braid.Tietze() sig_on() cdef int i = thurstontype(nstrands, l) sig_off() if i == 1: return 'periodic' elif i==2: return 'reducible' elif i==3: return 'pseudo-anosov' def rigidity(braid): r""" Return the rigidity of the braid """ nstrands = braid.parent().strands() l = braid.Tietze() sig_on() cdef int i = Rigidity_ext(nstrands, l) sig_off() return i def sliding_circuits(braid): r""" Return the set of sliding circuits of the braid """ nstrands = braid.parent().strands() l = braid.Tietze() sig_on() cdef list[list[list[list[int]]]] rop = SlidingCircuits(nstrands, l) sig_off() return rop