pax_global_header00006660000000000000000000000064120756300540014514gustar00rootroot0000000000000052 comment=747707c0df136bf8d9d241adedca4049ae7d6614 gfan-0.5+dfsg/000077500000000000000000000000001207563005400132125ustar00rootroot00000000000000gfan-0.5+dfsg/COPYING000066400000000000000000000430711207563005400142520ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) 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 this service 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 make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. 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. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the 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 a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE 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. END OF TERMS AND CONDITIONS Appendix: 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 convey 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) 20yy 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 2 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision 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, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This 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 Library General Public License instead of this License. gfan-0.5+dfsg/Doxyfile000066400000000000000000001452451207563005400147330ustar00rootroot00000000000000# Doxyfile 1.5.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = "Gfan Source Code" # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = 0.3.1 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = dox # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, # Italian, Japanese, Japanese-en (Japanese with English messages), Korean, # Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, # Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. OUTPUT_LANGUAGE = English # This tag can be used to specify the encoding used in the generated output. # The encoding is not always determined by the language that is chosen, # but also whether or not the output is meant for Windows or non-Windows users. # In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES # forces the Windows encoding (this is the default for the Windows binary), # whereas setting the tag to NO uses a Unix-style encoding (the default for # all platforms other than Windows). USE_WINDOWS_ENCODING = NO # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like the Qt-style comments (thus requiring an # explicit @brief command for a brief description. JAVADOC_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the DETAILS_AT_TOP tag is set to YES then Doxygen # will output the detailed description near the top, like JavaDoc. # If set to NO, the detailed description appears after the member # documentation. DETAILS_AT_TOP = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for Java. # For instance, namespaces will be presented as packages, qualified scopes # will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to # include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = NO # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = NO # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from the # version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be abled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES #CHANGED!!! # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES (the default) # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES (the default) # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. Otherwise they will link to the documentstion. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compressed HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be # generated containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are # probably better off using the HTML help feature. GENERATE_TREEVIEW = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = YES # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. This is useful # if you want to understand what is going on. On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option is superseded by the HAVE_DOT option below. This is only a # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will # generate a call dependency graph for every global function or class method. # Note that enabling this option will significantly increase the time of a run. # So in most cases it will be better to enable call graphs for selected # functions only using the \callgraph command. CALL_GRAPH = YES #CHANGED! # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will # generate a caller dependency graph for every global function or class method. # Note that enabling this option will significantly increase the time of a run. # So in most cases it will be better to enable caller graphs for selected # functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_WIDTH = 1024 # The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_HEIGHT = 1024 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that a graph may be further truncated if the graph's # image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH # and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), # the graph is not depth-constrained. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, which results in a white background. # Warning: Depending on the platform used, enabling this option may lead to # badly anti-aliased labels on the edges of a graph (i.e. they become hard to # read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO gfan-0.5+dfsg/LICENSE000066400000000000000000000005561207563005400142250ustar00rootroot00000000000000The Gfan software is distributed under the "GNU GENERAL PUBLIC LICENSE" as described in the file "COPYING". Ask the author if you want a more reasonable license. The manual for Gfan is NOT distributed under the GNU GENERAL PUBLIC LICENSE. The manual may be freely redistributed but is not allowed to be changed. The manual may be removed from the software package. gfan-0.5+dfsg/Makefile000066400000000000000000000305231207563005400146550ustar00rootroot00000000000000ALL: default # GPROFFLAG = -pg GPROFFLAG = -g PREFIX?=/usr/local BINDIR=$(PREFIX)/bin RELEASEDIR = gfan0.5 MAIN = gfan GCATSPATH = ./ ifeq ($(sagepath),) SAGE_LINKOPTIONS = SAGE_INCLUDEOPTIONS = else SAGE_LINKOPTIONS = -L$(sagepath)/ -lpython2.6 -lcsage -lsingular SAGE_INCLUDEOPTIONS = -I $(sagepath)/ SAGE_OBJECTS = sage.o sage_link.so sage_link.so: sage_link.pyx setup.py python setup.py build_ext --inplace --pyrex-include-dirs=$(SAGE_ROOT)/devel/sage/ endif ifeq ($(gmppath),) GMP_LINKOPTIONS = -lgmp GMP_INCLUDEOPTIONS = else GMP_LINKOPTIONS = $(gmppath)/lib/libgmp.a GMP_INCLUDEOPTIONS = -I $(gmppath)/include endif ifeq ($(cddpath),) CDD_LINKOPTIONS = -L/usr/local -lcddgmp CDD_INCLUDEOPTIONS = else CDD_LINKOPTIONS = $(cddpath)/lib/libcddgmp.a CDD_INCLUDEOPTIONS = -I $(cddpath)/include endif ifeq ($(soplex),) SOPLEX_PATH = SOPLEX_LINKOPTIONS = SOPLEX_INCLUDEOPTIONS = SOPLEX_OBJECTS = else SOPLEX_PATH = $(HOME)/math/software/soplex-1.3.2 # SOPLEX_LINKOPTIONS = -lz $(SOPLEX_PATH)/lib/libsoplex.linux.x86.gnu.opt.a SOPLEX_LINKOPTIONS = -lz $(SOPLEX_PATH)/lib/libsoplex.darwin.x86.gnu.opt.a SOPLEX_INCLUDEOPTIONS = -I $(SOPLEX_PATH)/src SOPLEX_OBJECTS = lp_soplexcdd.o endif ifeq ($(singular),) SINGULAR_PATH = SINGULAR_LINKOPTIONS = SINGULAR_INCLUDEOPTIONS = SINGULAR_OBJECTS = else SINGULAR_PATH = $(HOME)/math/software/Singular-3-1-0 SINGULAR_LINKOPTIONS = -L$(SINGULAR_PATH)/Singular -lsingular -lncurses -lreadline SINGULAR_INCLUDEOPTIONS = -I $(SINGULAR_PATH)/kernel -I $(SINGULAR_PATH)/omalloc SINGULAR_OBJECTS = singular.o singularconversion.o endif ADDITIONALLINKOPTIONS = $(CDD_LINKOPTIONS) $(GMP_LINKOPTIONS) $(SOPLEX_LINKOPTIONS) $(SINGULAR_LINKOPTIONS) $(SAGE_LINKOPTIONS) ADDITIONALINCLUDEOPTIONS = $(CDD_INCLUDEOPTIONS) $(GMP_INCLUDEOPTIONS) $(SOPLEX_INCLUDEOPTIONS) $(SINGULAR_INCLUDEOPTIONS) $(SAGE_INCLUDEOPTIONS) MKDIR=mkdir -p SHELL = /bin/sh #ARCH = LINUX CC = gcc CLINKER = $(CC) CXX = g++ CCLINKER = $(CXX) #OPTFLAGS = -O2 -DGMPRATIONAL -DNDEBUG OPTFLAGS = -O2 -DGMPRATIONAL -Wuninitialized CFLAGS = $(OPTFLAGS) $(GPROFFLAG) $(ADDITIONALINCLUDEOPTIONS) #-pedantic CCFLAGS = $(CFLAGS) FFLAGS = $(OPTFLAGS) CATSOBJECTS = $(GCATSPATH)lp_cdd.o \ $(SOPLEX_OBJECTS) \ $(SINGULAR_OBJECTS) \ $(SAGE_OBJECTS) \ $(GCATSPATH)parser.o \ $(GCATSPATH)field.o \ $(GCATSPATH)monomial.o \ $(GCATSPATH)printer.o \ $(GCATSPATH)polynomial.o \ $(GCATSPATH)termorder.o \ $(GCATSPATH)term.o \ $(GCATSPATH)vektor.o \ $(GCATSPATH)division.o \ $(GCATSPATH)buchberger.o \ $(GCATSPATH)wallideal.o \ $(GCATSPATH)lp.o \ $(GCATSPATH)enumeration.o \ $(GCATSPATH)ep_standard.o \ $(GCATSPATH)ep_xfig.o \ $(GCATSPATH)reversesearch.o \ $(GCATSPATH)application.o \ $(GCATSPATH)timer.o \ $(GCATSPATH)renderer.o \ $(GCATSPATH)field_rationals.o \ $(GCATSPATH)symmetry.o \ $(GCATSPATH)breadthfirstsearch.o \ $(GCATSPATH)genericwalk.o \ $(GCATSPATH)minkowskisum.o \ $(GCATSPATH)newtonpolytope.o \ $(GCATSPATH)tropical.o \ $(GCATSPATH)dimension.o \ $(GCATSPATH)bergman.o \ $(GCATSPATH)subspace.o \ $(GCATSPATH)polyhedralcone.o \ $(GCATSPATH)gfanapplication.o \ $(GCATSPATH)polyhedralfan.o \ $(GCATSPATH)tropical2.o \ $(GCATSPATH)gmpallocator.o \ $(GCATSPATH)field_zmodpz.o \ binomial.o \ matrix.o \ latticeideal.o \ scarf.o \ xfig.o \ halfopencone.o \ lll.o \ multiplicity.o \ substitute.o \ polymakefile.o \ saturation.o \ determinant.o \ polynomialring.o \ log.o \ tropicalbasis.o \ symmetriccomplex.o \ linalg.o \ minors.o \ continuedfractions.o \ triangulation.o \ minkowskidual.o \ regularsubdivision.o \ fieldlp.o \ field_rationalfunctions.o \ tropical_weildivisor.o \ intsinpolytope.o\ lattice.o \ graph.o \ restrictedautoreduction.o \ tropicaltraverse.o \ groebnerengine.o \ ge_gfan.o \ nbody.o \ codimoneconnectedness.o \ tropicalmap.o \ symmetrictraversal.o \ traverser_tropical.o \ traverser_groebnerfan.o \ field_rationalfunctions2.o \ mixedvolume.o \ traverser_stableintersection.o \ traverser_secondaryfan.o \ linalgfloat.o \ primarydecomposition.o \ tropicaldeterminant.o \ determinantpoly.o \ traverser_sphere.o \ gfanlib_zcone.o \ gfanlib_symmetry.o \ gfanlib_symmetriccomplex.o \ gfanlib_polyhedralfan.o \ gfanlib_zfan.o \ gfanlib_polymakefile.o \ padic.o \ integergb.o \ # restrictedgfan.o \ APPDELETEOBJECTS = app_add.o \ app_berndssuggestion.o \ app_grassmanndata2.o \ app_grassmanndata3.o \ app_construction.o \ app_checkridges.o \ app_edwinsconjecture.o \ app_fvector.o \ app_grassmanndata.o \ app_groupfacetbinomials.o \ app_istriangulation.o \ app_latticetest.o \ app_markpolynomialset.o \ app_moeckel.o \ app_polytopetopolynomial.o \ app_rendernewtonpolytope.o \ app_tropical.o \ app_xfigconstruction.o \ app_liststandardmonomials.o \ # app_isrefinement.o \ # needs to be fixed so that it compiles with gcc version 2.96 (legolas.imf.au.dk) APPOBJECTS = app_main.o \ app_buchberger.o \ app_doesidealcontain.o \ app_facets.o \ app_groebnercone.o \ app_homogeneityspace.o \ app_homogenize.o \ app_initialforms.o \ app_interactive.o \ app_isgroebnerbasis.o \ app_ismarkedgroebnerbasis.o \ app_krulldimension.o \ app_leadingterms.o \ app_multiplymatrix.o \ app_polynomialsetunion.o \ app_render.o \ app_renderstaircase.o \ app_stats.o \ app_substitute.o \ app_supportindices.o \ app_tolatex.o \ app_transposematrix.o \ app_tropicalbasis.o \ app_tropicalintersection.o \ app_tropicalstartingcone.o \ app_tropicaltraverse.o \ app_walk.o \ app_weightvector.o \ app_scarfisgeneric.o \ app_scarfvisualize.o \ app_scarfcomplex.o \ app_sturmsequence.o \ app_latticeideal.o \ app_lll.o \ app_tropicalmultiplicity.o \ app_idealintersection.o \ app_test.o \ app_saturation.o \ app_idealproduct.o \ app_representatives.o \ app_tropicallifting.o \ app_topolyhedralfan.o \ app_tropicalbruteforce.o \ app_secondaryfan.o \ app_composepermutations.o \ app_minors.o \ app_tropicalrank.o \ app_minkowski.o \ app_triangulate.o \ app_tropicallinearspace.o \ app_combinerays.o \ app_regularsubdivision.o \ app_lpsolve.o \ app_tropicalweildivisor.o \ app_lattice.o \ app_intsinpolytope.o\ app_tropicalevaluation.o \ app_smalessixth.o \ app_smalessixth2.o \ app_nbody.o \ app_spolynomial.o \ app_link.o \ app_normalfancleanup.o \ app_tropicalfunction.o \ app_volume.o \ app_isconnected.o \ app_tropicalhypersurface.o \ app_product.o \ app_commonrefinement.o \ app_tropicalimage.o \ app_groebnerfan.o \ app_fanhomology.o \ app_genericlinearchange.o \ app_mixedvolume.o \ app_fiberpolytope.o \ app_symmetries.o \ app_evaluate.o \ app_exponentlattice.o \ app_minimalassociatedprimes.o \ app_realroots.o \ app_initialdeterminant.o \ app_fansubfan.o \ app_fancones.o \ app_issmooth.o \ app_fancoarsening.o \ app_pointconfiguration.o \ app_librarytest.o \ app_padic.o \ app_integergb.o \ app_matrixproduct.o \ app_traversetropicalintersection.o \ app_markpolynomialset.o \ EXECS = $(MAIN) # Define suffixes to make the program compile on legolas.imf.au.dk : .SUFFIXES: .o .cpp .c OBJECTS = $(CATSOBJECTS) $(APPOBJECTS) all: $(MAIN) $(BINDIR): $(PREFIX) $(MKDIR) $(BINDIR) $(PREFIX): $(MKDIR) $(PREFIX) default: $(OBJECTS) $(ADDITIONALOBJECTS) $(EXECS) $(MAIN): $(OBJECTS) $(CCLINKER) $(OBJECTS) $(ADDITIONALLINKOPTIONS) $(GPROFFLAG) -o $(MAIN) release: rm -f -r $(RELEASEDIR)/* mkdir -p $(RELEASEDIR) cp *.cpp $(RELEASEDIR) cp *.h $(RELEASEDIR) cp Makefile $(RELEASEDIR) cp macmake $(RELEASEDIR) cp README $(RELEASEDIR) cp LICENSE $(RELEASEDIR) cp COPYING $(RELEASEDIR) mkdir -p $(RELEASEDIR)/gfanlib cp gfanlib/Makefile $(RELEASEDIR)/gfanlib/ cp gfanlib/Makefile.in $(RELEASEDIR)/gfanlib/ cp gfanlib/README.txt $(RELEASEDIR)/gfanlib/ cp gfanlib/configure $(RELEASEDIR)/gfanlib/ cp gfanlib/configure.ac $(RELEASEDIR)/gfanlib/ cp Doxyfile $(RELEASEDIR) echo const char *GFAN_RELEASEDIR=\"$(RELEASEDIR)\"";" const char *GFAN_FORKTIME= >$(RELEASEDIR)/versioninfo.h date "+\"%s %a %h %d %H:%M:%S %Y\"" >>$(RELEASEDIR)/versioninfo.h echo ";" >>$(RELEASEDIR)/versioninfo.h mkdir -p $(RELEASEDIR)/examples/ #General examples: cp examples/2x2of2x3 $(RELEASEDIR)/examples/ cp examples/2x2of2x4 $(RELEASEDIR)/examples/ cp examples/2x2of3x3 $(RELEASEDIR)/examples/ cp examples/2x2of4x4 $(RELEASEDIR)/examples/ cp examples/4x4of4x5 $(RELEASEDIR)/examples/ cp examples/4x4of5x5 $(RELEASEDIR)/examples/ cp examples/6x6-subPfaffians $(RELEASEDIR)/examples/ cp examples/cyclic4 $(RELEASEDIR)/examples/ cp examples/linhyper5_2 $(RELEASEDIR)/examples/ cp examples/linhyper5_2.cone $(RELEASEDIR)/examples/ cp examples/pablo $(RELEASEDIR)/examples/ cp examples/symmetryTest $(RELEASEDIR)/examples/ #Examples in Groebner fan paper: cp examples/examplePaper $(RELEASEDIR)/examples/ cp examples/sturmfels3.9 $(RELEASEDIR)/examples/ cp examples/3x3of3x4 $(RELEASEDIR)/examples/ cp examples/3x3of3x5 $(RELEASEDIR)/examples/ cp examples/3x3of4x4 $(RELEASEDIR)/examples/ # cp examples/3x3of4x4sym $(RELEASEDIR)/examples/ cp examples/grassmann2_5 $(RELEASEDIR)/examples/ cp examples/cyclic5 $(RELEASEDIR)/examples/ # cp examples/J4 $(RELEASEDIR)/examples/ #Examples useful for tropical computations: # cp examples/grassmann2_5 $(RELEASEDIR)/examples/ cp examples/grassmann2_5.cone $(RELEASEDIR)/examples/ cp examples/grassmann2_6 $(RELEASEDIR)/examples/ cp examples/grassmann2_6.cone $(RELEASEDIR)/examples/ cp examples/grassmann3_6 $(RELEASEDIR)/examples/ cp examples/grassmann3_6.cone $(RELEASEDIR)/examples/ #Examples in tropical paper: cp examples/hankel3x3of4x4 $(RELEASEDIR)/examples/ cp examples/hankel3x3of4x4.cone $(RELEASEDIR)/examples/ cp examples/hankel3x3of4x5 $(RELEASEDIR)/examples/ cp examples/hankel3x3of4x5.cone $(RELEASEDIR)/examples/ # cp examples/hankel3x3of5x5 $(RELEASEDIR)/examples/ # cp examples/hankel3x3of5x5.cone $(RELEASEDIR)/examples/ cp examples/3x3of3x5.cone $(RELEASEDIR)/examples/ # cp examples/3x3of4x4sym $(RELEASEDIR)/examples/ cp examples/3x3of4x4sym.cone $(RELEASEDIR)/examples/ # cp examples/3x3of5x5sym $(RELEASEDIR)/examples/ # cp examples/3x3of5x5sym.cone $(RELEASEDIR)/examples/ cp examples/commat2x2 $(RELEASEDIR)/examples/ cp examples/commat2x2.cone $(RELEASEDIR)/examples/ # cp examples/commat3x3 $(RELEASEDIR)/examples/ # cp examples/commat3x3.cone $(RELEASEDIR)/examples/ cp -r testsuite $(RELEASEDIR)/ mkdir -p $(RELEASEDIR)/doc/ cp doc/Makefile $(RELEASEDIR)/doc/ cp doc/*.bib $(RELEASEDIR)/doc/ cp doc/*.bbl $(RELEASEDIR)/doc/ cp doc/*.tex $(RELEASEDIR)/doc/ cp doc/*.dvi $(RELEASEDIR)/doc/ cp doc/*.eps $(RELEASEDIR)/doc/ cp doc/*.bst $(RELEASEDIR)/doc/ cp doc/Makefile $(RELEASEDIR)/doc/ mkdir -p $(RELEASEDIR)/homepage/ cp homepage/*.png $(RELEASEDIR)/homepage/ cp homepage/*.html $(RELEASEDIR)/homepage/ cp homepage/Makefile $(RELEASEDIR)/homepage/ mkdir -p $(RELEASEDIR)/homepage/presentation cp homepage/presentation/*.fig $(RELEASEDIR)/homepage/presentation/ cp homepage/presentation/*.tex $(RELEASEDIR)/homepage/presentation/ cp homepage/presentation/*.eps $(RELEASEDIR)/homepage/presentation/ cp homepage/presentation/*.bib $(RELEASEDIR)/homepage/presentation/ cp homepage/presentation/*.bbl $(RELEASEDIR)/homepage/presentation/ cp homepage/presentation/*.ps $(RELEASEDIR)/homepage/presentation/ cp homepage/presentation/*.pdf $(RELEASEDIR)/homepage/presentation/ cp homepage/presentation/Makefile $(RELEASEDIR)/homepage/presentation/ tar -c $(RELEASEDIR) > $(RELEASEDIR).tar gzip $(RELEASEDIR).tar clean: /bin/rm -f *.o $(EXECS) $(MAIN) install: $(BINDIR) cp $(EXECS) $(BINDIR) # cp $(EXECS) /usr/local/bin # ./gfan installlinks --path $(BINDIR)/ cd $(BINDIR) && ./gfan installlinks library: /bin/rm -f gfanlib/*.a /bin/rm -f gfanlib/*.o cp gfanlib.h gfanlib/ cp gfanlib_* gfanlib/ tar zcf - gfanlib > gfanlib.tar.gz .c.o: $(CC) $(CFLAGS) -c $< .cc.o: $(CXX) -c $< .cpp.o: $(CXX) $(CFLAGS) -c $< .C.o: $(CXX) -c $< # wget http://ftp.sunet.se/pub/gnu/gmp/gmp-4.2.2.tar.gz # tar -xzvf gmp-4.2.2.tar.gz # cd gmp-4.2.2 # ./configure --prefix=$HOME/gmp # make # make install # make check # cd.. # wget ftp://ftp.ifor.math.ethz.ch/pub/fukuda/cdd/cddlib-094d.tar.gz # THIS LINE DOES NOT WORK! # tar -xzvf cddlib-094d.tar.gz # cd cddlib-094d # ./configure --prefix="$HOME/cddlib" CFLAGS="-I$HOME/gmp/include -L$HOME/gmp/lib" gfan-0.5+dfsg/README000066400000000000000000000002321207563005400140670ustar00rootroot00000000000000This is the Gfan software package for computing Groebner fans. See the user manual in "doc/" for more information and LICENSE for the distribution terms. gfan-0.5+dfsg/app_buchberger.cpp000066400000000000000000000075501207563005400166750ustar00rootroot00000000000000/* TO DO: Remove Timer */ #include "parser.h" #include "printer.h" #include "polynomial.h" #include "buchberger.h" #include "reversesearch.h" #include "termorder.h" #include "genericwalk.h" #include "gfanapplication.h" #include "field_rationalfunctions2.h" #include "timer.h" #include "log.h" //#include "singular.h" static Timer globalTimer("Global-timer",1); class BuchbergerApplication : public GFanApplication { SimpleOption optionReadWeightVector; SimpleOption optionReverse; SimpleOption optionWalk; SimpleOption optionGenericWalk; IntegerOption optionParameters; // SimpleOption optionPerformanceTimer; public: const char *helpText() { return "This program computes a reduced lexicographic Groebner basis of the polynomial ideal given as input. The default behavior is to use Buchberger\'s algorithm. The ordering of the variables is $a>b>c...$ (assuming that the ring is Q[a,b,c,...]).\n"; } BuchbergerApplication(): optionReadWeightVector("-w","Compute a Groebner basis with respect to a degree lexicographic order with $a>b>c...$ instead. The degrees are given by a weight vector which is read from the input after the generating set has been read.\n"), optionReverse("-r","Use the reverse lexicographic order (or the reverse lexicographic order as a tie breaker if -w is used). The input must be homogeneous if the pure reverse lexicographic order is chosen. Ignored if -W is used.\n"), optionWalk("-W","Do a Groebner walk. The input must be a minimal Groebner basis. If -W is used -w is ignored.\n"), optionGenericWalk("-g","Do a generic Groebner walk. The input must be homogeneous and must be a minimal Groebner basis with respect to the reverse lexicographic term order. The target term order is always lexicographic. The -W option must be used.\n"), optionParameters("--parameters","With this option you can specify how many variables to treat as parameters instead of variables. This makes it possible to do computations where the coefficient field is the field of rational functions in the parameters. This does not work well at the moment.",0) //,optionPerformanceTimer("-T","enable performance timer") { registerOptions(); } const char *name() { return "_buchberger"; } int main() { TermOrder *myOrder; PolynomialSet g=FileParser(Stdin).parsePolynomialSetWithRing(); if(optionParameters.getValue())g=makeVariablesParameters(makeVariablesParameters(g.getRing(),optionParameters.getValue()),g); if(optionReadWeightVector.getValue()) { IntegerVector w=FileParser(Stdin).parseIntegerVector(); if(optionReverse.getValue()) myOrder = new WeightReverseLexicographicTermOrder(w); else myOrder = new WeightTermOrder(w); } else if(optionReverse.getValue()) myOrder = new ReverseLexicographicTermOrder; else myOrder = new LexicographicTermOrder; globalTimer.on(); if(optionWalk.getValue()) { g.scaleMarkedCoefficientsToOne(); log1 fprintf(Stderr,"Auto-reducing input...\n"); autoReduce(&g,LexicographicTermOrder()); log1 fprintf(Stderr,"Walking...\n"); if(optionGenericWalk.getValue()) { g=genericWalk(g, ReverseLexicographicTermOrder(), LexicographicTermOrder()); } else { g=ReverseSearch(LexicographicTermOrder()).findRoot(g); } } else { //fprintf(Stderr,"TESTING Singular interface\n"); //singularBuchberger(&g,*myOrder); buchberger(&g,*myOrder); // AsciiPrinter(Stderr).printPolynomialSet(g); // fprintf(Stderr,"\n\n\n"); g.scaleMarkedCoefficientsToOne();// buchberger(&g,*myOrder); autoReduce(&g,LexicographicTermOrder()); } globalTimer.off(); AsciiPrinter(Stdout).printPolynomialRing(g.getRing()); printf("\n"); AsciiPrinter(Stdout).printPolynomialSet(g); // if(optionPerformanceTimer.getValue())Timer::printList(); return 0; } }; static BuchbergerApplication theApplication; gfan-0.5+dfsg/app_combinerays.cpp000066400000000000000000000051561207563005400171000ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "lp.h" #include "gfanapplication.h" #include "polyhedralcone.h" #include "polymakefile.h" #include "determinant.h" #include "subspace.h" #include "triangulation.h" #include "symmetry.h" class CombineRaysApplication : public GFanApplication { StringOption inputOption; StringOption sectionOption; SimpleOption dumpOption; IntegerOption dumpHeightOption; IntegerOption dumpWidthOption; public: const char *helpText() { return "This program combines rays from the specified polymake file by adding according to a list of vectors of indices given on the standard input.\n"; } CombineRaysApplication(): inputOption("-i","Specify the name of the input file.","examples/grassmann3_7.out"), sectionOption("--section","Specify a section of the polymake file to use as input, rather than standard input.",0), dumpOption("--dump","Dump specified section as a matrix rather than combining the rays"), dumpHeightOption("--dheight","Specify height of matrix to be dumped.",1), dumpWidthOption("--dwidth","Specify width of matrix to be dumped.",1) { dumpOption.hide(); dumpHeightOption.hide(); dumpWidthOption.hide(); registerOptions(); } const char *name() { return "_combinerays"; } int main() { PolymakeFile inFile; inFile.open(inputOption.getValue()); if(dumpOption.getValue()) { pout< > l=inFile.readMatrixIncidenceProperty(sectionOption.getValue()); for(vector >::const_iterator i=l.begin();i!=l.end();i++) { IntegerVector temp(i->size()); int J=0; for(list::const_iterator j=i->begin();j!=i->end();j++,J++)temp[J]=*j; comb.push_back(temp); } } else comb=P.parseIntegerVectorList(); IntegerVectorList result; for(IntegerVectorList::const_iterator j=comb.begin();j!=comb.end();j++) { IntegerVector interiorPoint(N); for(int i=0;isize();i++) { interiorPoint+=rays[(*j)[i]]; } result.push_back(interiorPoint); } AsciiPrinter(Stdout).printVectorList(result); fprintf(Stdout,"\n"); return 0; } }; static CombineRaysApplication theApplication; gfan-0.5+dfsg/app_commonrefinement.cpp000066400000000000000000000021061207563005400201220ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "lp.h" #include "gfanapplication.h" #include "polyhedralcone.h" #include "polyhedralfan.h" #include "polymakefile.h" class CommonRefinementApplication : public GFanApplication { StringOption input1Option; StringOption input2Option; public: const char *helpText() { return "This program takes two polyhedral fans and computes their common refinement.\n"; } CommonRefinementApplication(): input1Option("-i1","Specify the name of the first input file.","polymake.out"), input2Option("-i2","Specify the name of the second input file.","polymake.out") { registerOptions(); } const char *name() { return "_fancommonrefinement"; } int main() { PolyhedralFan f1=PolyhedralFan::readFan(input1Option.getValue()); PolyhedralFan f2=PolyhedralFan::readFan(input2Option.getValue()); PolyhedralFan f=refinement(f1,f2); AsciiPrinter P(Stdout); f.printWithIndices(&P,FPF_default/*|FPF_multiplicities|FPF_values*/); return 0; } }; static CommonRefinementApplication theApplication; gfan-0.5+dfsg/app_composepermutations.cpp000066400000000000000000000016151207563005400207010ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "matrix.h" #include "symmetry.h" #include "gfanapplication.h" class ComposePermutationApplication : public GFanApplication { FieldOption theFieldOption; public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program takes a list of permutations and composes them in the given order.\n"; } ComposePermutationApplication() { registerOptions(); } const char *name() { return "_composepermutations"; } int main() { IntegerMatrix m=rowsToIntegerMatrix(FileParser(Stdin).parseIntegerVectorList()); int n=m.getWidth(); IntegerVector p=SymmetryGroup::identity(n); for(int i=0;i class EvaluationApplication : public GFanApplication { SimpleOption optionComplex; public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program evaluates a list of polynomials in a point.\n"; } EvaluationApplication(): optionComplex("--complex","Read and evaluate using complex numbers rather than real numbers.") { registerOptions(); } const char *name() { return "_evaluation"; } int main() { FileParser P(Stdin); PolynomialSet g=P.parsePolynomialSetWithRing(); if(0){ for(int i1=1;i1<20;i1++) for(int i2=1;i2<20;i2++) for(int i3=1;i3<20;i3++) { FloatVector v(4); v[0]=i1/20.0; v[1]=i2/20.0; v[2]=i3/20.0; v[3]=1-v[1]-v[2]-v[0]; pout.printFloatVector(g.evaluateFloat(v)); } } if(optionComplex.getValue()) { ComplexVector x=P.parseComplexVector(); pout.printComplexVector(g.evaluateComplex(x)); } else { FloatVector x=P.parseFloatVector(); pout.printFloatVector(g.evaluateFloat(x)); } pout<<"\n"; return 0; } }; static EvaluationApplication theApplication; gfan-0.5+dfsg/app_exponentlattice.cpp000066400000000000000000000021041207563005400177610ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "wallideal.h" #include "termorder.h" #include "gfanapplication.h" #include "matrix.h" #include "linalg.h" class ExponentLatticeApplication : public GFanApplication { public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program computes a list of generators for the lattice generated by the exponent differences of monomials of the same polynomial in the input list of polynomials.\n"; } ExponentLatticeApplication() { registerOptions(); } const char *name() { return "_exponentlattice"; } int main() { FileParser P(Stdin); PolynomialSet g=P.parsePolynomialSetWithRing(); int n=g.getRing().getNumberOfVariables(); IntegerVectorList l=exponentDifferences(g); FieldMatrix L=integerMatrixToFieldMatrix(rowsToIntegerMatrix(l,n),Q); L.reduce(false,true); L.removeZeroRows(); pout< coneIndicesAtRidge; vector F1,F2; public: bool includeInDefaultInstallation() { return false; } IntegerVectorList inequalitiesForCone(IntegerVector const &codim1interior, IntegerVector const &newDirection) { int i=0; } const char *helpText() { return "This program reads in a codimension-one fan (with support equal to the codimension-1 skeleton of the normal fan of a polytope) and constructs the normal fan of the polytope.\n"; } FanCoarseningApplication(): inputOption("-i","Specify the name of the input file.","polymake.out") // resultantOption("--resultant","Take codim 1 skeleton and wipe out bad cones.") { registerOptions(); } const char *name() { return "_fancoarsening"; } /* bool zeroOrTwo(int v) { return (v==0) || (v==2); }*/ class MyTarget : public SymmetricTarget { list normals; bool process(ConeTraverser &traverser) { SphereTraverser *t=dynamic_cast (&traverser); normals.push_back(t->currentNormal); return true; } public: PolyhedralCone toCone() { PolyhedralCone c(normals,IntegerVectorList(),normals.begin()->size()); c.canonicalize(); return c; } }; class MyTraverser: public ConeTraverser { int currentConeIndex; vector const &cones; map > adjacency; PolyhedralCone theCone; //void updatePolyhedralCone(); void moveToCone(IntegerVector const &v, IntegerVector const &normal) { SphereTraverser traverser(cones,adjacency,v,normal); MyTarget myTarget; SymmetryGroup s(normal.size()); symmetricTraverse(traverser,myTarget); theCone=myTarget.toCone(); } public: // IntegerVector currentNormal; MyTraverser(vector const &cones_, map > const &adjacency_, IntegerVector const &v, IntegerVector const &normal): cones(cones_), adjacency(adjacency_) { moveToCone(v,normal); } virtual void changeCone(IntegerVector const &ridgeVector, IntegerVector const &rayVector) { moveToCone(ridgeVector,rayVector); } virtual IntegerVectorList link(IntegerVector const &ridgeVector) { IntegerVector v=theCone.link(ridgeVector).getUniquePoint(); IntegerVectorList ret; ret.push_back(v); ret.push_back(-v); return ret; } PolyhedralCone & refToPolyhedralCone() { return theCone; } }; int main() { PolyhedralFan f1=PolyhedralFan::readFan(inputOption.getValue(),true,0,0,0); AsciiPrinter P(Stdout); for(PolyhedralFan::coneIterator i=f1.conesBegin();i!=f1.conesEnd();i++)F1.push_back(*i); map > adjacency; for(int i=0;igetUniquePoint()].push_back(i); } // SphereTraverser(vector const &cones_, map > const &ajacency_, IntegerVector const &startCone, IntegerVector const &normal); SphereTraverser traverser(F1,adjacency,F1[0].getUniquePoint(),*F1[0].getEquations().begin()); MyTarget myTarget; SymmetryGroup s(f1.getAmbientDimension()); // SymmetricTargetFanBuilder myTarget(f1.getAmbientDimension(),s); symmetricTraverse(traverser,myTarget); // myTarget.getFanRef().printWithIndices(&pout); myTarget.toCone().print(&debug); { MyTraverser traverser(F1,adjacency,F1[0].getUniquePoint(),*F1[0].getEquations().begin()); SymmetryGroup s(f1.getAmbientDimension()); SymmetricTargetFanBuilder myTarget(f1.getAmbientDimension(),s); symmetricTraverse(traverser,myTarget); myTarget.getFanRef().printWithIndices(&pout); } return 0; } }; static FanCoarseningApplication theApplication; gfan-0.5+dfsg/app_fancones.cpp000066400000000000000000000034301207563005400163520ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "lp.h" #include "gfanapplication.h" #include "polyhedralcone.h" #include "polyhedralfan.h" #include "symmetry.h" #include "polymakefile.h" class FanConesApplication : public GFanApplication { StringOption inputOption; SimpleOption resultantOption; public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program lists the cones of a polyhedral fan.\n"; } FanConesApplication(): inputOption("-i","Specify the name of the input file.","polymake.out"), resultantOption("--resultant","Take codim 1 skeleton and wipe out bad cones.") { registerOptions(); } const char *name() { return "_fancones"; } bool zeroOrTwo(int v) { return (v==0) || (v==2); } int main() { PolyhedralFan f1=PolyhedralFan::readFan(inputOption.getValue(),true,0,0,0); AsciiPrinter P(Stdout); if(resultantOption.getValue()) { PolyhedralFan f2=f1.facetComplex(); PolyhedralFan f3(f2.getAmbientDimension()); for(PolyhedralFan::coneIterator i=f2.conesBegin();i!=f2.conesEnd();i++) { IntegerVector v=i->getEquations().front(); IntegerVector u=v.supportAsZeroOneVector(); if(zeroOrTwo(u[0]+u[1]+u[2]+u[3]) && zeroOrTwo(u[4]+u[5]+u[6]) && zeroOrTwo(u[7]+u[8]/*+u[5]*/)) f3.insert(*i); } f3.printWithIndices(&pout); // pout << f2; } else for(PolyhedralFan::coneIterator i=f1.conesBegin();i!=f1.conesEnd();i++) { P<<*i; P<<"-------------------------------------\n"; } return 0; } }; static FanConesApplication theApplication; gfan-0.5+dfsg/app_fanhomology.cpp000066400000000000000000000354161207563005400171110ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "lp.h" #include "gfanapplication.h" #include "polyhedralcone.h" #include "polyhedralfan.h" #include "polymakefile.h" #include "symmetriccomplex.h" #include "lll.h" #include "linalg.h" #include "log.h" /* * About the homology computation: * The boundary map matrices are computed by SymmetricComplex, but since these are very large * this program does not store the complete matrices in the -o mode. Instead sparse matrices are used. * For each homology group we need to consider two boundary map matrices B2 and B1. We have to compute the kernel * of B1 modulo the image of B2. One way to do this is by first computing a lattice basis of the * kernel of B1 and then write the columns of B2 in new coordinates. In these new coordinates * we check how much of the space is spanned by computing an integer row echelon form of the transposed matrix * of generators. The quotient can now be read of from the pivots, while the number of non-pivot rows * are the Betti numbers. * In the optimized -o version, we instead start by investigating the second matrix B1 which we need to * compute the kernel of. It often turns out that some coordinates of a vector in the kernel are implicit * in the sense that given the others we can determine what they are. This happens every time we have a * non-zero entry in the matrix. We can then erase that column and row of the matrix if we update the * other columns of B1 accordingly. In an attempt to avoid coefficient growth we only pick an entry which * is +/-1 when removing its rows and columns. If we were not worried about coefficient growth we could * repeat this process until B1 has the full space as a kernel - but we avoid this in the current * implementation. We update B2 by removing the rows of B2 which correspond to the removed columns of B1. * We now row reduce B1 transposed - or at least we do this partly by identifying possible pivots with * */ class SparseMatrix { /* We choose a cache friendly vector for storing a column: * even entries refer to a row index, while odd entries are values. * The pairs are kept sorted. */ vector columns; set remainingRows; set remainingColumns; public: SparseMatrix(int height, int width): columns(width) { for(int i=0;i const &indices, vector const &values) { IntegerVector temp(indices.size()*2); set > s; for(int k=0;k(indices[k],values[k])); } int k=0; for(set >::const_iterator i=s.begin();i!=s.end();i++,k++) { temp[k*2]=i->first; temp[k*2+1]=i->second; } columns[col]=temp; } set getRemainingColumns() { return remainingColumns; } IntegerMatrix remainingToIntegerMatrix() { int height=remainingRows.size(); int width=remainingColumns.size(); IntegerMatrix ret(height,width); int J=0; for(set::const_iterator j=remainingColumns.begin();j!=remainingColumns.end();j++,J++) { int a=0; int I=0; for(set::const_iterator i=remainingRows.begin();i!=remainingRows.end();i++,I++) { if(a>=columns[*j].size())break; if(columns[*j][a]==*i) { ret[I][J]=columns[*j][a+1]; a+=2; } } } return ret; } /* Returns -1 if entry does not exist. Otherwise index into column data (multiplied by 2 already)*/ int lookUpIndex(int i, int j) { for(int k=0;klo) { int med=((hi>>1)+(lo>>1))&(-2); if(columns[j][med]::const_iterator j=remainingColumns.begin();j!=remainingColumns.end();j++) { int k=lookUpIndex(i,*j); if(k!=-1) { columns[*j]=concatenation(columns[*j].subvector(0,k),columns[*j].subvector(k+2,columns[*j].size())); } } remainingRows.erase(i); } void eraseColumn(int col) { assert(col=0); remainingColumns.erase(col); columns[col]=IntegerVector(); } void multiplyAddColumn(int source, int dest, int multiplier) { if(multiplier==0)return; IntegerVector temp; int si=0; int di=0; while(sicolumns[dest][di]) { temp.grow(temp.size()+2); temp[temp.size()-2]=columns[dest][di]; temp[temp.size()-1]=columns[dest][di+1]; di+=2; } else { int sum=columns[dest][di+1]+multiplier*columns[source][si+1]; if(sum<-32000 || sum>32000) { cerr<<"Overflow in homology computation"<::const_iterator i=remainingRows.begin();i!=remainingRows.end();i++)cerr<<*i;cerr<::const_iterator i=remainingColumns.begin();i!=remainingColumns.end();i++)cerr<<*i;cerr<::const_iterator i=columns.begin();i!=columns.end();i++)AsciiPrinter(Stderr)<<*i; } void killEntry(int i, int j) { int v=lookUp(i,j); assert(v==-1 || v==1); for(set::const_iterator a=remainingColumns.begin();a!=remainingColumns.end();a++) if(*a!=j) { multiplyAddColumn(j, *a, -v*lookUp(i,*a)); } eraseColumn(j); eraseRow(i); log3 debug(); } bool getEntryToKill(int &reti, int &retj) { for(set::const_iterator i=remainingColumns.begin();i!=remainingColumns.end();i++) { for(int j=0;j0) { if(!first)P<<"x"; P<<"Z^"; P.printInteger(quotientRank); first=false; } if(first)P<<"{0}"; P<<"\n"; } int main() { PolyhedralFan f=PolyhedralFan::readFan(inputOption.getValue()); AsciiPrinter P(Stdout); AsciiPrinter PP(Stderr); SymmetricComplex s=f.toSymmetricComplex(0); log1 PP<linealityDim;i--) { log1 PP<<"H_"; log1 PP.printInteger(i-linealityDim-1); log1 PP<<"()\n"; IntegerMatrix b1,b2; if(noOptimizeOption.getValue()) { b1=s.boundaryMap(i); b2=s.boundaryMap(i+1); log1{ PP<<"Boundary map "; PP.printInteger(i-linealityDim); PP<<"\n"<size(); SymmetryGroup s(n); if(optionSymmetry.getValue()) { IntegerVectorList generators=FileParser(Stdin).parseIntegerVectorList(); s.computeClosure(generators); } PolyhedralFan f1=PolyhedralFan::readFan(inputOption.getValue(),true,0,0,(optionSymmetry.getValue())?&s:0); PolyhedralFan f2(n); for(IntegerVectorList::const_iterator i=theVectors.begin();i!=theVectors.end();i++) f2.insert(f1.coneContaining(*i)); AsciiPrinter P(Stdout); f2.printWithIndices(&P,FPF_default | FPF_primitiveRays | FPF_multiplicities); return 0; } }; static SubfanApplication theApplication; gfan-0.5+dfsg/app_fiberpolytope.cpp000066400000000000000000000131001207563005400174340ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "reversesearch.h" #include "breadthfirstsearch.h" #include "termorder.h" #include "ep_standard.h" #include "ep_xfig.h" #include "gfanapplication.h" #include "timer.h" #include "log.h" #include "matrix.h" #include "lll.h" #include "polyhedralfan.h" #include "linalg.h" #include "determinant.h" #include "triangulation.h" #include "intsinpolytope.h" #include "graph.h" #include "triangulation2.h" #include "traverser_secondaryfan.h" #include "symmetrictraversal.h" #include #include class FiberPolytopeApplication : public GFanApplication { public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program computes the normal fan of a fiber polytope. The input is a list of vertices of a polytope, followed by a list linear map given by a matrix.\n"; } FiberPolytopeApplication() { registerOptions(); } const char *name() { return "_fiberpolytope"; } int main() { IntegerMatrix A=rowsToIntegerMatrix(FileParser(Stdin).parseIntegerVectorList()); IntegerMatrix map=rowsToIntegerMatrix(FileParser(Stdin).parseIntegerVectorList()); IntegerMatrix transformedPoints=(A*map).transposed(); IntegerVectorList temp=transformedPoints.getRows(); temp.push_back(IntegerVector::allOnes(transformedPoints.getWidth())); IntegerMatrix B=rowsToIntegerMatrix(temp); /* If the vector configuration B does not have full rank then change coordinates. */ if(rank(B)!=B.getHeight()) { FieldMatrix M=integerMatrixToFieldMatrix(B,Q); M.reduce(false,true);//force integer operations - preserving volume M.removeZeroRows(); B=fieldMatrixToIntegerMatrix(M); } AsciiPrinter P(Stdout); P< T=Triangulation::triangulate(B.transposed()); for(list::const_iterator i=T.begin();i!=T.end();i++) { IntegerVector v=i->size(); int J=0; for(Triangulation::Cone::const_iterator j=i->begin();j!=i->end();j++,J++) v[J]=*j; t.bases.insert(v); } } log1 debug<<"Done computing initial triangulation\n"; AsciiPrinter p(Stdout); int n=B.getWidth(); SymmetryGroup s(n); SymmetricTargetFanBuilder target(n,s); log1 debug<<"Initializing\n"; SecondaryFanTraverser traverser(triangulationWithFullDimensionalIntersection(t,C),C); log1 debug<<"Done initializing\n"; log1 debug<<"Traversing\n"; symmetricTraverse(traverser,target,&s); log1 debug<<"Done traversing\n"; target.getFanRef().printWithIndices(&p, FPF_default/*| (symmetryOption.getValue()?FPF_group|FPF_conesCompressed:0)*/, &s); return 0; /* if(symmetryOption.getValue()) { IntegerVectorList generators=FileParser(Stdin).parseIntegerVectorList(); for(IntegerVectorList::const_iterator i=generators.begin();i!=generators.end();i++) { assert(i->size()==n); FieldMatrix M1=integerMatrixToFieldMatrix(A,Q); FieldMatrix M2=integerMatrixToFieldMatrix(rowsToIntegerMatrix(SymmetryGroup::permuteIntegerVectorList(A.getRows(),*i)),Q); M1.reduce(); M1.REformToRREform(true); M2.reduce(); M2.REformToRREform(true); if(!(M1==M2)) { AsciiPrinter(Stderr) << "Permutation "<< *i << " does not keep the configuration fixed.\n"; assert(0); } } s.computeClosure(generators); } */ /* If the vector configuration A does not have full rank then change coordinates. */ /* if(rank(A)!=A.getHeight()) { FieldMatrix M=integerMatrixToFieldMatrix(A,Q); M.reduce(false,true);//force integer operations - preserving volume M.removeZeroRows(); A=fieldMatrixToIntegerMatrix(M); } Triangulation2 t; t.A=A; // Convert a Triangulation to a Triangulation2 { list T=Triangulation::triangulate(A.transposed()); for(list::const_iterator i=T.begin();i!=T.end();i++) { IntegerVector v=i->size(); int J=0; for(Triangulation::Cone::const_iterator j=i->begin();j!=i->end();j++,J++) v[J]=*j; t.bases.insert(v); } } { AsciiPrinter p(Stdout); SymmetricTargetFanBuilder target(n,s); if(!optionRestrictingFan.getValue()) { SecondaryFanTraverser traverser(t); symmetricTraverse(traverser,target,&s); } else { PolyhedralFan f1=PolyhedralFan::readFan(optionRestrictingFan.getValue(),true,0,0,0,true); for(PolyhedralFan::coneIterator i=f1.conesBegin();i!=f1.conesEnd();i++) { static int a; log2 cerr<<"Processing Cone "<dimension()< const &substitutionTable, PolynomialRing const &R2) { IntegerVector v=m.exponent; Polynomial ret=R2.one(); for(int i=0;i const &substitutionTable, PolynomialRing const &R2) { Polynomial ret(R2); for(TermMap::const_iterator i=f.terms.begin();i!=f.terms.end();i++) { ret+=R2.polynomialFromField(i->second)*substitueMonomial(i->first,substitutionTable,R2); } return ret; } int main() { FileParser P(Stdin); PolynomialSet g=P.parsePolynomialSetWithRing(); PolynomialRing R1=g.getRing(); int n=g.getRing().getNumberOfVariables(); vector names=matrixVariableNames("g",n,n); for(int i=0;i substitutionTable; for(int i=0;i newInequalities; for(IntegerVectorList::const_iterator i=normals.begin();i!=normals.end();i++) newInequalities.insert(A.canonicalize(integerVectorToFieldVector(*i,Q)).primitive()); normals=IntegerVectorList(); for(set::const_iterator i=newInequalities.begin();i!=newInequalities.end();i++) normals.push_back(*i); } log1 fprintf(Stderr,"Inequalities"); log1 AsciiPrinter(Stderr).printVectorList(normals); log1 fprintf(Stderr,"Equations"); log1 AsciiPrinter(Stderr).printVectorList(equalities); PolyhedralCone c(normals,equalities,n); c.canonicalize(); if(!optionAsFan.getValue()) AsciiPrinter(Stdout).printPolyhedralCone(c); else { AsciiPrinter P(Stdout); IntegerVectorList empty; HalfOpenCone C(n,c.getEquations(),c.getHalfSpaces(),empty,true); // PolyhedralFan F=faceComplexOfCone(C); PolyhedralCone C2=C.closure(); C2.canonicalize(); PolyhedralFan F(n);F.insert(C2); F.printWithIndices(&P,FPF_default); // F.printWithIndices(&P,false,0,false,false,optionXml.getValue()); } return 0; } }; static GroebnerConeApplication theApplication; gfan-0.5+dfsg/app_groebnerfan.cpp000066400000000000000000000133701207563005400170520ustar00rootroot00000000000000#include #include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "reversesearch.h" #include "breadthfirstsearch.h" #include "termorder.h" #include "ep_standard.h" #include "ep_xfig.h" #include "field_rationalfunctions2.h" #include "gfanapplication.h" #include "timer.h" #include "log.h" #include "traverser_groebnerfan.h" class GroebnerFanApplication : public GFanApplication { SimpleOption optionInputIsGroebnerBasis; SimpleOption optionSymmetry; SimpleOption optionDisableSymmetryTest; StringOption optionRestrictingFan; //StringOption optionRestrictingFanSymmetry; IntegerOption optionParameters; SimpleOption optionIgnoreCones; public: const char *helpText() { return "This is a program for computing the Groebner fan of a polynomial ideal as a polyhedral complex. It takes a generating set for the ideal as input. If the ideal is symmetric the symmetry option is useful and enumeration will be done up to symmetry. The program needs a starting Groebner basis to do its computations. If the -g option is not specified it will compute one using Buchberger's algorithm.\n"; } GroebnerFanApplication(): optionInputIsGroebnerBasis("-g", "Tells the program that the input is already a Groebner basis (with the initial term of each polynomial being " "the first ones listed). Use this option if it takes too much time to compute " "the starting (standard degree lexicographic) Groebner basis and the input is already a Groebner basis.\n"), optionSymmetry("--symmetry", "Tells the program to read in generators for a group of symmetries (subgroup of $S_n$) after having read in the ideal. The program checks that the ideal stays fixed when permuting the variables with respect to elements in the group. The program uses breadth first search to compute the set of reduced Groebner bases up to symmetry with respect to the specified subgroup.\n"), optionDisableSymmetryTest("--disableSymmetryTest","When using --symmetry this option will disable the check that the group read off from the input actually is a symmetry group with respect to the input ideal.\n"), optionRestrictingFan("--restrictingfan","Specify the name of a file containing a polyhedral fan in Polymake format. The computation of the Groebner fan will be restricted to this fan. If the --symmetry option is used then this restricting fan must be invariant under the symmetry and the orbits in the file must be with respect to the specified group of symmetries. The orbits of maximal cones of the file are then read in rather than the maximal cones.\n",0), //optionRestrictingFan("--restrictingfansymmetry","Use this option to indicate that the restricting fan also has the same symmetries.\n",0), optionParameters("--parameters","With this option you can specify how many variables to treat as parameters instead of variables. This makes it possible to do computations where the coefficient field is the field of rational functions in the parameters. This does not work well at the moment.",0), optionIgnoreCones("--nocones","Tells the program not to output the CONES and MAXIMAL_CONES sections, but still output CONES_COMPRESSED and MAXIMAL_CONES_COMPRESSED if --symmetry is used.") { registerOptions(); } const char *name() { return "_groebnerfan"; } int main() { LexicographicTermOrder myOrder; PolynomialSet g=FileParser(Stdin).parsePolynomialSetWithRing(); if(optionParameters.getValue())g=makeVariablesParameters(makeVariablesParameters(g.getRing(),optionParameters.getValue()),g); int n=g.numberOfVariablesInRing(); if(optionInputIsGroebnerBasis.getValue()) { log1 fprintf(Stderr,"Minimizing and autoreducing input...\n"); minimize(&g); autoReduce(&g, LexicographicTermOrder()); } else { log1 fprintf(Stderr,"Computing Groebner Basis...\n"); buchberger(&g,StandardGradedLexicographicTermOrder()); log2 AsciiPrinter(Stderr).printPolynomialSet(g); } log1 fprintf(Stderr,"A reduced Groebner basis has been computed\n"); SymmetryGroup s(n); IntegerVectorList generators; if(optionSymmetry.getValue()) generators=FileParser(Stdin).parseIntegerVectorList(); if(!optionDisableSymmetryTest.getValue()) { for(IntegerVectorList::iterator i=generators.begin();i!=generators.end();i++) { assert(areIdealsEqual(g,SymmetryGroup::permutePolynomialSet(g,*i))); } } s.computeClosure(generators); s.createTrie(); log3 s.print(Stderr); SymmetricTargetFanBuilder target(n,s); if(!optionRestrictingFan.getValue()) { GroebnerFanTraverser traverser(g); symmetricTraverse(traverser,target,&s); } else { //PolyhedralFan f1=PolyhedralFan::readFan(optionRestrictingFan.getValue()); //static PolyhedralFan readFan(string const &filename, bool onlyMaximal=true, IntegerVector *w=0, set const *conesIndice=0, SymmetryGroup const *sym=0, bool readCompressedIfNotSym=false); PolyhedralFan f1=PolyhedralFan::readFan(optionRestrictingFan.getValue(),true,0,0,/*optionSymmetry.getValue()?&s:0*/0,true); for(PolyhedralFan::coneIterator i=f1.conesBegin();i!=f1.conesEnd();i++) { static int t; log2 cerr<<"Processing Cone "<dimension()<homogenization(h.getRing(),&grading)); } AsciiPrinter(Stdout).printPolynomialSet(h); return 0; } }; static HomogenizeApplication theApplication; gfan-0.5+dfsg/app_idealintersection.cpp000066400000000000000000000015521207563005400202660ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "saturation.h" #include "gfanapplication.h" #include "lp.h" class IdealIntersectionApplication : public GFanApplication { FieldOption theFieldOption; public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program computes the intersection of two ideals generated by sets of polynomials given in the input.\n"; } IdealIntersectionApplication() { registerOptions(); } const char *name() { return "_idealintersection"; } int main() { FileParser P(Stdin); PolynomialRing theRing=P.parsePolynomialRing(); PolynomialSet a=P.parsePolynomialSet(theRing); PolynomialSet b=P.parsePolynomialSet(theRing); pout< #include "parser.h" #include "printer.h" #include "polynomial.h" #include "buchberger.h" #include "wallideal.h" #include "termorder.h" #include "gfanapplication.h" #include "determinantpoly.h" #include "log.h" using namespace std; class InitialDeterminantApplication : public GFanApplication { public: bool includeInDefaultInstallation() { return false; } SimpleOption optionTakeDerivatives; const char *helpText() { return "This program \n"; } InitialDeterminantApplication(): optionTakeDerivatives("-j","Take derivatives of input vector.") { registerOptions(); } const char *name() { return "_initialdeterminant"; } int main() { FileParser P(Stdin); PolynomialSet g=P.parsePolynomialSetWithRing(); if(optionTakeDerivatives.getValue()) { PolynomialSet G=P.parsePolynomialSet(g.getRing()); G.markAndScale(LexicographicTermOrder()); PolynomialSet::iterator I=g.begin(); for(PolynomialSet::const_iterator i=G.begin();i!=G.end();i++,I++) { *I=Term(i->getMarked().c,Monomial(g.getRing(),-(i->getMarked().m.exponent)))**I; } debug< rows=interval(g.size(),!optionTakeDerivatives.getValue()); list columns=interval(g.size(),!optionTakeDerivatives.getValue()); cerr< #include "parser.h" #include "printer.h" #include "polynomial.h" #include "buchberger.h" #include "wallideal.h" #include "termorder.h" #include "gfanapplication.h" #include "tropical2.h" #include "tropicaldeterminant.h" #include "log.h" using namespace std; class PolyMatrix { public: class PolyMatrixEntry { public: bool isZero; Polynomial p; int maxDegree,minDegree; vector forms; PolyMatrixEntry(Polynomial const &p_, IntegerVector const &w): p(p_), isZero(p_.isZero()) { if(p.isZero()) { maxDegree=-1; minDegree=0; return; } maxDegree=p_.degree(w); minDegree=-p_.degree(-w); // debug<first.exponent,w)]+=Term(i->second,i->first); } } }; list::iterator indexOfSparsestRow(list &rows, list const &columns) { list::iterator ret=rows.end(); int bestNumberOfZeros=-1; for(list::iterator i=rows.begin();i!=rows.end();i++) { int numberOfZeros=0; for(list::const_iterator j=columns.begin();j!=columns.end();j++)numberOfZeros+=data[*i][*j].isZero; if(numberOfZeros>bestNumberOfZeros) { bestNumberOfZeros=numberOfZeros; ret=i; } } // cerr<<":"< > data; PolynomialRing theRing; //constructor for Jacobi matrix PolyMatrix(PolynomialSet const &generators, IntegerVector const &w): theRing(generators.getRing()) { int n=generators.size(); PolynomialSet::const_iterator I=generators.begin(); for(int i=0;i row; for(int j=0;jderivative(j); // debug< l) { cerr<<"{"; for(list::const_iterator i=l.begin();i!=l.end();i++) cerr<<*i<<","; cerr<<"}\n"; } Polynomial determinantForm(list rows, list columns, int degree, int level) { Polynomial ret(theRing); if(rows.size()==1)return data[rows.front()][columns.front()].p; list::iterator chosenRowIterator=indexOfSparsestRow(rows, columns);//rows.begin(); int chosenrow=*chosenRowIterator; { list::iterator temp=chosenRowIterator;temp++; rows.erase(chosenRowIterator); //no need to update rows afterwards since it is stored on the stack } if(level==0)cerr<<"-"<::iterator i=columns.begin();i!=columns.end();i++) { int chosencol=*i; if(!data[chosenrow][chosencol].isZero) { list::iterator temp=i;temp++; columns.erase(i); i=temp; ret+=data[chosenrow][chosencol].p*determinantForm(rows,columns,degree,level+1)*theRing.getField().zHomomorphism(sign); columns.insert(i,chosencol); i--; } sign*=-1; } rows.push_front(chosenrow); return ret; } }; class InitialDeterminantApplication : public GFanApplication { public: const char *helpText() { return "This program \n"; } InitialDeterminantApplication() { registerOptions(); } char *name() { return "_initialdeterminant"; } list interval(int n) { list ret; for(int i=0;i rows=interval(g.size()); list columns=interval(g.size()); pout< #include "parser.h" #include "printer.h" #include "polynomial.h" #include "buchberger.h" #include "wallideal.h" #include "termorder.h" #include "gfanapplication.h" #include "tropical2.h" #include "log.h" using namespace std; class InitialFormsApplication : public GFanApplication { SimpleOption optionIdeal; SimpleOption optionPair; SimpleOption optionMark; SimpleOption optionList; public: const char *helpText() { return "This program converts a list of polynomials to a list of their initial forms with respect to the vector given after the list.\n"; } InitialFormsApplication(): optionIdeal("--ideal","Treat input as an ideal. This will make the program compute the initial ideal of the ideal generated by the input polynomials. The computation is done by computing a Groebner basis with respect to the given vector. The vector must be positive or the input polynomials must be homogeneous in a positive grading. None of these conditions are checked by the program.\n"), optionPair("--pair","Produce a pair of polynomial lists. Used together with --ideal this option will also write a compatible reduced Groebner basis for the input ideal to the output. This is useful for finding the Groebner cone of a non-monomial initial ideal.\n"), optionMark("--mark","If the --pair option is and the --ideal option is not used this option will still make sure that the second output basis is marked consistently with the vector."), optionList("--list","Read in a list of vectors instead of a single vector and produce a list of polynomial sets as output.") { registerOptions(); } const char *name() { return "_initialforms"; } int main() { FileParser P(Stdin); PolynomialSet g=P.parsePolynomialSetWithRing(); IntegerVectorList wList; if(optionList.getValue()) wList=P.parseIntegerVectorList(); else wList.push_back(P.parseIntegerVector()); for(IntegerVectorList::const_iterator i=wList.begin();i!=wList.end();i++) { log1 cerr<<"-\n"; assert(i->size()==g.getRing().getNumberOfVariables()); if(optionMark.getValue()) { WeightReverseLexicographicTermOrder T(*i); g.markAndScale(T); } if(optionIdeal.getValue()) { WeightReverseLexicographicTermOrder T(*i); buchberger(&g,T); } pout< using namespace std; class IntegerGBApplication : public GFanApplication { SimpleOption gbOption; SimpleOption initialOption; SimpleOption gFanOption; SimpleOption gConeOption; SimpleOption listOption; SimpleOption optionInputIsGroebnerBasis; public: const char *helpText() { return "This program is an experimental implementation of Groebner bases for ideals in Z[x_1,...,x_n].\n" "Several operations are supported by specifying the appropriate option:\n" " (1) computation of the reduced Groebner basis with respect to a given vector (tiebroken lexicographically),\n" " (2) computation of an initial ideal,\n" " (3) computation of the Groebner fan,\n" " (4) computation of a single Groebner cone.\n" "Since Gfan only knows polynomial rings with coefficients being elements of a field, the ideal is specified by giving a set of polynomials in the polynomial ring Q[x_1,...,x_n]. That is, by using Q instead of Z when specifying the ring. The ideal MUST BE HOMOGENEOUS (in a positive grading) for computation of the Groebner fan. Non-homogeneous ideals are allowed for the other computations if the specified weight vectors are positive.\n" "NOTE: This program is experimental and expected to change behaviour in future releases, so don't write your SAGE and M2 interfaces just yet.\n"; } IntegerGBApplication(): gbOption("--groebnerBasis","Asks the program to compute a marked Groebner basis with respect to a weight vector tie-broken lexicographically.\n" "The input order is: Ring ideal vector.\n"), initialOption("--initialIdeal","Asks the program to compute an initial ideal with respect to a vector. " "The input order is: Ring ideal vector.\n"), gFanOption("--groebnerFan","Asks the program to compute the Groebner fan. \n " "The input order is: Ring ideal.\n"), gConeOption("--groebnerCone","Asks the program to compute a single Groebner cone containing the specified vector in its relative interior. The output is stored as a fan. " "The input order is: Ring ideal vector."), listOption("-m","For the operations taking a vector as input, read in a list of vectors instead, and perform the operation for each vector in the list."), optionInputIsGroebnerBasis("-g", "Tells the program that the input is already a Groebner basis (with the initial term of each polynomial being " "the first ones listed). Use this option if the usual --groebnerFan is too slow.\n") { registerOptions(); } const char *name() { return "_overintegers"; } int main() { if(gbOption.getValue()+initialOption.getValue()+gFanOption.getValue()+gConeOption.getValue()!=1) { debug<<"WRONG COMBINATION OF COMMAND LINE OPTIONS\n"; assert(0); } LexicographicTermOrder tieBreaker; FileParser P(Stdin); PolynomialSet a=P.parsePolynomialSetWithRing(); int n=a.getRing().getNumberOfVariables(); // IntegerVectorList omegas=P.parseIntegerVectorList(); if(gFanOption.getValue()) { SymmetryGroup G(n); SymmetricTargetFanBuilder target(n,G); if(optionInputIsGroebnerBasis.getValue()) { IntegerVectorList empty; IntegerVector w=PolyhedralCone(wallInequalities(a),empty).getRelativeInteriorPoint(); WeightReverseLexicographicTermOrder tieBreaker(w); zAutoReduce(&a,tieBreaker); } else { WeightReverseLexicographicTermOrder tieBreaker(IntegerVector::allOnes(n)); zBuchberger(a,tieBreaker); } IntegerGroebnerFanTraverser traverser(a); symmetricTraverse(traverser,target); AsciiPrinter Q(Stdout); target.getFanRef().printWithIndices(&Q, FPF_default); } else { IntegerVectorList omegas; if(listOption.getValue()) omegas=P.parseIntegerVectorList(); else omegas.push_back(P.parseIntegerVector()); for(IntegerVectorList::const_iterator i=omegas.begin();i!=omegas.end();i++) { if(i->size()!=a.getRing().getNumberOfVariables()) { debug<<"ERROR: The number of entries of the weight vector is not equal to the number of variables in the ring.\n"; assert(0); } if(gbOption.getValue()) { WeightTermOrder T(*i); zBuchberger(a,T); pout<printLatexStart(); P=Q; } else P= new AsciiPrinter(Stdout); // P->printString("-------------------------------------------------\n"); printVertex(*P,"Old Vertex",gOld); printVertex(*P,"Current Vertex",g); // P->printPolynomialSet(g.markedTermIdeal()); P->printNewLine(); PolynomialSet wall(theRing); IntegerVectorList normals=wallInequalities(g); IntegerVectorList flipableNormals=wallFlipableNormals(g,false); { wall=wallIdeal(g,*flipableNormals.begin()); PolynomialSet sat=nonHomogeneousSaturation(wall); P->printString("Saturated wall ideal: "); P->printPolynomialSet(sat); } if(optionPrintInequalities.getValue()) { P->printString("Inequalities:"); P->printNewLine(); P->printVectorList(normals); } if(optionPrintWeightVector.getValue()) { P->printString("An interior point: "); PolyhedralCone C=PolyhedralCone(normals,IntegerVectorList()); P->printVector(intersection(PolyhedralCone::positiveOrthant(C.ambientDimension()),C).getRelativeInteriorPoint()); P->printNewLine(); //interiorPoint(normals,Stdout,true); } if(outputLatex) P->printString("\\begin{enumerate}"); IntegerVectorList facets; int itemIndex=0; for(IntegerVectorList::const_iterator i=flipableNormals.begin();i!=flipableNormals.end();i++) { // if(isFacet(normals,i)) // if(wallContainsPositiveVector(*i)) { itemIndex++; facets.push_back(*i); if(outputLatex) P->printString("\\item "); else { P->printString("--"); P->printInteger(itemIndex); } wall=wallIdeal(g,*i); WeightTermOrder flipOrder(*i); wall.markAndScale(flipOrder); PolynomialSet oldWall=wall; P->printNewLine(); P->printString("Facet normal: "); P->printVector(*i); if(optionPrintWeightVector.getValue()) { P->printNewLine(); P->printString("Relative interior point: "); IntegerVectorList l; l.push_back(*i); // AsciiPrinter(Stdout).printVector(PolyhedralCone(normals,l).relativeInteriorPoint(true)); P->printVector(intersection(PolyhedralCone(normals,l),PolyhedralCone::positiveOrthant(i->size())).getRelativeInteriorPoint()); } //int numberOfPolynomials=wall.size(); //P->printString("Number of polynomials\n"); //P->printInteger(numberOfPolynomials); //int numberOfMonomials=0; //for(PolynomialSet::const_iterator j=wall.begin();j!=wall.end();j++) // if(j->isMonomial())numberOfMonomials++; // P->printString("Number of monomials\n"); //P->printInteger(numberOfMonomials); P->printNewLine(); if(optionPrintWallIdeal.getValue()) { //P->printString("Gr\\\"obner basis of wall"); P->printString("Wall ideal: "); P->printPolynomialSet(wall); P->printNewLine(); PolynomialSet sat=nonHomogeneousSaturation(wall); P->printString("Saturated wall ideal: "); P->printPolynomialSet(sat); } if(outputLatex||optionPrintFlipped.getValue()) { flipOrder=WeightTermOrder(-*i); buchberger(&wall,flipOrder); P->printNewLine(); P->printString("New Gr\\\"obner basis of wall"); P->printPolynomialSet(wall); } } } if(outputLatex) P->printString("\\end{enumerate}"); if(outputLatex) { Q->printLatexEnd(); fclose(latexFile); system("latex "FILENAME".tex >/dev/null"); } { if(optionExitImmediately.getValue()) { fprintf(Stderr,"exiting.\n"); break; } int t; fscanf(Stdin,"%i",&t); t--; if(t<0)break; IntegerVectorList::const_iterator i=facets.begin(); while(t>0) { i++; t--; } gOld=g; g=flip(g,*i); } } return 0; } }; static InteractiveApplication theApplication; gfan-0.5+dfsg/app_intsinpolytope.cpp000066400000000000000000000106601207563005400176610ustar00rootroot00000000000000#include "vektor.h" #include "printer.h" #include "parser.h" #include "gfanapplication.h" #include "intsinpolytope.h" #include "lattice.h" #include "determinant.h" class IntsInPolytopeApplication : public GFanApplication { public: bool includeInDefaultInstallation() { return false; } IntsInPolytopeApplication() { registerOptions(); } const char *name() { return "_intsinpolytope"; } // a is a squarematrix whose rows span a simplicial cone bool isInSimplicialCone(IntegerMatrix const &a, IntegerVector const &v) { for(int i=0;i > partsOfZBases(set > const &s, IntegerMatrix const &M) { set > setsToCheck; for(set >::const_iterator i=s.begin();i!=s.end();i++) { for(int j=0;j temp=*i; temp.insert(j); if(temp.size()!=i->size()) { bool isOK=true; /* if(temp.size()==5) { IntegerMatrix MM(5,5); int I=0; for(set::const_iterator k=temp.begin();k!=temp.end();k++,I++) { MM[I]=M[*k]; } IntegerVector v(5); v[0]=2;//????????????????????????????????????????????????? v[1]=2; v[2]=2; v[3]=17; v[4]=8; if(!isInSimplicialCone(MM,v)) isOK=false; }*/ if(isOK) for(set::const_iterator k=temp.begin();k!=temp.end();k++) { set temp2=temp; temp2.erase(*k); if(s.count(temp2)==0) { isOK=false; break; } } if(isOK) { static int c; c++; if(!(c&4095))fprintf(stderr,"tocheck:%i\n",c); /* if(temp.size()==5) { IntegerMatrix MM(5,5); int I=0; for(set::const_iterator k=temp.begin();k!=temp.end();k++,I++) { MM[I]=M[*k]; } fprintf(stderr,"Candidate:\n"); AsciiPrinter(Stderr).printVectorList(MM.getRows()); }*/ setsToCheck.insert(temp); } } } } fprintf(stderr,"Sets to test: %i\n",setsToCheck.size()); set > ret; for(set >::const_iterator i=setsToCheck.begin();i!=setsToCheck.end();i++) { static int c; c++; if(!(c&4095))fprintf(stderr,"%i\n",c); IntegerVectorList l; for(set::const_iterator j=i->begin();j!=i->end();j++) l.push_back(M[*j]); if(isPartOfAZBasis(l))ret.insert(*i); } fprintf(stderr,"Produced sets: %i\n",ret.size()); return ret; } int main() { FileParser p(Stdin); IntegerVectorList ivl=p.parseIntegerVectorList(); IntegerMatrix A=rowsToIntegerMatrix(ivl);//.transposed(); IntegerVector rightHandSide=p.parseIntegerVector(); IntegerVector v=p.parseIntegerVector(); AsciiPrinter P(stdout); fprintf(Stdout,"Lattice Kernel:\n"); IntegerVectorList l=intsInPolytopeGivenIneqAndPt(A,rightHandSide,v); P.printVectorList(l); // return 0;//!!!!!!!!!!!!!!!!!!!!!!!! // P.printVectorList(intsInPolytopeGivenIneq(A,rightHandSide)); { IntegerVectorList l2; for(IntegerVectorList::const_iterator i=l.begin();i!=l.end();i++) { IntegerVector temp(i->size()+1); temp[0]=1; for(int j=0;jsize();j++)temp[j+1]=(*i)[j]; l2.push_back(temp); /* IntegerVectorList k; k.push_back(*i); if(isPartOfAZBasis(k)) P.printVector(*i); */ } IntegerVectorList l3; for(IntegerVectorList::const_iterator i=l2.begin();i!=l2.end();i++) //if(((*i)[1]<=2)&&((*i)[2]<=2)&&((*i)[3]<=17)&&((*i)[4]<=8)) l3.push_back(*i); // if(((*i)[0]<=2)&&((*i)[1]<=2)&&((*i)[2]<=17)&&((*i)[3]<=8))l3.push_back(*i); IntegerMatrix M=rowsToIntegerMatrix(l3); P.printVectorList(M.getRows()); fprintf(stdout,"size:%i\n",M.getHeight()); set > s; s.insert(set()); for(int i=0;i<5;i++) { s=partsOfZBases(s,M); for(set >::const_iterator i=s.begin();i!=s.end();i++) { for(set::const_iterator j=i->begin();j!=i->end();j++) { // fprintf(stderr,"%i ",*j); } // fprintf(stderr,"\n"); } // fprintf(stderr,"\n\n\n\n"); } } return 0; } const char *helpText() { return "This program computes the integer points in a polytope.\n"; } }; static IntsInPolytopeApplication theApplication; gfan-0.5+dfsg/app_isconnected.cpp000066400000000000000000000030721207563005400170560ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "lp.h" #include "gfanapplication.h" #include "polyhedralcone.h" #include "polyhedralfan.h" #include "symmetry.h" #include "polymakefile.h" class IsConnectedApplication : public GFanApplication { StringOption inputOption; SimpleOption optionSymmetry; public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program checks if a PURE d-dimensional fan is connected in codimension one (in the sense of [Bogart, Jensen, Speyer, Sturmfels, Thomas]).\n"; } IsConnectedApplication(): inputOption("-i","Specify the name of the input file.","polymake.out"), optionSymmetry("--symmetry", "Reads in the cone stored with symmetry. The generators of the symmetry group are given on the input. IF SYMMETRY IS SPECIFIED THEN " "THE CHECK IS NOT COMPLETE AND IT WILL ONLY BE CHECKED IF THAT GIVEN" "TWO CONES THAT EXIST ELEMENTS IN THE TWO RESPECTIVE ORBITS" "WHICH ARE CONNECTED BY A RIDGE PATH\n") { registerOptions(); } const char *name() { return "_isconnected"; } int main() { PolyhedralFan f=PolyhedralFan::readFan(inputOption.getValue(),true,0,0,0,true); int n=f.getAmbientDimension(); SymmetryGroup s(n); if(optionSymmetry.getValue()) { IntegerVectorList generators=FileParser(Stdin).parseIntegerVectorList(); s.computeClosure(generators); } cout << f.isConnected(&s) << endl; return 0; } }; static IsConnectedApplication theApplication; gfan-0.5+dfsg/app_isgroebnerbasis.cpp000066400000000000000000000045021207563005400177400ustar00rootroot00000000000000#include "vektor.h" #include "printer.h" #include "parser.h" #include "gfanapplication.h" #include "minkowskisum.h" #include "newtonpolytope.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" class IsGroebnerBasisApplication : public GFanApplication { FieldOption theFieldOption; SimpleOption optionUGBTest; public: bool includeInDefaultInstallation() // Not included since it requires Christophe's Minkowski sum program { return false; } const char *helpText() { return "Checks if an unmarked polynomial set is a Groebner basis with respect to some termorder.\n"; } IsGroebnerBasisApplication(): optionUGBTest("--ugb","Universal Groebner Basis test. Check if something is a Groebner basis with respect to any termorder.") { registerOptions(); } const char *name() { return "_isgroebnerbasis"; } int main() { lpSetSolver("cddgmp"); FileParser P(Stdin); PolynomialSet g=P.parsePolynomialSetWithRing(); PolynomialRing theRing=g.getRing(); IntegerVectorListList polytopes; for(PolynomialSet::const_iterator i=g.begin();i!=g.end();i++) { polytopes.push_back(newtonPolytope(*i)); } IntegerVectorListList sums; IntegerVectorList polytope=minkowski(polytopes,&sums); fprintf(Stderr,"Number of extreme vertices in Minkowski sum: %i\n",polytope.size()); bool isGroebnerBasis=false; int counter=0; for(IntegerVectorListList::const_iterator i=sums.begin();i!=sums.end();i++) { fprintf(Stderr,"Checking vertex %i\n",counter++); IntegerVectorList::const_iterator j=i->begin(); for(PolynomialSet::iterator k=g.begin();k!=g.end();k++) { k->mark(Monomial(theRing,*j)); j++; } IntegerVectorList normals=wallInequalities(g); if(hasInteriorPoint(normals,true)) { if(isMarkedGroebnerBasis(g)) { AsciiPrinter(Stderr).printPolynomialSet(g); isGroebnerBasis=true; if(!optionUGBTest.getValue())break; } else { fprintf(Stderr,"Marking is not a Groebner basis\n"); if(optionUGBTest.getValue()) { AsciiPrinter(Stderr).printPolynomialSet(g); assert(0); } } } else fprintf(Stderr,"Cone has no positive interior point\n"); } fprintf(Stdout,isGroebnerBasis?"true\n":"false\n"); return 0; } }; static IsGroebnerBasisApplication theApplication; gfan-0.5+dfsg/app_ismarkedgroebnerbasis.cpp000066400000000000000000000022011207563005400211160ustar00rootroot00000000000000#include "vektor.h" #include "printer.h" #include "parser.h" #include "gfanapplication.h" #include "newtonpolytope.h" #include "buchberger.h" #include "wallideal.h" #include "log.h" class IsMarkedGroebnerBasisApplication : public GFanApplication { public: const char *helpText() { return "This program checks if a set of marked polynomials is a Groebner basis with respect to its marking. First it is checked if the markings are consistent with respect to a positive vector. Then Buchberger's S-criterion is checked. The output is boolean value.\n"; } IsMarkedGroebnerBasisApplication() { registerOptions(); } const char *name() { return "_ismarkedgroebnerbasis"; } int main() { FileParser P(Stdin); PolynomialSet g=P.parsePolynomialSetWithRing(); bool isConsistent=isMarkingConsistent(g); log1 fprintf(Stderr,"Is marking consistent:%i\n",isConsistent); bool isGroebnerBasis=isConsistent; if(isGroebnerBasis) isGroebnerBasis=isMarkedGroebnerBasis(g); fprintf(Stdout,isGroebnerBasis?"true\n":"false\n"); return 0; } }; static IsMarkedGroebnerBasisApplication theApplication; gfan-0.5+dfsg/app_issmooth.cpp000066400000000000000000000042201207563005400164210ustar00rootroot00000000000000#include "vektor.h" #include "printer.h" #include "parser.h" #include "gfanapplication.h" #include "buchberger.h" #include "wallideal.h" #include "dimension.h" #include "saturation.h" #include "determinantpoly.h" #include "tropical2.h" #include "log.h" class IsSmoothApplication : public GFanApplication { SimpleOption optionInitialForms; public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "Checks if the input ideal defines a smooth variety in $(C^*)^n$.\n"; } IsSmoothApplication(): optionInitialForms("--initialideals","Check the condition for the initial ideals of the ideals with respect to a given list of weight vectors. THE INPUT IDEAL MUST BE HOMOGENEOUS.") { registerOptions(); } const char *name() { return "_issmooth"; } bool processSingle(PolynomialSet g)const { g=g.multiDeHomogenization(); PolynomialRing theRing=g.getRing(); PolynomialSet G=nonHomogeneousSaturation(g); log1 debug<getMarked())); } AsciiPrinter(Stdout).printPolynomialSet(LT); } int main() { FileParser P(Stdin); if(!optionMultipleSets.getValue()) { PolynomialSet s=P.parsePolynomialSetWithRing(); AsciiPrinter(Stdout).printPolynomialRing(s.getRing()); AsciiPrinter(Stdout).printNewLine(); p(s); } else { PolynomialSetList l=P.parsePolynomialSetListWithRing(); assert(l.size()!=0); AsciiPrinter(Stdout).printPolynomialRing(l.begin()->getRing()); AsciiPrinter(Stdout).printNewLine(); fprintf(Stdout,"{\n"); for(PolynomialSetList::const_iterator i=l.begin();i!=l.end();i++) { if(i!=l.begin())fprintf(Stdout,",\n"); p(*i); } fprintf(Stdout,"}\n"); } return 0; } }; static LeadingTermsApplication theApplication; gfan-0.5+dfsg/app_librarytest.cpp000066400000000000000000000061701207563005400171260ustar00rootroot00000000000000/* * app_librarytest.cpp * * Created on: Sep 28, 2010 * Author: anders */ #include "gfanapplication.h" #include "gfanlib.h" #include "printer.h" #include #include using namespace gfan; class LibraryTestApplication : public GFanApplication { public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program tests the gfan library.\n"; } LibraryTestApplication() { registerOptions(); } const char *name() { return "_librarytest"; } int main() { int n=4; QVector s(n); QMatrix M(0,n); for(int i=0;i coneIndices; for(int i=0;i B; for(int i=0;i<3;i++)B.insert(2*i+1); lp.setCurrentBasis(B); */ if(!lp.findFeasibleBasis()) { fprintf(Stderr,"LP is infeasible\n"); } else { int status; do { AsciiPrinter Q(Stdout); lp.print(Q); status=lp.step(); } while(status==1); fprintf(Stderr,status?"LP is unbounded.\n":"Optimal solution found.\n"); } return 0; } const char *helpText() { return "Test program for FieldLP.\n"; } }; static LPSolveApplication theApplication; gfan-0.5+dfsg/app_main.cpp000066400000000000000000000155141207563005400155100ustar00rootroot00000000000000/* TO DO: Remove Timer Remove Subspace option and maybe add an option for restricting to an arbitrary polyhedral cone instead. Remove Minkowski code */ #include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "reversesearch.h" #include "breadthfirstsearch.h" #include "termorder.h" #include "ep_standard.h" #include "ep_xfig.h" #include "field_rationalfunctions2.h" #include "gfanapplication.h" #include "timer.h" #include "log.h" #include "traverser_groebnerfan.h" static Timer globalTimer("Global-timer",1); class GCats : public GFanApplication { const char *name1; SimpleOption optionInputIsGroebnerBasis; SimpleOption optionSymmetry; SimpleOption optionEchoSymmetry; SimpleOption optionSubspace; // SimpleOption optionPerformanceTimer; SimpleOption optionDisableSymmetryTest; IntegerOption optionParameters; public: bool includeInDefaultInstallation() { return name1[0]!=0;//Make sure that "gfan" itself does not go to the documentation section of the manual. } const char *helpText() { #define HELP "This is a program for computing all reduced Groebner bases of a polynomial ideal. It takes the ring and a generating set for the ideal as input. By default the enumeration is done by an almost memoryless reverse search. If the ideal is symmetric the symmetry option is useful and enumeration will be done up to symmetry using a breadth first search. The program needs a starting Groebner basis to do its computations. If the -g option is not specified it will compute one using Buchberger's algorithm.\n" // if(name1[0]) // return "This is the Gfan program for computing Groebner fans and tropical vaieties"HELP; return HELP; } GCats(const char *name2): name1(name2), // optionPerformanceTimer("-T", // "Enable performance timer.\n"), optionInputIsGroebnerBasis("-g", "Tells the program that the input is already a Groebner basis (with the initial term of each polynomial being " "the first ones listed). Use this option if it takes too much time to compute " "the starting (standard degree lexicographic) Groebner basis and the input is already a Groebner basis.\n"), optionSymmetry("--symmetry", "Tells the program to read in generators for a group of symmetries (subgroup of $S_n$) after having read in the ideal. The program checks that the ideal stays fixed when permuting the variables with respect to elements in the group. The program uses breadth first search to compute the set of reduced Groebner bases up to symmetry with respect to the specified subgroup.\n"), optionEchoSymmetry("-e","Echo. Output the generators for the symmetry group.\n"), optionSubspace("--subspace", "Only do breadth first search on cones with their interior intersecting a specified subspace. The subspace is given by a list of hyperplane normals at the end of the input. The intersection of the hyperplanes is the subspace being specified. Note that the set of Groebner cones intersecting the subspace could be disconnected and that only one connected component is computed. Works only together with --symmetry.\n"), optionDisableSymmetryTest("--disableSymmetryTest","When using --symmetry this option will disable the check that the group read off from the input actually is a symmetry group with respect to the input ideal.\n"), optionParameters("--parameters","With this option you can specify how many variables to treat as parameters instead of variables. This makes it possible to do computations where the coefficient field is the field of rational functions in the parameters. This does not work well at the moment.",0) { registerOptions(); optionSubspace.hide();//Is not supported anymore } const char *name() { return name1; // return ""; } int main() { if(name1[0]==0) { debug<<"This is the Gfan program for computing Groebner fans and tropical varieties.\n" "Use the command \"gfan list\" to view all subcommands.\n" "The command \"gfan\" is deprecate for computing all Groebner bases of an ideal.\n" "Please use subcommand \"gfan _bases\" instead. Awaiting input. -D to end.\n"; } LexicographicTermOrder myOrder; PolynomialSet g=FileParser(Stdin).parsePolynomialSetWithRing(); if(optionParameters.getValue())g=makeVariablesParameters(makeVariablesParameters(g.getRing(),optionParameters.getValue()),g); log3 AsciiPrinter(Stderr).printPolynomialSet(g); AsciiPrinter(Stdout).printPolynomialRing(g.getRing()); printf("\n"); EnumerationFilePrinter *ep; { ep=new StandardEnumerationPrinter(); } bool outputLatex=true; Printer *P; LatexPrinter *Q; FILE *latexFile; globalTimer.on(); { if(optionInputIsGroebnerBasis.getValue()) { log1 fprintf(Stderr,"Minimizing and autoreducing input...\n"); minimize(&g); autoReduce(&g, LexicographicTermOrder()); } else { log1 fprintf(Stderr,"Computing Groebner Basis...\n"); buchberger(&g,StandardGradedLexicographicTermOrder()); log2 AsciiPrinter(Stderr).printPolynomialSet(g); } log1 fprintf(Stderr,"A reduced Groebner basis has been computed\n"); } SymmetryGroup s(g.numberOfVariablesInRing()); IntegerVectorList generators; { EnumerationAlgorithm *rs; if(optionSymmetry.getValue()) { generators=FileParser(Stdin).parseIntegerVectorList(); if(!optionDisableSymmetryTest.getValue()) { for(IntegerVectorList::iterator i=generators.begin();i!=generators.end();i++) { // fprintf(Stderr,"testing\n"); assert(areIdealsEqual(g,SymmetryGroup::permutePolynomialSet(g,*i))); } } s.computeClosure(generators); log1 s.print(Stderr); if(0) {//using old breadth first traversal BreadthFirstSearch *bs=new BreadthFirstSearch(s,/*minkowski*/0); /* if(optionSubspace.getValue()) bs->setSubspace(FileParser(Stdin).parseIntegerVectorList()); */ rs=bs; if(optionEchoSymmetry.getValue())AsciiPrinter(Stdout).printVectorList(generators); ep->open(Stdout); rs->setEnumerationTarget(ep); rs->enumerate(g); delete rs; } else {//using new traversal GroebnerFanTraverser traverser(g); TargetGlue target(*ep); if(optionEchoSymmetry.getValue())AsciiPrinter(Stdout).printVectorList(generators); ep->open(Stdout); symmetricTraverse(traverser,target,&s); } } else { rs=new ReverseSearch(myOrder); ep->open(Stdout); rs->setEnumerationTarget(ep); rs->enumerate(g); delete rs; } } ep->close(); delete ep; printf("\n"); globalTimer.off(); // if(optionPerformanceTimer.getValue())Timer::printList(); return 0; } }; static GCats theApplication("_bases"); static GCats theApplication2(""); gfan-0.5+dfsg/app_markpolynomialset.cpp000066400000000000000000000020421207563005400203260ustar00rootroot00000000000000#include "vektor.h" #include "printer.h" #include "parser.h" #include "gfanapplication.h" #include "minkowskisum.h" #include "newtonpolytope.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" class MarkPolynomialSetApplication : public GFanApplication { public: const char *helpText() { return "This program marks a set of polynomials with respect to the vector given at the end of the input, meaning that the largest terms are moved to the front. In case of a tie the lexicographic term order with $a>b>c...$ is used to break it.\n"; } MarkPolynomialSetApplication() { registerOptions(); } const char *name() { return "_markpolynomialset"; } int main() { FileParser P(Stdin); PolynomialSet g=P.parsePolynomialSetWithRing(); IntegerVector v=P.parseIntegerVector(); WeightTermOrder t(v); g.markAndScale(t); AsciiPrinter(Stdout).printPolynomialRing(g.getRing()); AsciiPrinter(Stdout).printPolynomialSet(g); return 0; } }; static MarkPolynomialSetApplication theApplication; gfan-0.5+dfsg/app_matrixproduct.cpp000066400000000000000000000017121207563005400174640ustar00rootroot00000000000000/* * app_matrixproduct.cpp * * Created on: Jan 4, 2011 * Author: anders */ #include "parser.h" #include "printer.h" #include "gfanapplication.h" #include "matrix.h" class MatrixProductApplication : public GFanApplication { public: SimpleOption optionTropical; bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program computes the product of two matrices.\n"; } MatrixProductApplication(): optionTropical("--tropical","Do the computation in the max-plus semi-ring.") { registerOptions(); } const char *name() { return "_matrixproduct"; } int main() { FileParser P(Stdin); IntegerMatrix A=rowsToIntegerMatrix(P.parseIntegerVectorList()); IntegerMatrix B=rowsToIntegerMatrix(P.parseIntegerVectorList()); pout<<((optionTropical.getValue())?tropicalProduct(A,B):A*B).getRows(); return 0; } }; static MatrixProductApplication theApplication; gfan-0.5+dfsg/app_minimalassociatedprimes.cpp000066400000000000000000000016041207563005400214650ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "primarydecomposition.h" #include "gfanapplication.h" class MinimalAssociatedPrimesApplication : public GFanApplication { public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program computes the minimal associated primes of an ideal. It attempts to call Singular through a Sage interface. The only reason for having this program is to illustrate how such communication can be done.\n"; } MinimalAssociatedPrimesApplication() { registerOptions(); } const char *name() { return "_minimalassociatedprimes"; } int main() { FileParser P(Stdin); PolynomialSet a=P.parsePolynomialSetWithRing(); AsciiPrinter(Stdout).printPolynomialSetList(minimalAssociatedPrimes(a)); return 0; } }; static MinimalAssociatedPrimesApplication theApplication; gfan-0.5+dfsg/app_minkowski.cpp000066400000000000000000000126231207563005400165750ustar00rootroot00000000000000#include #include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "reversesearch.h" #include "breadthfirstsearch.h" #include "termorder.h" #include "ep_standard.h" #include "ep_xfig.h" #include "gfanapplication.h" #include "polyhedralfan.h" #include "minkowskidual.h" #include "log.h" class MinkowskiEnumerationTarget:public EnumerationTarget { SymmetryGroup const &s; public: IntegerVectorList weightVectors; MinkowskiEnumerationTarget(SymmetryGroup const &s_): s(s_) { } virtual void beginEnumeration(const PolynomialSet &groebnerBasis) { } virtual void endEnumeration() { } virtual bool basis(const PolynomialSet &groebnerBasis) { // log0 cerr<<"ETST"< class MinorsApplication : public GFanApplication { IntegerOption rOption; IntegerOption dOption; IntegerOption nOption; SimpleOption M2Option; SimpleOption optionWithNames; SimpleOption dressianOption; SimpleOption pluckerSymmetriesOption; SimpleOption grassmannNormalizOption; SimpleOption symmetryOption; SimpleOption parametrizeOption; // SimpleOption threeTermOption; public: const char *helpText() { return "This program will generate the r*r minors of a d*n matrix of indeterminates.\n"; } MinorsApplication(): rOption("-r","Specify r.",1), dOption("-d","Specify d.",1), nOption("-n","Specify n.",1), M2Option("-M2","Use Macaulay2 conventions for order of variables."), dressianOption("--dressian","Produce tropical defining the Dressian(3,n) instead. (The signs may not be correct, that is the equations may not be Pluecker relations.)"), optionWithNames("--names","Assign names to the minors."), pluckerSymmetriesOption("--pluckersymmetries","Do nothing but produce symmetry generators for the Pluecker ideal."), grassmannNormalizOption("--grassmannnormalize","Produce polynomials describing the tropical polynomial map taking a plucker vector to a plucker vector where the leaf edges have length one."), symmetryOption("--symmetry","Produces a list of generators for the group of symmetries keeping the set of minors fixed. (Only without --names)."), parametrizeOption("--parametrize","Parametrize the set of d times n matrices of Barvinok rank less than or equal to r-1 by a list of tropical polynomials.") /*, threeTermOption("--threeTerm","Do nothing but output the three term Plucker relations.")*/ { registerOptions(); grassmannNormalizOption.hide(); } const char *name() { return "_minors"; } IntegerVectorList symmetries(int r, int d, int n) { IntegerVectorList ret; { IntegerVector v1(d*n); IntegerVector v2(d*n); IntegerVector v3(d*n); IntegerVector v4(d*n); for(unsigned int i=0;i const &v, int i) { for(int j=0;j pnames=subsetVariableNames("p",n,d,M2); vector qnames=subsetVariableNames("q",n,d,M2); vector names(pnames.size()*2); for(int i=0;i I; for(int i=0;i setkl; setkl.insert(k); setkl.insert(l); Polynomial f(R); Polynomial g(R); vector J; for(int i=0;i setij; setij.insert(i); setij.insert(j); set setik; setik.insert(i); setik.insert(k); set setjk; setjk.insert(j); setjk.insert(k); set setil; setil.insert(i); setil.insert(l); set setjl; setjl.insert(j); setjl.insert(l); if((J[l]==0)) { IntegerVector v=w; v[subsetToVariableIndex(setil,n,d,M2)]+=-1; v[subsetToVariableIndex(setjl,n,d,M2)]+=-1; v[subsetToVariableIndex(setij,n,d,M2)]+=1; v[subsetToVariableIndex(setkl,n,d,M2)]+=1; f+=Polynomial(Term(R.getField().zHomomorphism(1),Monomial(R,v))); } if((J[k]==0)) { IntegerVector v=w; v[subsetToVariableIndex(setik,n,d,M2)]+=-1; v[subsetToVariableIndex(setjk,n,d,M2)]+=-1; v[subsetToVariableIndex(setij,n,d,M2)]+=1; v[subsetToVariableIndex(setkl,n,d,M2)]+=1; g+=Polynomial(Term(R.getField().zHomomorphism(1),Monomial(R,v))); } } while(next_permutation(J.begin(),J.end())); IntegerVector v(names.size()); v[pnames.size()+subsetToVariableIndex(setkl,n,d,M2)]=1; ret.push_back(Polynomial(Term(R.getField().zHomomorphism(-1),Monomial(R,v)))+f*g); } while(next_permutation(I.begin(),I.end())); return ret; } int main() { FileParser P(Stdin); int d=dOption.getValue(); int n=nOption.getValue(); int r=rOption.getValue(); bool M2=M2Option.getValue(); assert(r<=d); assert(r<=n); PolynomialRing R(Q,matrixVariableNames("m",d,n)); if(parametrizeOption.getValue()) { vector A=matrixVariableNames("a",d,r-1); vector B=matrixVariableNames("b",r-1,n); A.insert(A.end(),B.begin(),B.end()); PolynomialRing R2(Q,A); PolynomialSet s(R2); for(int i=0;i I; if(n-d-2>=0)if(d-2>=0) for(int i=0;i ijkl; set S; int m=32873; for(int i=0;i s=S;s.insert(i);s.insert(j);//s.insert(m); pA[subsetToVariableIndex(s,n,d,M2)]=1; } { set s=S;s.insert(k);s.insert(l);//s.insert(m); pA[subsetToVariableIndex(s,n,d,M2)]=1; } { set s=S;s.insert(i);s.insert(k);//s.insert(m); pB[subsetToVariableIndex(s,n,d,M2)]=1; } { set s=S;s.insert(j);s.insert(l);//s.insert(m); pB[subsetToVariableIndex(s,n,d,M2)]=1; } { set s=S;s.insert(i);s.insert(l);//s.insert(m); pC[subsetToVariableIndex(s,n,d,M2)]=1; } { set s=S;s.insert(j);s.insert(k);//s.insert(m); pC[subsetToVariableIndex(s,n,d,M2)]=1; } Polynomial p= Polynomial(Term(R.getField().zHomomorphism(1),Monomial(R,pA))) -Polynomial(Term(R.getField().zHomomorphism(1),Monomial(R,pB))) +Polynomial(Term(R.getField().zHomomorphism(1),Monomial(R,pC))); g.push_back(p); } } while(next_permutation(I.begin(),I.end())); AsciiPrinter(Stdout).printPolynomialRing(R); AsciiPrinter(Stdout).printNewLine(); AsciiPrinter(stdout).printPolynomialSet(g); } else if(pluckerSymmetriesOption.getValue()) { int N=subsetVariableNames("p",n,d,M2).size(); IntegerVectorList permutations1; { IntegerVector p1(n); IntegerVector p2(n); for(int i=0;i2) { p2[0]=1; p2[1]=0; } permutations1.push_back(p1); permutations1.push_back(p2); } IntegerVectorList permutations2; IntegerVectorList signs2; for(IntegerVectorList::const_iterator k=permutations1.begin();k!=permutations1.end();k++) { IntegerVector p(N); IntegerVector signs(N); vector I; for(int i=0;i indexSet1; set indexSet2; list indexSet2List; for(int i=0;i::const_iterator i=indexSet2List.begin();i!=indexSet2List.end();i++) for(list::const_iterator j=indexSet2List.begin();j!=i;j++) if(*i<*j)permSign*=-1; p[subsetToVariableIndex(indexSet1,n,r,M2)]=subsetToVariableIndex(indexSet2,n,r,M2); signs[subsetToVariableIndex(indexSet2,n,r,M2)]=permSign; } while(next_permutation(I.begin(),I.end())); signs2.push_back(signs); permutations2.push_back(p); } AsciiPrinter(Stdout).printVectorList(permutations2); AsciiPrinter(Stdout).printVectorList(signs2); } /* else if(threeTermOption.getValue()) { for(int i=0;i S; vector ijkl; list indexSet2List; for(int i=0;i a=matrixVariableNames("m",d,n); vector b=subsetVariableNames("p",n,d,M2); for(vector::const_iterator i=b.begin();i!=b.end();i++)a.push_back(*i); R=PolynomialRing(Q,a); } PolynomialSet p=minors(R,r,d,n,optionWithNames.getValue(),M2); AsciiPrinter(Stdout).printPolynomialRing(p.getRing()); AsciiPrinter(Stdout).printNewLine(); AsciiPrinter(Stdout).printPolynomialSet(p); } if(symmetryOption.getValue()) { AsciiPrinter(Stdout)< #include "parser.h" #include "printer.h" #include "polynomial.h" #include "mixedvolume.h" #include "gfanapplication.h" class MixedVolumeApplication : public GFanApplication { public: const char *helpText() { return "This program computes the mixed volume of the Newton polytopes of a list of polynomials. The ring is specified on the input. After this follows the list of polynomials.\n"; } MixedVolumeApplication() { registerOptions(); } const char *name() { return "_mixedvolume"; } int main() { FileParser P(Stdin); PolynomialSet s=P.parsePolynomialSetWithRing(); cout << mixedVolume(s) << endl; return 0; } }; static MixedVolumeApplication theApplication; gfan-0.5+dfsg/app_multiplymatrix.cpp000066400000000000000000000014311207563005400176610ustar00rootroot00000000000000#include "vektor.h" #include "printer.h" #include "parser.h" #include "gfanapplication.h" class MultiplyMatrixApplication : public GFanApplication { public: bool includeInDefaultInstallation() // Not included since the program has no relation to the main programs { return false; } MultiplyMatrixApplication() { registerOptions(); } const char *name() { return "_multiplymatrix"; } int main() { FileParser P(Stdin); IntegerVectorList a=P.parseIntegerVectorList(); IntegerVectorList b=P.parseIntegerVectorList(); AsciiPrinter(Stdout).printVectorList(multiplyIntegerVectorList(a,b)); return 0; } const char *helpText() { return "Takes two matrices and multiplies them.\n"; } }; static MultiplyMatrixApplication theApplication; gfan-0.5+dfsg/app_nbody.cpp000066400000000000000000000077751207563005400157110ustar00rootroot00000000000000#include "vektor.h" #include "printer.h" #include "parser.h" #include "gfanapplication.h" #include "nbody.h" #include "field_rationals.h" #include class NBodyApplication : public GFanApplication { IntegerOption NOption; SimpleOption optionWithMasses; SimpleOption optionSymmetric; SimpleOption optionDziobek; IntegerOption optionDeterminants; SimpleOption optionMM; SimpleOption optionSVariables; SimpleOption optionLaurent; //SimpleOption optionKaloshin; public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program computes the AC equations for the nbody problem.\n"; } NBodyApplication(): NOption("-N","Specify number of bodies.",3), optionWithMasses("--masses","Include mass variables."), optionSymmetric("--symmetric","Produce the symmetric equations"), optionDziobek("--dziobek","Produce the Dziobek equations"), optionDeterminants("--codim","Produce the determinant equations",-1), optionMM("--mm","Add in additional mass equation"), optionSVariables("-s","Treat the Sij polynomials as variables"), optionLaurent("--laurent","Output Laurent polynomials instead of multiplying") // optionKaloshin("--kaloshin","Produce the polynomials from the Albouy Kaloshin paper") { registerOptions(); } const char *name() { return "_nbody"; } /* int offset(int N, int i, int j) { } Polynomial varz(PolynomialRing const &r, int i) { int N=4; return r.ithVariable(i); } Polynomial varw(PolynomialRing const &r, int i) { int N=4; return r.ithVariable(N+i); } Polynomial varZ(PolynomialRing const &r, int i, int j) { int N=4; int sign=(i #include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "reversesearch.h" #include "termorder.h" #include "ep_standard.h" #include "ep_xfig.h" #include "gfanapplication.h" #include "polyhedralcone.h" #include "polyhedralfan.h" #include "tropical.h" #include "tropical2.h" #include "symmetry.h" #include "halfopencone.h" #include "log.h" class NormalFanCleanUpApplication : public GFanApplication { SimpleOption optionPreprocess; public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program takes a list of polynomials and outputs a subcomplex of its normalfan. After the polynomial list follows a generating set for the symmetry group and then a list of vectors. The cones which are output are the ones picked by the list of vectors. The output is symmetric with respect to the symmetry group.\n"; } NormalFanCleanUpApplication(): optionPreprocess("-pre","Preprocess cones before building polyhedral fan - that is find representatives for each orbit first.\n") { registerOptions(); } const char *name() { return "_normalfancleanup"; } int main() { FileParser P(Stdin); PolynomialSet g=P.parsePolynomialSetWithRing(); int n=g.numberOfVariablesInRing(); SymmetryGroup sym(n); sym.computeClosure(P.parseIntegerVectorList()); IntegerVectorList l=P.parseIntegerVectorList(); cerr<<"Number of input rays: " << l.size() <<"\n"; if(optionPreprocess.getValue()) { set l2; for(IntegerVectorList::const_iterator i=l.begin();i!=l.end();i++) { { static int a; if(!((++a)&255)) { cerr<::const_iterator i=l2.begin();i!=l2.end();i++)l3.push_back(*i); AsciiPrinter(f)<::const_iterator i=l2.begin();i!=l2.end();i++)l3.push_back(*i); AsciiPrinter(Stdout)< using namespace std; class PAdicApplication : public GFanApplication { IntegerOption primeOption; SimpleOption gbOption; SimpleOption initialOption; SimpleOption gComplexOption; SimpleOption gPolyhedronOption; SimpleOption listOption; public: const char *helpText() { return "This program is an experimental implementation of p-adic Groebner bases as proposed by Diane Maclagan.\n" "Several operations are supported by specifying the appropriate option:\n" " (1) computation of Groebner basis with respect to a given vector (tiebroken lexicographically),\n" " (2) computation of the p-adic initial ideal,\n" " (3) computation of the p-adic Groebner complex as defined by Maclagan and Sturmfels,\n" " (4) computation of a single polyhedron of the p-adic Groebner complex.\n" "The input ideal should be an ideal of the polynomial ring with coefficient field Q. The valuation is specified with the option -p. The ideal MUST BE HOMOGENEOUS (in a positive grading).\n" "Since gfan can only handle fans and not polyhedral complexes in general, what is computed as the Groebner complex is actually the \"fan over\" the complex - in other words, the first coordinate is supposed to be 1 in the output fan.\n" "Similarly, the weight vectors must be specified in an homogeneous way, for example by adding an additional 1 entry as first coordinate. (If fractions are needed, use the entry as a common denominator.) " "NOTE: This program is experimental and expected to change behaviour in future releases, so don't write your SAGE and M2 interfaces just yet. In particular this program uses the tropical minimum-convention!!\n"; } PAdicApplication(): primeOption("-p","Defines the prime used for the valuation.",2), gbOption("--groebnerBasis","Asks the program to compute a marked Groebner basis with respect to a weight vector (tie-broken lexicographically).\n" "The input order is: Ring ideal vector.\n"), initialOption("--initialIdeal","Asks the program to compute an initial ideal with respect to a vector. " "The input order is: Ring ideal vector.\n"), gComplexOption("--groebnerComplex","Asks the program to compute the p-adic Groebner complex. \n " "The input order is: Ring ideal.\n"), gPolyhedronOption("--groebnerPolyhedron","Asks the program to compute a single polyhedron of the Groebner complex containing the specified vector in its relative interior. The output is stored as a fan. " "The input order is: Ring ideal vector."), listOption("-m","For the operations taking a vector as input, read in a list of vectors instead, and perform the operation for each vector in the list.") { registerOptions(); } const char *name() { return "_padic"; } int main() { if(gbOption.getValue()+initialOption.getValue()+gComplexOption.getValue()+gPolyhedronOption.getValue()!=1) { debug<<"WRONG COMBINATION OF COMMAND LINE OPTIONS\n"; assert(0); } LexicographicTermOrder tieBreaker; FileParser P(Stdin); int prime=primeOption.getValue(); PolynomialSet a=P.parsePolynomialSetWithRing(); int n=a.getRing().getNumberOfVariables(); if(gComplexOption.getValue()) { SymmetryGroup G(n+1); SymmetricTargetFanBuilder target(n+1,G); PAdicGroebnerFanTraverser traverser(a,prime); symmetricTraverse(traverser,target); AsciiPrinter Q(Stdout); target.getFanRef().printWithIndices(&Q, FPF_default); } else { IntegerVectorList omegas; if(listOption.getValue()) omegas=P.parseIntegerVectorList(); else omegas.push_back(P.parseIntegerVector()); for(IntegerVectorList::const_iterator i=omegas.begin();i!=omegas.end();i++) { if(i->size()!=a.getRing().getNumberOfVariables()+1) { debug<<"ERROR: The number of entries of the weight vector is not one higher than the number of variables in the ring.\n"; assert(0); } if(gbOption.getValue()) { //debug<<"P-ADIC GROEBNER BASIS:\n"; pAdicBuchberger(a,prime,*i,tieBreaker); pout<=2); assert(d2>=2); IntegerMatrix A(d1*d2,d1+d2); IntegerVector p1(d1*d2); IntegerVector p2(d1*d2); IntegerVector p3(d1*d2); IntegerVector p4(d1*d2); for(int b=0;bb.getMarked().m.exponent.sum())return false; return LexicographicTermOrder()(a.getMarked().m.exponent,b.getMarked().m.exponent); } }; public: const char *helpText() { return "This program computes the union of a list of polynomial sets given as input. The polynomials must all belong to the same ring. The ring is specified on the input. After this follows the list of polynomial sets.\n"; } PolynomialSetUnionApplication(): optionSpecialMode("-s","Sort output by degree.\n") { registerOptions(); } const char *name() { return "_polynomialsetunion"; } int main() { FileParser P(Stdin); PolynomialRing r=P.parsePolynomialRing(); int c=P.nextNonBlank(); bool first=true; assert(P.isLeftBracket(c)); PolynomialSet s=P.parsePolynomialSet(r); c=P.nextNonBlank(); while(','==c || first) { PolynomialSet temp=P.parsePolynomialSet(r); // if(optionSpecialMode.getValue())temp.markAndScale(LexicographicTermOrder()); s.unionSet(temp); c=P.nextNonBlank(); first=false; } assert(P.isRightBracket(c)); if(optionSpecialMode.getValue())s.sort(PolynomialCmp()); AsciiPrinter(Stdout).printPolynomialRing(r); AsciiPrinter(Stdout).printNewLine(); AsciiPrinter(Stdout).printPolynomialSet(s); return 0; } }; static PolynomialSetUnionApplication theApplication; gfan-0.5+dfsg/app_product.cpp000066400000000000000000000020261207563005400162360ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "lp.h" #include "gfanapplication.h" #include "polyhedralcone.h" #include "polyhedralfan.h" #include "polymakefile.h" class ProductApplication : public GFanApplication { StringOption input1Option; StringOption input2Option; public: const char *helpText() { return "This program takes two polyhedral fans and computes their product.\n"; } ProductApplication(): input1Option("-i1","Specify the name of the first input file.","polymake.out"), input2Option("-i2","Specify the name of the second input file.","polymake.out") { registerOptions(); } const char *name() { return "_fanproduct"; } int main() { PolyhedralFan f1=PolyhedralFan::readFan(input1Option.getValue()); PolyhedralFan f2=PolyhedralFan::readFan(input2Option.getValue()); PolyhedralFan f=product(f1,f2); AsciiPrinter P(Stdout); f.printWithIndices(&P,FPF_default|FPF_multiplicities/*|FPF_values*/); return 0; } }; static ProductApplication theApplication; gfan-0.5+dfsg/app_realroots.cpp000066400000000000000000000201331207563005400165670ustar00rootroot00000000000000#include "dimension.h" #include "printer.h" #include "parser.h" #include "gfanapplication.h" #include "division.h" #include "field_rationals.h" #include "buchberger.h" class RealRootsApplication : public GFanApplication { public: PolynomialSet sturmPolynomials(Polynomial f1) { Polynomial f2=f1.derivative(); PolynomialRing theRing=f1.getRing(); PolynomialSet result(theRing); result.push_back(f1); while(!f2.isZero()) { result.push_back(f2); PolynomialSet g(theRing); Polynomial temp=f2; g.push_back(f2); g.markAndScale(LexicographicTermOrder()); f2=(f1-f1)-division(f1,g,LexicographicTermOrder()); f1=temp; } return result; } int numberOfSignChangesAtMinusInfinity(PolynomialSet const &l) { int ret=0; int sign=0; for(PolynomialSet::const_iterator i=l.begin();i!=l.end();i++) { Polynomial p=*i; p.mark(LexicographicTermOrder()); int newSign=p.getMarked().c.sign()*(1-2*(p.getMarked().m.exponent[0]&1)); if(newSign && (newSign!=sign)) { ret++; sign=newSign; } } return ret; } int numberOfSignChangesAtInfinity(PolynomialSet const &l) { int ret=0; int sign=0; for(PolynomialSet::const_iterator i=l.begin();i!=l.end();i++) { Polynomial p=*i; p.mark(LexicographicTermOrder()); int newSign=p.getMarked().c.sign(); if(newSign && (newSign!=sign)) { ret++; sign=newSign; } } return ret; } int numberOfSignChanges(PolynomialSet const &l, FieldElement const &a) { int ret=0; int sign=0; for(PolynomialSet::const_iterator i=l.begin();i!=l.end();i++) { FieldElement v=i->evaluate(a); int newSign=v.sign(); if(newSign && (newSign!=sign)) { ret++; sign=newSign; } } return ret; } /** * Returns a negative number less than all roots of the polynomial whose Sturm sequence is given. */ FieldElement lowerBoundForRoots(PolynomialSet const &l) { FieldElement ret=Q.zHomomorphism(-1); while(numberOfSignChangesAtMinusInfinity(l)!=numberOfSignChanges(l,ret))ret*=Q.zHomomorphism(2); return ret-Q.zHomomorphism(1); } FieldElement upperBoundForRoots(PolynomialSet const &l) { FieldElement ret=Q.zHomomorphism(1); while(numberOfSignChangesAtInfinity(l)!=numberOfSignChanges(l,ret))ret*=Q.zHomomorphism(2); return ret+Q.zHomomorphism(1); } list intervals(PolynomialSet const &l) { list ret; FieldElement lo(lowerBoundForRoots(l)); // ret.push_back(a); while(1) { FieldElement hi=upperBoundForRoots(l); int cLo=numberOfSignChanges(l,lo); int cHi=numberOfSignChanges(l,hi); if(cLo<=cHi)break; { while(cHi!=cLo-1) { FieldElement med=(hi+lo)*Q.zHomomorphism(2).inverse(); int cMed=numberOfSignChanges(l,med); if(cMed==cLo) { lo=med; cLo=cMed; } else { hi=med; cHi=cMed; } } ret.push_back(lo); ret.push_back(hi); } lo=hi; } return ret; } list narrow(PolynomialSet const &l, list intervals, FieldElement epsilon) { list ret; for(list::const_iterator i=intervals.begin();i!=intervals.end();i++) { FieldElement lo=*i;i++; FieldElement hi=*i; while((hi-lo-epsilon).sign()>0) { FieldElement med=(hi+lo)*Q.zHomomorphism(2).inverse(); if(numberOfSignChanges(l,med)==numberOfSignChanges(l,hi)) hi=med; else lo=med; } ret.push_back(lo); ret.push_back(hi); } return ret; } //Returns a length that fist in between any two consequtive intervals FieldElement smallestDistance(list intervals) { FieldElement ret=Q.zHomomorphism(1000); if(intervals.size()>=4) { list::const_iterator i=intervals.begin(); i++; for(;i!=intervals.end();i++) { FieldElement a=*i;i++; FieldElement diff=*i-a; if((diff-ret).sign()<0)ret=diff; } } return ret; } /*int numberOfRootsBetweenMinusInfinityAndHere(FieldElement ) { }*/ bool includeInDefaultInstallation() { return false; } const char *helpText() { return "Not working yet. Given generators for a zero-dimensional ideal this program will compute all real points on the variety.\n"; } RealRootsApplication() { registerOptions(); } const char *name() { return "_realroots"; } int main() { FileParser P(Stdin); PolynomialSet g=P.parsePolynomialSetWithRing(); PolynomialRing r=g.getRing(); int n=r.getNumberOfVariables(); // Polynomial f1=P.parsePolynomialWithRing(); WeightReverseLexicographicTermOrder T(IntegerVector::allOnes(n)); buchberger(&g,T); debug< l; l.push_back(i); PolynomialSet intersection=g.polynomialRingIntersection(r2,&l); assert(intersection.size()==1); projectionPolys.push_back(*intersection.begin()); } debug< l=intervals(*i); FieldElement epsilon=(upperBoundForRoots(*i)-lowerBoundForRoots(*i))*Q.zHomomorphism(100).inverse(); l=narrow(*i,l,epsilon); for(list::const_iterator j=l.begin();j!=l.end();j++) debug<<*j<<" "<< fieldElementToFloatingPoint(*j)<<"\n"; FieldElement b=upperBoundForRoots(*i)-lowerBoundForRoots(*i); // if(boundfirst.m.v)); } g2.push_back(f); } pout << g2; LexicographicTermOrder T2; buchberger(g2,T2); Polynomial p(r2); for(PolynomialSet::const_iterator i=g2.begin();i!=g2.end();i++) { if(i->numberOfVariablesInUseConsecutive()==1)p=*i; } PolynomialRing r3(k,1); */ //AsciiPrinter(Stdout).printPolynomialSet(result); /* if(evaluateOption.getValue()) { IntegerVector v=P.parseIntegerVector(); for(int i=0;ievaluate(x)); AsciiPrinter(Stdout).printNewLine(); } } } */ return 0; } }; static RealRootsApplication theApplication; gfan-0.5+dfsg/app_regularsubdivision.cpp000066400000000000000000000017621207563005400205040ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "wallideal.h" #include "lp.h" #include "polyhedralcone.h" #include "gfanapplication.h" #include "polyhedralfan.h" #include "halfopencone.h" #include "matrix.h" #include "regularsubdivision.h" #include "log.h" class RegularSubdivisionApplication : public GFanApplication { public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program takes a point configuration and a lifting vector a computes the corresponding regular subdivision PROJECTIVELY?.\n"; } RegularSubdivisionApplication() { registerOptions(); } const char *name() { return "_regularsubdivision"; } int main() { FileParser P(Stdin); IntegerMatrix m=rowsToIntegerMatrix(P.parseIntegerVectorList()); IntegerVector w=P.parseIntegerVector(); printSetSetInt(stdout,regularSubdivision(m,w)); return 0; } }; static RegularSubdivisionApplication theApplication; gfan-0.5+dfsg/app_render.cpp000066400000000000000000000040511207563005400160350ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "reversesearch.h" #include "termorder.h" #include "ep_standard.h" #include "ep_xfig.h" #include "gfanapplication.h" #include "renderer.h" #include "xfig.h" #include class RenderApplication : public GFanApplication { SimpleOption optionLargerTriangle; IntegerOption optionShiftVariablesWhenDrawing; public: const char *helpText() { return "This program renders a Groebner fan as an xfig file. To be more precise, the input is the list of all reduced Groebner bases of an ideal. The output is a drawing of the Groebner fan intersected with a triangle. The corners of the triangle are (1,0,0) to the right, (0,1,0) to the left and (0,0,1) at the top. If there are more than three variables in the ring these coordinates are extended with zeros. It is possible to shift the 1 entry cyclic with the option --shiftVariables.\n"; } RenderApplication(): optionLargerTriangle("-L", "Make the triangle larger so that the shape of the Groebner region appears."), optionShiftVariablesWhenDrawing("--shiftVariables", "Shift the positions of the variables in the drawing. For example with the value equal to 1 the corners will be right: (0,1,0,0,...), left: (0,0,1,0,...) and top: (0,0,0,1,...). The shifting is done modulo the number of variables in the polynomial ring. The default value is 0.") { registerOptions(); } const char *name() { return "_render"; } int main() { FileParser P(Stdin); PolynomialSetList l; l=P.parsePolynomialSetListWithRing(); XfigEnumerationPrinter ep(optionLargerTriangle.getValue()); ep.setVariableShift(optionShiftVariablesWhenDrawing.getValue()); ep.open(Stdout); if(l.size()) { ep.beginEnumeration(*l.begin()); for(PolynomialSetList::const_iterator i=l.begin();i!=l.end();i++)ep.basis(*i); ep.endEnumeration(); } ep.close(); return 0; } }; static RenderApplication theApplication; gfan-0.5+dfsg/app_renderstaircase.cpp000066400000000000000000000041161207563005400177360ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "reversesearch.h" #include "termorder.h" #include "ep_standard.h" #include "ep_xfig.h" #include "gfanapplication.h" #include "renderer.h" class RenderStaircaseApplication : public GFanApplication { SimpleOption optionListOfPolynomialSets; IntegerOption optionMaxEntry; IntegerOption optionWidth; public: const char *helpText() { return "This program renders a staircase diagram of a monomial initial ideal to an xfig file. The input is a Groebner basis of a (not necessarily monomial) polynomial ideal. The initial ideal is given by the leading terms in the Groebner basis. Using the -m option it is possible to render more than one staircase diagram. The program only works for ideals in a polynomial ring with three variables.\n"; } RenderStaircaseApplication(): optionListOfPolynomialSets("-m","Read multiple ideals from the input. The ideals are given as a list of lists of polynomials. For each polynomial list in the list a staircase diagram is drawn.\n"), optionMaxEntry("-d","Specifies the number of boxes being shown along each axis. Be sure that this number is large enough to give a correct picture of the standard monomials. The default value is 8.\n",8), optionWidth("-w","Width. Specifies the number of staircase diagrams per row in the xfig file. The default value is 5.\n",5) { registerOptions(); } const char *name() { return "_renderstaircase"; } int main() { FileParser P(Stdin); StandardMonomialRenderer r(Stdout); r.setMaxEntry(optionMaxEntry.getValue()); r.setNumberOfDrawingsPerLine(optionWidth.getValue()); if(optionListOfPolynomialSets.getValue()) { PolynomialSetList l=P.parsePolynomialSetListWithRing(); for(PolynomialSetList::const_iterator i=l.begin();i!=l.end();i++) r.render(*i); } else { PolynomialSet p=P.parsePolynomialSetWithRing(); r.render(p); } return 0; } }; static RenderStaircaseApplication theApplication; gfan-0.5+dfsg/app_representatives.cpp000066400000000000000000000035531207563005400200070ustar00rootroot00000000000000#include "vektor.h" #include "printer.h" #include "parser.h" #include "gfanapplication.h" #include "minkowskisum.h" #include "newtonpolytope.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "tropical.h" #include "division.h" #include "bergman.h" #include "tropical2.h" #include "dimension.h" #include "timer.h" class RepresentativesApplication : public GFanApplication { FieldOption theFieldOption; public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program computes takes generaters for a subgroup of S_n and a list of n-dimensional integer vectors. The output is a list of vectors, one from each orbit of elements of the list. \n"; } RepresentativesApplication() { registerOptions(); } const char *name() { return "_representatives"; } int main() { PolynomialSetList tropical; lpSetSolver("cddgmp"); FileParser P(Stdin); AsciiPrinter p(Stdout); IntegerVectorList generators=P.parseIntegerVectorList(); assert(generators.size()!=0); int n=generators.begin()->size(); SymmetryGroup s(n); s.computeClosure(generators); s.print(Stderr); fprintf(Stderr,"\n"); IntegerVectorList vList=P.parseIntegerVectorList(); IntegerVectorList rep; for(IntegerVectorList::const_iterator i=vList.begin();i!=vList.end();i++) { bool found=false; for(IntegerVectorList::const_iterator j=rep.begin();j!=rep.end();j++) { if(i->sum()==j->sum()) { for(SymmetryGroup::ElementContainer::const_iterator k=s.elements.begin();k!=s.elements.end();k++) if(SymmetryGroup::compose(*k,*j)==*i) { found=true; break; } } if(found)break; } if(!found)rep.push_back(*i); } p.printVectorList(rep); return 0; } }; static RepresentativesApplication theApplication; gfan-0.5+dfsg/app_saturation.cpp000066400000000000000000000024211207563005400167460ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "saturation.h" #include "tropical.h" #include "gfanapplication.h" class SaturationApplication : public GFanApplication { SimpleOption optionIsHomogeneous; SimpleOption optionNoIdeal; public: const char *helpText() { return "This program computes the saturation of the input ideal with the product of the variables x_1,...,x_n. The ideal does not have to be homogeneous.\n"; } SaturationApplication(): optionIsHomogeneous("-h","Tell the program that the input is a homogeneous ideal (with homogeneous generators).\n"), optionNoIdeal("--noideal","Do not treat input as an ideal but just factor out common monomial factors of the input polynomials.") { registerOptions(); } const char *name() { return "_saturation"; } int main() { FileParser P(Stdin); PolynomialSet a=P.parsePolynomialSetWithRing(); AsciiPrinter(Stdout).printPolynomialRing(a.getRing()); AsciiPrinter(Stdout).printNewLine(); if(optionNoIdeal.getValue()) { a.saturate(); pout<0); radius= 2500/steps; if(A.getWidth()==2) { signature(xfig,12000,-15000); xfig.drawString(16000, -15000,string(" x1 x2"),60); xfig.drawString(16000, -15000+900,string(" y1 y2"),60); for(int i=2;i #include class SecondaryFanApplication : public GFanApplication { SimpleOption hirschOption; SimpleOption searchOption; IntegerOption scaleOption; StringOption optionRestrictingFan; SimpleOption symmetryOption; SimpleOption optionIgnoreCones; public: const char *helpText() { return "This program computes the secondary fan of a vector configuration. The configuration is given as an ordered list of vectors. In order to compute the secondary fan of a point configuration an additional coordinate of ones must be added. For example {(1,0),(1,1),(1,2),(1,3)}.\n"; } SecondaryFanApplication(): searchOption("--unimodular","Use heuristics to search for unimodular triangulation rather than computing the complete secondary fan"), scaleOption("--scale","Assuming that the first coordinate of each vector is 1, this option will take the polytope in the 1 plane and scale it. The point configuration will be all lattice points in that scaled polytope. The polytope must have maximal dimension. When this option is used the vector configuration must have full rank. This option may be removed in the future."), symmetryOption("--symmetry","Tells the program to read in generators for a group of symmetries (subgroup of $S_n$) after having read in the vector configuration. The program checks that the configuration stays fixed when permuting the variables with respect to elements in the group. The output is grouped according to the symmetry.\n"), optionRestrictingFan("--restrictingfan","Specify the name of a file containing a polyhedral fan in Polymake format. The computation of the Secondary fan will be restricted to this fan. If the --symmetry option is used then this restricting fan must be invariant under the symmetry and the orbits in the file must be with respect to the specified group of symmetries. The orbits of maximal cones of the file are then read in rather than the maximal cones.\n",0), optionIgnoreCones("--nocones","Tells the program not to output the CONES and MAXIMAL_CONES sections, but still output CONES_COMPRESSED and MAXIMAL_CONES_COMPRESSED if --symmetry is used."), hirschOption("--hirsch","") { hirschOption.hide(); registerOptions(); } const char *name() { return "_secondaryfan"; } PolyhedralFan enumerate(Triangulation2 const &t) { PolyhedralFan ret(t.getN()); list active; active.push_back(t); IntegerVectorList interiorPoints; interiorPoints.push_back(t.interiorPoint()); while(!active.empty()) { Triangulation2 a=active.front(); PolyhedralCone C=a.secondaryCone(); // if(active.size()>100)break;//SLETMIGGGGG //log0 fprintf(stderr,"a\n"); /* { PolyhedralCone C2=C; C2.canonicalize(); }*/ C.canonicalize(); //log0 fprintf(stderr,"b\n"); ret.insert(C); AsciiPrinter P(Stderr); // C.print(&P); active.pop_front(); // fprintf(stderr,"pop\n"); IntegerVectorList flips=a.facets(); for(IntegerVectorList::const_iterator i=flips.begin();i!=flips.end();i++) { { IntegerVectorList t=C.getEquations(); t.push_back(*i); PolyhedralCone CF(C.getHalfSpaces(),t); CF.findFacets(); // CF.canonicalize(); } if(!i->isNonNegative()) //is this the right condition or should i be negated? // if(!(-*i).isNonNegative()) //is this the right condition or should i be negated? { Triangulation2 b=a; log1 AsciiPrinter(Stderr)<<*i; /*fprintf(stderr,"Before:"); b.print(P);*/ // b.flip(*i); b.flipNew(-*i); /*fprintf(stderr,"After:"); b.print(P);*/ if(!b.isEmpty()) { IntegerVectorList inequalities=b.inequalities(); bool isKnown=false; for(IntegerVectorList::const_iterator j=interiorPoints.begin();j!=interiorPoints.end();j++) { bool match=true; for(IntegerVectorList::const_iterator k=inequalities.begin();k!=inequalities.end();k++) { if(dotLong(-*k,*j)<0) { match=false; break; } } if(match)isKnown=true; } if(!isKnown) { active.push_back(b); interiorPoints.push_back(b.interiorPoint()); } } } } } return ret; } PolyhedralFan interactive(Triangulation2 const &t) { Triangulation2 a=t; while(1) { fprintf(stdout,"Triangles in current triangulation:%i\n",a.bases.size()); PolyhedralCone C=a.secondaryCone(); C.canonicalize(); AsciiPrinter Pstd(Stderr); IntegerVectorList flips=a.facets(); int I=0; for(IntegerVectorList::const_iterator i=flips.begin();i!=flips.end();i++,I++) { fprintf(stdout,"%i:\n",I); Pstd.printVector(*i); if(!i->isNonNegative()) { Triangulation2 b=a; //fprintf(stderr,"Before:"); //b.print(P); // b.flip(*i); /* b.flipNew(*i); //fprintf(stderr,"After:"); //b.print(P); fprintf(stdout,"Triangles in new triangulation:%i\n",b.bases.size()); */ } fprintf(stdout,"\n"); } int s; //cin >> s; fscanf(stdin,"%i",&s); if((s>=0)&&(sisNonNegative()) { Triangulation2 b=a; b.flipNew(-*i); fprintf(stdout,"Triangles in new triangulation:%i\n",b.bases.size()); if(b.bases.size()==abortAtSize) { b.print(Pstd); exit(0); } if((b.bases.size()>a.bases.size())||((rand()&127)==0)) { a=b; break; } } } } PolyhedralFan ret(0); return ret; } PolyhedralFan automaticHirsch(Triangulation2 const &t) { Triangulation2 a=t; while(1) { int nVertices=a.bases.size(); int nEdges=a.coDimensionOneTriangles().size(); int diameter=a.edgeGraph().diameter(); int dimension=a.getD(); int nFacets=a.usedRays().size(); fprintf(stdout,"NVER: %i NEDGES: %i DIAMETER:%i DIMENSION:%i NFACETS:%i\n",nVertices,nEdges,diameter,dimension,nFacets); AsciiPrinter Pstd(Stderr); IntegerVectorList flips=a.facets(); int I=0; float currentScore=a.hirschScore(); cerr << "Current score: " << currentScore <isNonNegative()) { Triangulation2 b=a; b.flipNew(-*i); float bScore=b.hirschScore(); fprintf(stdout,"New score:%f\n",bScore); if((bScore>currentScore)||((rand()&31)==0)) { a=b; break; } } } } PolyhedralFan ret(0); return ret; } int main() { IntegerMatrix A=rowsToIntegerMatrix(FileParser(Stdin).parseIntegerVectorList()).transposed(); int n=A.getWidth(); SymmetryGroup s(n); if(symmetryOption.getValue()) { IntegerVectorList generators=FileParser(Stdin).parseIntegerVectorList(); for(IntegerVectorList::const_iterator i=generators.begin();i!=generators.end();i++) { assert(i->size()==n); FieldMatrix M1=integerMatrixToFieldMatrix(A,Q); FieldMatrix M2=integerMatrixToFieldMatrix(rowsToIntegerMatrix(SymmetryGroup::permuteIntegerVectorList(A.getRows(),*i)),Q); M1.reduce(); M1.REformToRREform(true); M2.reduce(); M2.REformToRREform(true); if(!(M1==M2)) { AsciiPrinter(Stderr) << "Permutation "<< *i << " does not keep the configuration fixed.\n"; assert(0); } } s.computeClosure(generators); s.createTrie(); } if(scaleOption.getValue()) { if(rank(A)!=A.getHeight()) { cerr << "The vector configuration must have full rank in order to use the scale option.\n"; assert(0); } int s=scaleOption.getValue(); cout << "Input configuration:" << endl; AsciiPrinter(Stdout)< T=Triangulation::triangulate(A.transposed()); for(list::const_iterator i=T.begin();i!=T.end();i++) { IntegerVector v=i->size(); int J=0; for(Triangulation::Cone::const_iterator j=i->begin();j!=i->end();j++,J++) v[J]=*j; t.bases.insert(v); } } if(searchOption.getValue()) { PolyhedralFan f=automatic(t,t.totalVolume()); } else if(hirschOption.getValue()) { PolyhedralFan f=automaticHirsch(t); } else { SymmetricTargetFanBuilder target(n,s); if(!optionRestrictingFan.getValue()) { SecondaryFanTraverser traverser(t); symmetricTraverse(traverser,target,&s); } else { PolyhedralFan f1=PolyhedralFan::readFan(optionRestrictingFan.getValue(),true,0,0,/*optionSymmetry.getValue()?&s:0*/0,false/*true*/); for(PolyhedralFan::coneIterator i=f1.conesBegin();i!=f1.conesEnd();i++) { static int a; log2 cerr<<"Processing Cone "<dimension()< #include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "lp.h" #include "gfanapplication.h" #include "polyhedralcone.h" #include "tropical2.h" #include "nbody.h" #include "polymakefile.h" #include "determinant.h" #include "subspace.h" #include "triangulation.h" #include "groebnerengine.h" class SmalesSixthApplication : public GFanApplication { StringOption inputOption; SimpleOption singleOption; public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program solves ........\n"; } SmalesSixthApplication(): // inputOption("-i","Specify the name of the input file.","examples/5body10sym.out"/*"examples/5bodyNEW.out2"*/) // inputOption("-i","Specify the name of the input file.","examples/4bodyMoreEquations.out"/*"examples/5bodyNEW.out2"*/) // inputOption("-i","Specify the name of the input file.","examples/nbody/5bodyACAC.out") // inputOption("-i","Specify the name of the input file.","examples/nbody/5bodyACACDZ.out") // inputOption("-i","Specify the name of the input file.","examples/nbody/5bodyACACDZDE.out"), inputOption("-i","Specify the name of the input file.","examples/nbody/5bodyACACDZDEMA.out"), singleOption("-s","Chekc just a single initial system.") { registerOptions(); } const char *name() { return "_smalessixth"; } void printIntList(list const &v) { FILE *f=Stderr; fprintf(f,"{"); for(list::const_iterator i=v.begin();i!=v.end();i++) { if(i!=v.begin())fprintf(f," "); fprintf(f,"%i",*i); } fprintf(f,"}\n"); } void printIntListList(list > const &l) { for(list >::const_iterator i=l.begin();i!=l.end();i++) printIntList(*i); } /* PolynomialSet DziobekEquations(PolynomialRing const &r) { StringParser P("{r243*r353 - r233*r243*r353 - r233*r453 + r233*r243*r453 +r233*r353*r453 - r243*r353*r453," " r253*r343 - r233*r253*r343 - r233*r453 + r233*r253*r453 + r233*r343*r453 - r253*r343*r453," " -r253*r343 + r243*r253*r343 + r243*r353 - r243*r253*r353 - r243*r343*r353 + r253*r343*r353," " r143*r353 - r133*r143*r353 - r133*r453 + r133*r143*r453 + r133*r353*r453 - r143*r353*r453," " r153*r343 - r133*r153*r343 - r133*r453 + r133*r153*r453 + r133*r343*r453 - r153*r343*r453," " -r153*r343 + r143*r153*r343 + r143*r353 - r143*r153*r353 - r143*r343*r353 + r153*r343*r353," " r143*r253 - r123*r143*r253 - r123*r453 + r123*r143*r453 + r123*r253*r453 - r143*r253*r453," " r153*r243 - r123*r153*r243 - r123*r453 + r123*r153*r453 + r123*r243*r453 - r153*r243*r453," " -r153*r243 + r143*r153*r243 + r143*r253 - r143*r153*r253 - r143*r243*r253 + r153*r243*r253," " r133*r253 - r123*r133*r253 - r123*r353 + r123*r133*r353 + r123*r253*r353 - r133*r253*r353," " r153*r233 - r123*r153*r233 - r123*r353 + r123*r153*r353 + r123*r233*r353 - r153*r233*r353," " -r153*r233 + r133*r153*r233 + r133*r253 - r133*r153*r253 - r133*r233*r253 + r153*r233*r253," " r133*r243 - r123*r133*r243 - r123*r343 + r123*r133*r343 + r123*r243*r343 - r133*r243*r343," " r143*r233 - r123*r143*r233 - r123*r343 + r123*r143*r343 + r123*r233*r343 - r143*r233*r343," " -r143*r233 + r133*r143*r233 + r133*r243 - r133*r143*r243 - r133*r233*r243 + r143*r233*r243}"); return P.parsePolynomialSet(r); }*/ PolynomialSet saturationHomog(PolynomialSet const &g, int i) { WeightReverseLexicographicTermOrder T(-1*IntegerVector::standardVector(g.getRing().getNumberOfVariables(),i)); PolynomialSet g2=GE_groebnerBasis(g,T,false); // g2.saturate(i); g2.saturate(); return g2; } PolynomialSet removePositiveFactors(PolynomialSet const &g) { PolynomialSet ret(g.getRing()); for(PolynomialSet::const_iterator i=g.begin();i!=g.end();i++) { Polynomial p=*i; if(p.numberOfTerms()==2) { FieldElement c1=p.terms.begin()->second; FieldElement c2=p.terms.rbegin()->second; IntegerVector e1=p.terms.begin()->first.exponent; IntegerVector e2=p.terms.rbegin()->first.exponent; if((c1+c2).isZero()) { int d=gcdOfVector(concatenation(e1,e2)); if(d&1) p=Polynomial(Term(c1,Monomial(g.getRing(),e1/d)))+Polynomial(Term(c2,Monomial(g.getRing(),e2/d))); else p=Polynomial(Term(c1,Monomial(g.getRing(),2*e1/d)))+Polynomial(Term(c2,Monomial(g.getRing(),2*e2/d))); } } ret.push_back(p); } return ret; } PolynomialSet withVariablesEqual(PolynomialSet const &g, Polynomial const &b) { PolynomialSet ret(g.getRing()); PolynomialSet B(g.getRing()); B.push_back(b); LexicographicTermOrder T; B.markAndScale(T); for(PolynomialSet::const_iterator i=g.begin();i!=g.end();i++) { ret.push_back(division(*i,B,T)); } // ret.push_back(); return ret; } PolynomialSet binomialReduce(PolynomialSet g) { PolynomialSet binomials(g.getRing()); for(PolynomialSet::const_iterator i=g.begin();i!=g.end();i++) if(i->numberOfTerms()==2)binomials.push_back(*i); for(PolynomialSet::const_iterator i=binomials.begin();i!=binomials.end();i++) { g=withVariablesEqual(g,*i); g.saturate(); } for(PolynomialSet::const_iterator i=binomials.begin();i!=binomials.end();i++) { g.push_back(*i); } return g; } void processSingle(PolynomialSet g, int N) { /* Om facstd() i Singular: Hvis to trinomiumsfaktorer afsluttes beregningen efter 6min med 97 baser Hvis foerste er binomium og andet trinomium afsluttes beregningen efter 5 min med 46 baser Hvis foerste er trionomium og andet binomium afsluttes efter 12 sek med 34 baser. Hvis begger er binomier afsluttes efter 1 sek med 29 baser. */ //g.push_back(StringParser("r35^1-r25^1").parsePolynomial(g.getRing()));//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // g.push_back(StringParser("r35^2+r35*r25+r25^2").parsePolynomial(g.getRing()));//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //g.push_back(StringParser("r45^1-r15^1").parsePolynomial(g.getRing()));//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // g.push_back(StringParser("r45^2+r45*r15+r15^2").parsePolynomial(g.getRing()));//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // g.push_back(StringParser("r34^1-r24^1").parsePolynomial(g.getRing()));//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // g.push_back(StringParser("r342+r24r34+r242").parsePolynomial(g.getRing()));//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // g.push_back(StringParser("r35^1-r25^1").parsePolynomial(g.getRing()));//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // g.push_back(StringParser("r352+r25r35+r252").parsePolynomial(g.getRing()));//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! /*g.push_back(StringParser("r452+r45r35+r352").parsePolynomial(g.getRing()));//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! g.push_back(StringParser("r342+r34r23+r232").parsePolynomial(g.getRing()));//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! g.push_back(StringParser("r352+r25r35+r252").parsePolynomial(g.getRing()));//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ /* PolynomialSet additional=StringParser( "{r25^3*r34^3-r25^3*r34^3*r35^3-r24^3*r35^3+r24^3*r34^3*r35^3+r24^3*r25^3*r35^3-r24^3*r25^3*r34^3," "-r13^3*r15^3*r34^3*r45^3+r13^3*r15^3*r34^3*r35^3*r45^3+r13^3*r14^3*r35^3*r45^3-r13^3*r14^3*r34^3*r35^3*r45^3-r13^3*r14^3*r15^3*r35^3*r45^3+r13^3*r14^3*r15^3*r34^3*r45^3," "-r12^3*r15^3*r24^3*r45^3+r12^3*r15^3*r24^3*r25^3*r45^3+r12^3*r14^3*r25^3*r45^3-r12^3*r14^3*r24^3*r25^3*r45^3-r12^3*r14^3*r15^3*r25^3*r45^3+r12^3*r14^3*r15^3*r24^3*r45^3," "-r12^3*r15^3*r23^3*r35^3+r12^3*r15^3*r23^3*r25^3*r35^3+r12^3*r13^3*r25^3*r35^3-r12^3*r13^3*r23^3*r25^3*r35^3-r12^3*r13^3*r15^3*r25^3*r35^3+r12^3*r13^3*r15^3*r23^3*r35^3," "-r12^3*r14^3*r23^3*r34^3+r12^3*r14^3*r23^3*r24^3*r34^3+r12^3*r13^3*r24^3*r34^3-r12^3*r13^3*r23^3*r24^3*r34^3-r12^3*r13^3*r14^3*r24^3*r34^3+r12^3*r13^3*r14^3*r23^3*r34^3}").parsePolynomialSet(g.getRing()); for(PolynomialSet::const_iterator i=additional.begin();i!=additional.end();i++) g.push_back(*i); */ //"-r14^3+r14^3*r34^3+r13^3-r13^3*r34^3" // g.push_back(StringParser("r14^3-r13^3").parsePolynomial(g.getRing()));//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // g.push_back(StringParser("r343-1").parsePolynomial(g.getRing()));//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //g.push_back(StringParser("r143-1").parsePolynomial(g.getRing()));//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // g.push_back(StringParser("r34-1").parsePolynomial(g.getRing()));//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! /*{//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PolynomialSet g2(g.getRing()); for(PolynomialSet::const_iterator i=g.begin();i!=g.end();i++) if(i->totalDegree()<20 && i->numberOfTerms()!=6 && i->numberOfTerms()<10 )g2.push_back(*i); g=g2; }*/ AsciiPrinter P(Stderr); g.saturate(); P<numberOfTerms()!=0)G2.push_back(*i); P<<"Intersection"<=0;i--) { cerr << i << endl; g2=saturationHomog(g2,i); { PolynomialSet G=g2.polynomialRingIntersection(r3); PolynomialSet G2(G.getRing()); for(PolynomialSet::const_iterator i=G.begin();i!=G.end();i++)if(i->numberOfTerms()!=0)G2.push_back(*i); P<<"Intersection"< > cones=inFile.readMatrixIncidenceProperty("CONES_COMPRESSED"); IntegerVectorList r; for(int i=0;i::const_iterator j=cones[i].begin();j!=cones[i].end();j++) { int sign=rays[*j].sum(); if(sign<0)hasNeg=true; if(sign>0)hasPos=true; v+=rays[*j]; } //r.push_front(v); if(hasPos ||((!hasPos)&&(!hasNeg))) { r.push_back(v); P.printInteger(r.size()-1); P<embeddedInto(ac.getRing())); if(dziobek) { PolynomialSet dziobek=DziobekEquations(ac.getRing(),N,true); for(PolynomialSet::const_iterator i=dziobek.begin();i!=dziobek.end();i++)all.push_back(*i); } PolynomialSet d=nbodyDeterminants(ac.getRing(),N,true,5); for(PolynomialSet::const_iterator i=d.begin();i!=d.end();i++)all.push_back(*i); if(massEquations)all.push_back(massEquation(ac.getRing(),N,true)); P<<"ALL\n"< #include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "lp.h" #include "gfanapplication.h" #include "polyhedralcone.h" #include "tropical2.h" #include "nbody.h" #include "polymakefile.h" #include "determinant.h" #include "subspace.h" #include "triangulation.h" #include "groebnerengine.h" class SmalesSixth2Application : public GFanApplication { StringOption inputOption; SimpleOption singleOption; public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program solves ........\n"; } SmalesSixth2Application(): inputOption("-i","Specify the name of the input file.","examples/nbody/5ACAC.out"), singleOption("-s","Chekc just a single initial system.") { registerOptions(); } const char *name() { return "_smalessixth2"; } void printIntList(list const &v) { FILE *f=Stderr; fprintf(f,"{"); for(list::const_iterator i=v.begin();i!=v.end();i++) { if(i!=v.begin())fprintf(f," "); fprintf(f,"%i",*i); } fprintf(f,"}\n"); } void printIntListList(list > const &l) { for(list >::const_iterator i=l.begin();i!=l.end();i++) printIntList(*i); } PolynomialSet saturationHomog(PolynomialSet const &g, int i) { WeightReverseLexicographicTermOrder T(-1*IntegerVector::standardVector(g.getRing().getNumberOfVariables(),i)); PolynomialSet g2=GE_groebnerBasis(g,T,false); // g2.saturate(i); g2.saturate(); return g2; } PolynomialSet removePositiveFactors(PolynomialSet const &g) { PolynomialSet ret(g.getRing()); for(PolynomialSet::const_iterator i=g.begin();i!=g.end();i++) { Polynomial p=*i; if(p.numberOfTerms()==2) { FieldElement c1=p.terms.begin()->second; FieldElement c2=p.terms.rbegin()->second; IntegerVector e1=p.terms.begin()->first.exponent; IntegerVector e2=p.terms.rbegin()->first.exponent; if((c1+c2).isZero()) { int d=gcdOfVector(concatenation(e1,e2)); if(d&1) p=Polynomial(Term(c1,Monomial(g.getRing(),e1/d)))+Polynomial(Term(c2,Monomial(g.getRing(),e2/d))); else p=Polynomial(Term(c1,Monomial(g.getRing(),2*e1/d)))+Polynomial(Term(c2,Monomial(g.getRing(),2*e2/d))); } } ret.push_back(p); } return ret; } PolynomialSet withVariablesEqual(PolynomialSet const &g, Polynomial const &b) { PolynomialSet ret(g.getRing()); PolynomialSet B(g.getRing()); B.push_back(b); LexicographicTermOrder T; B.markAndScale(T); for(PolynomialSet::const_iterator i=g.begin();i!=g.end();i++) { ret.push_back(division(*i,B,T)); } // ret.push_back(); return ret; } PolynomialSet binomialReduce(PolynomialSet g) { PolynomialSet binomials(g.getRing()); for(PolynomialSet::const_iterator i=g.begin();i!=g.end();i++) if(i->numberOfTerms()==2)binomials.push_back(*i); for(PolynomialSet::const_iterator i=binomials.begin();i!=binomials.end();i++) { g=withVariablesEqual(g,*i); g.saturate(); } for(PolynomialSet::const_iterator i=binomials.begin();i!=binomials.end();i++) { g.push_back(*i); } return g; } void processSingle(PolynomialSet g, int N) { {//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PolynomialSet g2(g.getRing()); for(PolynomialSet::const_iterator i=g.begin();i!=g.end();i++) if(i->totalDegree()<20 && i->numberOfTerms()!=6 && i->numberOfTerms()<10 )g2.push_back(*i); g=g2; } AsciiPrinter P(Stderr); g.saturate(); P<numberOfTerms()!=0)G2.push_back(*i); P<<"Intersection"<=0;i--) { cerr << i << endl; g2=saturationHomog(g2,i); { PolynomialSet G=g2.polynomialRingIntersection(r3); PolynomialSet G2(G.getRing()); for(PolynomialSet::const_iterator i=G.begin();i!=G.end();i++)if(i->numberOfTerms()!=0)G2.push_back(*i); P<<"Intersection"<429)return true; if(I==41 || I==48 || I==180 || I==223 || I==235 || I==236 || I==264 || I==418 || I==419 || I==420 || I==421)return true; if(I==41 || I==48 || I==110 || I==143 || I==175 || I==180 || I==189 || I==192 || I==193 || I==198 || I==228 || I==232 || I==235 || I==236 || I==254 || I==264 || I==270 || I==298 || I==342 || I==399 || I==400 || I==418 || I==419 || I==420 || I==421 || (I==423) || (I==424) || (I==425) || (I==426) || I==427 || I==428 || I==428 || I==429)return true; if(I==22 || I==23 || I==30 || I==36 || I==54 || I==61 || I==64 || I==108 || I==149 || I==161 || I==162 || I==172 || I==173 || I==174 || I==177 || I==178 || (I==187) || I==190 || I==191 || I==194 || I==195 || I==204 || I==206 || I==207 || I==209 || I==211 || I==212 || I==213 || I==214 || I==217 || I==219 || I==222 || I==224 || (I==225) || I==230 || (I==233) || I==234 || I==241 || (I==244) || I==246 || I==249 || I==255 || I==257 || I==263 || I==271 || I==283 || I==338 || I==339 || I==345 || I==360 || I==396 || I==397 || I==398 || I==401 || I==404 || I==409 || I==410 || I==415)return true; return false; } int main() { int N=5; LpSolver::printList(Stderr); lpSetSolver("cddgmp"); if(singleOption.getValue()) { PolynomialSet g=FileParser(Stdin).parsePolynomialSetWithRing(); processSingle(g,N); return 0; } AsciiPrinter P(Stderr); // cerr<< "Simplified"< > cones=inFile.readMatrixIncidenceProperty("CONES_COMPRESSED"); // P<embeddedInto(ac.getRing())); P<<"ALL\n"< skipped; int I=cones.size()-1; for(int i=0;i::const_iterator j=cones[i].begin();j!=cones[i].end();j++) { v+=rays[*j]; if(dotLong(IntegerVector::allOnes(n),rays[*j])>=0)hasNegativeSum=true; raySubset.push_back(rays[*j]); } AsciiPrinter(Stderr)< #include "parser.h" #include "printer.h" #include "polynomial.h" #include "buchberger.h" #include "reversesearch.h" #include "termorder.h" #include "genericwalk.h" #include "gfanapplication.h" #include "timer.h" #include "tropical2.h" #include "log.h" #include "field_rationals.h" class SPolynomialApplication : public GFanApplication { SimpleOption optionTakeInitialForms; public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program takes a list of polynomials and a weight vector. The output is the set of all...\n"; } SPolynomialApplication(): optionTakeInitialForms("-f",".\n") { registerOptions(); } const char *name() { return "_spolynomial"; } int main() { PolynomialSet g=FileParser(Stdin).parsePolynomialSetWithRing(); IntegerVector w=FileParser(Stdin).parseIntegerVector(); // WeightReverseLexicographicTermOrder T(w); WeightTermOrder T(w); g.markAndScale(T); PolynomialSet out(g.getRing()); int I=0; for(PolynomialSet::const_iterator i=g.begin();i!=g.end();i++,I++) { int J=0; for(PolynomialSet::const_iterator j=g.begin();j!=i;j++,J++) { Polynomial s=sPolynomial(*i,*j); IntegerVector cancelingTerm=max(i->getMarked().m.exponent,j->getMarked().m.exponent); int cancelDegree=dotLong(cancelingTerm,w); if(optionTakeInitialForms.getValue()) { if(cancelDegree!=s.degree(w)) { out.push_back(initialForm(s,w)); if(initialForm(s,w).numberOfTerms()<=8)cerr<<"S("<numberOfTerms() << " "; if(i->numberOfTerms()<=8) { AsciiPrinter(Stdout)<<"\n"<< *i<<"\n"; out2.push_back(*i); } } out2.saturate(); out2=out2.embeddedInto(PolynomialRing(Q,15)); AsciiPrinter(Stdout).printPolynomialRing(out2.getRing()); AsciiPrinter(Stdout).printPolynomialSet(out2); return 0; } }; static SPolynomialApplication theApplication; gfan-0.5+dfsg/app_stats.cpp000066400000000000000000000045231207563005400157200ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "reversesearch.h" #include "polyhedralfan.h" #include "breadthfirstsearch.h" #include "termorder.h" #include "ep_standard.h" #include "ep_xfig.h" #include "gfanapplication.h" #include "timer.h" class StatsApplication : public GFanApplication { public: const char *helpText() { return "This program takes a list of reduced Groebner bases for the same ideal and computes various statistics. The following information is listed: the number of bases in the input, the number of variables, the dimension of the homogeneity space, the maximal total degree of any polynomial in the input and the minimal total degree of any basis in the input, the maximal number of polynomials and terms in a basis in the input.\n"; } StatsApplication() { registerOptions(); } const char *name() { return "_stats"; } int main() { FileParser p(Stdin); PolynomialRing theRing=p.parsePolynomialRing(); int c=p.nextNonBlank(); int dmin=-1; int dmax=-1; int homog=-1; int n=-1; int maxNumberOfTerms=-1; int maxNumberOfPolynomials=-1; int counter=0; assert(p.isLeftBracket(c)); do { PolynomialSet g=p.parsePolynomialSet(theRing); if(homog==-1) { n=g.numberOfVariablesInRing(); homog=dimensionOfHomogeneitySpace(g); } int d=g.totalDegree(); if(dmin==-1 || ddmax)dmax=d; if(maxNumberOfTerms<(int)g.totalNumberOfTerms())maxNumberOfTerms=(int)g.totalNumberOfTerms(); if(maxNumberOfPolynomials<(int)g.size())maxNumberOfPolynomials=(int)g.size(); counter++; } while((c=p.nextNonBlank())==','); assert(p.isRightBracket(c)); fprintf(Stdout,"Number of reduced Groebner bases: %i\n",counter); fprintf(Stdout,"Number of variables: %i\n",n); fprintf(Stdout,"Dimension of homogeneity space: %i\n",homog); fprintf(Stdout,"Maximal total degree of a Groebner basis: %i\n",dmax); fprintf(Stdout,"Minimal total degree of a Groebner basis: %i\n",dmin); pout<<"Maximal number of polynomials in Groebner basis: "<evaluate(x)); AsciiPrinter(Stdout).printNewLine(); } } } return 0; } }; static SturmSequenceApplication theApplication; gfan-0.5+dfsg/app_substitute.cpp000066400000000000000000000022461207563005400167750ustar00rootroot00000000000000#include "vektor.h" #include "printer.h" #include "parser.h" #include "gfanapplication.h" typedef list StringList; class SubstituteApplication : public GFanApplication { public: const char *helpText() { return "This program changes the variable names of a polynomial ring. The input is a polynomial ring, a polynomial set in the ring and a new polynomial ring with the same coefficient field but different variable names. The output is the polynomial set written with the variable names of the second polynomial ring.\n" "Example:\n" "Input:\n" "Q[a,b,c,d]{2a-3b,c+d}Q[b,a,c,x]\n" "Output:\n" "Q[b,a,c,x]{2*b-3*a,c+x}\n"; } SubstituteApplication() { registerOptions(); } const char *name() { return "_substitute"; } int main() { FileParser P(Stdin); PolynomialRing r=P.parsePolynomialRing(); PolynomialSet s=P.parsePolynomialSet(r); PolynomialRing r2=P.parsePolynomialRing(); AsciiPrinter(Stdout).printPolynomialRing(r2); AsciiPrinter(Stdout).printNewLine(); AsciiPrinter(Stdout).printPolynomialSet(s.embeddedInto(r2)); return 0; } }; static SubstituteApplication theApplication; gfan-0.5+dfsg/app_supportindices.cpp000066400000000000000000000012611207563005400176310ustar00rootroot00000000000000#include "vektor.h" #include "printer.h" #include "parser.h" #include "gfanapplication.h" class SupportIndicesApplication : public GFanApplication { public: bool includeInDefaultInstallation() { return false; } SupportIndicesApplication() { registerOptions(); } const char *name() { return "_supportindices"; } int main() { FileParser P(Stdin); IntegerVector v=P.parseIntegerVector(); for(int i=0;i=2); SymmetryGroup signSymmetries(2*n); if(optionSymmetry.getValue()) { IntegerVectorList generators=P.parseIntegerVectorList(); IntegerMatrix torusAction(generators.size(),n); if(optionTorusSymmetry.getValue()) { torusAction=rowsToIntegerMatrix(P.parseIntegerVectorList()); } else { for(int i=0;i #include #include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "reversesearch.h" #include "termorder.h" #include "ep_standard.h" #include "ep_xfig.h" #include "polyhedralcone.h" #include "gfanapplication.h" #include "saturation.h" #include "field_rationals.h" #include "field_zmodpz.h" #include "field_rationalfunctions.h" #include "symmetry.h" #include "linalg.h" #include "fieldlp.h" class TestApplication : public GFanApplication { StringOption testSuiteFolderOption; StringOption executableOption; public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This runs the test suite and checks against the stored result. If no result exists, it is generated.\n"; } TestApplication(): testSuiteFolderOption("--suite","Specify the folder which contains the test suite.","testsuite"), executableOption("--gfan","Specify name of gfan executable to test.","./gfan") { registerOptions(); } const char *name() { return "_test"; } void lpRationalFunctionTest() { //int n=3; // IntegerVectorList L=StringParser("{(1,0,2),(1,2,0)}").parseIntegerVectorList(); // IntegerVectorList L=StringParser("{(1,2,0)}").parseIntegerVectorList(); // int n=4; // IntegerVectorList L=StringParser("{(1,0,2,3),(1,2,3,0)}").parseIntegerVectorList(); /* int n=16; IntegerVectorList L=StringParser("{(1,0,2,3,5,4,6,7,9,8,10,11,13,12,14,15)," "(3,0,1,2,7,4,5,6,11,8,9,10,15,12,13,14)," "(0,4,8,12,1,5,9,13,2,6,10,14,3,7,11,15)}").parseIntegerVectorList(); */ int n=9; IntegerVectorList L=StringParser("{(1,0,2,4,3,5,7,6,8)," "(1,2,0,4,5,3,7,8,6)," "(3,4,5,0,1,2,6,7,8)," "(3,4,5,6,7,8,0,1,2)" "}").parseIntegerVectorList(); /* int n=9; IntegerVectorList L=StringParser("{(1,0,2,4,3,5,7,6,8)," "(1,2,0,4,5,3,7,8,6)," "(0,3,6,1,4,7,2,5,8)}").parseIntegerVectorList(); */ SymmetryGroup s(n); s.computeClosure(L); FieldRationalFunctions F(Q,"t"); FieldMatrix M(F,s.elements.size(),n); int I=0; for(SymmetryGroup::ElementContainer::const_iterator i=s.elements.begin();i!=s.elements.end();i++,I++) { for(int j=0;j"+outputName; cerr<<"Running command:\""< subFolderNames() { #define tempName "GfAnTeMpTeStS" char command[256]; system("rm "tempName); sprintf(command,"ls %s>" tempName ,testSuiteFolderOption.getValue()); system(command); list ret; FILE *f=fopen(tempName,"r"); assert(f); char name[256]; while(fgets(name,255,f)) { for(int i=0;i<255 && name[i];i++)if(name[i]=='\n'){name[i]=0;} if(name[0]>='0' && name[0]<='9')ret.push_back(string(testSuiteFolderOption.getValue())+"/"+string(name)); } fclose(f); return ret; } int main() { // lpRationalFunctionTest(); // testRationalFunctionField(); list testFolders=subFolderNames(); list testList; for(list::const_iterator i=testFolders.begin();i!=testFolders.end();i++) { testList.push_back(TestCase(*i)); } cout<<"Number of tests to perform "<::iterator i=testList.begin();i!=testList.end();i++) if(i->perform(executableOption.getValue())) good++; else bad++; cout<<"Number of succesful tests "< using namespace std; class TropicalIntersectionTraverser: public ConeTraverser { PolynomialSet allPolys; PolynomialSet iForms; PolyhedralCone theCone; int n;//,d; int prime; bool collect; IntegerVectorList collection; void updatePolyhedralCone() { theCone=PolyhedralCone(fastNormals(wallInequalities(allPolys)),wallInequalities(iForms),n); theCone.canonicalize(); if(collect) { collection.push_back(theCone.getRelativeInteriorPoint()); int temp=collection.size(); if((temp&(2*(temp-1)))==temp)pout<<"RELINT:\n"<::const_iterator i=l.conesBegin();i!=l.conesEnd();i++) if(!(i->getUniquePoint().isZero()))ret.push_back(i->getUniquePoint()); assert(ret.size()>1); return ret; } PolyhedralCone & refToPolyhedralCone() { return theCone; } }; class TraverseTropicalIntersectionApplication : public GFanApplication { SimpleOption optionSymmetry; public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program \n"; } TraverseTropicalIntersectionApplication(): optionSymmetry("--symmetry","Do computations up to symmetry and group the output accordingly. If this option is used the program will read in a list of generators for a symmetry group after the other input.") { registerOptions(); } const char *name() { return "_traversetropicalintersection"; } int main() { FileParser P(Stdin); PolynomialSet a=P.parsePolynomialSetWithRing(); int n=a.getRing().getNumberOfVariables(); IntegerVector omega=P.parseIntegerVector(); { SymmetryGroup G(n); if(optionSymmetry.getValue()) { IntegerVectorList generators=P.parseIntegerVectorList(); G.computeClosure(generators); G.createTrie(); } SymmetricTargetFanBuilder target(n,G); TropicalIntersectionTraverser traverser(a,omega); symmetricTraverse(traverser,target,&G); AsciiPrinter Q(Stdout); target.getFanRef().printWithIndices(&Q, FPF_default); } return 0; } }; static TraverseTropicalIntersectionApplication theApplication; gfan-0.5+dfsg/app_triangulate.cpp000066400000000000000000000102501207563005400170730ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "lp.h" #include "gfanapplication.h" #include "polyhedralcone.h" #include "polymakefile.h" #include "determinant.h" #include "subspace.h" #include "triangulation.h" class TriangulateApplication : public GFanApplication { FieldOption theFieldOption; StringOption inputOption; StringOption outputOption; public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program ........\n"; } TriangulateApplication(): inputOption("-i","Specify the name of the input file.","polymake.out"), outputOption("-o","Specify the name of the output file.","polymake.out2") { registerOptions(); } const char *name() { return "_triangulate"; } void printIntList(list const &v) { FILE *f=Stderr; fprintf(f,"{"); for(list::const_iterator i=v.begin();i!=v.end();i++) { if(i!=v.begin())fprintf(f," "); fprintf(f,"%i",*i); } fprintf(f,"}\n"); } void printIntListList(list > const &l) { for(list >::const_iterator i=l.begin();i!=l.end();i++) printIntList(*i); } int main() { LpSolver::printList(Stderr); lpSetSolver("cddgmp"); PolymakeFile inFile; fprintf(Stderr,"Test\n"); inFile.open(inputOption.getValue()); fprintf(Stderr,"Test\n"); int n=inFile.readCardinalProperty("AMBIENT_DIM"); //int d=inFile.readCardinalProperty("DIM"); int nRays=inFile.readCardinalProperty("N_RAYS"); fprintf(Stderr,"%i %i\n",n,nRays); IntegerMatrix rays=inFile.readMatrixProperty("RAYS",nRays,n); {/* Make sure that representatives of rays are in the same subspace. */ IntegerVectorList rays2; IntegerMatrix linealitySpace=inFile.readMatrixProperty("LINEALITY_SPACE",nRays,n); Subspace l(linealitySpace.getRows(),linealitySpace.getWidth()); for(int i=0;i > cones=inFile.readMatrixIncidenceProperty("MAXIMAL_CONES_COMPRESSED"); IntegerVectorList r; for(int i=0;i::const_iterator j=cones[i].begin();j!=cones[i].end();j++) { //AsciiPrinter(Stderr).printVector(v);fprintf(Stderr,"%i\n",*j); v+=rays[*j]; //AsciiPrinter(Stderr).printVector(rays[*j]);fprintf(Stderr,"%i\n",*j); } r.push_back(v); } PolymakeFile outFile; outFile.create(outputOption.getValue(),"topaz","SimplicialComplex"); outFile.writeMatrixProperty("INTERIOR_POINTS",rowsToIntegerMatrix(r)); outFile.close(); }*/ // vector cones=inFile.readMatrixIncidenceProperty("MAXIMAL_CONES"); vector > cones=inFile.readMatrixIncidenceProperty("MAXIMAL_CONES"); for(vector >::const_iterator i=cones.begin();i!=cones.end();i++) printIntList(*i); AsciiPrinter(Stderr).printVectorList(rays.getRows()); vector simplicialComplex; // for(vector::const_iterator i=cones.begin();i!=cones.end();i++) for(vector >::const_iterator i=cones.begin();i!=cones.end();i++) { // fprintf(Stderr,"Triangulating:\n"); // printIntList(*i); // list coneList=Triangulation::triangulate(*i,rays); list coneList=Triangulation::triangulate(*i,rays); // fprintf(Stderr,"Result:\n"); for(list::const_iterator j=coneList.begin();j!=coneList.end();j++) { // printIntList(*j); simplicialComplex.push_back(*j); } } PolymakeFile outFile; outFile.create(outputOption.getValue(),"topaz","SimplicialComplex"); outFile.writeCardinalProperty("N_VERTICES",nRays); // outFile.writeCardinalProperty("DIM",d); outFile.writeIncidenceMatrixProperty("INPUT_FACES",Triangulation::removeOrientation(simplicialComplex),nRays); outFile.close(); return 0; } }; static TriangulateApplication theApplication; gfan-0.5+dfsg/app_tropicalbasis.cpp000066400000000000000000000060631207563005400174220ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "reversesearch.h" #include "termorder.h" #include "ep_standard.h" #include "ep_xfig.h" #include "gfanapplication.h" #include "polyhedralcone.h" #include "polyhedralfan.h" #include "tropical.h" #include "tropical2.h" #include "tropicalbasis.h" #include "log.h" class TropicalBasisApplication : public GFanApplication { SimpleOption optionHomogenize; public: const char *helpText() { return "This program computes a tropical basis for an ideal defining a tropical curve. Defining a tropical curve means that the Krull dimension of R/I is at most 1 + the dimension of the homogeneity space of I where R is the polynomial ring. The input is a generating set for the ideal. If the input is not homogeneous option -h must be used.\n"; } TropicalBasisApplication(): optionHomogenize("-h","Homogenise the input before computing a tropical basis and dehomogenise the output. This is needed if the input generators are not already homogeneous.") { registerOptions(); } const char *name() { return "_tropicalbasis"; } int main() { FileParser P(Stdin); /* StringParser P1("{1+76*a2*b*c+6*a2*c4+72*a*b3*c3," "46*b3*c+68*b3*a2*c+42*a3*c4+47*b6*a2}"); StringParser P2("{1-79ab^4-27b^3c^2+32a^4b^2c," "-36c-35b^3c^3+11a^4b^2c^2+90a^3b^6}"); */ PolynomialSet theInput=P.parsePolynomialSetWithRing(); PolynomialRing originalRing=theInput.getRing(); if(optionHomogenize.getValue()) { log1 fprintf(Stderr,"Homogenizing...\n"); IntegerVector grading=IntegerVector::allOnes(theInput.numberOfVariablesInRing()); /* { // It is not necessary to compute the true homogenization WeightReverseLexicographicTermOrder t(grading); buchberger(&theInput,t); }*/ PolynomialSet h=theInput.homogenization(theInput.getRing().withVariablesAppended("H")); wallInequalities(h); log1 fprintf(Stderr,"The homogenized ideal:\n"); log1 AsciiPrinter(Stderr).printPolynomialSet(h); theInput=h; } int n=theInput.numberOfVariablesInRing(); int homog=-1; { log1 debug.printString("Computing homogeneity space\n"); PolynomialSet idealGroebnerBasis=theInput; IntegerVector grading=IntegerVector::allOnes(theInput.numberOfVariablesInRing()); WeightReverseLexicographicTermOrder t(grading); buchberger(&idealGroebnerBasis,t); PolyhedralCone hspace=homogeneitySpace(idealGroebnerBasis); IntegerVectorList hv=hspace.dualCone().getEquations(); homog=hv.size(); log1 debug.printString("..done homogeneity space.\n"); } PolynomialSet theOutput=tropicalBasisOfCurve(n,theInput,0,homog); if(optionHomogenize.getValue()) { theOutput=theOutput.embeddedInto(originalRing); } AsciiPrinter(Stdout).printPolynomialRing(theOutput.getRing()); AsciiPrinter(Stdout).printNewLine(); AsciiPrinter(Stdout).printPolynomialSet(theOutput); return 0; } }; static TropicalBasisApplication theApplication; gfan-0.5+dfsg/app_tropicalbruteforce.cpp000066400000000000000000000063601207563005400204610ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "reversesearch.h" #include "polyhedralfan.h" #include "breadthfirstsearch.h" #include "termorder.h" #include "ep_standard.h" #include "ep_xfig.h" #include "gfanapplication.h" #include "timer.h" #include "dimension.h" #include "tropical.h" #include "tropical2.h" #include "log.h" class TropicalBruteForceApplication : public GFanApplication { //SimpleOption OptionTPlane; public: const char *helpText() { return "This program takes a marked reduced Groebner basis for a homogeneous ideal and computes the tropical " "variety of the ideal as a subfan of the Groebner fan. " "The program is slow but works for any homogeneous ideal. If " "you know that your ideal is prime over the complex numbers or you " "simply know that its tropical variety is pure and connected in " "codimension one then use gfan_tropicalstartingcone and " "gfan_tropicaltraverse instead.\n"; } TropicalBruteForceApplication() { registerOptions(); } const char *name()//: // OptionTPlane("--tplane","This option intersect the resulting { return "_tropicalbruteforce"; } int main() { FileParser p(Stdin); PolynomialRing r=p.parsePolynomialRing(); PolynomialSet G=p.parsePolynomialSet(r); if(!isMarkingConsistent(G)) { fprintf(Stderr,"Input polynomial set is not marked consistently.\n"); assert(0); } if(!isMarkedGroebnerBasis(G)) { fprintf(Stderr,"Input polynomial set is not a marked Groebner basis.\n"); assert(0); } autoReduce(&G, LexicographicTermOrder()); int homog=dimensionOfHomogeneitySpace(G); int n=r.getNumberOfVariables(); IntegerVector f=IntegerVector(n-homog+1); IntegerVector fTrop=IntegerVector(n-homog+1); // ReverseLexicographicTermOrder A; LexicographicTermOrder A; ReverseSearch rs(A); EnumerationTargetCollector C; rs.setEnumerationTarget(&C); rs.enumerate(G); PolynomialSetList glist=C.getList(); PolyhedralFan result(n); for(PolynomialSetList::const_iterator j=glist.begin();j!=glist.end();j++) { PolynomialSet g=*j; PolyhedralCone c=groebnerCone(g,true); PolyhedralFan F(n); F.insert(c); for(int i=0;idegree(m[i]); } AsciiPrinter(Stdout).printVectorList(result.getRows()); return 0; } }; static TropicalEvaluationApplication theApplication; gfan-0.5+dfsg/app_tropicalfunction.cpp000066400000000000000000000026411207563005400201440ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "reversesearch.h" #include "termorder.h" #include "ep_standard.h" #include "ep_xfig.h" #include "gfanapplication.h" #include "polyhedralcone.h" #include "polyhedralfan.h" #include "tropical.h" #include "tropical2.h" #include "symmetry.h" #include "halfopencone.h" #include "log.h" class TropicalFunctionApplication : public GFanApplication { public: const char *helpText() { return "This program takes a polynomial and tropicalizes it. The output is piecewise linear function represented by a fan whose cones are the linear regions. Each ray of the fan gets the value of the tropical function assigned to it. In other words this program computes the normal fan of the Newton polytope of the input polynomial with additional information."; } TropicalFunctionApplication() { registerOptions(); } const char *name() { return "_tropicalfunction"; } int main() { FileParser P(Stdin); PolynomialSet f=P.parsePolynomialSetWithRing(); int n=f.numberOfVariablesInRing(); PolyhedralFan F=PolyhedralFan::normalFanOfNewtonPolytope(*f.begin()); { AsciiPrinter p(Stdout); PolyhedralFan a=F; a.printWithIndices(&p,FPF_default|FPF_values); } return 0; } }; static TropicalFunctionApplication theApplication; gfan-0.5+dfsg/app_tropicalhypersurface.cpp000066400000000000000000000024671207563005400210250ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "reversesearch.h" #include "termorder.h" #include "ep_standard.h" #include "ep_xfig.h" #include "gfanapplication.h" #include "polyhedralcone.h" #include "polyhedralfan.h" #include "tropical.h" #include "tropical2.h" #include "symmetry.h" #include "halfopencone.h" #include "log.h" class TropicalHypersurfaceApplication : public GFanApplication { public: const char *helpText() { return "This program computes the tropical hypersurface defined by a principal" " ideal. The input is the polynomial ring followed by a set containing" " just a generator of the ideal."; } TropicalHypersurfaceApplication() { registerOptions(); } const char *name() { return "_tropicalhypersurface"; } int main() { FileParser P(Stdin); PolynomialSet f=P.parsePolynomialSetWithRing(); int n=f.numberOfVariablesInRing(); assert(f.size()==1); PolyhedralFan F=PolyhedralFan::bergmanOfPrincipalIdeal(*f.begin()); { AsciiPrinter p(Stdout); PolyhedralFan a=F; a.printWithIndices(&p,FPF_default|FPF_values|FPF_multiplicities); } return 0; } }; static TropicalHypersurfaceApplication theApplication; gfan-0.5+dfsg/app_tropicalimage.cpp000066400000000000000000000026551207563005400174060ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "lp.h" #include "gfanapplication.h" #include "polyhedralcone.h" #include "polyhedralfan.h" #include "polymakefile.h" #include "tropicalmap.h" class TropicalImageApplication : public GFanApplication { StringOption inputOption; public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program computes the image of the tropicalization of a polynomial map. The output is a polyhedral fan with support equal to the image. The input is the polynomial ring, followed by a list of coordinate polynomials. A domain different from $R^n$ can be chosen with the option -i.\n"; } TropicalImageApplication(): inputOption("-i","Specify the name of the file containing a polyhedral fan whose support is the domain of the function.",0) { registerOptions(); } const char *name() { return "_tropicalimage"; } int main() { PolynomialSet g=FileParser(Stdin).parsePolynomialSetWithRing(); int n=g.getRing().getNumberOfVariables(); PolyhedralFan domain=PolyhedralFan::fullSpace(n); if(inputOption.getValue()) { domain=PolyhedralFan::readFan(inputOption.getValue()); } PolyhedralFan f=imageOfTropicalMap(g,domain); AsciiPrinter P(Stdout); f.printWithIndices(&P,FPF_default|FPF_multiplicities/*|FPF_values*/); return 0; } }; static TropicalImageApplication theApplication; gfan-0.5+dfsg/app_tropicalintersection.cpp000066400000000000000000000256351207563005400210350ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "reversesearch.h" #include "termorder.h" #include "ep_standard.h" #include "ep_xfig.h" #include "gfanapplication.h" #include "polyhedralcone.h" #include "polyhedralfan.h" #include "tropical.h" #include "tropical2.h" #include "symmetry.h" #include "halfopencone.h" #include "symmetrictraversal.h" #include "traverser_groebnerfan.h" #include "tropical_weildivisor.h" #include "log.h" class SymmetricTargetTropicalBasisTester : public SymmetricTarget { public: PolynomialSet g; SymmetricTargetTropicalBasisTester(PolynomialSet const &g_): g(g_) { } bool process(ConeTraverser &traverser) { IntegerVector w=traverser.refToPolyhedralCone().getRelativeInteriorPoint(); log2 AsciiPrinter(Stderr) << "Testing weight vector:\n"<isZero())) { AsciiPrinter(Stdout).printVector(*i); fprintf(Stdout," :"); AsciiPrinter(Stdout).printInteger(multiplicity(initialIdeal(theInput,*i))); fprintf(Stdout,"\n"); } } } int t=optionNumberOfNegativeVariables.getValue(); assert(t<=n); IntegerVectorList equations,inequalities; for(int i=0;i=0)isNeg=false; } if(isNeg) { AsciiPrinter(Stdout).printVector(v);fprintf(Stdout,"\n"); } } return 0; } }; static TropicalLiftingApplication theApplication; gfan-0.5+dfsg/app_tropicallinearspace.cpp000066400000000000000000000213641207563005400206100ustar00rootroot00000000000000#include "vektor.h" #include "printer.h" #include "parser.h" #include "gfanapplication.h" #include "minors.h" #include "field_rationals.h" #include #include #include #include #include "regularsubdivision.h" #include "lp.h" using namespace std; static int64 fak(int a) { if(a==0)return 1; return a*fak(a-1); } static int choose(int n, int d) { return fak(n)/fak(n-d)/fak(d); } static int isInEdge(int v, pair edge) { if(edge.first==v)return edge.second; if(edge.second==v)return edge.first; return -1; } static int isLeaf(int v, list > edges) //returns parent { int c=0; int parent=0; for(list >::const_iterator i=edges.begin();i!=edges.end();i++) { if(isInEdge(v,*i)>=0) { c++; parent=isInEdge(v,*i); } } if(c<=1)return parent; return -1; } static int isCherry(int v, list > edges) { int parent=isLeaf(v,edges); if(parent<0)return -1; int count=0; int other=-1; for(list >::const_iterator i=edges.begin();i!=edges.end();i++) { if(isInEdge(parent,*i)>=0) { int child=isInEdge(parent,*i); //fprintf(stderr,"in edge v:%i p:%i c:%i childleaf?%i\n",v,parent,child,isLeaf(child,edges)); if((v!=child) && (isLeaf(child,edges)>=0)) { count++; other=child; } } } if(count==1)return other; return -1; } list treeStrings(int d, int n, IntegerVector const &v) { list ret; IntegerVector w(choose(n-1,d-1)); for(int k=0;k I; IntegerVector p(n-1); for(int i=0;i > subd=regularSubdivision(hyperSimplex2,w); // printSetSetInt(Stderr,subd); vector vertexLabels(subd.size()+n-1); vector vertexCell(subd.size()+n-1); int J=0; for(int j=0;j >::const_iterator K=subd.begin();K!=subd.end();K++) { vertexLabels[J++]='I'; for(set::const_iterator L=K->begin();L!=K->end();L++) vertexCell[J-1].push_back(hyperSimplex2[*L]); } /* for(int i=0;i > edges; for(int b=0;b(a,b)); } } /* for(list >::const_iterator j=edges.begin();j!=edges.end();j++) { fprintf(Stderr,"%i %i\n",j->first,j->second); } */ set allLeafs; set allCherries; int numberOfCherries=0; for(int i=0;i=0) { allCherries.insert(i); numberOfCherries++; } if(isLeaf(i,edges)>=0)allLeafs.insert(i); } stringstream s; if(n==7 && numberOfCherries==6) { set left=allLeafs; //fprintf(Stdout,"S("); s << "S("; while(left.size()) { int a=*left.begin(); int b=isCherry(a,edges); left.erase(a); left.erase(b); //fprintf(Stdout,"%c%c",vertexLabels[a],vertexLabels[b]); s << vertexLabels[a] << vertexLabels[b]; if(left.size()) //fprintf(Stdout,","); s << ","; } //fprintf(Stdout,")\n"); s << ")"; } else if(n==7 && numberOfCherries==4) { set leftCherries=allCherries; set left=allLeafs; int a=*leftCherries.begin(); int b=isCherry(a,edges); leftCherries.erase(a); leftCherries.erase(b); int e=*leftCherries.begin(); int f=isCherry(e,edges); int ab=isLeaf(a,edges); set allConnections; for(list >::const_iterator i=edges.begin();i!=edges.end();i++) if(isInEdge(ab,*i)>=0)allConnections.insert(isInEdge(ab,*i)); allConnections.erase(a); allConnections.erase(b); int C=*allConnections.begin(); int c=-1; for(list >::const_iterator i=edges.begin();i!=edges.end();i++) if(isInEdge(C,*i)>=0) if(isLeaf(isInEdge(C,*i),edges)>=0)c=isInEdge(C,*i); left.erase(a); left.erase(b); left.erase(c); left.erase(e); left.erase(f); int d=*left.begin(); //fprintf(Stdout,"C(%i%i,%i%i,%i%i)\n",a,b,c,d,e,f); // fprintf(Stdout,"C(%c%c,%c%c,%c%c)\n",vertexLabels[a],vertexLabels[b],vertexLabels[c],vertexLabels[d],vertexLabels[e],vertexLabels[f]); s<<"C("<< vertexLabels[a] << vertexLabels[b] << "," << vertexLabels[c] << vertexLabels[d] <<","< v) { int ret=0; for(int i=0;i s=treeStrings(d,n,v); for(list::const_iterator i=s.begin();i!=s.end();i++) fprintf(stderr,"%s\n",i->c_str()); } else { vector names=vectorVariableNames("x",n); vector names2(names.size()+1); for(int i=0;i I; for(int i=0;i J=I; J[jr]=1-J[jr]; tExponent+=sign*v[permutationIndex(J)]; IntegerVector exponentVector(n+1); exponentVector[jr+1]=1; exponentVector[0]=tExponent; p+=Term(R.getField().zHomomorphism(1),Monomial(R,exponentVector)); } ret.push_back(p); } while(prev_permutation(I.begin(),I.end())); } AsciiPrinter(Stdout).printPolynomialRing(R); AsciiPrinter(Stdout).printPolynomialSet(ret); } return 0; } }; static TropicalLinearSpaceApplication theApplication; gfan-0.5+dfsg/app_tropicalmultiplicity.cpp000066400000000000000000000015761207563005400210550ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "gfanapplication.h" #include "multiplicity.h" #include "lp.h" #include "saturation.h" #include "log.h" class TropicalMultiplicityApplication : public GFanApplication { public: const char *helpText() { return "This program computes the multiplicity of a tropical cone given a marked reduced Groebner basis for its initial ideal.\n"; } TropicalMultiplicityApplication() { registerOptions(); } const char *name() { return "_tropicalmultiplicity"; } int main() { PolynomialSet g=FileParser(Stdin).parsePolynomialSetWithRing(); log1 AsciiPrinter(Stdout).printPolynomialSet(nonHomogeneousSaturation(g)); AsciiPrinter(Stdout).printInteger(multiplicity(g)); AsciiPrinter(Stdout).printNewLine(); return 0; } }; static TropicalMultiplicityApplication theApplication; gfan-0.5+dfsg/app_tropicalrank.cpp000066400000000000000000000040131207563005400172450ustar00rootroot00000000000000#include "vektor.h" #include "printer.h" #include "parser.h" #include "gfanapplication.h" #include "minors.h" #include "field_rationals.h" #include "tropical2.h" #include "matrix.h" #include "buchberger.h" #include "tropicaldeterminant.h" class TropicalRankApplication : public GFanApplication { SimpleOption optionKapranov; SimpleOption optionDeterminant; public: const char *helpText() { return "This program will compute the tropical rank of matrix given as input. Tropical addition is MAXIMUM.\n"; } TropicalRankApplication(): optionKapranov("--kapranov","Compute Kapranov rank instead of tropical rank."), optionDeterminant("--determinant","Compute the tropical determinant instead.") { registerOptions(); } const char *name() { return "_tropicalrank"; } int main() { FileParser P(Stdin); IntegerMatrix m=rowsToIntegerMatrix(P.parseIntegerVectorList()); if(optionDeterminant.getValue()) { // tropicalDeterminantTest(); pout<n?n:d; for(int r=1;r<=min;r++) { PolynomialRing R(Q,matrixVariableNames("m",d,n)); PolynomialSet p=minors(R,r,d,n,false,false); if(optionKapranov.getValue()) { WeightReverseLexicographicTermOrder T(w); buchberger(&p,T); } PolynomialSet q=initialForms(p,w); bool containsMonomial=false; for(PolynomialSet::const_iterator i=q.begin();i!=q.end();i++) if(i->isMonomial()) { containsMonomial=true; break; } fprintf(Stderr,"%ix%i picks monomial: %s %i\n",r,r,containsMonomial?"true, meaning that rank is >":"false, meaning that rank is <=",r-1); if(!containsMonomial) { theRank=r-1; break; } } if(theRank==-1) theRank=min; AsciiPrinter(Stdout).printInteger(theRank); AsciiPrinter(Stdout).printNewLine(); return 0; } }; static TropicalRankApplication theApplication; gfan-0.5+dfsg/app_tropicalstartingcone.cpp000066400000000000000000000055561207563005400210270ustar00rootroot00000000000000#include "vektor.h" #include "printer.h" #include "parser.h" #include "gfanapplication.h" #include "minkowskisum.h" #include "newtonpolytope.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "tropical.h" #include "division.h" #include "bergman.h" #include "tropical2.h" #include "dimension.h" #include "timer.h" #include "log.h" class TropicalStartingConeApplication : public GFanApplication { SimpleOption useThisConeOption; SimpleOption dimensionOption; SimpleOption optionStableIntersection; public: bool includeInDefaultInstallation() { return true; } const char *helpText() { return "This program attempts to compute a starting pair of marked reduced Groebner bases to be used as input for gfan_tropicaltraverse. If unsuccessful the program will say so. The input is a homogeneous ideal whose tropical variety is a pure d-dimensional polyhedral complex.\n"; } TropicalStartingConeApplication(): useThisConeOption("-g","Tell the program that the input is already a reduced Groebner basis."), dimensionOption("-d","Output dimension information to standard error."), optionStableIntersection("--stable","Find starting cone in the stable intersection or, equivalently, pretend that the coefficients are genereric.") { registerOptions(); } const char *name() { return "_tropicalstartingcone"; } int main() { lpSetSolver("cddgmp"); FileParser P(Stdin); PolynomialSet g=P.parsePolynomialSetWithRing(); if(!useThisConeOption.getValue() && !optionStableIntersection.getValue()) { buchberger(&g,StandardGradedLexicographicTermOrder()); } // assert(!containsMonomial(g)); if(dimensionOption.getValue()) { fprintf(Stderr,"Krull dimension of input ideal: %i\n",krullDimension(g)); fprintf(Stderr,"Dimension of homogeneity space for full ideal: %i\n",dimensionOfHomogeneitySpace(g)); } PolynomialSet fullBasis(g.getRing()); log0 fprintf(Stderr,"guessing..\n"); PolynomialSet g2=(optionStableIntersection.getValue())? guessInitialIdealWithoutMonomialStably(g,&fullBasis,false): guessInitialIdealWithoutMonomial(g,&fullBasis,false); // PolynomialSet g2=guessInitialIdealWithoutMonomial(g,&fullBasis,true); //CHANGETHIS to false if(dimensionOption.getValue()) { fprintf(Stderr,"Krull dimension of input ideal: %i\n",krullDimension(g)); fprintf(Stderr,"Dimension of homogeneity space for full ideal: %i\n",dimensionOfHomogeneitySpace(g)); fprintf(Stderr,"Dimension of homogeneity space for initial ideal: %i\n",dimensionOfHomogeneitySpace(g2)); } AsciiPrinter(Stdout).printPolynomialRing(g2.getRing()); AsciiPrinter(Stdout).printNewLine(); AsciiPrinter(Stdout).printPolynomialSet(g2); AsciiPrinter(Stdout).printPolynomialSet(fullBasis); return 0; } }; static TropicalStartingConeApplication theApplication; gfan-0.5+dfsg/app_tropicaltraverse.cpp000066400000000000000000000227711207563005400201600ustar00rootroot00000000000000#include "vektor.h" #include "printer.h" #include "parser.h" #include "gfanapplication.h" #include "minkowskisum.h" #include "newtonpolytope.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "tropical.h" #include "division.h" #include "bergman.h" #include "tropical2.h" #include "dimension.h" #include "timer.h" #include "log.h" #include "linalg.h" #include "tropicaltraverse.h" #include "traverser_tropical.h" #include "symmetrictraversal.h" #include "traverser_stableintersection.h" class TropicalTraverseApplication : public GFanApplication { // SimpleOption optionPerformanceTimer; SimpleOption optionSymmetry; // SimpleOption optionNoIncidencePrinting; SimpleOption optionTorusSymmetry; SimpleOption optionIgnoreCones; SimpleOption optionDisableSymmetryTest; SimpleOption optionStableIntersection; // SimpleOption optionInitialIdealPrinting; // SimpleOption optionLargeDimensionalPrinting; public: bool includeInDefaultInstallation() { return true; } const char *helpText() { return "This program computes a polyhedral fan representation of the tropical variety of a homogeneous prime ideal $I$. Let $d$ be the Krull dimension of $I$ and let $\\omega$ be a relative interior point of $d$-dimensional Groebner cone contained in the tropical variety. The input for this program is a pair of marked reduced Groebner bases with respect to the term order represented by $\\omega$, tie-broken in some way. The first one is for the initial ideal $in_\\omega(I)$ the second one for $I$ itself. The pair is the starting point for a traversal of the $d$-dimensional Groebner cones contained in the tropical variety. If the ideal is not prime but with the tropical variety still being pure $d$-dimensional the program will only compute a codimension $1$ connected component of the tropical variety.\n"; } TropicalTraverseApplication(): // optionPerformanceTimer("-T","Enable performance timer"), optionSymmetry("--symmetry","Do computations up to symmetry and group the output accordingly. If this option is used the program will read in a list of generators for a symmetry group after the pair of Groebner bases have been read. Two advantages of using this option is that the output is nicely grouped and that the computation can be done faster."), // optionNoIncidencePrinting("--noincidence","Disables printing of incidence information. This will avoid extracting the full fan from its orbits and avoid computation of the lower dimensional faces. The output is a list of orbits of maximal cones and a list of orbits of codimension 1 cones."), // optionInitialIdealPrinting("--initialideals","Print the initial ideals during incidence printing ONLY without --noincidence."), // optionLargeDimensionalPrinting("--largedimensional","Print the full dimensional cones and the codimension 1 cones computed in the traversal.") optionDisableSymmetryTest("--disableSymmetryTest","When using --symmetry this option will disable the check that the group read off from the input actually is a symmetry group with respect to the input ideal.\n"), optionTorusSymmetry("--symsigns","Specify for each generator of the symmetry group an element of ${-1,+1}^n$ which by its multiplication on the variables together with the permutation will keep the ideal fixed. The vectors are given as the rows of a matrix."), optionIgnoreCones("--nocones","Tells the program not to output the CONES and MAXIMAL_CONES sections, but still output CONES_ORBITS and MAXIMAL_CONES_ORBITS if --symmetry is used."), optionStableIntersection("--stable","Traverse the stable intersection or, equivalently, pretend that the coefficients are genereric.") { registerOptions(); } const char *name() { return "_tropicaltraverse"; } int main() { PolynomialSetList tropical; // lpSetSolver("cddgmp"); FileParser P(Stdin); AsciiPrinter p(Stdout); PolynomialSet coneGroebnerBasis=P.parsePolynomialSetWithRing(); PolynomialSet idealGroebnerBasis=P.parsePolynomialSet(coneGroebnerBasis.getRing()); coneGroebnerBasis.changeNumberOfVariables(idealGroebnerBasis.numberOfVariablesInRing()); SymmetryGroup s(idealGroebnerBasis.numberOfVariablesInRing()); if(optionSymmetry.getValue()) { IntegerVectorList generators=P.parseIntegerVectorList(); FieldMatrix *torusAction=0; FieldMatrix m(idealGroebnerBasis.getRing().getField(),0,0); if(optionTorusSymmetry.getValue()) { m=integerMatrixToFieldMatrix(rowsToIntegerMatrix(P.parseIntegerVectorList()),idealGroebnerBasis.getRing().getField()); torusAction=&m; } if(!optionDisableSymmetryTest.getValue()) assertSymmetriesMatch(generators,idealGroebnerBasis,torusAction); s.computeClosure(generators); s.createTrie(); log2 s.print(Stderr); log2 fprintf(Stderr,"\n"); } if(optionTorusSymmetry.getValue() && !optionSymmetry.getValue()) { fprintf(Stderr,"Option --torus can only be used in combination with option --symmetry.\n"); } int n=idealGroebnerBasis.numberOfVariablesInRing(); PolyhedralCone hspace=homogeneitySpace(idealGroebnerBasis); IntegerVectorList hv=hspace.dualCone().getEquations(); int h=hv.size(); int d=krullDimension(idealGroebnerBasis); log1 fprintf(Stderr,"Ambient dimension: %i\n",n); log1 fprintf(Stderr,"Dimension of homogeneity space: %i\n",h); log1 fprintf(Stderr,"Dimension of tropical variety: %i\n",d); // fprintf(Stdout,"Homogeneity space:\n"); { IntegerVectorList ridges=StringParser("{(7,-8,-8,2,7,-8,7,7,2,-8,1,1,1,-4,1)," //"(9,-11,-11,-1,14,-3,7,7,2,-13,-6,4,4,-1,-1)," //"(7,-8,-8,2,7,4,4,4,-1,-11,-11,4,4,-1,4)," //"(11,-4,-14,-4,11,2,2,7,2,-13,-13,2,7,2,2)," /////"(9,-11,-11,-1,14,-3,7,7,2,-13,-6,4,4,-1,-1)," //"(2,-8,-8,2,12,-1,4,4,-1,-6,-1,4,4,-1,-6)," //"(6,-4,-14,-4,16,-3,2,7,2,-8,-3,2,7,2,-8)," //"(9,-11,-11,-1,14,-3,7,7,2,-13,-6,4,4,-1,-1)," "(11,-4,-14,-4,11,-10,5,10,5,-10,-1,-1,4,-1,-1)}").parseIntegerVectorList(); IntegerVectorList rays=StringParser("{(3,0,0,-6,3,0,-1,-1,2,0,-3,1,1,4,-3)," //"(5,0,0,0,-5,9,-3,-3,-3,0,-14,3,3,3,5)," //"(1,0,0,-2,1,-1,0,0,1,0,0,0,0,1,-1)," //"(0,-2,0,2,0,0,1,0,-1,0,0,1,0,-1,0)," /////"(-8,0,0,0,8,3,-1,-1,-1,0,5,1,1,1,-8)," //"(2,0,0,-2,0,-1,0,0,1,0,-1,0,0,1,0)," //"(0,-2,0,2,0,0,1,0,-1,0,0,1,0,-1,0)," //"(3,0,0,0,-3,-12,4,4,4,0,9,-4,-4,-4,3)," "(-8,-2,0,2,8,3,0,-1,-2,0,5,2,1,0,-8)}").parseIntegerVectorList(); // coneChangeDebugger(coneGroebnerBasis,idealGroebnerBasis,ridges,rays); //return 0; } PolyhedralFan p1(0); if(1) { if(optionStableIntersection.getValue()) { StableIntersectionTraverser traverser(coneGroebnerBasis,idealGroebnerBasis); SymmetricTargetFanBuilder target(n,s); symmetricTraverse(traverser,target,&s); p1=target.getFanRef(); } else { TropicalTraverser traverser(coneGroebnerBasis,idealGroebnerBasis); SymmetricTargetFanBuilder target(n,s); symmetricTraverse(traverser,target,&s); p1=target.getFanRef(); } } else if(1) { BergmanFan f=bergman(coneGroebnerBasis,idealGroebnerBasis,&s); f.computeMultiplicities(); /* log1 fprintf(Stderr,"Is simplicial: %s\n",f.isSimplicial()?"true":"false");*/ log1 fprintf(Stderr,"Order of input symmetry group: %i\n",s.elements.size()); log1 fprintf(Stderr,"Number of maximal cones: %i\n",f.numberOfMaximalCones()); log1 fprintf(Stderr,"Modulo the homogeneity space:\n"); log1 AsciiPrinter(Stderr).printVectorList(hv); log1 fprintf(Stderr,"Converting representation to a polyhedral complex modulo symmetry...\n"); p1=f.toPolyhedralFan(); log1 fprintf(Stderr,"Done converting representation to a polyhedral complex modulo symmetry.\n"); } else p1=tropicalTraverse(coneGroebnerBasis,idealGroebnerBasis,&s); /* if(optionNoIncidencePrinting.getValue()) f.print(p); else*/ { p1.removeAllLowerDimensional(); AsciiPrinter Q(Stdout); p1.printWithIndices(&Q, FPF_multiplicities| (optionSymmetry.getValue()?FPF_group|FPF_conesCompressed:0)| (optionIgnoreCones.getValue()?0:FPF_conesExpanded)| FPF_maximalCones|FPF_cones, &s); // p1.printWithIndices(&Q,true,&s,optionSymmetry.getValue(),optionIgnoreCones.getValue()); } /* if(optionInitialIdealPrinting.getValue()) { // AsciiPrinter p(Stderr); PolyhedralFan p1=f.toPolyhedralFan(); int n=p1.getAmbientDimension(); IncidenceList a=p1.getIncidenceList(&s); fprintf(Stderr,"Computing rays...\n"); IntegerVectorList rays=p1.getRaysInPrintingOrder(&s); fprintf(Stderr,"Done computing rays.\n"); p.printString("Rays:\n"); p.printVectorList(rays); vector rays2(rays.size()); int K=0; for(IntegerVectorList::const_iterator k=rays.begin();k!=rays.end();k++) rays2[K++]=*k; for(IncidenceList::const_iterator j=a.begin();j!=a.end();j++) { p.printInteger(j->first); for(IntegerVectorList::const_iterator i=j->second.begin();i!=j->second.end();i++) { p.printVector(*i); IntegerVector v(n); for(int t=0;tsize();t++) { v+=rays2[(*i)[t]]; } p.printVector(v); PolynomialSet g2=idealGroebnerBasis; buchberger(&g2,WeightReverseLexicographicTermOrder(v)); g2=initialFormsAssumeMarked(g2,v); g2=saturatedIdeal(g2); p.printPolynomialSet(g2); } } }*/ // if(optionPerformanceTimer.getValue())Timer::printList(); return 0; } }; static TropicalTraverseApplication theApplication; gfan-0.5+dfsg/app_tropicalweildivisor.cpp000066400000000000000000000135631207563005400206640ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "reversesearch.h" #include "termorder.h" #include "gfanapplication.h" #include "wallideal.h" #include "polyhedralfan.h" #include "linalg.h" #include "polymakefile.h" #include "tropical_weildivisor.h" #include "log.h" #include "symmetry.h" class TropicalWeilDivisorApplication : public GFanApplication { StringOption inputOption1; StringOption inputOption2; public: const char *helpText() { return "This program computes the tropical Weil divisor of piecewise linear (or tropical rational) function on a tropical k-cycle. See the Gfan manual for more information.\n"; } TropicalWeilDivisorApplication(): inputOption1("-i1","Specify the name of the Polymake input file containing the k-cycle.","polymake1.out"), inputOption2("-i2","Specify the name of the Polymake input file containing the piecewise linear function.","polymake2.out") { registerOptions(); } const char *name() { return "_tropicalweildivisor"; } IntegerVectorList readLinealitySpace(const char *filename) { PolymakeFile inFile; inFile.open(filename); int n=inFile.readCardinalProperty("AMBIENT_DIM"); int homog=inFile.readCardinalProperty("LINEALITY_DIM"); IntegerMatrix rays=inFile.readMatrixProperty("LINEALITY_SPACE",homog,n); return rays.getRows(); } IntegerVectorList readRays(const char *filename) { PolymakeFile inFile; inFile.open(filename); int n=inFile.readCardinalProperty("AMBIENT_DIM"); int nRays=inFile.readCardinalProperty("N_RAYS"); IntegerMatrix rays=inFile.readMatrixProperty("RAYS",nRays,n); return rays.getRows(); } PolyhedralFan readFan(const char *filename, bool readRayValues, bool readLinearForms, bool readMultiplicities) { PolymakeFile inFile; inFile.open(filename); int n=inFile.readCardinalProperty("AMBIENT_DIM"); int nRays=inFile.readCardinalProperty("N_RAYS"); int lindim=inFile.readCardinalProperty("LINEALITY_DIM"); IntegerMatrix rays=inFile.readMatrixProperty("RAYS",nRays,n); vector > cones=inFile.readMatrixIncidenceProperty("MAXIMAL_CONES"); IntegerMatrix multiplicities; if(readMultiplicities) multiplicities=inFile.readMatrixProperty("MULTIPLICITIES",cones.size(),1); PolyhedralFan ret(n); IntegerVectorList equations=inFile.readMatrixProperty("LINEALITY_SPACE",lindim,n).getRows(); IntegerMatrix linearForms(cones.size(),n); if(readLinearForms)linearForms=inFile.readMatrixProperty("LINEAR_FORMS",cones.size(),n); IntegerMatrix rayValues(nRays,1); if(readRayValues)rayValues=inFile.readMatrixProperty("RAY_VALUES",nRays,1); IntegerMatrix linealityValues(lindim,1); if(readRayValues)linealityValues=inFile.readMatrixProperty("LINEALITY_VALUES",lindim,1); int I=0; for(vector >::const_iterator i=cones.begin();i!=cones.end();i++,I++) { IntegerVectorList coneGenerators; FieldMatrix LFA(Q,lindim+i->size(),n); FieldVector LFB(Q,lindim+i->size()+n); int J=0; for(list::const_iterator j=i->begin();j!=i->end();j++,J++) { coneGenerators.push_back(rays[*j]); LFA[J]=integerVectorToFieldVector(rays[*j],Q); LFB[J]=Q.zHomomorphism(rayValues[*j][0]); } int K=0; for(IntegerVectorList::const_iterator j=equations.begin();j!=equations.end();j++,J++,K++) { LFA[J]=integerVectorToFieldVector(*j,Q); LFB[J]=Q.zHomomorphism(linealityValues[K][0]); } if(readRayValues) { AsciiPrinter P(Stderr);//log0 P< comments=f.renamingStrings(divisor.getRaysInPrintingOrder(&sym),originalRays,linealitySpace,&sym); // divisor.printWithIndices(&Q,true,0,false,false,false,false,&comments); divisor.printWithIndices(&Q,FPF_default|FPF_multiplicities,0,&comments); /* FileParser P(Stdin); PolynomialRing R=P.parsePolynomialRing(); PolynomialSet s=P.parsePolynomialSet(R); Polynomial sum(R); for(PolynomialSet::const_iterator i=s.begin();i!=s.end();i++) sum+=*i; AsciiPrinter(Stdout).printPolynomial(sum); */ return 0; } }; static TropicalWeilDivisorApplication theApplication; gfan-0.5+dfsg/app_unfold.cpp000066400000000000000000000042271207563005400160520ustar00rootroot00000000000000#include "vektor.h" #include "printer.h" #include "parser.h" #include "gfanapplication.h" #include "lp.h" #include "polyhedralcone.h" #include "polyhedralfan.h" using namespace std; class UnfoldApplication : public GFanApplication { class Edge{ public: int i,j; }; class Facet{ vector edges; public: }; class Surface{ vector edges; vector facets; public: }; public: bool includeInDefaultInstallation() // Not included since the program has no relation to the main programs { return false; } UnfoldApplication(): input1Option("-i1","Specify the name of the first input file.","polymake.out") { registerOptions(); } const char *name() { return "_unfold"; } int main() { FileParser P(Stdin); PolyhedralFan f1=PolyhedralFan::readFan(input1Option.getValue()); assert(f1.getAmbientDimension()==4); int boxSize=2; IntegerVectorList equations; IntegerVectorList inequalities; inequalities.push_back(boxSize*IntegerVector::standardVector(4,0)+IntegerVector::standardVector(n,1)); inequalities.push_back(boxSize*IntegerVector::standardVector(4,0)+IntegerVector::standardVector(n,2)); inequalities.push_back(boxSize*IntegerVector::standardVector(4,0)+IntegerVector::standardVector(n,3)); PolyhedralCone C(inequalities,equalities,4); C.canonicalize(); PolyhedralFan F(4); F.insert(C); PolyhedralFan f2=refinement(f1,F); IntegerVectorList rays=f2.getRays(); Surface s; for(PolyhedralFan::coneIterator i=f2.conesBegin();i!=f2.conesEnd();i++) { if(i->dimension()==3) { PolyhedralFan f3=PolyhedralFan::facetsOfCone(*i); for(PolyhedralFan::coneIterator i=f3.conesBegin();i!=f3.conesEnd();i++) { Facet F; int J=0; for(IntegerVectorList::const_iterator j=rays.begin();j!=rays.end();j++,J++) if(i->contains(*j)) F.edges.push_back(J); } } s.facets.push_back(F); } IntegerVectorList v=P.parseIntegerVectorList(); fprintf(Stderr,"Rank:%i\n",rankOfMatrix(v)); AsciiPrinter(Stdout).printVectorList(transposeIntegerVectorList(v)); return 0; } const char *helpText() { return "\n"; } }; static UnfoldApplication theApplication; gfan-0.5+dfsg/app_volume.cpp000066400000000000000000000023051207563005400160650ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "lp.h" #include "gfanapplication.h" #include "polyhedralcone.h" #include "polymakefile.h" #include "determinant.h" #include "subspace.h" #include "triangulation.h" #include "polyhedralfan.h" #include "symmetry.h" class VolumeApplication : public GFanApplication { StringOption inputOption; public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program computes the volume of a polyhedral fan intersected with the standard cube with edge length 2 centered at the origin. This is done for each dimension\n"; } VolumeApplication(): inputOption("-i","Specify the name of the input file.","polymake.out") { registerOptions(); } const char *name() { return "_volume"; } int main() { PolyhedralFan F=PolyhedralFan::readFan(inputOption.getValue(),true,0,0,0,true); IntegerVectorList generators=FileParser(Stdin).parseIntegerVectorList(); SymmetryGroup s(F.getAmbientDimension()); s.computeClosure(generators); cout << F.volume(21,&s).toString(); return 0; } }; static VolumeApplication theApplication; gfan-0.5+dfsg/app_walk.cpp000066400000000000000000000034221207563005400155150ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "reversesearch.h" #include "termorder.h" #include "ep_standard.h" #include "ep_xfig.h" #include "genericwalk.h" #include "gfanapplication.h" #include "timer.h" class WalkApplication : public GFanApplication { FieldOption theFieldOption; public: bool includeInDefaultInstallation() { return false; } WalkApplication() { registerOptions(); } const char *name() { return "_walk"; } int main() { lpSetSolver("cddgmp"); FileParser p(Stdin); PolynomialSet g=p.parsePolynomialSetWithRing(); // StandardGradedLexicographicTermOrder t1; WeightReverseLexicographicTermOrder t1(StringParser("(1,1,1,1,1,1)").parseIntegerVector()); AsciiPrinter P(Stderr); assert(g.checkMarkings(t1)); // g.mark(t1); // AsciiPrinter(Stdout).printPolynomialSet(g); t1.printMatrix(P,6); LexicographicTermOrder t2; // LexicographicTermOrder t1(1); // LexicographicTermOrder t2; fprintf(Stderr,"Computing starting Groebner basis\n"); autoReduce(&g,t1); // buchberger(&g,t1); AsciiPrinter(Stdout).printPolynomialSet(g); fprintf(Stderr,"Walking with perturbation\n"); // int n=g.numberOfVariablesInRing(); // for(int i=n;i>=0;i--) // for(int i=n-4;i>=0;i--) { PolynomialSet g2(g.getRing()); // g2=genericWalkPerturbation(g,t1,t2,i,i); g2=genericWalkPerturbation(g,t1,t2,6,6); AsciiPrinter(Stdout).printPolynomialSet(g2); } return 0; } const char *helpText() { return "This program walks. THIS PROGRAM NEEDS TO BE FIXED.\n"; } }; static WalkApplication theApplication; gfan-0.5+dfsg/app_weightvector.cpp000066400000000000000000000041211207563005400172660ustar00rootroot00000000000000#include "parser.h" #include "printer.h" #include "polynomial.h" #include "division.h" #include "buchberger.h" #include "wallideal.h" #include "lp.h" #include "reversesearch.h" #include "termorder.h" #include "gfanapplication.h" #include "wallideal.h" #include "polyhedralcone.h" class WeightVectorApplication : public GFanApplication { SimpleOption optionMultiple; SimpleOption optionEcho; public: bool includeInDefaultInstallation() { return false; } const char *helpText() { return "This program computes a strictly positive interior point of the cone given by the marked Groebner basis on the input.\n"; } WeightVectorApplication(): optionMultiple("-m","Do the same thing for a list of Groebner bases. The output is the list of interior points.\n"), optionEcho("-e","Echo the input. The program will output the Groebner basis before outputting its weight vector.\n") { registerOptions(); } const char *name() { return "_weightvector"; } void process(PolynomialSet const &g) { IntegerVectorList normals=wallInequalities(g); if(optionEcho.getValue()) { AsciiPrinter(Stdout).printString("("); AsciiPrinter(Stdout).printPolynomialSet(g); AsciiPrinter(Stdout).printString(","); } PolyhedralCone C(normals,IntegerVectorList()); AsciiPrinter(Stdout).printVector(intersection(PolyhedralCone::positiveOrthant(C.ambientDimension()),C).getRelativeInteriorPoint()); if(optionEcho.getValue()) AsciiPrinter(Stdout).printString(")"); } int main() { LpSolver::printList(Stderr); lpSetSolver("cddgmp"); FileParser P(Stdin); if(optionMultiple.getValue()) { fprintf(Stdout,"{\n"); PolynomialSetList l=P.parsePolynomialSetListWithRing(); for(PolynomialSetList::const_iterator i=l.begin();i!=l.end();i++) { if(i!=l.begin())fprintf(Stdout,",\n"); process(*i); } fprintf(Stdout,"}\n"); } else { PolynomialSet p=P.parsePolynomialSetWithRing(); process(p); } //interiorPoint(normals,Stdout,true); return 0; } }; static WeightVectorApplication theApplication; gfan-0.5+dfsg/application.cpp000066400000000000000000000332731207563005400162310ustar00rootroot00000000000000#include "application.h" #include #include #include #include #include #include "field.h" //REMOVE THIS INCLUDE using namespace std; #define APPLICATIONNAME "gfan" Application *Application::applicationList; Application::Option *Application::Option::constructionList; static char *findName(char *p) { // extracts filename from argv[0] int l=strlen(p); assert(l>0); do { l--; } while(p[l]!=0 && p[l]!='/'); return p+l+1; } static char* tail(char *p) { const char *n=APPLICATIONNAME; const char *m=n; assert(p); while(*m) { assert(*p==*m); m++; p++; } return p; } //-------------------------------------------------- // Main - starts an application //-------------------------------------------------- int main(int argc, char *argv[]) { bool helpOption=false; if(argc==2)if(strcmp(argv[1],"--help")==0)helpOption=true; if(argc==3)if(strcmp(argv[2],"--help")==0)helpOption=true; /* if(argc==2) { if(strcmp(argv[1],"installlinks")==0) { Application::makeSymbolicLinks(APPLICATIONNAME,false,""); return 0; } if(strcmp(argv[1],"installlinksall")==0) { Application::makeSymbolicLinks(APPLICATIONNAME,true,""); return 0; } if(strcmp(argv[1],"documentation")==0) { Application::produceLatexDocumentation(false); return 0; } if(strcmp(argv[1],"--help")==0)helpOption=true; } if(argc==3) { if(strcmp(argv[1],"installlinks")==0) { Application::makeSymbolicLinks(APPLICATIONNAME,false,argv[2]); return 0; } if(strcmp(argv[1],"installlinksall")==0) { Application::makeSymbolicLinks(APPLICATIONNAME,true,argv[2]); return 0; } if(strcmp(argv[2],"--help")==0)helpOption=true; } */ // fprintf(Stderr,"Extracted name=%s",); // Application *app=Application::applicationList; int argumentsToSkip=0; Application *app=0; Application *app2=0; if(argc>1)app2=Application::findApplication(argv[1]); Application *app3=Application::findApplication(tail(findName(argv[0]))); if(app2) { argumentsToSkip=1; app=app2; } else app=app3; if(app==0) { fprintf(stderr,"Application not found!\n"); assert(0); return 0; } /* if((!app) || app->next) { fprintf(Stderr,app?"Error: multiple applications defined.\n" :"Error: no applications defined.\n"); assert(0); return 0; }*/ if(helpOption) { app->printHelp(); return 0; } if(app->parseOptions(argc,argv,argumentsToSkip)) { int ret=app->main(); // fprintf(Stderr,"Number of rationals living:%i\n",FieldElementRationalsLiving); app->onExit(); return ret; } return 0; } //-------------------------------------------------- // A few internal applications for installation // and generating documentation. //-------------------------------------------------- class DocumentationApplication : public Application { bool includeInDefaultInstallation() { return false; } const char *helpText() { return "Internal application for generating the LaTeX documentation.\n"; } const char *name() { return "documentation"; } int main() { Application::produceLatexDocumentation(false); return 0; } }; DocumentationApplication theDocumentationApplication; class InstallationApplication : public Application { SimpleOption optionAll; StringOption optionPath; bool includeInDefaultInstallation() { return false; } public: InstallationApplication(): optionAll("--all","Install all links to all programs. Also the ones only known by the author.\n"), optionPath("--path","Specify the installation path.\n","") { registerOptions(); } const char *helpText() { return "Internal application for installing symboilic links.\n"; } const char *name() { return "installlinks"; } int main() { Application::makeSymbolicLinks(APPLICATIONNAME,optionAll.getValue(),optionPath.getValue()); return 0; } }; InstallationApplication theInstallationApplication; //-------------------------------------------------- // Application::Option //-------------------------------------------------- Application::Option::Option() { bool hidden=false; next=constructionList;constructionList=this; } Application::Option *Application::Option::getOptionList() { Option *ret=constructionList;constructionList=0;return ret; } void Application::Option::onOptionsParsed() { } bool Application::Option::isHidden()const { return hidden; } void Application::Option::hide(bool b) { hidden=b; } //-------------------------------------------------- // Application::StringMatchingOption //-------------------------------------------------- bool Application::StringMatchingOption::isExactMatch(const char *s) { return std::string(s)==std::string(matchString); } Application::StringMatchingOption::StringMatchingOption(const char *s, const char *description_): matchString(s), description(description_) { } bool Application::StringMatchingOption::matches(const char *s) { for(int i=0;matchString[i];i++) if(matchString[i]!=s[i])return false; return true; } std::string Application::StringMatchingOption::documentationMatchString() { return std::string(matchString); } std::string Application::StringMatchingOption::documentationDescription() { return description; } //-------------------------------------------------- // Application::SimpleOption //-------------------------------------------------- Application::SimpleOption::SimpleOption(const char *s, const char *description): StringMatchingOption(s, description), value(false) { } void Application::SimpleOption::parseValue(int t, char **argv, bool *ok, int *numberOfArgumentsParsed) { *numberOfArgumentsParsed=0; if(isExactMatch(argv[t])) { value=true; *ok=true; } else *ok=false; } bool Application::SimpleOption::getValue() { return value; } //-------------------------------------------------- // Application::ValueOption //-------------------------------------------------- Application::ValueOption::ValueOption(const char *s, const char *description): StringMatchingOption(s, description) { } std::string Application::ValueOption::documentationMatchString() { return std::string(matchString)+" value"; } void Application::ValueOption::parseValue(int t, char **argv, bool *ok, int *numberOfArgumentsParsed) { if(isExactMatch(argv[t])) { if(argv[t+1]==0 || argv[t+1][0]=='-') { assignValue(""); *ok=true; *numberOfArgumentsParsed=0; } else { assignValue(argv[t+1]); if(argv[t+1]) { *ok=true; *numberOfArgumentsParsed=1; } else { *ok=false; *numberOfArgumentsParsed=0; } } } else { assignValue(argv[t]+std::string(matchString).length()); *ok=true; *numberOfArgumentsParsed=0; } } //-------------------------------------------------- // Application::StringOption //-------------------------------------------------- Application::StringOption::StringOption(const char *s, const char *description, const char *initialValue): ValueOption(s, description), value(initialValue) { } void Application::StringOption::assignValue(const char *s) { value=s; } const char *Application::StringOption::getValue() { return value; } //-------------------------------------------------- // Application::IntegerOption //-------------------------------------------------- Application::IntegerOption::IntegerOption(const char *s, const char *description, int initialValue): ValueOption(s, description), value(initialValue), hasRange(false) { } Application::IntegerOption::IntegerOption(const char *s, const char *description, int initialValue, int lower_, int upper_): ValueOption(s, description), value(initialValue), hasRange(true), lower(lower_), upper(upper_) { } void Application::IntegerOption::assignValue(const char *s) { bool onlyDigits=true; value=0; for(int t=0;s[t];t++) { if(s[t]<'0' || s[t]>'9')onlyDigits=false; value*=10; value+=s[t]-'0'; } assert(onlyDigits); if(hasRange) if(lower>value || uppernext) { if(i->matches(argv[t]))numberOfMatchesFound++; } // fprintf(Stderr,"NumberOfMatches %i\n",numberOfMatchesFound); assert(numberOfMatchesFound<2); if(numberOfMatchesFound==0) { fprintf(stderr,"UNKNOWN OPTION: %s.\n",argv[t]); fprintf(stderr,"USE --help AS A SINGLE OPTION TO VIEW THE HELP TEXT.\n"); return false; } for(Option *i=optionList;i;i=i->next) if(i->matches(argv[t])) { bool ok=false; int argumentsParsed=1; i->parseValue(t,argv,&ok,&argumentsParsed); if(!ok) { fprintf(stderr,"PARSE ERROR PARSING ARGUMENTS IN OPTION %s.\n",argv[t]); fprintf(stderr,"USE --help AS A SINGLE OPTION TO VIEW THE HELP TEXT.\n"); // assert(0); // exit(0); return false; } t+=argumentsParsed; break; } } for(Option *i=optionList;i;i=i->next)i->onOptionsParsed(); return true; } void Application::registerOptions() {//merge current list of options with new list Option *l=Option::getOptionList(); while(l) { Option *o=l; l=o->next; o->next=optionList; optionList=o; } } void Application::printHelp() { fprintf(stderr,"%s",helpText()); Application *p=applicationList; FILE *f=stderr; Option *l=optionList; if(l) { fprintf(f,"Options:\n"); while(l) { if(!l->isHidden())fprintf(f,"%s:\n %s\n",l->documentationMatchString().c_str(),l->documentationDescription().c_str()); l=l->next; } } }; class Application *Application::findApplication(char *name) { Application *p=applicationList; while(p) { if(strcmp(name,p->name())==0)return p; p=p->next; } return 0; } void Application::makeSymbolicLinks(const char *name, bool all, const char *path) { Application *p=applicationList; while(p) { if(all || p->includeInDefaultInstallation()) if(strlen(p->name())>0) { char c[1024]; sprintf(c,"ln -s %s%s %s%s%s\n",path,name,path,name,p->name()); fprintf(stderr,"%s",c); system(c); } p=p->next; } } static int substituteSingleString(FILE *f,const char* s, const char* pattern, const char* substitute) { int n=0; while(*pattern) { if(*s!=*pattern)return 0; pattern++; s++; n++; } fprintf(f,"%s",substitute); return n; } static void quoteLatexPrint(FILE *f, const char *s) { while(*s) { s+=substituteSingleString(f,s,"\\omega","\\omega"); if(s[0]=='-' && s[1]=='-') { fprintf(f,"-\\hspace{0.013cm}-"); s++; } else if(s[0]=='G' && s[1]=='r' && s[2]=='o' && s[3]=='e') { fprintf(f,"Gr\\\"o"); s+=3; } else if(s[0]=='~') fprintf(f,"\\~{}"); else if(s[0]=='{') fprintf(f,"\\{"); else if(s[0]=='}') fprintf(f,"\\}"); else if(s[0]=='_') fprintf(f,"\\_"); else if(s[0]=='\\') fprintf(f,"\\backslash"); else if(s[0]=='<') fprintf(f,"\\symbol{60}"); else fprintf(f,"%c",s[0]); s++; } } static bool compare_appname(Application *a, Application *b) { return string(a->name())name()); } std::list Application::getSortedApplicationList() { Application *p=applicationList; list alist2; while(p) { alist2.push_back(p); p=p->next; } alist2.sort(compare_appname); return alist2; } void Application::produceLatexDocumentation(bool all) { FILE *f=stdout; std::list alist2=getSortedApplicationList(); // while(p) for(list::const_iterator i=alist2.begin();i!=alist2.end();i++) { Application *p=*i; if(all || p->includeInDefaultInstallation()) { fprintf(f,"{\\subsection{%s",APPLICATIONNAME); quoteLatexPrint(f,p->name()); fprintf(f,"}"); fprintf(f,"\\label{applist:%s}\n",p->name()); quoteLatexPrint(f,p->helpText()); Option *l=p->optionList; bool containsNonHidden=false; Option *l2=l; while(l2){if(!l2->isHidden())containsNonHidden=true;l2=l2->next;} if(containsNonHidden) { fprintf(f,"\\newline\n"); fprintf(f,"{\\bf Options:}\n"); fprintf(f,"\\begin{description}\n"); while(l) { if(!l->isHidden()) { fprintf(f,"\\item["); quoteLatexPrint(f,l->documentationMatchString().c_str()); fprintf(f,"]"); quoteLatexPrint(f,l->documentationDescription().c_str()); } l=l->next; } fprintf(f,"\\end{description}\n"); } fprintf(f,"\n\n"); } // p=p->next; } } void Application::onExit() { } gfan-0.5+dfsg/application.h000066400000000000000000000236411207563005400156740ustar00rootroot00000000000000#ifndef APPLICATION_H_INCLUDED #define APPLICATION_H_INCLUDED #include #include // A general application. // This could solve several problems: // - the help text could be automatically generated // - duplicate main code could be removed // - it would be easy to parse options // - all applications could be linked to a single file thereby saving disk-space /** @brief A command line application. The class Application describes the general command line application. The compiled Gfan executable consists of several command line applications. When the static main() is run it is decided which application to invoke by investigating argv[0] and other command line options. A command line application will register itself during construction. Typically the Appliction is a static object. Therefore the Application has been registered when main() is executed. The static main() is a friend of Application which makes it possible for main() to search through the linked list of Applications. The Application::next member is used as a next pointer in the linked list of registered Application s. An Application can have a set of associated Option s. When an Option is constructed it is put into a static temporary linked list. When an Application has constructed all its Options it should call registerOptions() to move the linked list of Options into the Application s linked lists of Option s. */ class Application{ // Nested Option Classes /** The general commmand line option. */ protected: /** This abstract superclass describes the general Option. An Option object is intended to be part of an Application object. Before the Application::main() is run the command line is parsed by matching argv[1], argv[2]... with the Option s of the Application in question. The matches() method is called with argv[i] and by the return value the Option tells if it matches the argv[i] string. If this is the case then the parseValue() method will be called to let the Option take values from argv[i+1], argv[i+2]... as it likes. All this has already been taken care of in the code of the subclasses of this class. These subclasses can be used without worrying about the implementation details. See the documentation for the respective subclasses. */ class Option{ bool hidden; protected: /** The base pointer for a temporary linked list of Option s. When an Option is created it is added to the list by its constructor. The content of this list is later moved to a linked list for the Application of which the Option is a part. */ static Option *constructionList; public: Option(); /** An Option can be hidden which means that it does not show up in the help text of the Application. This function tells whether the Option is hidden or not. */ bool isHidden()const; /** This method hides the Option. See isHidden(). */ void hide(bool b=true); /** This method tells whether the Option matches a given string or not. Notice that a Option may match more than a single string allowing command line parameters such as -n2 and -n7 to match the same Option. @param s The string to be matched. */ virtual bool matches(const char *s)=0; /** @todo document this method */ virtual void onOptionsParsed(); /** This function returns a string that will be used in the documentation to denote the Option. */ virtual std::string documentationMatchString()=0; /** This function returns the a string describing the Option to be used for documentation. */ virtual std::string documentationDescription()=0; /** When this method is called the Option has the possibility to read off its value from the command line through argv[]. This only happens if the Option already accepted the argv[t] string as a match through matches(). How many additional strings the Option reads its value from is written to *numberOfArguments. @param t the index of the matching command line string. @param argv the command line strings. @param ok is considered to be a return value telling whether the commandline strings were parsed correctly. The pointer is not allowed to be null. @param numberOfArguments is considered to be return value telling how many additional (besides argv[t]) command line strings the method parsed. This allows each option to "eat" a different number of command line strings. The pointer is not allowed to be null. */ virtual void parseValue(int t, char **argv, bool *ok, int *numberOfArgumentsParsed)=0; static Option *getOptionList(); Option *next; }; class StringMatchingOption: public Option { protected: const char *matchString; const char *description; bool isExactMatch(const char *s); public: virtual std::string documentationMatchString(); virtual std::string documentationDescription(); StringMatchingOption(const char *s, const char *description_=""); bool matches(const char *s); }; class SimpleOption: public StringMatchingOption{ bool value; public: SimpleOption(const char *s, const char *description); void parseValue(int t, char **argv, bool *ok, int *numberOfArgumentsParsed); bool getValue(); }; class ValueOption: public StringMatchingOption{ public: virtual std::string documentationMatchString(); virtual void assignValue(const char *s)=0; ValueOption(const char *s, const char *description); void parseValue(int t, char **argv, bool *ok, int *numberOfArgumentsParsed); }; class StringOption: public ValueOption{ const char *value; public: StringOption(const char *s, const char *description, const char *initialValue=0); void assignValue(const char *s); const char *getValue(); }; class IntegerOption: public ValueOption{ int value; bool hasRange; int lower,upper; public: IntegerOption(const char *s, const char *description, int initialValue=0); IntegerOption(const char *s, const char *description, int initialValue, int lower, int upper); void assignValue(const char *s); int getValue(); }; class ZeroOneOption: public IntegerOption{ public: ZeroOneOption(const char *s, const char *description, int initialValue=0); }; // Application members private: static class Application *applicationList; static class Application *findApplication(char *name); protected: static std::list getSortedApplicationList(); /** This static procedure makes a symbolic link (on the file system) for registered Application s to the Gfan executable in the specified path. This procedure is supposed to be called during the installation of Gfan. @param name The name of the Gfan executable. @param all If false an Application only gets a symbolic link if its includeInDefaultInstallation() returns true. @param path The path to the Gfan executable and directory of the symbolic links. Must be terminated by a '/'. */ static void makeSymbolicLinks(const char *name, bool all, const char *path); /** This procedure produces the list of Gfan Application s in the appendix of the Gfan user's manual. The contents is written as LaTeX to stdout. The output contains one subsection for each Application. An application is not included in the list if its includeInDefaultInstallation() returns false. @param all Forces all Application s to be documented. */ static void produceLatexDocumentation(bool all); /** The base pointer for a the linked list of the Option s of the Application. */ class Application::Option* optionList; public: /** Superconstructor. Adds the Application to the static linked list of Application s. */ Application(); /** The next pointer for the linked list of existing Application s. */ class Application *next; /** This procedure parses the arguments for the static main() and assigns values of the appropriate Option s of the Application. @param argc The number of arguments on the command line (including the name of the command). See K&R:"The C Programming Language". @param argv The arguments. See K&R:"The C Programming Language". @param argumentsToSkip The number of arguments to skip (excluding the name of the executable). Usually no options are skipped, but if the program is not invoked using a symbolic link, the first (index 0) argument is the executable name and the second (index 1) argument is the Application name which should be skipped when parsing Option s. */ bool parseOptions(int argc, char **argv, int argumentsToSkip); /** @return true if the Application should appear in the documentation / be installed during default installation of Gfan. */ virtual bool includeInDefaultInstallation(); /** After construction of its Application::Option s an Application should call this procedure to collect the Option s in the optionList. */ void registerOptions(); /** This procedure writes the help text of the Application to stderr and lists the Option s. */ virtual void printHelp(); /** This virtual method contains the code to be executed when the Application is run. @return The value to be passed to the shell when the program finishes execution. */ virtual int main()=0; virtual void onExit(); /** @return The help text for the documentation. The format is usual ASCII. */ virtual const char *helpText()=0; friend int main(int argc, char *argv[]); /** This function returns the name of the Application. This name is used for matching with arg[0] and other options to decide which application to run. */ virtual const char *name()=0; }; #endif gfan-0.5+dfsg/bergman.cpp000066400000000000000000000736211207563005400153420ustar00rootroot00000000000000#include "bergman.h" #include "enumeration.h" #include "reversesearch.h" #include "tropical.h" #include "buchberger.h" #include "division.h" #include "dimension.h" #include "wallideal.h" #include "lp.h" #include "subspace.h" #include "symmetry.h" #include "tropical2.h" #include "tropicalbasis.h" #include "polyhedralcone.h" #include "polyhedralfan.h" #include "multiplicity.h" #include "log.h" #include "restrictedautoreduction.h" #include "groebnerengine.h" #include static Polynomial wallPolynomial(Polynomial const &p, Subspace const &subspace) // This routine should be deleted since it is inefficient // hmm... does this actually work? { Polynomial r(p.getRing()); IntegerVector markedExponent=p.getMarked().m.exponent; for(TermMap::const_iterator i=p.terms.begin();i!=p.terms.end();i++) { IntegerVector dif=markedExponent-i->first.exponent; if(subspace.contains(dif)) r+=Polynomial(Term(i->second,i->first)); } r.mark(Monomial(p.getRing(),markedExponent)); return r; } static PolynomialSet wallIdeal(PolynomialSet const &groebnerBasis, Subspace const &subspace) { // fprintf(Stderr,"wallIdeal %i",perp.size()); PolynomialSet ret(groebnerBasis.getRing()); for(PolynomialSet::const_iterator i=groebnerBasis.begin();i!=groebnerBasis.end();i++) ret.push_back(wallPolynomial(*i,subspace)); // fprintf(Stderr,"done\n"); return ret; } BergmanFan bergmanRayIntersection(PolynomialSet const &idealGroebnerBasis) // Input ideal is assumed to be homogeneous with respect to a positive vector // Input ideal is assumed not to contain a monomial // Call the Krull dimensionn of the ring/ideal d // The ideal is homogenous with respect to a vector space of dimension d-1 // All d dimensional cones in the Gro\"obner fan with no monomials are computed { BergmanFan bfan; int n=idealGroebnerBasis.numberOfVariablesInRing(); // log0 AsciiPrinter(Stderr).printPolynomialSet(idealGroebnerBasis); int d=krullDimension(idealGroebnerBasis); //There should be a better way of doing this PolyhedralFan bergmanFan(n); PolynomialSet tropBasis=tropicalBasisOfCurve(n,idealGroebnerBasis,&bergmanFan,d-1); // PolyhedralFan bergmanFan=tropicalPrincipalIntersection(n,tropBasis,d-1); IntegerVectorList rays=bergmanFan.getRays(d); int maximalConeLabel=0; // fprintf(Stderr,"---------------------------------------------------------\n"); // AsciiPrinter(Stderr).printVectorList(rays); // fprintf(Stderr,"---------------------------------------------------------\n"); log2 cerr<<"BBLABL"; for(IntegerVectorList::const_iterator i=rays.begin();i!=rays.end();i++) { log2 cerr<<"1"; PolynomialSet g=idealGroebnerBasis; g=GE_groebnerBasis(g,WeightReverseLexicographicTermOrder(*i),true); // buchberger(&g,WeightReverseLexicographicTermOrder(*i)); PolynomialSet cg=initialFormsAssumeMarked(g,*i); log2 cerr<<"2"; bool inList=false; for(BergmanFan::MaximalConeList::const_iterator j=bfan.cones.begin();j!=bfan.cones.end();j++) { if(areIdealsEqual(j->coneGroebnerBasis,cg)) { inList=true; break; } } log2 cerr<<"3"; if(!inList) { bfan.cones.push_back(BergmanFan::MaximalCone(cg,g,true,maximalConeLabel++)); } log2 cerr<<"4"; } log2 cerr<<"BBLAB END"; // AsciiPrinter temp(Stderr); // bfan.print(temp); return bfan; } BergmanFan bergmanRay(PolynomialSet const &idealGroebnerBasis) // Input ideal is assumed to be homogeneous with respect to a positive vector // Input ideal is assumed not to contain a monomial // Call the Krull dimensionn of the ring/ideal d // The ideal is homogenous with respect to a vector space of dimension d-1 // All d dimensional cones in the Gro\"obner fan with no monomials are computed { BergmanFan bfan; EnumerationTargetCollector gfan; LexicographicTermOrder myTermOrder; ReverseSearch rs(myTermOrder); rs.setEnumerationTarget(&gfan); rs.enumerate(idealGroebnerBasis); int n=idealGroebnerBasis.numberOfVariablesInRing(); fprintf(Stderr,"rankOfMatrix(wallin.idealGroebnerBasis=%i\n",rankOfMatrix(wallInequalities(idealGroebnerBasis))); AsciiPrinter(Stderr).printVectorList(wallInequalities(idealGroebnerBasis)); int d=n-rankOfMatrix(wallInequalities(idealGroebnerBasis))+1; int krull=krullDimension(idealGroebnerBasis); //AsciiPrinter(Stderr).printVectorList(wallInequalities(idealGroebnerBasis)); assert(rankOfMatrix(wallInequalities(idealGroebnerBasis))==Subspace(wallInequalities(idealGroebnerBasis)).dimension()); // fprintf(Stderr,"d: %i krull: %i\n",d,krull); // assert(d==krull); int maximalConeLabel=0; for(PolynomialSetList::const_iterator g=gfan.theList.begin();g!=gfan.theList.end();g++) { PolynomialSetList s; //fprintf(Stderr,"current gbasis:\n"); //AsciiPrinter(Stderr).printPolynomialSet(*g); if(0) { s=fullColoredIdeals(*g,false); fprintf(Stderr,"Full colored ideals computed, #=%i\n",s.size()); } else { IntegerVectorList inequalities=wallInequalities(*g); inequalities=wallFlipableNormals(*g,true); int isize=inequalities.size(); // fprintf(Stderr,"cdd facets to rays "); // AsciiPrinter(Stderr).printVectorList(inequalities); IntegerVectorList rays=extremeRaysInequalityIndices(inequalities); //fprintf(Stderr,"done\n"); //AsciiPrinter(Stderr).printVectorList(rays); // AsciiPrinter(Stderr).printVectorList(rays); for(IntegerVectorList::const_iterator i=rays.begin();i!=rays.end();i++) if(i->size()!=isize) { IntegerVectorList perp; int j=0; int K=0; for(IntegerVectorList::const_iterator k=inequalities.begin();k!=inequalities.end()&&jsize();k++,K++) if((*i)[j]==K) { perp.push_back(*k); j++; } s.push_back(wallIdeal(*g,Subspace(perp))); } } //fprintf(Stderr,"Number of face ideals to check:%i\n",s.size()); for(PolynomialSetList::const_iterator i=s.begin();i!=s.end();i++) { //fprintf(Stderr,"d:%i\n",d); //fprintf(Stderr,"krull:%i\n",krull); //fprintf(Stderr,"n:%i\n",n); //fprintf(Stderr,"rank: %i\n",rankOfMatrix(wallInequalities(*i))); assert(i->isMarked()); // fprintf(Stderr,"d: %i, rank %i",d,n-rankOfMatrix(wallInequalities(*i))); if(d==n-rankOfMatrix(wallInequalities(*i)))//dimension check { // fprintf(Stderr,"Checking monomial containment"); if(!containsMonomial(*i)) { // fprintf(Stderr,"Done - no\n"); PolynomialSet cg=*i; //buchberger(&cg,StandardGradedLexicographicTermOrder()); The cg is already a Groebner basis bool inList=false; for(BergmanFan::MaximalConeList::const_iterator j=bfan.cones.begin();j!=bfan.cones.end();j++) { if(areIdealsEqual(j->coneGroebnerBasis,cg)) { inList=true; break; } } if(!inList) { bfan.cones.push_back(BergmanFan::MaximalCone(cg,*g,true,maximalConeLabel++)); } } // else // fprintf(Stderr,"Done - yes\n"); } else fprintf(Stderr,"dimension check fails\n"); } } //fprintf(Stderr,"No duplicates:\n"); /* for(PolynomialSetList::const_iterator i=tropical.begin();i!=tropical.end();i++) { AsciiPrinter(Stdout).printPolynomialList(i->coneGroebnerBasis); int coDim=rankOfMatrix(wallInequalities(*i)); int d=i->numberOfVariablesInRing()-coDim; fprintf(Stderr,"%i\n",d); } */ return bfan; } /*static bool staticInOrbit(PolynomialSet const &groebnerBasis1, PolynomialSet const &groebnerBasis2, SymmetryGroup const &s) { for(SymmetryGroup::ElementContainer::const_iterator j=s.elements.begin();j!=s.elements.end();j++) if(areIdealsEqual(SymmetryGroup::permutePolynomialSet(groebnerBasis2,*j),groebnerBasis1))return true; return false; }*/ /*static bool staticPermutationFixesCone(PolynomialSet const &groebnerBasis, IntegerVector const &v) { // Cone is fixed iff the cone ideal is fixed. PolynomialSet q(groebnerBasis.getRing()); for(PolynomialSet::const_iterator i=groebnerBasis.begin();i!=groebnerBasis.end();i++) { q.push_back(SymmetryGroup::permutePolynomial(*i,v)); } return areIdealsEqual(q,groebnerBasis); }*/ /*static int staticOrbitSize(PolynomialSet const &groebnerBasis, SymmetryGroup const &s) { int groupSize=s.elements.size(); int numFixed=0; for(SymmetryGroup::ElementContainer::const_iterator j=s.elements.begin();j!=s.elements.end();j++) if(staticPermutationFixesCone(groebnerBasis,*j))numFixed++; // fprintf(Stderr,"groupSize = %i, numFixed = %i\n",groupSize,numFixed); return groupSize/numFixed; } */ /** Objects of this class represent ConeOrbits of facet of a tropical variety. */ class ConeOrbit { public: const SymmetryGroup &s; PolynomialSet coneGroebnerBasis; PolynomialSet idealGroebnerBasis; int label; // PolynomialSetList markedFacets; PolyhedralCone theCone; // IntegerVectorList markedFacets; //marked facets of dim d cone. The facet of a facet is a ridge of the tropical variety. IntegerVector stableRay; //stable relative interior point IntegerVectorList unMarkedFacetNormals; ConeOrbit(const SymmetryGroup &s_, PolynomialSet const &coneGroebnerBasis_, PolynomialSet const &idealGroebnerBasis_, int label_): coneGroebnerBasis(coneGroebnerBasis_), idealGroebnerBasis(idealGroebnerBasis_), label(label_), s(s_), theCone(fastNormals(wallInequalities(idealGroebnerBasis_)),//wallFlipableNormals(idealGroebnerBasis_,false), wallInequalities(coneGroebnerBasis_), idealGroebnerBasis_.getRing().getNumberOfVariables()) { /* log0 AsciiPrinter(Stderr).printPolynomialSet(coneGroebnerBasis_); log0 AsciiPrinter(Stderr).printPolynomialSet(idealGroebnerBasis_); log0 fprintf(Stderr,"inequalities:\n"); log0 AsciiPrinter(Stderr).printVectorList(wallInequalities(coneGroebnerBasis_)); log0 fprintf(Stderr,"equalities:\n"); log0 AsciiPrinter(Stderr).printVectorList(wallFlipableNormals(idealGroebnerBasis_,false)); AsciiPrinter P(Stderr); log0 theCone.print(&P); */ theCone.findFacets(); // theCone.canonicalize();//REMOVE ME JAN 2009 stableRay=PolyhedralFan::stableRay(theCone,&s); unMarkedFacetNormals=theCone.getHalfSpaces(); } IntegerVector getStableRay()const { return stableRay; } bool doesPermutationFixCone(IntegerVector const &v)const { // Cone is fixed iff stableRay is fixed. return (SymmetryGroup::compose(v,stableRay)==stableRay); } int orbitSize()const { int groupSize=s.elements.size(); int numFixed=0; for(SymmetryGroup::ElementContainer::const_iterator j=s.elements.begin();j!=s.elements.end();j++) if(doesPermutationFixCone(*j))numFixed++; // fprintf(Stderr,"groupSize = %i, numFixed = %i\n",groupSize,numFixed); return groupSize/numFixed; } void markFacet(IntegerVector const &relIntRidgeVector) { for(SymmetryGroup::ElementContainer::const_iterator j=s.elements.begin();j!=s.elements.end();j++) if(doesPermutationFixCone(*j)) { IntegerVector relIntRidgeVector2=SymmetryGroup::compose(*j,relIntRidgeVector); { for(IntegerVectorList::iterator i=unMarkedFacetNormals.begin();i!=unMarkedFacetNormals.end();) if(dotLong(*i,relIntRidgeVector2)==0) { IntegerVectorList::iterator temp=i; temp++; unMarkedFacetNormals.erase(i); i=temp; } else i++; } } } /* bool containsAndMark(PolynomialSet const &coneGroebnerBasis_, PolynomialSet const &facetIdeal, IntegerVector *labelPermutation) { for(SymmetryGroup::ElementContainer::const_iterator j=s.elements.begin();j!=s.elements.end();j++) if(areIdealsEqual(coneGroebnerBasis,SymmetryGroup::permutePolynomialSet(coneGroebnerBasis_,*j))) { PolynomialSet facetIdeal2=SymmetryGroup::permutePolynomialSet(facetIdeal,*j); bool found=false; for(PolynomialSetList::const_iterator i=markedFacets.begin();i!=markedFacets.end();i++) if(areIdealsEqual(*i,facetIdeal2)) { found=true; break; } // assert(!found); //this is not a mistake is it? markedFacets.push_back(facetIdeal2); if(labelPermutation)*labelPermutation=*j; return true; } return false; }*/ /* Alternative using only geometric information. */ bool containsAndMark(IntegerVector const &relIntFacetVector, IntegerVector const &relIntRidgeVector, IntegerVector *labelPermutation) { for(SymmetryGroup::ElementContainer::const_iterator j=s.elements.begin();j!=s.elements.end();j++) if(theCone.contains(SymmetryGroup::compose(*j,relIntFacetVector))) { markFacet(SymmetryGroup::compose(*j,relIntRidgeVector)); if(labelPermutation)*labelPermutation=*j; return true; } return false; } bool hasUnmarkedFacet()const { return(!unMarkedFacetNormals.empty()); } IntegerVector getUnmarkedFacet()const { assert(!unMarkedFacetNormals.empty()); return *unMarkedFacetNormals.begin(); } /* bool isMarkedFacet(PolynomialSet const &f) { for(SymmetryGroup::ElementContainer::const_iterator j=s.elements.begin();j!=s.elements.end();j++) if(staticPermutationFixesCone(coneGroebnerBasis,*j)) for(PolynomialSetList::const_iterator i=markedFacets.begin();i!=markedFacets.end();i++) if(areIdealsEqual(SymmetryGroup::permutePolynomialSet(f,*j),*i))return true; return false; }*/ void print(AsciiPrinter &p)const { p.printString("ConeOrbit{\n"); p.printInteger(label); p.printNewLine(); IntegerVector v=getStableRay(); /* if(v.size()==25) { p.printVector(v.subvector(0,5));p.printNewLine(); p.printVector(v.subvector(5,10));p.printNewLine(); p.printVector(v.subvector(10,15));p.printNewLine(); p.printVector(v.subvector(15,20));p.printNewLine(); p.printVector(v.subvector(20,25));p.printNewLine(); }*/ p.printVector(v); p.printNewLine(); p.printString("Orbit size:"); p.printInteger(orbitSize()); p.printString("\nConeIdeal:\n"); p.printPolynomialSet(coneGroebnerBasis); p.printString("\nFullIdeal:\n"); p.printPolynomialSet(idealGroebnerBasis); // p.printString("Unmarked facet normals:\n"); // p.printVectorList(unMarkedFacetNormals); theCone.print(&p); p.printString("}ConeOrbit\n"); } IntegerVectorList getEquations()const { return theCone.getEquations(); } IntegerVectorList getInequalities()const { return theCone.getHalfSpaces(); } }; class ConeOrbitContainer { typedef list ConeOrbitList; ConeOrbitList l; public: void push_back(const ConeOrbit &orbit) { l.push_back(orbit); } bool empty() { return l.empty(); } ConeOrbit &front() { return *l.begin(); } int size() { return l.size(); } void pop_front() { l.pop_front(); } void print(AsciiPrinter &p) { p.printString("OrbitList{\n"); for(ConeOrbitList::const_iterator i=l.begin();i!=l.end();i++) { i->print(p); // p.printPolynomialSet(i->coneGroebnerBasis); //p.printNewLine(); } p.printString("}OrbitList\n"); } bool containsAndMark(IntegerVector const &relIntFacetVector, IntegerVector const &relIntRidgeVector, int *label, IntegerVector *labelPermutation) // bool containsAndMark(PolynomialSet const &coneGroebnerBasis, PolynomialSet const &facetIdeal, int *label, IntegerVector *labelPermutation) { // fprintf(Stderr,"listlength:%i",l.size()); // int I=0; // for(ConeOrbitList::const_iterator i=l.begin();i!=l.end();i++) // { // fprintf(Stderr,"%i",I++); // } for(ConeOrbitList::iterator i=l.begin();i!=l.end();i++) { /* fprintf(Stderr,"Comparing:\n"); AsciiPrinter(Stderr).printPolynomialSet(coneGroebnerBasis); AsciiPrinter(Stderr).printPolynomialSet(i->coneGroebnerBasis); */ // if(i->containsAndMark(coneGroebnerBasis,facetIdeal,labelPermutation)) if(i->containsAndMark(relIntFacetVector,relIntRidgeVector,labelPermutation)) // if(areIdealsEqual(coneGroebnerBasis,i->coneGroebnerBasis))// this could be slow! { *label=i->label; return true; } // if(i->coneGroebnerBasis==coneGroebnerBasis)return true; } /* fprintf(Stderr,"________________NOT IN LIST:\n"); AsciiPrinter(Stderr).printPolynomialSet(coneGroebnerBasis); */ return false; } }; static int staticOrbitSize(PolynomialSet const &coneGroebnerBasis, PolynomialSet const &idealGroebnerBasis, SymmetryGroup const &s) { return ConeOrbit(s, coneGroebnerBasis, idealGroebnerBasis, -1).orbitSize(); } BergmanFan bergman(PolynomialSet const &coneGroebnerBasis1, PolynomialSet const &idealGroebnerBasis1, SymmetryGroup const *symmetryGroup) { PolynomialRing theRing=coneGroebnerBasis1.getRing(); bool useFanIntersection=true; bool isSimplicial=true; assert(coneGroebnerBasis1.numberOfVariablesInRing()==idealGroebnerBasis1.numberOfVariablesInRing()); int n=coneGroebnerBasis1.numberOfVariablesInRing(); SymmetryGroup localSymmetryGroup(n); if(!symmetryGroup)symmetryGroup=&localSymmetryGroup; BergmanFan ret; ret.setSymmetryGroup(*symmetryGroup); ConeOrbitContainer active; int maximalConeLabel=0; { ConeOrbit newConeOrbit(*symmetryGroup,coneGroebnerBasis1,idealGroebnerBasis1,maximalConeLabel++); log1 fprintf(Stderr,"Adding orbit of size: %i\n",newConeOrbit.orbitSize()); active.push_back(newConeOrbit); } while(!active.empty()) { log1 fprintf(Stderr,"\n-------------------------------------\n"); log1 fprintf(Stderr,"Size of active set: %i, Completed: %i\n",active.size(),ret.cones.size()); log1 fprintf(Stderr,"-------------------------------------\n"); AsciiPrinter p(Stderr); ConeOrbit ¤t=active.front(); /* AsciiPrinter p2(stdout);//REMOVE THESE THREE LINES current.print(p2); fflush(stdout); */ // IntegerVectorList equalities=wallInequalities(current.coneGroebnerBasis); // IntegerVectorList normals=wallFlipableNormals(current.idealGroebnerBasis,false); /* { PolyhedralCone p(normals,equalities); p.findFacets(); isSimplicial&=p.isSimplicial(); }HUSK AT INDSÆTTE DETTE IGEN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ // removeRedundantRows(&normals,&equalities,true);//IS THIS RIGHT? IntegerVectorList facePerp=current.getEquations();//equalities; /* int numberOfNormals=normals.size(); int numberOfEqualities=equalities.size(); IntegerVectorList inequalities=equalities; inequalities.splice(inequalities.begin(),normals,normals.begin(),normals.end()); IntegerVector equalitySet(inequalities.size()); for(int i=0;iidealGroebnerBasis.isMarked()); log2 cerr<<"8"; PolynomialSet g2(theRing); WeightTermOrder termOrder(termorderWeight(initialIdeal)); for(PolynomialSet::const_iterator j=i->idealGroebnerBasis.begin();j!=i->idealGroebnerBasis.end();j++) g2.push_back(divisionLift(*j, initialIdeal, current.idealGroebnerBasis, termOrder)); assert(g2.isMarked()); log2 cerr<<"9"; if(1) { log2 cerr << "AUTOREDUCTION"; autoReduce(&g2,LexicographicTermOrder()); log2 cerr << "AUTOREDUCTION END"<idealGroebnerBasis); log0 cerr << "RESTRICTED AUTOREDUCTION END"<coneGroebnerBasis,g2,-1); log2 cerr<<"0"; IntegerVector relIntFacetVector=tempConeOrbit.getStableRay(); log2 cerr<<"A"; int label=-1; IntegerVector labelPermutation; if(!active.containsAndMark(relIntFacetVector,relIntRidgeVector,&label,&labelPermutation)) // if(!active.containsAndMark(i->coneGroebnerBasis,initialIdeal,&label,&labelPermutation)) { log2 cerr<<"B"; if(!ret.contains(i->coneGroebnerBasis)) { label=maximalConeLabel++; labelPermutation=SymmetryGroup::identity(n); ConeOrbit newConeOrbit(*symmetryGroup,i->coneGroebnerBasis,g2,label); log1 fprintf(Stderr,"Adding orbit of size: %i\n",newConeOrbit.orbitSize()); //newConeOrbit.markFacet(initialIdeal); newConeOrbit.markFacet(relIntRidgeVector); active.push_back(newConeOrbit); } else { assert(0);//Can this ever happen? REMOVE JAN 2009 } log2 cerr<<"C"; } log2 cerr<<"D"; ret.codimensionOneCones.back().incidenceList.push_back(label); log2 cerr<<"E"; ret.codimensionOneCones.back().incidencePermutationList.push_back(labelPermutation); log2 cerr<<"F"; } } // else // numberOfAlreadyMarkedFacets++; } else { assert(0); } } // equalitySet[I]=0; // i++; //assert(0);//for timing purposes } log1 fprintf(Stderr,"Done processing this orbit - Number of valid facets: %i Number of already marked facets: %i\n",numberOfValidFacets,numberOfAlreadyMarkedFacets); ret.cones.push_back(BergmanFan::MaximalCone(current.coneGroebnerBasis,current.idealGroebnerBasis,false,current.label,numberOfValidFacets)); active.pop_front(); } ret.setSimplicial(isSimplicial); return ret; } //-------------------------------------- // BergmanFan //-------------------------------------- BergmanFan::MaximalCone::MaximalCone(PolynomialSet const &coneGroebnerBasis_, PolynomialSet const &idealGroebnerBasis_, bool storeIdealBasis, int label_, int numberOfFacets_): idealBasisStored(storeIdealBasis), coneGroebnerBasis(coneGroebnerBasis_), idealGroebnerBasis(idealGroebnerBasis_), label(label_), numberOfFacets(numberOfFacets_), multiplicity(-1), theCone(fastNormals(wallInequalities(idealGroebnerBasis_)), wallInequalities(coneGroebnerBasis_), idealGroebnerBasis_.getRing().getNumberOfVariables()) { if(!storeIdealBasis)idealGroebnerBasis=PolynomialSet(coneGroebnerBasis_.getRing()); theCone.canonicalize(); } int BergmanFan::numberOfMaximalCones()const { int ret=0;; for(MaximalConeList::const_iterator i=cones.begin();i!=cones.end();i++) { IntegerVector stableRay=PolyhedralFan::stableRay(i->theCone,&symmetryGroup); //ConeOrbit C(symmetryGroup, i->coneGroebnerBasis, i->idealGroebnerBasis, -1); ret+=symmetryGroup.orbitSize(stableRay);//C.orbitSize(); // ret+=staticOrbitSize(i->coneGroebnerBasis, symmetryGroup); } return ret; } void BergmanFan::print(Printer &p) { int numberOfMaximalCones=0; p.printString("Printing tropical variety modulo symmetry\n"); p.printString("-----------------"); p.printNewLine(); p.printString("1. Maximal cones:\n"); p.printString("-----------------"); p.printNewLine(); for(MaximalConeList::const_iterator i=cones.begin();i!=cones.end();i++) { p.printString("Orbit index: "); p.printInteger(i->label); p.printString("\n"); p.printString("Initial ideal:\n"); p.printPolynomialSet(i->coneGroebnerBasis); //p.printPolynomialSet(i->idealGroebnerBasis); int orbitSize=(symmetryGroup.sizeOfBaseSet())?staticOrbitSize(i->coneGroebnerBasis,i->coneGroebnerBasis,symmetryGroup):1; p.printString("OrbitSize:"); p.printInteger(orbitSize); p.printString("\n"); p.printString("NumberOfFacets:"); p.printInteger(i->numberOfFacets); p.printString("\n\n"); numberOfMaximalCones+=orbitSize; /* { IntegerVectorList normals=wallInequalities(i->idealGroebnerBasis); IntegerVectorList equations=wallInequalities(i->coneGroebnerBasis); PolyhedralCone c(normals,equations); c.canonicalize(); c.print(&p); } */ if(symmetryGroup.sizeOfBaseSet()) { list indices; int index=0; /* //This needs to be changed so that torus permutations are considered too. for(MaximalConeList::const_iterator j=cones.begin();j!=cones.end();j++,index++) if(staticInOrbit(j->coneGroebnerBasis,i->coneGroebnerBasis,symmetryGroup))indices.push_back(index); */ if(indices.size()>1) { fprintf(Stderr,"Conflicting orbits!!!!:"); for(list::const_iterator j=indices.begin();j!=indices.end();j++) fprintf(Stderr," %i ",*j); fprintf(Stderr,"\n"); } } } p.printString("-----------------------"); p.printNewLine(); p.printString("2. Codimension 1 cones:\n"); p.printString("-----------------------"); p.printNewLine(); for(CodimensionOneConeList::const_iterator i=codimensionOneCones.begin();i!=codimensionOneCones.end();i++) { //p.printString("----------------------"); // p.printNewLine(); p.printString("Groebner basis of initial ideal:\n"); p.printPolynomialSet(i->idealGroebnerBasis); // p.printNewLine(); p.printString("Adjacent maximal cones (orbit index, permutation):\n"); p.printString("("); IntegerVectorList::const_iterator J=i->incidencePermutationList.begin(); for(list::const_iterator j=i->incidenceList.begin();j!=i->incidenceList.end() && J!=i->incidencePermutationList.end();j++,J++) { if(j!=i->incidenceList.begin())p.printString(",\n"); p.printString("("); p.printInteger(*j); p.printString(", "); p.printVector(*J); p.printString(")"); } p.printString(")\n"); { int index=*(i->incidenceList.begin()); MaximalConeList::const_iterator j=cones.begin(); while(index>0){index--;j++;} // IntegerVectorList normals=wallInequalities(SymmetryGroup::permutePolynomialSet(j->idealGroebnerBasis,*(i->incidencePermutationList.begin()))); /* IntegerVectorList normals=wallInequalities(SymmetryGroup::permutePolynomialSet(j->idealGroebnerBasis,SymmetryGroup::inverse(*(i->incidencePermutationList.begin())))); IntegerVectorList equations=wallInequalities(i->idealGroebnerBasis); PolyhedralCone c(normals,equations); c.canonicalize(); c.print(&p); */ /* p.printString("-----------"); p.printNewLine(); PolyhedralFan F=PolyhedralFan::facetsOfCone(c); F.print(&p); p.printString("-----------"); p.printNewLine(); */ //p.printString("----------------------"); p.printNewLine(); } } p.printString("Done printing tropical variety - #maxcones="); p.printInteger(numberOfMaximalCones); p.printString(" ("); p.printInteger(cones.size()); p.printString(") #codim1cones= ? ("); p.printInteger(codimensionOneCones.size()); p.printString(")"); p.printNewLine(); } bool BergmanFan::contains(PolynomialSet const &g) { for(MaximalConeList::const_iterator i=cones.begin();i!=cones.end();i++) { if(areIdealsEqual(g,i->coneGroebnerBasis)) { return true; } } return false; } void BergmanFan::setSymmetryGroup(SymmetryGroup const &s) { symmetryGroup=s; } PolyhedralFan BergmanFan::toPolyhedralFan()const { assert(!cones.empty()); int n=cones.begin()->idealGroebnerBasis.numberOfVariablesInRing(); PolyhedralFan ret(n); for(MaximalConeList::const_iterator i=cones.begin();i!=cones.end();i++) { //PolyhedralCone c1(wallInequalities(i->idealGroebnerBasis),wallInequalities(i->coneGroebnerBasis)); // PolyhedralCone c1(wallFlipableNormals(i->idealGroebnerBasis,false),wallInequalities(i->coneGroebnerBasis),n); PolyhedralCone c1=i->theCone; log2 fprintf(Stderr,"Cononicalising...\n"); c1.canonicalize(); log2 fprintf(Stderr,"... done canonicalising...\n"); // fprintf(Stderr,"a\n"); // for(SymmetryGroup::ElementContainer::const_iterator j=symmetryGroup.elements.begin();j!=symmetryGroup.elements.end();j++) // { /* IntegerVectorList normals=wallInequalities(SymmetryGroup::permutePolynomialSet(i->idealGroebnerBasis,*j)); IntegerVectorList equations=wallInequalities(SymmetryGroup::permutePolynomialSet(i->coneGroebnerBasis,*j)); PolyhedralCone c(normals,equations); */ // PolyhedralCone c=c1.permuted(*j); // c.canonicalize(); c1.setMultiplicity(i->multiplicity); ret.insert(c1); // } } return ret; } void BergmanFan::setSimplicial(bool b) { simplicial=b; } bool BergmanFan::isSimplicial()const { return simplicial; } void BergmanFan::computeMultiplicities() { for(MaximalConeList::iterator i=cones.begin();i!=cones.end();i++) i->multiplicity=multiplicity(i->coneGroebnerBasis); //MULTIPLICITY TEST // AsciiPrinter(Stderr).printPolynomialSet(current.coneGroebnerBasis); // fprintf(Stderr,"MULTIPLICITY :%i\n",multiplicity(current.coneGroebnerBasis)); } gfan-0.5+dfsg/bergman.h000066400000000000000000000045411207563005400150020ustar00rootroot00000000000000#ifndef BERGMAN_H_INCLUDED #define BERGMAN_H_INCLUDED #include "polynomial.h" #include "printer.h" #include "symmetry.h" #include "polyhedralfan.h" /** Represents a tropical variety up to symmetry. New strategy implemented January 2009: We should only store the idealGroebnerBasis when actually needed. This means that for computing tropical varieties of curves it is stored, while for tropical varieties of prime ideals it should not be stored. Instead of storing the Groebner basis a polyhedral cone is stored. */ class BergmanFan { bool simplicial; public: SymmetryGroup symmetryGroup; class CodimensionOneCone { public: list incidenceList; IntegerVectorList incidencePermutationList; PolynomialSet idealGroebnerBasis; CodimensionOneCone(PolynomialSet const &idealGroebnerBasis_): idealGroebnerBasis(idealGroebnerBasis_) { } }; class MaximalCone { public: bool idealBasisStored; int label; int numberOfFacets; PolynomialSet coneGroebnerBasis; PolynomialSet idealGroebnerBasis; PolyhedralCone theCone; int multiplicity; MaximalCone(PolynomialSet const &coneGroebnerBasis_, PolynomialSet const &idealGroebnerBasis_, bool storeIdealBasis, int label_, int numberOfFacets_=-1); }; void print(Printer &p); bool contains(PolynomialSet const &g); typedef list MaximalConeList; typedef list CodimensionOneConeList; BergmanFan(): symmetryGroup(0), simplicial(false) { } MaximalConeList cones; CodimensionOneConeList codimensionOneCones; void setSymmetryGroup(SymmetryGroup const &s); PolyhedralFan toPolyhedralFan()const; int numberOfMaximalCones()const; void setSimplicial(bool b); bool isSimplicial()const; void computeMultiplicities(); }; BergmanFan bergmanRay(PolynomialSet const &idealGroebnerBasis); /** * This routine computes a tropical curve. The input is a monomial-free * homogeneous (in some positive grading) ideal with dimension equal to * 1 plus the dimension of the homogeneity space. * The output is a BergmanFan object with one MaximalCone for each ray of the curve. */ BergmanFan bergmanRayIntersection(PolynomialSet const &idealGroebnerBasis); BergmanFan bergman(PolynomialSet const &coneGroebnerBasis, PolynomialSet const &idealGroebnerBasis, SymmetryGroup const *symmetryGroup=0); #endif gfan-0.5+dfsg/bergmanBackup.cpp000066400000000000000000000625121207563005400164650ustar00rootroot00000000000000#include "bergman.h" #include "enumeration.h" #include "reversesearch.h" #include "tropical.h" #include "buchberger.h" #include "division.h" #include "dimension.h" #include "wallideal.h" #include "lp.h" #include "subspace.h" #include "symmetry.h" #include "tropical2.h" #include "tropicalbasis.h" #include "polyhedralcone.h" #include "multiplicity.h" #include "log.h" static Polynomial wallPolynomial(Polynomial const &p, Subspace const &subspace) // This routine should be deleted since it is inefficient // hmm... does this actually work? { Polynomial r(p.getRing()); IntegerVector markedExponent=p.getMarked().m.exponent; for(TermMap::const_iterator i=p.terms.begin();i!=p.terms.end();i++) { IntegerVector dif=markedExponent-i->first.exponent; if(subspace.contains(dif)) r+=Polynomial(Term(i->second,i->first)); } r.mark(Monomial(p.getRing(),markedExponent)); return r; } static PolynomialSet wallIdeal(PolynomialSet const &groebnerBasis, Subspace const &subspace) { // fprintf(Stderr,"wallIdeal %i",perp.size()); PolynomialSet ret(groebnerBasis.getRing()); for(PolynomialSet::const_iterator i=groebnerBasis.begin();i!=groebnerBasis.end();i++) ret.push_back(wallPolynomial(*i,subspace)); // fprintf(Stderr,"done\n"); return ret; } BergmanFan bergmanRayIntersection(PolynomialSet const &idealGroebnerBasis) // Input ideal is assumed to be homogeneous with respect to a positive vector // Input ideal is assumed not to contain a monomial // Call the Krull dimensionn of the ring/ideal d // The ideal is homogenous with respect to a vector space of dimension d-1 // All d dimensional cones in the Gro\"obner fan with no monomials are computed { BergmanFan bfan; int n=idealGroebnerBasis.numberOfVariablesInRing(); int d=krullDimension(idealGroebnerBasis); //There should be a better way of doing this PolyhedralFan bergmanFan(n); PolynomialSet tropBasis=tropicalBasisOfCurve(n,idealGroebnerBasis,&bergmanFan,d-1); // PolyhedralFan bergmanFan=tropicalPrincipalIntersection(n,tropBasis,d-1); IntegerVectorList rays=bergmanFan.getRays(d); int maximalConeLabel=0; // fprintf(Stderr,"---------------------------------------------------------\n"); // AsciiPrinter(Stderr).printVectorList(rays); // fprintf(Stderr,"---------------------------------------------------------\n"); for(IntegerVectorList::const_iterator i=rays.begin();i!=rays.end();i++) { PolynomialSet g=idealGroebnerBasis; buchberger(&g,WeightReverseLexicographicTermOrder(*i)); PolynomialSet cg=initialFormsAssumeMarked(g,*i); bool inList=false; for(BergmanFan::MaximalConeList::const_iterator j=bfan.cones.begin();j!=bfan.cones.end();j++) { if(areIdealsEqual(j->coneGroebnerBasis,cg)) { inList=true; break; } } if(!inList) { bfan.cones.push_back(BergmanFan::MaximalCone(cg,g,maximalConeLabel++)); } } // AsciiPrinter temp(Stderr); // bfan.print(temp); return bfan; } BergmanFan bergmanRay(PolynomialSet const &idealGroebnerBasis) // Input ideal is assumed to be homogeneous with respect to a positive vector // Input ideal is assumed not to contain a monomial // Call the Krull dimensionn of the ring/ideal d // The ideal is homogenous with respect to a vector space of dimension d-1 // All d dimensional cones in the Gro\"obner fan with no monomials are computed { BergmanFan bfan; EnumerationTargetCollector gfan; LexicographicTermOrder myTermOrder; ReverseSearch rs(myTermOrder); rs.setEnumerationTarget(&gfan); rs.enumerate(idealGroebnerBasis); int n=idealGroebnerBasis.numberOfVariablesInRing(); fprintf(Stderr,"rankOfMatrix(wallin.idealGroebnerBasis=%i\n",rankOfMatrix(wallInequalities(idealGroebnerBasis))); AsciiPrinter(Stderr).printVectorList(wallInequalities(idealGroebnerBasis)); int d=n-rankOfMatrix(wallInequalities(idealGroebnerBasis))+1; int krull=krullDimension(idealGroebnerBasis); //AsciiPrinter(Stderr).printVectorList(wallInequalities(idealGroebnerBasis)); assert(rankOfMatrix(wallInequalities(idealGroebnerBasis))==Subspace(wallInequalities(idealGroebnerBasis)).dimension()); // fprintf(Stderr,"d: %i krull: %i\n",d,krull); // assert(d==krull); int maximalConeLabel=0; for(PolynomialSetList::const_iterator g=gfan.theList.begin();g!=gfan.theList.end();g++) { PolynomialSetList s; //fprintf(Stderr,"current gbasis:\n"); //AsciiPrinter(Stderr).printPolynomialSet(*g); if(0) { s=fullColoredIdeals(*g,false); fprintf(Stderr,"Full colored ideals computed, #=%i\n",s.size()); } else { IntegerVectorList inequalities=wallInequalities(*g); inequalities=wallFlipableNormals(*g,true); int isize=inequalities.size(); // fprintf(Stderr,"cdd facets to rays "); // AsciiPrinter(Stderr).printVectorList(inequalities); IntegerVectorList rays=extremeRaysInequalityIndices(inequalities); //fprintf(Stderr,"done\n"); //AsciiPrinter(Stderr).printVectorList(rays); // AsciiPrinter(Stderr).printVectorList(rays); for(IntegerVectorList::const_iterator i=rays.begin();i!=rays.end();i++) if(i->size()!=isize) { IntegerVectorList perp; int j=0; int K=0; for(IntegerVectorList::const_iterator k=inequalities.begin();k!=inequalities.end()&&jsize();k++,K++) if((*i)[j]==K) { perp.push_back(*k); j++; } s.push_back(wallIdeal(*g,Subspace(perp))); } } //fprintf(Stderr,"Number of face ideals to check:%i\n",s.size()); for(PolynomialSetList::const_iterator i=s.begin();i!=s.end();i++) { //fprintf(Stderr,"d:%i\n",d); //fprintf(Stderr,"krull:%i\n",krull); //fprintf(Stderr,"n:%i\n",n); //fprintf(Stderr,"rank: %i\n",rankOfMatrix(wallInequalities(*i))); assert(i->isMarked()); // fprintf(Stderr,"d: %i, rank %i",d,n-rankOfMatrix(wallInequalities(*i))); if(d==n-rankOfMatrix(wallInequalities(*i)))//dimension check { // fprintf(Stderr,"Checking monomial containment"); if(!containsMonomial(*i)) { // fprintf(Stderr,"Done - no\n"); PolynomialSet cg=*i; //buchberger(&cg,StandardGradedLexicographicTermOrder()); The cg is already a Groebner basis bool inList=false; for(BergmanFan::MaximalConeList::const_iterator j=bfan.cones.begin();j!=bfan.cones.end();j++) { if(areIdealsEqual(j->coneGroebnerBasis,cg)) { inList=true; break; } } if(!inList) { bfan.cones.push_back(BergmanFan::MaximalCone(cg,*g,maximalConeLabel++)); } } // else // fprintf(Stderr,"Done - yes\n"); } else fprintf(Stderr,"dimension check fails\n"); } } //fprintf(Stderr,"No duplicates:\n"); /* for(PolynomialSetList::const_iterator i=tropical.begin();i!=tropical.end();i++) { AsciiPrinter(Stdout).printPolynomialList(i->coneGroebnerBasis); int coDim=rankOfMatrix(wallInequalities(*i)); int d=i->numberOfVariablesInRing()-coDim; fprintf(Stderr,"%i\n",d); } */ return bfan; } static bool staticInOrbit(PolynomialSet const &groebnerBasis1, PolynomialSet const &groebnerBasis2, SymmetryGroup const &s) { for(SymmetryGroup::ElementContainer::const_iterator j=s.elements.begin();j!=s.elements.end();j++) if(areIdealsEqual(SymmetryGroup::permutePolynomialSet(groebnerBasis2,*j),groebnerBasis1))return true; return false; } static bool staticPermutationFixesCone(PolynomialSet const &groebnerBasis, IntegerVector const &v) { // Cone is fixed iff the cone ideal is fixed. PolynomialSet q(groebnerBasis.getRing()); for(PolynomialSet::const_iterator i=groebnerBasis.begin();i!=groebnerBasis.end();i++) { q.push_back(SymmetryGroup::permutePolynomial(*i,v)); } return areIdealsEqual(q,groebnerBasis); } static int staticOrbitSize(PolynomialSet const &groebnerBasis, SymmetryGroup const &s) { int groupSize=s.elements.size(); int numFixed=0; for(SymmetryGroup::ElementContainer::const_iterator j=s.elements.begin();j!=s.elements.end();j++) if(staticPermutationFixesCone(groebnerBasis,*j))numFixed++; // fprintf(Stderr,"groupSize = %i, numFixed = %i\n",groupSize,numFixed); return groupSize/numFixed; } class ConeOrbit { public: const SymmetryGroup &s; PolynomialSet coneGroebnerBasis; PolynomialSet idealGroebnerBasis; int label; PolynomialSetList markedFacets; PolyhedralCone theCone; ConeOrbit(const SymmetryGroup &s_, PolynomialSet const &coneGroebnerBasis_, PolynomialSet const &idealGroebnerBasis_, int label_): coneGroebnerBasis(coneGroebnerBasis_), idealGroebnerBasis(idealGroebnerBasis_), label(label_), s(s_), theCone(wallInequalities(coneGroebnerBasis_), wallFlipableNormals(idealGroebnerBasis_,false), idealGroebnerBasis_.getRing().getNumberOfVariables()) { theCone.findFacets(); } void markFacet(PolynomialSet const &f) { markedFacets.push_back(f); } bool containsAndMark(PolynomialSet const &coneGroebnerBasis_, PolynomialSet const &facetIdeal, IntegerVector *labelPermutation) { for(SymmetryGroup::ElementContainer::const_iterator j=s.elements.begin();j!=s.elements.end();j++) if(areIdealsEqual(coneGroebnerBasis,SymmetryGroup::permutePolynomialSet(coneGroebnerBasis_,*j))) { PolynomialSet facetIdeal2=SymmetryGroup::permutePolynomialSet(facetIdeal,*j); bool found=false; for(PolynomialSetList::const_iterator i=markedFacets.begin();i!=markedFacets.end();i++) if(areIdealsEqual(*i,facetIdeal2)) { found=true; break; } // assert(!found); //this is not a mistake is it? markedFacets.push_back(facetIdeal2); if(labelPermutation)*labelPermutation=*j; return true; } return false; } /* Alternative using only geometric information. */ /* bool containsAndMark(IntegerVector const &v, IntegerVector *labelPermutation) { for(SymmetryGroup::ElementContainer::const_iterator j=s.elements.begin();j!=s.elements.end();j++) if(theCone.contains(SymmetryGroup::compose(*j,v))) { // PolynomialSet facetIdeal2=SymmetryGroup::permutePolynomialSet(facetIdeal,*j); bool found=false; for(PolynomialSetList::const_iterator i=markedFacets.begin();i!=markedFacets.end();i++) if(areIdealsEqual(*i,facetIdeal2)) { found=true; break; } // assert(!found); //this is not a mistake is it? markedFacets.push_back(facetIdeal2); if(labelPermutation)*labelPermutation=*j; return true; } return false; }*/ bool isMarkedFacet(PolynomialSet const &f) { for(SymmetryGroup::ElementContainer::const_iterator j=s.elements.begin();j!=s.elements.end();j++) if(staticPermutationFixesCone(coneGroebnerBasis,*j)) for(PolynomialSetList::const_iterator i=markedFacets.begin();i!=markedFacets.end();i++) if(areIdealsEqual(SymmetryGroup::permutePolynomialSet(f,*j),*i))return true; return false; } int orbitSize() { return staticOrbitSize(coneGroebnerBasis,s); } void print(AsciiPrinter &p)const { p.printString("ConeOrbit{\n"); p.printInteger(label); p.printString("\nConeIdeal:\n"); p.printPolynomialSet(coneGroebnerBasis); p.printString("\nFullIdeal:\n"); p.printPolynomialSet(idealGroebnerBasis); p.printString("Marked facets:\n"); p.printPolynomialSetList(markedFacets); p.printString("}ConeOrbit\n"); } }; class ConeOrbitContainer { typedef list ConeOrbitList; ConeOrbitList l; public: void push_back(const ConeOrbit &orbit) { l.push_back(orbit); } bool empty() { return l.empty(); } ConeOrbit &front() { return *l.begin(); } int size() { return l.size(); } void pop_front() { l.pop_front(); } void print(AsciiPrinter &p) { p.printString("OrbitList{\n"); for(ConeOrbitList::const_iterator i=l.begin();i!=l.end();i++) { i->print(p); // p.printPolynomialSet(i->coneGroebnerBasis); //p.printNewLine(); } p.printString("}OrbitList\n"); } bool containsAndMark(PolynomialSet const &coneGroebnerBasis, PolynomialSet const &facetIdeal, int *label, IntegerVector *labelPermutation) { // fprintf(Stderr,"listlength:%i",l.size()); // int I=0; // for(ConeOrbitList::const_iterator i=l.begin();i!=l.end();i++) // { // fprintf(Stderr,"%i",I++); // } for(ConeOrbitList::iterator i=l.begin();i!=l.end();i++) { /* fprintf(Stderr,"Comparing:\n"); AsciiPrinter(Stderr).printPolynomialSet(coneGroebnerBasis); AsciiPrinter(Stderr).printPolynomialSet(i->coneGroebnerBasis); */ if(i->containsAndMark(coneGroebnerBasis,facetIdeal,labelPermutation)) // if(areIdealsEqual(coneGroebnerBasis,i->coneGroebnerBasis))// this could be slow! { *label=i->label; return true; } // if(i->coneGroebnerBasis==coneGroebnerBasis)return true; } /* fprintf(Stderr,"________________NOT IN LIST:\n"); AsciiPrinter(Stderr).printPolynomialSet(coneGroebnerBasis); */ return false; } }; BergmanFan bergman(PolynomialSet const &coneGroebnerBasis1, PolynomialSet const &idealGroebnerBasis1, SymmetryGroup const *symmetryGroup) { PolynomialRing theRing=coneGroebnerBasis1.getRing(); bool useFanIntersection=true; bool isSimplicial=true; assert(coneGroebnerBasis1.numberOfVariablesInRing()==idealGroebnerBasis1.numberOfVariablesInRing()); int n=coneGroebnerBasis1.numberOfVariablesInRing(); SymmetryGroup localSymmetryGroup(n); if(!symmetryGroup)symmetryGroup=&localSymmetryGroup; BergmanFan ret; ret.setSymmetryGroup(*symmetryGroup); ConeOrbitContainer active; int maximalConeLabel=0; { ConeOrbit newConeOrbit(*symmetryGroup,coneGroebnerBasis1,idealGroebnerBasis1,maximalConeLabel++); log1 fprintf(Stderr,"Adding orbit of size: %i\n",newConeOrbit.orbitSize()); active.push_back(newConeOrbit); } while(!active.empty()) { log1 fprintf(Stderr,"\n-------------------------------------\n"); log1 fprintf(Stderr,"Size of active set: %i, Completed: %i\n",active.size(),ret.cones.size()); log1 fprintf(Stderr,"-------------------------------------\n"); AsciiPrinter p(Stderr); // fprintf(Stderr,"----------------Active--------------------\n"); // active.print(p); // ret.print(p); ConeOrbit ¤t=active.front(); assert(current.idealGroebnerBasis.isMarked()); assert(current.coneGroebnerBasis.isMarked()); /* fprintf(Stderr,"ConeGroebnerBasis:\n"); AsciiPrinter(Stderr).printPolynomialSet(current.coneGroebnerBasis); fprintf(Stderr,"\n"); fprintf(Stderr,"IdealGroebnerBasis:\n"); AsciiPrinter(Stderr).printPolynomialSet(current.idealGroebnerBasis); fprintf(Stderr,"\n"); */ IntegerVectorList equalities=wallInequalities(current.coneGroebnerBasis); /*fprintf(Stderr,"Perp:\n"); AsciiPrinter(Stderr).printVectorList(facePerp); AsciiPrinter(Stderr).printPolynomialSet(current.idealGroebnerBasis); */ IntegerVectorList normals=wallFlipableNormals(current.idealGroebnerBasis,false); /*fprintf(Stderr,"Normals:\n"); AsciiPrinter(Stderr).printVectorList(normals); */ { PolyhedralCone p(normals,equalities); p.findFacets(); isSimplicial&=p.isSimplicial(); } removeRedundantRows(&normals,&equalities,true);//IS THIS RIGHT? IntegerVectorList facePerp=equalities; int numberOfNormals=normals.size(); int numberOfEqualities=equalities.size(); IntegerVectorList inequalities=equalities; inequalities.splice(inequalities.begin(),normals,normals.begin(),normals.end()); IntegerVector equalitySet(inequalities.size()); for(int i=0;iidealGroebnerBasis.isMarked()); int label=-1; IntegerVector labelPermutation; if(!active.containsAndMark(i->coneGroebnerBasis,initialIdeal,&label,&labelPermutation)) { if(!ret.contains(i->coneGroebnerBasis)) { /*fprintf(Stderr,"Lifting...\n"); AsciiPrinter(Stderr).printPolynomialSet(i->idealGroebnerBasis); */ PolynomialSet g2(theRing); for(PolynomialSet::const_iterator j=i->idealGroebnerBasis.begin();j!=i->idealGroebnerBasis.end();j++) g2.push_back(divisionLift(*j, initialIdeal, current.idealGroebnerBasis, LexicographicTermOrder())); //fprintf(Stderr,"Done lifting.\n"); assert(g2.isMarked()); //fprintf(Stderr,"Autoreducing...\n"); //AsciiPrinter(Stderr).printPolynomialSet(g2); autoReduce(&g2,LexicographicTermOrder()); //fprintf(Stderr,"Done autoreducing.\n"); // fprintf(Stderr,"Inserting:\n"); // AsciiPrinter(Stderr).printPolynomialSet(i->coneGroebnerBasis); // AsciiPrinter(Stderr).printPolynomialSet(g2); label=maximalConeLabel++; labelPermutation=SymmetryGroup::identity(n); ConeOrbit newConeOrbit(*symmetryGroup,i->coneGroebnerBasis,g2,label); log1 fprintf(Stderr,"Adding orbit of size: %i\n",newConeOrbit.orbitSize()); newConeOrbit.markFacet(initialIdeal); active.push_back(newConeOrbit); } } ret.codimensionOneCones.back().incidenceList.push_back(label); ret.codimensionOneCones.back().incidencePermutationList.push_back(labelPermutation); } } else numberOfAlreadyMarkedFacets++; } } equalitySet[I]=0; i++; } log1 fprintf(Stderr,"Done processing this orbit - Number of valid facets: %i Number of already marked facets: %i\n",numberOfValidFacets,numberOfAlreadyMarkedFacets); ret.cones.push_back(BergmanFan::MaximalCone(current.coneGroebnerBasis,current.idealGroebnerBasis,current.label,numberOfValidFacets)); active.pop_front(); } ret.setSimplicial(isSimplicial); return ret; } //-------------------------------------- // BergmanFan //-------------------------------------- int BergmanFan::numberOfMaximalCones()const { int ret=0;; for(MaximalConeList::const_iterator i=cones.begin();i!=cones.end();i++) ret+=staticOrbitSize(i->coneGroebnerBasis, symmetryGroup); return ret; } void BergmanFan::print(Printer &p) { int numberOfMaximalCones=0; p.printString("Printing tropical variety modulo symmetry\n"); p.printString("-----------------"); p.printNewLine(); p.printString("1. Maximal cones:\n"); p.printString("-----------------"); p.printNewLine(); for(MaximalConeList::const_iterator i=cones.begin();i!=cones.end();i++) { p.printString("Orbit index: "); p.printInteger(i->label); p.printString("\n"); p.printString("Groebner pair:\n"); p.printPolynomialSet(i->coneGroebnerBasis); p.printPolynomialSet(i->idealGroebnerBasis); int orbitSize=(symmetryGroup.sizeOfBaseSet())?staticOrbitSize(i->coneGroebnerBasis,symmetryGroup):1; p.printString("OrbitSize:"); p.printInteger(orbitSize); p.printString("\n"); p.printString("NumberOfFacets:"); p.printInteger(i->numberOfFacets); p.printString("\n\n"); numberOfMaximalCones+=orbitSize; /* { IntegerVectorList normals=wallInequalities(i->idealGroebnerBasis); IntegerVectorList equations=wallInequalities(i->coneGroebnerBasis); PolyhedralCone c(normals,equations); c.canonicalize(); c.print(&p); } */ if(symmetryGroup.sizeOfBaseSet()) { list indices; int index=0; for(MaximalConeList::const_iterator j=cones.begin();j!=cones.end();j++,index++) if(staticInOrbit(j->coneGroebnerBasis,i->coneGroebnerBasis,symmetryGroup))indices.push_back(index); if(indices.size()>1) { fprintf(Stderr,"Conflicting orbits!!!!:"); for(list::const_iterator j=indices.begin();j!=indices.end();j++) fprintf(Stderr," %i ",*j); fprintf(Stderr,"\n"); } } } p.printString("-----------------------"); p.printNewLine(); p.printString("2. Codimension 1 cones:\n"); p.printString("-----------------------"); p.printNewLine(); for(CodimensionOneConeList::const_iterator i=codimensionOneCones.begin();i!=codimensionOneCones.end();i++) { //p.printString("----------------------"); // p.printNewLine(); p.printString("Groebner basis of initial ideal:\n"); p.printPolynomialSet(i->idealGroebnerBasis); // p.printNewLine(); p.printString("Adjacent maximal cones (orbit index, permutation):\n"); p.printString("("); IntegerVectorList::const_iterator J=i->incidencePermutationList.begin(); for(list::const_iterator j=i->incidenceList.begin();j!=i->incidenceList.end() && J!=i->incidencePermutationList.end();j++,J++) { if(j!=i->incidenceList.begin())p.printString(",\n"); p.printString("("); p.printInteger(*j); p.printString(", "); p.printVector(*J); p.printString(")"); } p.printString(")\n"); { int index=*(i->incidenceList.begin()); MaximalConeList::const_iterator j=cones.begin(); while(index>0){index--;j++;} // IntegerVectorList normals=wallInequalities(SymmetryGroup::permutePolynomialSet(j->idealGroebnerBasis,*(i->incidencePermutationList.begin()))); /* IntegerVectorList normals=wallInequalities(SymmetryGroup::permutePolynomialSet(j->idealGroebnerBasis,SymmetryGroup::inverse(*(i->incidencePermutationList.begin())))); IntegerVectorList equations=wallInequalities(i->idealGroebnerBasis); PolyhedralCone c(normals,equations); c.canonicalize(); c.print(&p); */ /* p.printString("-----------"); p.printNewLine(); PolyhedralFan F=PolyhedralFan::facetsOfCone(c); F.print(&p); p.printString("-----------"); p.printNewLine(); */ //p.printString("----------------------"); p.printNewLine(); } } p.printString("Done printing tropical variety - #maxcones="); p.printInteger(numberOfMaximalCones); p.printString(" ("); p.printInteger(cones.size()); p.printString(") #codim1cones= ? ("); p.printInteger(codimensionOneCones.size()); p.printString(")"); p.printNewLine(); } bool BergmanFan::contains(PolynomialSet const &g) { for(MaximalConeList::const_iterator i=cones.begin();i!=cones.end();i++) { if(areIdealsEqual(g,i->coneGroebnerBasis)) { return true; } } return false; } void BergmanFan::setSymmetryGroup(SymmetryGroup const &s) { symmetryGroup=s; } PolyhedralFan BergmanFan::toPolyhedralFan()const { assert(!cones.empty()); int n=cones.begin()->idealGroebnerBasis.numberOfVariablesInRing(); PolyhedralFan ret(n); for(MaximalConeList::const_iterator i=cones.begin();i!=cones.end();i++) { PolyhedralCone c1(wallInequalities(i->idealGroebnerBasis),wallInequalities(i->coneGroebnerBasis)); log1 fprintf(Stderr,"Cononicalising...\n"); c1.canonicalize(); log1 fprintf(Stderr,"... done canonicalising...\n"); // fprintf(Stderr,"a\n"); // for(SymmetryGroup::ElementContainer::const_iterator j=symmetryGroup.elements.begin();j!=symmetryGroup.elements.end();j++) // { /* IntegerVectorList normals=wallInequalities(SymmetryGroup::permutePolynomialSet(i->idealGroebnerBasis,*j)); IntegerVectorList equations=wallInequalities(SymmetryGroup::permutePolynomialSet(i->coneGroebnerBasis,*j)); PolyhedralCone c(normals,equations); */ // PolyhedralCone c=c1.permuted(*j); // c.canonicalize(); c1.setMultiplicity(i->multiplicity); ret.insert(c1); // } } return ret; } void BergmanFan::setSimplicial(bool b) { simplicial=b; } bool BergmanFan::isSimplicial()const { return simplicial; } void BergmanFan::computeMultiplicities() { for(MaximalConeList::iterator i=cones.begin();i!=cones.end();i++) i->multiplicity=multiplicity(i->coneGroebnerBasis); //MULTIPLICITY TEST // AsciiPrinter(Stderr).printPolynomialSet(current.coneGroebnerBasis); // fprintf(Stderr,"MULTIPLICITY :%i\n",multiplicity(current.coneGroebnerBasis)); } gfan-0.5+dfsg/binomial.cpp000066400000000000000000000020231207563005400155050ustar00rootroot00000000000000#include "binomial.h" #include "field_zmodpz.h" IntegerVector binomialToIntegerVector(Polynomial const &p) { if(p.isZero()) { assert(0); // There is no way of finding the dimension!! return IntegerVector(0); } assert(p.numberOfTerms()==2); assert(p.isMarked()); IntegerVector markedExponent=p.getMarked().m.exponent; IntegerVector ret; for(TermMap::const_iterator j=p.terms.begin();j!=p.terms.end();j++) { IntegerVector dif=markedExponent-j->first.exponent; if(!dif.isZero()) { ret=dif; } } return ret; } Polynomial integerVectorToBinomial(IntegerVector const &v, PolynomialRing const &r) { IntegerVector pos=max(v,IntegerVector(v.size())); IntegerVector neg=pos-v; Field field=r.getField(); // if(!field)field=theZMod2ZField();//should this be changed to the global field?? Term a(field.zHomomorphism(1),Monomial(r,pos)); Term b(field.zHomomorphism(-1),Monomial(r,neg)); Polynomial p=Polynomial(a)+Polynomial(b); p.mark(Monomial(r,pos)); return p; } gfan-0.5+dfsg/binomial.h000066400000000000000000000003771207563005400151640ustar00rootroot00000000000000#ifndef BINOMIAL_H_INCLUDED #define BINOMIAL_H_INCLUDED #include "vektor.h" #include "polynomial.h" IntegerVector binomialToIntegerVector(Polynomial const &p); Polynomial integerVectorToBinomial(IntegerVector const &v, PolynomialRing const &r); #endif gfan-0.5+dfsg/breadthfirstsearch.cpp000066400000000000000000000325421207563005400175730ustar00rootroot00000000000000// To do: The facet detection in this file may not work for non-homogeneous ideals since facets pass the test even if they do not contain a positive vector. Check if this is the case and fix the bug. #include "breadthfirstsearch.h" #include "buchberger.h" #include "wallideal.h" #include "printer.h" #include "polyhedralcone.h" #include "polyhedralfan.h" #include "lp.h" #include "log.h" #include bool findPermutationTakingVectorToCone(SymmetryGroup const &s, PolyhedralCone const &cone, IntegerVector const &w, IntegerVector &perm, IntegerVector const &facetNormal) {//Assume full dimensional log3 AsciiPrinter(Stderr)<<"Find perm called on, w" < computePolynomialLengths(const PolynomialSet &s) { list l; for(PolynomialSet::const_iterator i=s.begin();i!=s.end();i++) l.push_back(i->numberOfTerms()); l.sort(); return l; } public: class Summary{ int numberOfPolynomials; list polynomialLengths; IntegerVector sortedExponentsSum; public: Summary(PolynomialSet const &g) { polynomialLengths=computePolynomialLengths(g); numberOfPolynomials=g.size(); PolynomialSet p=g.markedTermIdeal(); sortedExponentsSum=p.exponentsSum(); sortedExponentsSum.sort(); } bool operator==(Summary const &b)const { if(b.numberOfPolynomials!=numberOfPolynomials)return false; if(b.sortedExponentsSum!=sortedExponentsSum)return false; list::const_iterator i=polynomialLengths.begin(); for(list::const_iterator j=b.polynomialLengths.begin();j!=b.polynomialLengths.end();j++) { if(*j!=*i)return false; i++; } return true; } }; private: const SymmetryGroup &s; PolynomialSet const *originalG; PolynomialSet g; // PolynomialSet initialIdeal; IntegerVectorList markedFacets; PolyhedralCone cone; Summary theSummary; public: IntegerVector stableRay; Orbit(const PolynomialSet &g_, const SymmetryGroup &s_, PolynomialSet const *originalG_=0): s(s_), g(g_), // initialIdeal(g_.markedTermIdeal()), cone(g_.getRing().getNumberOfVariables()), theSummary(g_), originalG(originalG_) //g(g_.markedTermIdeal()) //monomialideal { g.sort_(); //initialIdeal.sort_();//added 27.02.2008 cone=coneFromMarkedBasis(g); stableRay=PolyhedralFan::stableRay(cone,&s); // log0 fprintf(Stderr,"Stable ray found\n"); if(originalG)g=PolynomialSet(g.getRing());// Forget basis if Minkowskisum } const PolynomialSet representative()const { if(originalG)// Reconstruct basis if Minkowskisum { PolynomialSet gret=*originalG; WeightTermOrder T(stableRay); gret.markAndScale(T); return gret; } return g; } const IntegerVectorList &getMarkedFacets()const { return markedFacets; } IntegerVectorList getFacets()const { return cone.getHalfSpaces(); } void markFacet(const IntegerVector &facet) { markedFacets.push_back(facet); } bool containsAndMark(const PolynomialSet &p_, Summary const &theSummary, IntegerVector const &w, const IntegerVector &v) { // log0 fprintf(stderr,"containsAndMark\n"); //PolynomialRing theRing=p_.getRing(); // PolynomialSet p=p_.markedTermIdeal(); if(!(theSummary==this->theSummary))return false; { /* PolynomialSet &g=initialIdeal; // simple tests if(p.size()!=g.size())return false; { list P=polynomialLengths(p); list G=polynomialLengths(g); list::const_iterator i=P.begin(); for(list::const_iterator j=G.begin();j!=G.end();j++) { if(*j!=*i)return false; i++; } } { vector a; // sort(a.begin(),a.end()); IntegerVector P=p.exponentsSum(); IntegerVector G=g.exponentsSum(); P.sort(); G.sort(); if(P!=G)return false; } */ // checking all elements IntegerVector perm; if(findPermutationTakingVectorToCone(s,cone,w,perm,v)) { markFacet(SymmetryGroup::compose(perm,v)); return true; } /* for(SymmetryGroup::ElementContainer::const_iterator j=s.elements.begin();j!=s.elements.end();j++) { if(cone.contains(SymmetryGroup::compose(*j,w))) { markFacet(SymmetryGroup::compose(*j,v)); return true; } }*/ } // log0 fprintf(stderr,"ret\n"); return false; } bool permutationFixesInitialIdeal(IntegerVector const &v) { /* PolynomialSet G=g.markedTermIdeal(); G.sort_(); PolynomialSet q(G.getRing()); for(PolynomialSet::const_iterator i=G.begin();i!=G.end();i++) { q.push_back(SymmetryGroup::permutePolynomial(*i,v)); } q.sort_(); return (q==G); */ return SymmetryGroup::compose(v,stableRay)==stableRay; } int orbitSize() { int groupSize=s.elements.size(); int numFixed=0; for(SymmetryGroup::ElementContainer::const_iterator j=s.elements.begin();j!=s.elements.end();j++) { // fprintf(Stderr,"1a\n"); if(permutationFixesInitialIdeal(*j))numFixed++; // fprintf(Stderr,"1b\n"); } log2 fprintf(Stderr,"numFixed = %i\n",numFixed); return groupSize/numFixed; } }; typedef list OrbitList; class OrbitContainer{ public: int theSize; OrbitList l; OrbitContainer(): theSize(0) { } void push_back(const Orbit &orbit) { theSize++; l.push_back(orbit); // breadth first // l.push_front(orbit); // depth first } bool empty() { return theSize==0; // return l.empty(); } Orbit &front() { return *l.begin(); } void pop_front() { l.pop_front(); theSize--; } bool containsAndMark(const PolynomialSet &g, IntegerVector const &w, const IntegerVector &v) { Orbit::Summary theSummary(g); for(OrbitList::iterator i=l.begin();i!=l.end();i++) { log3 AsciiPrinter(Stderr)<<"loopin\n"; if(i->containsAndMark(g,theSummary,w,v))return true; } return false; } void print(FILE *f) { AsciiPrinter p(f); p.printString("<\n"); for(OrbitList::const_iterator i=l.begin();i!=l.end();i++) { p.printVector(i->stableRay); p.printPolynomialSet(i->representative()); p.printVectorList(i->getMarkedFacets()); } p.printString(">\n"); } int size() { return theSize; } }; void BreadthFirstSearch::setSubspace(IntegerVectorList const &subspacePerp_) { subspacePerp=subspacePerp_; } void BreadthFirstSearch::enumerate(const PolynomialSet &groebnerBasis) { int n=groebnerBasis.getRing().getNumberOfVariables(); int numberOfClosedVertices=0; int numberOfVertices=0; targetBeginEnumeration(groebnerBasis); OrbitContainer active; if(minkowski) active.push_back(Orbit(groebnerBasis,symmetryGroup,&groebnerBasis)); else active.push_back(Orbit(groebnerBasis,symmetryGroup)); while(!active.empty()) { if(!subspacePerp.empty()) { IntegerVectorList inequalities=wallInequalities(active.front().representative()); for(IntegerVectorList::const_iterator i=subspacePerp.begin();i!=subspacePerp.end();i++) inequalities.push_front(*i); IntegerVector equalitySet(inequalities.size()); for(int i=0;i class Boundary2 { typedef pair EFirst; typedef pair ESecond; SymmetryGroup const &sym; map theSet; int theSetSize; public: Boundary2(SymmetryGroup const &sym_): sym(sym_), theSetSize(0) { } int size()const { return theSetSize; } pair normalForm(IntegerVector const &ridge, IntegerVector const &ray)const { pair ret; IntegerVector perm; ret.first=sym.orbitRepresentative(ridge,&perm); ret.second=sym.orbitRepresentativeFixing(SymmetryGroup::compose(perm,ray),ret.first); return ret; } bool containsFlip(IntegerVector const &ridge, IntegerVector const &ray, IntegerVectorList *storedInList_, IntegerVectorList::iterator listIterator_) { assert(ridge.size()==ray.size()); EFirst p=normalForm(ridge,ray); if(theSet.count(p)==1) { theSet[p].first->erase(theSet[p].second); theSet.erase(p); theSetSize--; return true; } theSet[p]=ESecond(storedInList_,listIterator_); theSetSize++; return false; } void removeDuplicates(IntegerVector const &ridge, IntegerVectorList &rays)const { IntegerVectorList ret; set representatives; for(IntegerVectorList::const_iterator i=rays.begin();i!=rays.end();i++) { IntegerVector rep=sym.orbitRepresentativeFixing(*i,ridge); if(representatives.count(rep)==0) { representatives.insert(rep); ret.push_back(*i); } } rays=ret; } void print()const { cerr<< "Boundary" <::const_iterator i=theSet.begin();i!=theSet.end();i++) { AsciiPrinter P(Stderr); P << i->first.first << i->first.second; cerr << endl; } cerr<getMarked().m.exponent==B->getMarked().m.exponent); } static void printMarkedTermIdeal(PolynomialSet const &g, string const &s) { PolynomialSet a=g.markedTermIdeal(); PolynomialSet b=a; minimize(&b); cerr << "Printing marked termideal. "< const &facetStack) { list::const_iterator i=facetStack.begin(); AsciiPrinter P(Stderr); cerr<<"STACK:"<ridges; cerr< facetStack; int numberOfCompletedFacets=0; int numberOfCompletedRidges=0; int stackSize=0; PolyhedralCone currentFacet(n); IntegerVector facetUniqueVector; goto entry; while(1) { if(!facetStack.front().ridges.empty()) { IntegerVector normal=facetStack.front().ridges.front(); current=(minkowski)?flipMinkowski(g,normal):flip(g,normal); //P<<"RIDGE"< #include #include #include "division.h" #include "printer.h" #include "timer.h" #include "parser.h" #include "log.h" static Timer buchbergerTimer("Buchberger",10); Polynomial sPolynomial(Polynomial a, Polynomial b) { bool comments=false; if(comments) { AsciiPrinter(Stderr).printString("S("); AsciiPrinter(Stderr).printPolynomial(a); AsciiPrinter(Stderr).printString(","); AsciiPrinter(Stderr).printPolynomial(b); AsciiPrinter(Stderr).printString(")="); } //marked coefficient of a and b must be one IntegerVector ina=a.getMarked().m.exponent; IntegerVector inb=b.getMarked().m.exponent; IntegerVector L=max(ina,inb); if(comments) AsciiPrinter(Stderr).printVector(L); FieldElement const &f=a.getMarked().c; Polynomial A=a;A*=Term(f.one(),Monomial(a.getRing(),L-ina)); Polynomial B=b;B*=Term(f.one(),Monomial(b.getRing(),L-inb)); if(comments) { AsciiPrinter(Stderr).printPolynomial(A-B); AsciiPrinter(Stderr).printString("\n"); } return A-B; } // Simple Buchberger void buchberger/*Simple*/(PolynomialSet *g, TermOrder const &termOrder, bool allowSaturation) { PolynomialRing theRing=g->getRing(); // log2 fprintf(Stderr,"ENTERING buchberger\n"); TimerScope ts(&buchbergerTimer); PolynomialSet sPolynomials(theRing); for(PolynomialSet::const_iterator i=g->begin();i!=g->end();i++) if(!i->isZero())sPolynomials.push_back(*i); // It is safe and useful to ignore the 0 polynomial if(allowSaturation)sPolynomials.saturate(); sPolynomials.markAndScale(termOrder); *g=PolynomialSet(theRing); while(!sPolynomials.empty()) { Polynomial p=*sPolynomials.begin(); sPolynomials.pop_front(); p=division(p,*g,termOrder); if(!p.isZero()) { if(allowSaturation)p.saturate(); p.mark(termOrder); p.scaleMarkedCoefficientToOne(); bool isMonomial=p.isMonomial(); for(PolynomialSet::const_iterator i=g->begin();i!=g->end();i++) if((!isMonomial) || (!i->isMonomial())) // 2 % speed up! { if(!relativelyPrime(i->getMarked().m.exponent,p.getMarked().m.exponent)) { Polynomial s=sPolynomial(*i,p); s.mark(termOrder); // with respect to some termorder s.scaleMarkedCoefficientToOne(); sPolynomials.push_back(s); } } g->push_back(p); { static int t; t++; // if((t&31)==0)fprintf(Stderr," gsize %i spolys:%i\n",g->size(),sPolynomials.size()); } } } //log2 fprintf(Stderr," buchberger minimize\n"); minimize(g); //log2 fprintf(Stderr," buchberger autoreduce\n"); autoReduce(g,termOrder); //log2 fprintf(Stderr,"LEAVING buchberger\n\n"); } // Buchberger with chain criterion struct ChainPair { PolynomialSet::const_iterator a,b; int A,B; IntegerVector lcm; ChainPair(PolynomialSet::const_iterator const &a_,PolynomialSet::const_iterator const &b_,int A_,int B_): a(a_), b(b_), A(A_), B(B_), lcm(max(a_->getMarked().m.exponent,b_->getMarked().m.exponent)) { } bool operator<(const ChainPair & b)const { if(b.lcm.sum()b.A)return false; if(Bb.B)return false; assert(0); } }; typedef set ChainPairList; static bool canBeRemoved(ChainPairList const &P, IntegerVector const &lcm, PolynomialSet::const_iterator i, PolynomialSet::const_iterator l) { // return false; for(ChainPairList::const_iterator t=P.begin();t!=P.end();t++) { if(t->a==i && t->b!=l && t->b->getMarked().m.exponent.divides(lcm)/* || t->b==i && t->a!=l && t->a->getMarked().m.exponent.divides(lcm) || t->a==l && t->b!=i && t->b->getMarked().m.exponent.divides(lcm) || t->b==l && t->a!=i && t->a->getMarked().m.exponent.divides(lcm)*/)return true; } return false; } void printPairs(ChainPairList const &P) { return; for(ChainPairList::const_iterator t=P.begin();t!=P.end();t++) { cerr<<"("<A<<","<B<<")["; AsciiPrinter(Stderr)<a->getMarked()<<","<b->getMarked()<<"]<"<lcm <<">"; } cerr<getRing(); TimerScope ts(&buchbergerTimer); { PolynomialSet g2(theRing); for(PolynomialSet::const_iterator i=g->begin();i!=g->end();i++) if(!i->isZero())g2.push_back(*i); // It is safe and useful to ignore the 0 polynomial *g=g2; } g->markAndScale(termOrder); ChainPairList P;//use better data structure for this ChainPairList Pchecked;//use better data structure for this int I=0; for(PolynomialSet::const_iterator i=g->begin();i!=g->end();i++,I++) { int J=0; for(PolynomialSet::const_iterator j=g->begin();j!=i;j++,J++) { P.insert(ChainPair(j,i,J,I));//here } } while(!P.empty()) { // cerr<<"P";printPairs(P);cerr<<"Pchecked";printPairs(Pchecked); PolynomialSet::const_iterator i=P.begin()->a; PolynomialSet::const_iterator l=P.begin()->b; int I=P.begin()->A; int L=P.begin()->B; if(relativelyPrime(i->getMarked().m.exponent,l->getMarked().m.exponent) || (i->isMonomial() && l->isMonomial())) { // Pchecked.push_back(P.front()); // P.pop_front(); Pchecked.insert(*P.begin()); P.erase(P.begin()); } else { IntegerVector lcm=max(i->getMarked().m.exponent,l->getMarked().m.exponent); if(canBeRemoved(P,lcm,i,l) || canBeRemoved(Pchecked,lcm,i,l)) { //cerr<<"removin"<size(); g->push_back(p); PolynomialSet::const_iterator k=g->end();k--; int I=0; for(PolynomialSet::const_iterator i=g->begin();i!=k;i++,I++) { P.insert(ChainPair(i,k,I,K));//here } } } } } // AsciiPrinter(Stderr)<<*g; minimize(g); autoReduce(g,termOrder); } // Sugar Cube Buchberger static const TermOrder * SPairTermOrder; class SPair { public: PolynomialSet::const_iterator i,j; //int indexi; int indexj; IntegerVector v; int sugar; SPair(PolynomialSet::const_iterator i_, PolynomialSet::const_iterator j_, int indexj_): i(i_), j(j_), //indexi(indexi_), indexj(indexj_) { // assert(indexigetSugar()-j->getMarked().m.exponent.sum(); int sugar2=i->getSugar()-i->getMarked().m.exponent.sum(); if(sugar1>sugar2) sugar=sugar1; else sugar=sugar2; sugar+=max(i->getMarked().m.exponent,j->getMarked().m.exponent).sum(); // fprintf(Stderr,"%i\n",sugar); // sugar=(max(i->getMarked().m.exponent,j->getMarked().m.exponent)).sum(); v=max(i->getMarked().m.exponent,j->getMarked().m.exponent); } Polynomial sPolynomial_()const{return sPolynomial(*i,*j);}; bool relativelyPrime_()const{return relativelyPrime(i->getMarked().m.exponent,j->getMarked().m.exponent);} bool operator<(const class SPair &a)const; void print(Printer &p)const { p.printString("S"); //p.printInteger(indexi); p.printString(","); p.printInteger(indexj); p.printString("("); p.printPolynomial(*i); p.printString(","); p.printPolynomial(*j); p.printString(")="); p.printPolynomial(sPolynomial_()); p.printString(" "); p.printVector(v); p.printString(" sugar: "); p.printInteger(sugar); p.printString("\n"); }; }; bool SPair::operator<(const class SPair &a)const //partial order { // if(sugara.sugar)return false; // int d=v.sum()-a.v.sum(); // if(d<0)return false; // if(d>0)return true; if((*SPairTermOrder)(v,a.v))return true; if((*SPairTermOrder)(a.v,v))return false; if(indexja.indexj)return false; //if(indexj>a.indexj)return true; //if(indexjb.indexj)return false; return false; */ } }; typedef set SPairSet; typedef list SPairList; void printSPairSet(SPairSet const &l) { AsciiPrinter p(Stderr); for(SPairSet::const_iterator i=l.begin();i!=l.end();i++)i->print(p); } void printSPairList(SPairList const &l) { AsciiPrinter p(Stderr); for(SPairList::const_iterator i=l.begin();i!=l.end();i++)i->print(p); } void updatePairs(SPairSet &sPolynomials, PolynomialSet *g, PolynomialSet *redundantOnes, PolynomialSet::iterator const &j, int indexj, int truncationDegree, IntegerVector const *grading) { if(truncationDegree) if(dot(*grading,j->getMarked().m.exponent)>truncationDegree)return; //divisionPolynomials.push_front(*j); // fprintf(Stderr,"1\n"); // 1 : Delete pairs in "sPolynomials" bool skip=false; //if(0) for(SPairSet::iterator ij=sPolynomials.begin();ij!=sPolynomials.end();) { skip=false; if(j->getMarked().m.exponent.divides(ij->v)) if(ij->v!=max(j->getMarked().m.exponent,ij->i->getMarked().m.exponent)) if(ij->v!=max(j->getMarked().m.exponent,ij->j->getMarked().m.exponent)) { SPairSet::iterator temp=ij; ij++;skip=true; sPolynomials.erase(temp); } if(!skip)ij++; } // fprintf(Stderr,"1b\n"); // : Generate new pairs in "newOnes" and move redundant polynomials from "g" into "redundantOnes" SPairList newOnes; { int indexi=0; for(PolynomialSet::iterator i=g->begin();i!=j;) { SPair s=SPair(i,j,indexj); if(truncationDegree==0 || dot(*grading,s.v)<=truncationDegree) newOnes.push_back(s); if(j->getMarked().m.exponent.divides(i->getMarked().m.exponent)) //redundancy removal { PolynomialSet::iterator temp=i; i++; redundantOnes->splice(redundantOnes->begin(),*g,temp); } else { i++; } /* if(j->getMarked().m.exponent.divides(i->getMarked().m.exponent)) //redundancy removal { PolynomialSet::iterator temp=i; i++; redundantOnes->splice(redundantOnes->begin(),*g,temp); newOnes.push_back(SPair(redundantOnes->begin(),j,indexj)); } else { newOnes.push_back(SPair(i,j,indexj)); i++; }*/ indexi++; } } // fprintf(Stderr,"2\n"); // 2 : Move one element from "newOnes" to "sPolynomials" for each equivalence class, // but none if tau is "divisible" or representable as "a disjoint union" if(!newOnes.empty()) { newOnes.sort(SPairLCMCompare()); IntegerVectorList divisionList; SPairList::const_iterator representative=newOnes.begin(); bool ignore=representative->relativelyPrime_(); divisionList.push_back(representative->v); for(SPairList::iterator i=newOnes.begin();i!=newOnes.end();i++) if(representative->v==i->v) { if(!ignore && i->relativelyPrime_())ignore=true; } else { if(!ignore)sPolynomials.insert(*representative); //else divisionList.pop_back();//stupid? representative=i; ignore=representative->relativelyPrime_(); for(IntegerVectorList::const_iterator k=divisionList.begin();k!=divisionList.end();k++) if(k->divides(i->v)) { ignore=true; break; } divisionList.push_back(i->v); } if(!ignore)sPolynomials.insert(*representative); } /* // fprintf(Stderr,"2\n"); // 2 : Remove elements from newOnes if tau of element is divisible for(SPairList::iterator s=newOnes.begin();s!=newOnes.end();) { bool remove=false; for(SPairList::const_iterator t=newOnes.begin();t!=newOnes.end();t++) if(t->v!=s->v) if(t->v.divides(s->v)) { remove=true; break; } if(remove) { SPairList::iterator temp=s; s++; newOnes.erase(temp); } else s++; } // fprintf(Stderr,"3+4\n"); // 3+4 : Add "newOnes" to "sPolynomials", but only one for each tau newOnes.sort(SPairLCMCompare()); SPairList::const_iterator best=newOnes.begin(); for(SPairList::const_iterator i=newOnes.begin();i!=newOnes.end();i++) if(best->v==i->v) { if(i->relativelyPrime_()) best=i; } else { if(!best->relativelyPrime_())sPolynomials.insert(*best); best=i; } if(best!=newOnes.end() && !best->relativelyPrime_())sPolynomials.insert(*best); */ } void buchberger2(PolynomialSet *g, TermOrder const &termOrder) { PolynomialRing theRing=g->getRing(); assert(0); // We do not use the Gebauer-Moeller implementation since it is not complete bool printComments=false; int truncationDegree=0; IntegerVector grading; grading=StringParser("(1,12223,12224,36674,61119,85569)").parseIntegerVector(); truncationDegree=89643482; // PolynomialSet divisionPolynomials; TimerScope ts(&buchbergerTimer); SPairTermOrder=&termOrder; g->markAndScale(termOrder); g->sort(PolynomialCompareMarkedTermsReverse(termOrder)); g->computeInitialSugar(); PolynomialSet redundantOnes(theRing); SPairSet sPolynomials; int indexj=0; for(PolynomialSet::iterator j=g->begin();j!=g->end();j++) { if(j!=g->begin()) updatePairs(sPolynomials,g,&redundantOnes,j,indexj,truncationDegree,&grading); indexj++; } // printSPairSet(sPolynomials); int numberOfCriticalPairsConsidered=0; int numberOfUsefulCriticalPairs=0; while(!sPolynomials.empty()) { Polynomial p=sPolynomial(*sPolynomials.begin()->i,*sPolynomials.begin()->j); p.mark(termOrder); p.scaleMarkedCoefficientToOne(); sPolynomials.erase(sPolynomials.begin()); numberOfCriticalPairsConsidered++; // if(printComments) { static int t; t++; if((t&31)==0)fprintf(Stderr," spolys:%i\n",sPolynomials.size()); } { static int t; if(++t==10) { //assert(divisionPolynomials.size()==g->size()); // divisionPolynomials.sort(PolynomialCompareMarkedTerms(termOrder)); t=0; // fprintf(Stderr,"test\n"); } } //p=division(p,divisionPolynomials,termOrder); p=division(p,*g,termOrder); if(!p.isZero()) { p.mark(termOrder); p.scaleMarkedCoefficientToOne(); g->push_back(p); numberOfUsefulCriticalPairs++; // if(printComments) { static int t; if(((++t)&=31)==0) fprintf(Stderr,"gsize:%i spolys:%i\n",g->size()+1,sPolynomials.size()); } PolynomialSet::iterator j=g->end();j--; updatePairs(sPolynomials,g,&redundantOnes,j,indexj,truncationDegree,&grading); indexj++; } } minimize(g); autoReduce(g,termOrder); // if(printComments) fprintf(Stderr,"Number of critical pairs considered %i Number of useful critical pairs %i",numberOfCriticalPairsConsidered,numberOfUsefulCriticalPairs); } struct polynomialOrder { TermOrder const ℴ polynomialOrder(TermOrder const &order_):order(order_){} bool operator()(const Polynomial &a, const Polynomial &b) { return order(a.getMarked().m.exponent, b.getMarked().m.exponent); } }; void minimize(PolynomialSet *g) {//CHECK THAT THIS ROUTINE WORKS IF TWO GENERATORS HAVE THE SAME INITIAL TERM!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PolynomialRing theRing=g->getRing(); PolynomialSet ret(theRing); g->sort(polynomialOrder(LexicographicTermOrder())); for(PolynomialSet::const_iterator i=g->begin();i!=g->end();i++) { bool someDivides=false; for(PolynomialSet::const_iterator j=ret.begin();j!=ret.end();j++) // for(PolynomialSet::const_iterator j=g->begin();j!=i;j++) //changed Feb 2009 { if(j->getMarked().m.exponent.divides(i->getMarked().m.exponent)) { someDivides=true; } } if(!someDivides) ret.push_back(*i); } *g=ret; } void autoReduce(PolynomialSet *g, TermOrder const &termOrder) { /** * TODO: there should be two options : supplying a termorder, or not supplying a termorder. In the latter case this routine should decide if it wants to compute one. */ // WeightTermOrder termOrder2(termorderWeight(*g));//REMOVE ME ?? JAN 2009 for(PolynomialSet::iterator i=g->begin();i!=g->end();i++) { Polynomial temp(*i); PolynomialSet::iterator tempIterator=i; tempIterator++; g->erase(i); Monomial monomial=temp.getMarked().m; g->insert(tempIterator,division(temp,*g,termOrder)); //g->insert(tempIterator,smartDivision(temp,*g,termOrder)); tempIterator--; i=tempIterator; i->mark(monomial); } } bool isMarkedGroebnerBasis(PolynomialSet const &g) { int counter=0; for(PolynomialSet::const_iterator i=g.begin();i!=g.end();i++) { log2 fprintf(Stderr,"%i ",counter++); for(PolynomialSet::const_iterator j=i;j!=g.end();j++) if(!relativelyPrime(i->getMarked().m.exponent,j->getMarked().m.exponent)) { Polynomial s=sPolynomial(*i,*j); if(!division(s,g,LexicographicTermOrder()).isZero()) { log3{AsciiPrinter(Stderr)<<"Spoly("<<*i<<","<<*j<<")="<terms.begin();j!=i->terms.end();j++) if(!(j->first.exponent==i->getMarked().m.exponent)) for(PolynomialSet::const_iterator k=temp.begin();k!=temp.end();k++) if(k->getMarked().m.exponent.divides(j->first.exponent))return false; return true; } gfan-0.5+dfsg/buchberger.h000066400000000000000000000022541207563005400154760ustar00rootroot00000000000000#ifndef BUCHBERGER_H_INCLUDED #define BUCHBERGER_H_INCLUDED #include "polynomial.h" Polynomial sPolynomial(Polynomial a, Polynomial b); void buchberger(PolynomialSet *g, TermOrder const &termOrder, bool allowSaturation=false); void minimize(PolynomialSet *g); /** * The Groebner basis g must be minimal before this function is called. */ void autoReduce(PolynomialSet *g, TermOrder const &termOrder); static inline void autoReduce_(PolynomialSet *g, TermOrder const &termOrder){return autoReduce(g,termOrder);}//<----avoiding scoperules. Should start using namespaces. bool isMarkedGroebnerBasis(PolynomialSet const &g); /* For the autoReduction procedure the TermOrder argument is only used as an argument for the division algorithm. This means that the input to autoReduce should be marked and that the term order does not have to agree. */ /** This routine takes a marked Groebner basis and checks if it is minimal. TODO: there is room for improvement here. */ bool isMinimal(PolynomialSet const &g); /** This routine takes a marekd Groebner basis and checks if it is autoreduced. This means that it also checks if the basis is minimal.*/ bool isReduced(PolynomialSet const &g); #endif gfan-0.5+dfsg/codimoneconnectedness.cpp000066400000000000000000000022751207563005400202750ustar00rootroot00000000000000#include "codimoneconnectedness.h" #include "graph.h" #include "log.h" #include #include void CodimOneConnectednessTester::insertFacetOrbit(IntegerVectorList const &ridges) { data.push_back(ridges); } bool CodimOneConnectednessTester::isConnected()const { set allRidges; for(list::const_iterator i=data.begin();i!=data.end();i++) for(IntegerVectorList::const_iterator j=i->begin();j!=i->end();j++) allRidges.insert(*j); vector allRidges2;//(allRidges.size()); for(set::const_iterator i=allRidges.begin();i!=allRidges.end();i++)allRidges2.push_back(*i); int nRidges=allRidges2.size(); int nFacets=data.size(); Graph g(nFacets+nRidges); int facetIndex=0; for(list::const_iterator i=data.begin();i!=data.end();i++,facetIndex++) for(IntegerVectorList::const_iterator j=i->begin();j!=i->end();j++) g.addEdge(facetIndex,nFacets+(lower_bound(allRidges2.begin(),allRidges2.end(),*j)-allRidges2.begin())); int diameter=g.diameter(); log2 cerr << "Diameter " << diameter << " nFacets " << nFacets << " nRidges " << nRidges << endl; return diameter data; public: /** Adds a facet orbit. The list of vectors is the canonoical symmetry (w.r.t. symmetries of the ridge) invariant interior points of its ridges. Futhermore, these should be unique orbit representatives rather than just vectors. */ void insertFacetOrbit(IntegerVectorList const &ridges); /* BE CAREFUL WHEN MAKING CONCLUSIONS - THIS ROUINE DOES NOT SUPPORT SYMMETRY. */ bool isConnected()const; }; gfan-0.5+dfsg/continuedfractions.cpp000066400000000000000000000024441207563005400176230ustar00rootroot00000000000000#include "continuedfractions.h" #include "vektor.h" #include void doubleToFraction(double f, int &numerator, int &denominator, int maksIter) { bool changeSign=f<0; if(changeSign)f*=-1; if(f<0.000001 || maksIter<1) { numerator=0; denominator=1; } else { double r=1/f; int R=int(r);//truncates r-=R; int n2,d2; doubleToFraction(r,n2,d2,maksIter-1); /* 1/f-R=r=n2/d2; => 1/f=(n2+d2*R)/d2; => f=d2/(n2+d2*R); */ numerator=d2; denominator=n2+d2*R; if(changeSign) numerator*=-1; } } void doubleVectorToFractions(vector v, vector &numerators, int &denominator) { int n=v.size(); numerators=vector(n); denominator=1; if(n==0)return; for(int i=0;i using namespace std; void doubleToFraction(double f, int &numerator, int &denominator, int maksIter=15); void doubleVectorToFractions(vector v, vector &numerators, int &denominator); #endif gfan-0.5+dfsg/determinant.cpp000066400000000000000000000054731207563005400162410ustar00rootroot00000000000000#include "field.h" #include "field_rationals.h" #include #include "vektor.h" #include "linalg.h" #include "printer.h" using namespace std; static void swapRow(vector > &m, int i, int j) { assert(i!=j); vector temp; temp=m[i]; m[i]=m[j]; m[j]=temp; } static void madd(vector > &m, int i, FieldElement a, int j, int width) { assert(i!=j); // if(a.isZero())return; for(int k=0;k > &m, int column, int currentRow) { for(int i=currentRow;i > const &m, int height, int width) { AsciiPrinter P(Stderr); for(int i=0;i > &m, int height, int width, bool returnIfZeroDeterminant=false) { int retSwaps=0; int currentRow=0; // fprintf(Stderr,"Reducing\n"); for(int i=0;i0); // if(n==0)return 1; vector >m; for(IntegerVectorList::const_iterator i=l.begin();i!=l.end();i++) { assert(i->size()==n); vector v(n); for(int j=0;j #include "printer.h" #include "buchberger.h" #include "wallideal.h" #include "termorder.h" #include "tropical2.h" #include "tropicaldeterminant.h" #include "log.h" using namespace std; static list interval(int n, bool sqrt) { list ret; for(int i=0;((sqrt)?i*i:i) forms; PolyMatrixEntry(Polynomial const &p_, IntegerVector const &w): p(p_), isZero(p_.isZero()) { if(p.isZero()) { maxDegree=td_minusInfinity; mminDegree=td_minusInfinity; return; } maxDegree=p_.degree(w); mminDegree=p_.degree(-w); // debug<first.exponent,w)+mminDegree]+=Term(i->second,i->first); } } }; list::iterator indexOfSparsestRow(list &rows, list const &columns, int &chosenRowIteratorIndex) { list::iterator ret=rows.end(); int bestNumberOfZeros=-1; int I=0; for(list::iterator i=rows.begin();i!=rows.end();i++,I++) { int numberOfZeros=0; for(list::const_iterator j=columns.begin();j!=columns.end();j++)numberOfZeros+=data[*i][*j].isZero; if(numberOfZeros>bestNumberOfZeros) { bestNumberOfZeros=numberOfZeros; ret=i; chosenRowIteratorIndex=I; } } // cerr<<":"< > data; PolynomialRing theRing; //constructor for Jacobi matrix PolyMatrix(PolynomialSet const &generators, IntegerVector const &w, bool takeDerivatives, int numberOfDVariables=-1): theRing(generators.getRing()) { if(takeDerivatives) { int n=generators.size(); if(numberOfDVariables==-1)numberOfDVariables=n; PolynomialSet::const_iterator I=generators.begin(); for(int i=0;i row; for(int j=0;jderivative(j),w)); data.push_back(row); I++; } } else { int n=generators.size(); for(int i=0;i=n){n=i;break;}assert(n*n==generators.size()); PolynomialSet::const_iterator I=generators.begin(); for(int i=0;i row; for(int j=0;j l) { cerr<<"{"; for(list::const_iterator i=l.begin();i!=l.end();i++) cerr<<*i<<","; cerr<<"}\n"; } IntegerMatrix subTropicalMatrix(bool max, list const &rows, list const &columns) { IntegerMatrix ret(rows.size(),columns.size()); list::const_iterator I=rows.begin(); for(int i=0;i::const_iterator J=columns.begin(); for(int j=0;j rows, list columns, int degree, int level) { Polynomial ret(theRing); IntegerMatrix matMax=subTropicalMatrix(true,rows,columns); IntegerMatrix matMMin=subTropicalMatrix(false,rows,columns); /* if(level==0) { debug<maxDet)return Polynomial(theRing); if(-degree>mminDet)return Polynomial(theRing); if(rows.size()==1) { if(data[rows.front()][columns.front()].isZero)return Polynomial(theRing); // cerr<::iterator chosenRowIterator=indexOfSparsestRow(rows, columns, chosenRowIteratorIndex);//rows.begin(); int chosenrow=*chosenRowIterator; { list::iterator temp=chosenRowIterator;temp++; rows.erase(chosenRowIterator); //no need to update rows afterwards since it is stored on the stack } /* if(level==0)cerr<<"-"<::iterator i=columns.begin();i!=columns.end();i++) { int chosencol=*i; if(!data[chosenrow][chosencol].isZero) { list::iterator temp=i;temp++; columns.erase(i); i=temp; // int D=degree+1; // if(data[chosenrow][chosencol].forms.size() rows=interval(data.size(),0); list columns=interval(data.size(),0); IntegerMatrix matMax=subTropicalMatrix(true,rows,columns); IntegerMatrix matMMin=subTropicalMatrix(false,rows,columns); int maxDet=tropicalDeterminant(matMax); int mminDet=tropicalDeterminant(matMMin); cerr<<"Max"<=-mminDet;d--) { log1 debug<<"Computing degree "< toIndexed(list const &l) { list ret; int a=0; for(list::const_iterator i=l.begin();i!=l.end();i++,a++)if(*i)ret.push_back(a); return ret; } PolynomialSet jacobiMinors(PolynomialSet const &g, int codim) { IntegerVector w(g.getRing().getNumberOfVariables()); PolyMatrix m(g,w,true,w.size()); //log1 m.print(); PolynomialSet ret(g.getRing()); if(codim<=g.size())if(codim<=w.size()) { list rows; for(int i=0;i cols; for(int i=0;igetMarked().m.exponent; e=e.supportVector(); ret.push_back(Polynomial(Term(i->getMarked().c,Monomial(theRing,e)))); } return ret; } static bool increase(IntegerVector &v, int &numberOfOnes) { int i=0; while(ibest)best=nOnes; if(ones.size()-nZerosdivides(ones)) { good=false; break; } if(good) { rek(ones,zeros,nOnes+1,nZeros,vectors,best); } ones[index]=0; IntegerVectorList vectorsSubset; for(IntegerVectorList::const_iterator i=vectors.begin();i!=vectors.end();i++) { if((*i)[index]==0)vectorsSubset.push_back(*i); } zeros[index]=1; rek(ones,zeros,nOnes,nZeros+1,vectorsSubset,best); // rek(ones,zeros,nOnes,nZeros+1,vectors,best); zeros[index]=0; } int krullDimensionOfMonomialIdeal(PolynomialSet const &monomialGenerators) { PolynomialSet temp=radicalOfMonomialIdeal(monomialGenerators); minimize(&temp); IntegerVectorList vectors; for(PolynomialSet::const_iterator i=temp.begin();i!=temp.end();i++) vectors.push_back(i->getMarked().m.exponent); int best=0; int n=monomialGenerators.getRing().getNumberOfVariables(); IntegerVector zeros(n); IntegerVector ones(n); rek(ones,zeros,0,0,vectors,best); return best; } /*int krullDimensionOfMonomialIdeal(PolynomialSet const &monomialGenerators) { PolynomialSet temp=radicalOfMonomialIdeal(monomialGenerators); minimize(&temp); IntegerVectorList vectors; for(PolynomialSet::const_iterator i=temp.begin();i!=temp.end();i++) vectors.push_back(i->getMarked().m.exponent); assert(!vectors.empty()); int n=vectors.begin()->size(); IntegerVector subset(n); int numberOfOnes=0; int dimension=0; do { // AsciiPrinter(Stderr).printVector(subset); if(numberOfOnes>dimension) { bool ok=true; for(IntegerVectorList::const_iterator i=vectors.begin();i!=vectors.end();i++) if(i->divides(subset)) { ok=false; break; } if(ok) dimension=numberOfOnes; } } while(increase(subset,numberOfOnes)); return dimension; } */ int krullDimension(PolynomialSet const &groebnerBasis) { return krullDimensionOfMonomialIdeal(groebnerBasis.markedTermIdeal()); } gfan-0.5+dfsg/dimension.h000066400000000000000000000004571207563005400153560ustar00rootroot00000000000000#ifndef DIMENSION_H_INCLUDED #define DIMENSION_H_INCLUDED #include "polynomial.h" PolynomialSet radicalOfMonomialIdeal(PolynomialSet const &monomialGenerators); int krullDimensionOfMonomialIdeal(PolynomialSet const &monomialGenerators); int krullDimension(PolynomialSet const &groebnerBasis); #endif gfan-0.5+dfsg/division.cpp000066400000000000000000000141331207563005400155440ustar00rootroot00000000000000#include "division.h" #include "printer.h" #include "wallideal.h" #include "lp.h" #include "timer.h" static Timer divisionTimer("Division",1); static Timer divisionTimer1("Division1",1); static Timer divisionTimer2("Division2",1); static Timer divisionTimer3("Division3",1); static Timer divisionTimer4("Division4",1); Polynomial division1(Polynomial p, PolynomialSet const &l, TermOrder const &termOrder, PolynomialSet *q); typedef map ReductionCache; Polynomial division(Polynomial p, PolynomialSet const &l, TermOrder const &termOrder, PolynomialSet *q) { return division1(p,l,termOrder,q); } Polynomial smartDivision(Polynomial p, PolynomialSet l, TermOrder const &termOrder) { Polynomial r(p.getRing()); for(TermMap::const_iterator i=p.terms.begin();i!=p.terms.end();i++) { r+=division(Term(i->second,Monomial(p.getRing(),i->first.exponent)),l,termOrder); } return r; } IntegerVector termorderWeight(PolynomialSet const &g) { IntegerVector ret=relativeInteriorPoint(g.getRing().getNumberOfVariables(),fastNormals(wallInequalities(g)),0); // fprintf(stderr,"WEIGHT"); //AsciiPrinter(Stderr).printVector(ret); //fprintf(stderr,"\n"); return ret; } Polynomial division1(Polynomial p, PolynomialSet const &l, TermOrder const &termOrder, PolynomialSet *q) { PolynomialRing theRing=p.getRing(); TimerScope ts(&divisionTimer); // WeightReverseLexicographicTermOrder termOrder2(termorderWeight(l));//REMOVE ME ?? JAN 2009 if(q) { *q=PolynomialSet(theRing); for(PolynomialSet::const_iterator i=l.begin();i!=l.end();i++) q->push_back(Polynomial(p.getRing())); } Polynomial r(p.getRing()); while(!p.isZero()) { // AsciiPrinter(Stderr).printPolynomial(p); // fprintf(Stderr,"Number Of terms: %i\n",p.terms.size()); p.mark(termOrder); Term initial=p.getMarked(); PolynomialSet::const_iterator i; PolynomialSet::iterator j; if(q)j=q->begin(); { TimerScope ts(&divisionTimer2); for(i=l.begin();i!=l.end();i++) { if(i->getMarked().m.exponent.divides(initial.m.exponent))break; if(q)j++; } } { TimerScope ts(&divisionTimer3); if(i!=l.end()) { Term s(-initial.c*i->getMarked().c.inverse(),Monomial(p.getRing(),initial.m.exponent-i->getMarked().m.exponent)); p.madd(s,*i); if(q)*j+=Polynomial(s); } else { TimerScope ts(&divisionTimer4); p-=initial; r+=initial; } } } return r; } #if 0 Polynomial divisionLift(Polynomial p, PolynomialSet l, PolynomialSet lLift, TermOrder const &termOrder, bool noMarking) { Polynomial lift(p.getRing()); Polynomial r(p.getRing()); Monomial marked=p.getMarked().m; for(PolynomialSet::iterator i=l.begin();i!=l.end();i++) i->scaleMarkedCoefficientToOne(); while(!p.isZero()) { p.mark(termOrder); /* fprintf(Stderr,"Polynomial:\n"); AsciiPrinter(Stderr).printPolynomial(p); fprintf(Stderr,"\n"); fprintf(Stderr,"Remainder:\n"); AsciiPrinter(Stderr).printPolynomial(r); fprintf(Stderr,"\n"); */ Term initial=p.getMarked(); PolynomialSet::const_iterator i; PolynomialSet::const_iterator iLift=lLift.begin(); for(i=l.begin();i!=l.end();i++) { if(i->getMarked().m.exponent.divides(initial.m.exponent))break; iLift++; } if(i!=l.end()) { Term s(initial.c,Monomial(p.getRing(),initial.m.exponent-i->getMarked().m.exponent)); p-=((*i)*s); // lift+=(*iLift)*s; lift.madd(s,*iLift); } else { p-=initial; r+=initial; } } if(!noMarking)lift.mark(marked); return lift; } #else Polynomial divisionLift(Polynomial p, PolynomialSet l, PolynomialSet lLift, TermOrder const &termOrder, bool noMarking) { Polynomial lift(p.getRing()); Polynomial r(p.getRing()); Monomial marked=p.getMarked().m; for(PolynomialSet::iterator i=l.begin();i!=l.end();i++) i->scaleMarkedCoefficientToOne(); PolynomialSet coefficientPolynomials(p.getRing()); for(PolynomialSet::iterator i=l.begin();i!=l.end();i++)coefficientPolynomials.push_back(p.getRing()); while(!p.isZero()) { p.mark(termOrder); /* fprintf(Stderr,"Polynomial:\n"); AsciiPrinter(Stderr).printPolynomial(p); fprintf(Stderr,"\n"); fprintf(Stderr,"Remainder:\n"); AsciiPrinter(Stderr).printPolynomial(r); fprintf(Stderr,"\n"); */ Term initial=p.getMarked(); PolynomialSet::const_iterator i; PolynomialSet::const_iterator iLift=lLift.begin(); PolynomialSet::iterator iCoeff=coefficientPolynomials.begin(); for(i=l.begin();i!=l.end();i++) { if(i->getMarked().m.exponent.divides(initial.m.exponent))break; iLift++; iCoeff++; } if(i!=l.end()) { Term s(initial.c,Monomial(p.getRing(),initial.m.exponent-i->getMarked().m.exponent)); p-=((*i)*s); // lift+=(*iLift)*s; // lift.madd(s,*iLift); *iCoeff+=s; } else { p-=initial; r+=initial; } } PolynomialSet::const_iterator iCoeff=coefficientPolynomials.begin(); for(PolynomialSet::const_iterator i=lLift.begin();i!=lLift.end();i++) { lift+=*i* *iCoeff; iCoeff++; } if(!noMarking)lift.mark(marked); return lift; } #endif bool isIdealContainedInIdeal(PolynomialSet const &generators, PolynomialSet const &groebnerBasis) { for(PolynomialSet::const_iterator i=generators.begin();i!=generators.end();i++) { // if(!division(*i,groebnerBasis,LexicographicTermOrder()).isZero())return false; if(!division(*i,groebnerBasis,StandardGradedLexicographicTermOrder()).isZero())return false; // fprintf(Stderr,".\n"); } return true; } bool areIdealsEqual(PolynomialSet const &groebnerBasis1, PolynomialSet const &groebnerBasis2) { return isIdealContainedInIdeal(groebnerBasis1,groebnerBasis2) && isIdealContainedInIdeal(groebnerBasis2,groebnerBasis1); } gfan-0.5+dfsg/division.h000066400000000000000000000022071207563005400152100ustar00rootroot00000000000000#ifndef DIVISION_H_INCLUDED #define DIVISION_H_INCLUDED #include "polynomial.h" Polynomial division(Polynomial p, PolynomialSet const &l, TermOrder const &termOrder, PolynomialSet *q=0); Polynomial smartDivision(Polynomial p, PolynomialSet l, TermOrder const &termOrder); Polynomial divisionLift(Polynomial p, PolynomialSet l, PolynomialSet lList, TermOrder const &termOrder, bool noMarking=false); /* Note the input PolynomialSet l should be marked. The term order argument is only used for choosing a term in p and does not have to agree with the marking. */ bool isIdealContainedInIdeal(PolynomialSet const &generators, PolynomialSet const &groebnerBasis); bool areIdealsEqual(PolynomialSet const &groebnerBasis1, PolynomialSet const &groebnerBasis2); /* Note the second parameter for isIdealContainedInIdeal must be a marked Groebner Basis and so must both parameters for areIdealsEqual*/ /** Computes a vector in the relative interior of the cone of weights giving the specified marking of g. This is a useful vector to use for a termorder when doing polynomial division. */ IntegerVector termorderWeight(PolynomialSet const &g); #endif gfan-0.5+dfsg/enumeration.cpp000066400000000000000000000037601207563005400162520ustar00rootroot00000000000000#include "enumeration.h" #include #include "printer.h" #include "log.h" EnumerationFilePrinter::EnumerationFilePrinter(): initialisedFile(0), file(0), filename("") { } EnumerationFilePrinter::~EnumerationFilePrinter() { assert(file==0); } void EnumerationFilePrinter::open(string filename) { this->filename=filename; string name=filename+extension(); initialisedFile=fopen(name.c_str(),"w"); file=initialisedFile; assert(file); fprintf(Stderr,"Output file opened: \"%s\"\n",name.c_str()); onOpened(); } void EnumerationFilePrinter::open(FILE *file) { initialisedFile=0; this->file=file; assert(file); onOpened(); } void EnumerationFilePrinter::close() { onClose(); if(initialisedFile) { fclose(initialisedFile); onClosed(); initialisedFile=0; } file=0; } string EnumerationFilePrinter::extension() { return ""; } void EnumerationAlgorithm::printProgress(int step) { while(step>0) { progressCounter++; // if(!(progressCounter&4095)) // if(!(progressCounter&255)) if(!(progressCounter&15)) log2 fprintf(Stderr,"Number of Gr\"obner Bases found %i\n",progressCounter); fflush(Stderr); step--; } } //-------------------------------------- // EnumerationTargetCollector //-------------------------------------- void EnumerationTargetCollector::beginEnumeration(PolynomialSet const &g) { theList=PolynomialSetList(); } void EnumerationTargetCollector::endEnumeration() { } bool EnumerationTargetCollector::basis(const PolynomialSet &groebnerBasis) { theList.push_back(groebnerBasis); return true; } PolynomialSetList EnumerationTargetCollector::getList() { return theList; } #include "traverser_groebnerfan.h" TargetGlue::TargetGlue(EnumerationTarget &target_): target(target_) { } bool TargetGlue::process(ConeTraverser &traverser) { GroebnerFanTraverser &r=dynamic_cast(traverser); return target.basis(r.refToGroebnerBasisRepresentation()); } gfan-0.5+dfsg/enumeration.h000066400000000000000000000036731207563005400157220ustar00rootroot00000000000000#ifndef ENUMERATION_H_INCLUDED #define ENUMERATION_H_INCLUDED #include "polynomial.h" class EnumerationTarget { public: virtual void beginEnumeration(const PolynomialSet &groebnerBasis)=0; virtual void endEnumeration()=0; virtual bool basis(const PolynomialSet &groebnerBasis)=0; /* return false to break enumaration */ }; class EnumerationTargetCollector: public EnumerationTarget { public: PolynomialSetList theList; void beginEnumeration(const PolynomialSet& g); void endEnumeration(); bool basis(const PolynomialSet &groebnerBasis); PolynomialSetList getList(); }; class EnumerationPrinter: public EnumerationTarget { }; class EnumerationFilePrinter: public EnumerationPrinter { FILE *initialisedFile; protected: string filename; FILE *file; public: EnumerationFilePrinter(); ~EnumerationFilePrinter(); void open(std::string filename); void open(FILE *file); void close(); virtual void onOpened()=0; virtual void onClose()=0; virtual void onClosed()=0; virtual string extension(); }; class EnumerationAlgorithm { protected: EnumerationTarget *target; int progressCounter; virtual void printProgress(int step=1); void targetBeginEnumeration(const PolynomialSet &groebnerBasis){if(target)target->beginEnumeration(groebnerBasis);} void targetEndEnumeration(){if(target)target->endEnumeration();} bool targetBasis(const PolynomialSet &groebnerBasis){bool ret=true;if(target)ret=target->basis(groebnerBasis);printProgress();return ret;} public: EnumerationAlgorithm(){target=0;progressCounter=0;} void setEnumerationTarget(EnumerationTarget *target){this->target=target;} virtual void enumerate(const PolynomialSet &groebnerBasis){} }; // The following is used to glue the old code to the new code #include "symmetrictraversal.h" class TargetGlue:public SymmetricTarget { EnumerationTarget ⌖ public: TargetGlue(EnumerationTarget &target_); bool process(ConeTraverser &traverser); }; #endif gfan-0.5+dfsg/ep_standard.cpp000066400000000000000000000014201207563005400161770ustar00rootroot00000000000000#include "ep_standard.h" #include "printer.h" StandardEnumerationPrinter::StandardEnumerationPrinter(): insertComma(false) { } void StandardEnumerationPrinter::onOpened() { fprintf(file,"{"); } void StandardEnumerationPrinter::onClose() { fprintf(file,"}"); } void StandardEnumerationPrinter::onClosed() { } void StandardEnumerationPrinter::beginEnumeration(const PolynomialSet &groebnerBasis) { basisCounter=0; } void StandardEnumerationPrinter::endEnumeration() { } bool StandardEnumerationPrinter::basis(const PolynomialSet &groebnerBasis) { if(insertComma)fprintf(file,",\n"); AsciiPrinter(file).printPolynomialSet(groebnerBasis); insertComma=true; basisCounter++; return true; } string StandardEnumerationPrinter::extension() { return ""; } gfan-0.5+dfsg/ep_standard.h000066400000000000000000000007141207563005400156510ustar00rootroot00000000000000#ifndef EP_STANDARD_H_INCLUDED #define EP_STANDARD_H_INCLUDED #include "enumeration.h" class StandardEnumerationPrinter: public EnumerationFilePrinter { int basisCounter; bool insertComma; public: StandardEnumerationPrinter(); bool basis(const PolynomialSet &groebnerBasis); string extension(); void beginEnumeration(const PolynomialSet &groebnerBasis); void endEnumeration(); void onOpened(); void onClose(); void onClosed(); }; #endif gfan-0.5+dfsg/ep_xfig.cpp000066400000000000000000000034541207563005400153450ustar00rootroot00000000000000#include "ep_xfig.h" #include "printer.h" #include "wallideal.h" #include "lp.h" #include "xfig.h" #include "log.h" XfigEnumerationPrinter::XfigEnumerationPrinter(bool _largerTriangle): largerTriangle(_largerTriangle), variableShift(0), xfig(0) { } void XfigEnumerationPrinter::onOpened() { xfig= new XFig(file); } void XfigEnumerationPrinter::onClose() { } void XfigEnumerationPrinter::onClosed() { delete xfig; } void XfigEnumerationPrinter::beginEnumeration(const PolynomialSet &groebnerBasis) { basisCounter=0; } void XfigEnumerationPrinter::endEnumeration() { } bool XfigEnumerationPrinter::basis(const PolynomialSet &groebnerBasis) { assert(xfig); XFig::Polygon p; if(largerTriangle) { p.push_back(XFig::Point(3,-1,-1)); p.push_back(XFig::Point(-1,3,-1)); p.push_back(XFig::Point(-1,-1,3)); } else { p.push_back(XFig::Point(1,0,0)); p.push_back(XFig::Point(0,1,0)); p.push_back(XFig::Point(0,0,1)); } IntegerVectorList normals=wallInequalities(groebnerBasis); for(IntegerVectorList::const_iterator i=normals.begin();i!=normals.end();i++) //if(wallContainsPositiveVector(*i)) if(isFacet(normals,i)) { if(i->size()>=3) { // AsciiPrinter(Stderr).printVector(*i); XFig::Point n((*i)[variableShift%i->size()],(*i)[(variableShift+1)%i->size()],(*i)[(variableShift+2)%i->size()]); p=xfig->intersect(p,n); // fprintf(Stderr,"%i\n",variableShift); } } log2 xfig->printPolygon(p); xfig->drawPolygon(p,0); basisCounter++; log2 fprintf(Stderr,"basisCounter:%i\n",basisCounter); return true; } string XfigEnumerationPrinter::extension() { return ""; } void XfigEnumerationPrinter::setVariableShift(int shift) { variableShift=shift; } gfan-0.5+dfsg/ep_xfig.h000066400000000000000000000010671207563005400150100ustar00rootroot00000000000000#ifndef EP_XFIG_H_INCLUDED #define EP_XFIG_H_INCLUDED #include "enumeration.h" #include class XfigEnumerationPrinter: public EnumerationFilePrinter { int basisCounter; bool largerTriangle; int variableShift; class XFig *xfig; public: XfigEnumerationPrinter(bool _largerTriangle=false); bool basis(const PolynomialSet &groebnerBasis); string extension(); void beginEnumeration(const PolynomialSet &groebnerBasis); void endEnumeration(); void onOpened(); void onClose(); void onClosed(); void setVariableShift(int shift); }; #endif gfan-0.5+dfsg/examples/000077500000000000000000000000001207563005400150305ustar00rootroot00000000000000gfan-0.5+dfsg/examples/2x2of2x3000066400000000000000000000001031207563005400162420ustar00rootroot00000000000000{ae-bd,af-cd,bf-ce} { (1,0,2,4,3,5), (1,2,0,4,5,3), (3,4,5,0,1,2)} gfan-0.5+dfsg/examples/2x2of2x4000066400000000000000000000001411207563005400162450ustar00rootroot00000000000000{af-be,ag-ce,ah-de,bg-cf,bh-df,ch-dg} { (1,0,2,3,5,4,6,7), (1,2,3,0,5,6,7,4), (4,5,6,7,0,1,2,3)} gfan-0.5+dfsg/examples/2x2of3x3000066400000000000000000000002171207563005400162510ustar00rootroot00000000000000{ae-bd,af-cd,bf-ce,ah-bg,ai-cg,bi-ch,dh-eg,di-fg,ei-fh} { (1,0,2,4,3,5,7,6,8), (1,2,0,4,5,3,7,8,6), (3,4,5,0,1,2,6,7,8), (3,4,5,6,7,8,0,1,2) } gfan-0.5+dfsg/examples/2x2of4x4000066400000000000000000000007171207563005400162600ustar00rootroot00000000000000{af-be,ag-ce,ah-de,bg-cf,bh-df,ch-dg, aj-bi,ak-ci,al-di,bk-cj,bl-dj,cl-dk, an-bm,ao-cm,ap-dm,bo-cn,bp-dn,cp-do, ej-fi,ek-gi,el-hi,fk-gj,fl-hj,gl-hk, en-fm,eo-gm,ep-hm,fo-gn,fp-hn,gp-ho, in-jm,io-km,ip-lm,jo-kn,jp-ln,kp-lo} { (1,2,3,0,5,6,7,4,9,10,11,8,13,14,15,12), (1,0,2,3,5,4,6,7,9,8,10,11,13,12,14,15), (4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3), (4,5,6,7,0,1,2,3,8,9,10,11,12,13,14,15), (0,4,8,12,1,5,9,13,2,6,10,14,3,7,11,15) } a b c d e f g h i j k l m n o p gfan-0.5+dfsg/examples/3x3of3x4000066400000000000000000000004141207563005400162530ustar00rootroot00000000000000{a*f*k-a*g*j-e*b*k+e*c*j+i*b*g-i*c*f, a*f*l-a*h*j-e*b*l+e*d*j+i*b*h-i*d*f, a*g*l-a*h*k-e*c*l+e*d*k+i*c*h-i*d*g, b*g*l-b*h*k-f*c*l+f*d*k+j*c*h-j*d*g} { (1,0,2,3,5,4,6,7,9,8,10,11), (3,0,1,2,7,4,5,6,11,8,9,10), (4,5,6,7,0,1,2,3,8,9,10,11), (4,5,6,7,8,9,10,11,0,1,2,3) } gfan-0.5+dfsg/examples/3x3of3x5000066400000000000000000000010201207563005400162460ustar00rootroot00000000000000{ a*g*m-a*h*l-f*b*m+f*c*l+k*b*h-k*c*g, a*g*n-a*i*l-f*b*n+f*d*l+k*b*i-k*d*g, a*g*o-a*j*l-f*b*o+f*e*l+k*b*j-k*e*g, a*h*n-a*i*m-f*c*n+f*d*m+k*c*i-k*d*h, a*h*o-a*j*m-f*c*o+f*e*m+k*c*j-k*e*h, a*i*o-a*j*n-f*d*o+f*e*n+k*d*j-k*e*i, b*h*n-b*i*m-g*c*n+g*d*m+l*c*i-l*d*h, b*h*o-b*j*m-g*c*o+g*e*m+l*c*j-l*e*h, b*i*o-b*j*n-g*d*o+g*e*n+l*d*j-l*e*i, c*i*o-c*j*n-h*d*o+h*e*n+m*d*j-m*e*i } { (1,0,2,3,4,6,5,7,8,9,11,10,12,13,14), (1,2,3,4,0,6,7,8,9,5,11,12,13,14,10), (5,6,7,8,9,0,1,2,3,4,10,11,12,13,14), (5,6,7,8,9,10,11,12,13,14,0,1,2,3,4) } gfan-0.5+dfsg/examples/3x3of3x5.cone000066400000000000000000000012231207563005400171760ustar00rootroot00000000000000{ e*i*m+d*h*o, e*i*l+d*g*o, e*i*k-a*i*o, e*h*l-e*g*m, e*h*k-a*h*o, e*g*k-a*g*o, d*h*l-d*g*m, d*h*k+a*i*m, d*g*k+a*i*l, a*h*l-a*g*m} { e*i*m-e*h*n-d*j*m+d*h*o+c*j*n-c*i*o, e*i*l-e*g*n-d*j*l+d*g*o+b*j*n-b*i*o, e*i*k-e*f*n-d*j*k+d*f*o+a*j*n-a*i*o, e*h*l-e*g*m-c*j*l+c*g*o+b*j*m-b*h*o, e*h*k-e*f*m-c*j*k+c*f*o+a*j*m-a*h*o, e*g*k-e*f*l-b*j*k+b*f*o+a*j*l-a*g*o, d*h*l-d*g*m-c*i*l+c*g*n+b*i*m-b*h*n, d*h*k-d*f*m-c*i*k+c*f*n+a*i*m-a*h*n, d*g*k-d*f*l-b*i*k+b*f*n+a*i*l-a*g*n, a*h*l+c*g*k-c*f*l-b*h*k+b*f*m-a*g*m} { (1,0,2,3,4,6,5,7,8,9,11,10,12,13,14), (1,2,3,4,0,6,7,8,9,5,11,12,13,14,10), (5,6,7,8,9,0,1,2,3,4,10,11,12,13,14), (5,6,7,8,9,10,11,12,13,14,0,1,2,3,4) } gfan-0.5+dfsg/examples/3x3of4x4000066400000000000000000000013661207563005400162630ustar00rootroot00000000000000{a*f*k-a*g*j-e*b*k+e*c*j+i*b*g-i*c*f, a*f*l-a*h*j-e*b*l+e*d*j+i*b*h-i*d*f, a*g*l-a*h*k-e*c*l+e*d*k+i*c*h-i*d*g, b*g*l-b*h*k-f*c*l+f*d*k+j*c*h-j*d*g, a*f*o-a*g*n-e*b*o+e*c*n+m*b*g-m*c*f, a*f*p-a*h*n-e*b*p+e*d*n+m*b*h-m*d*f, a*g*p-a*h*o-e*c*p+e*d*o+m*c*h-m*d*g, b*g*p-b*h*o-f*c*p+f*d*o+n*c*h-n*d*g, a*j*o-a*k*n-i*b*o+i*c*n+m*b*k-m*c*j, a*j*p-a*l*n-i*b*p+i*d*n+m*b*l-m*d*j, a*k*p-a*l*o-i*c*p+i*d*o+m*c*l-m*d*k, b*k*p-b*l*o-j*c*p+j*d*o+n*c*l-n*d*k, e*j*o-e*k*n-i*f*o+i*g*n+m*f*k-m*g*j, e*j*p-e*l*n-i*f*p+i*h*n+m*f*l-m*h*j, e*k*p-e*l*o-i*g*p+i*h*o+m*g*l-m*h*k, f*k*p-f*l*o-j*g*p+j*h*o+n*g*l-n*h*k} {(1,0,2,3,5,4,6,7,9,8,10,11,13,12,14,15), (3,0,1,2,7,4,5,6,11,8,9,10,15,12,13,14), (4,5,6,7,0,1,2,3,8,9,10,11,12,13,14,15), (4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3)} gfan-0.5+dfsg/examples/3x3of4x4sym.cone000066400000000000000000000010511207563005400177260ustar00rootroot00000000000000{a*e*h-a*f2-b2*h+2*b*c*f-c2*e, a*e*i-b2*i, a*f*i-b*c*i, b*f*i-e*c*i, a*e*j-b2*j, a*f*j-b*c*j, b*f*j-e*c*j, a*h*j-c2*j, b*h*j-f*c*j, e*h*j-f2*j} {a*e*h-a*f2-b2*h+2*b*c*f-c2*e, a*e*i-a*g*f-b2*i+b*d*f+c*b*g-c*d*e, a*f*i-a*g*h-b*c*i+b*d*h+c2*g-c*d*f, b*f*i-b*g*h-e*c*i+e*d*h+f*c*g-d*f2, a*e*j-a*g2-b2*j+2*b*d*g-d2*e, a*f*j-a*g*i-b*c*j+b*d*i+d*c*g-d2*f, b*f*j-b*g*i-e*c*j+e*d*i+c*g2-g*d*f, a*h*j-a*i2-c2*j+2*c*d*i-d2*h, b*h*j-b*i2-f*c*j+f*d*i+g*c*i-g*d*h, e*h*j-e*i2-f2*j+2*f*g*i-g2*h} {(0,1,2,3,4,5,6,7,8,9), (4,1,5,6,0,2,3,7,8,9), (4,5,6,1,7,8,2,9,3,0)} gfan-0.5+dfsg/examples/4x4of4x5000066400000000000000000000026051207563005400162630ustar00rootroot00000000000000(d*h*l*p - c*i*l*p - d*g*m*p + b*i*m*p + c*g*n*p - b*h*n*p - d*h*k*q + c*i*k*q + d*f*m*q - a*i*m*q - c*f*n*q + a*h*n*q + d*g*k*r - b*i*k*r - d*f*l*r + a*i*l*r + b*f*n*r - a*g*n*r - c*g*k*s + b*h*k*s + c*f*l*s - a*h*l*s - b*f*m*s + a*g*m*s, e*h*l*p - c*j*l*p - e*g*m*p + b*j*m*p + c*g*o*p - b*h*o*p - e*h*k*q + c*j*k*q + e*f*m*q - a*j*m*q - c*f*o*q + a*h*o*q + e*g*k*r - b*j*k*r - e*f*l*r + a*j*l*r + b*f*o*r - a*g*o*r - c*g*k*t + b*h*k*t + c*f*l*t - a*h*l*t - b*f*m*t + a*g*m*t, e*i*l*p - d*j*l*p - e*g*n*p + b*j*n*p + d*g*o*p - b*i*o*p - e*i*k*q + d*j*k*q + e*f*n*q - a*j*n*q - d*f*o*q + a*i*o*q + e*g*k*s - b*j*k*s - e*f*l*s + a*j*l*s + b*f*o*s - a*g*o*s - d*g*k*t + b*i*k*t + d*f*l*t - a*i*l*t - b*f*n*t + a*g*n*t, e*i*m*p - d*j*m*p - e*h*n*p + c*j*n*p + d*h*o*p - c*i*o*p - e*i*k*r + d*j*k*r + e*f*n*r - a*j*n*r - d*f*o*r + a*i*o*r + e*h*k*s - c*j*k*s - e*f*m*s + a*j*m*s + c*f*o*s - a*h*o*s - d*h*k*t + c*i*k*t + d*f*m*t - a*i*m*t - c*f*n*t + a*h*n*t, e*i*m*q - d*j*m*q - e*h*n*q + c*j*n*q + d*h*o*q - c*i*o*q - e*i*l*r + d*j*l*r + e*g*n*r - b*j*n*r - d*g*o*r + b*i*o*r + e*h*l*s - c*j*l*s - e*g*m*s + b*j*m*s + c*g*o*s - b*h*o*s - d*h*l*t + c*i*l*t + d*g*m*t - b*i*m*t - c*g*n*t + b*h*n*t} {(1,0,2,3,4,6,5,7,8,9,11,10,12,13,14,16,15,17,18,19), (1,2,3,4,0,6,7,8,9,5,11,12,13,14,10,16,17,18,19,15), (5,6,7,8,9,0,1,2,3,4,10,11,12,13,14,15,16,17,18,19), (5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,0,1,2,3,4)} gfan-0.5+dfsg/examples/4x4of5x5000066400000000000000000000143621207563005400162670ustar00rootroot00000000000000(d*h*l*p - c*i*l*p - d*g*m*p + b*i*m*p + c*g*n*p - b*h*n*p - d*h*k*q + c*i*k*q + d*f*m*q - a*i*m*q - c*f*n*q + a*h*n*q + d*g*k*r - b*i*k*r - d*f*l*r + a*i*l*r + b*f*n*r - a*g*n*r - c*g*k*s + b*h*k*s + c*f*l*s - a*h*l*s - b*f*m*s + a*g*m*s, e*h*l*p - c*j*l*p - e*g*m*p + b*j*m*p + c*g*o*p - b*h*o*p - e*h*k*q + c*j*k*q + e*f*m*q - a*j*m*q - c*f*o*q + a*h*o*q + e*g*k*r - b*j*k*r - e*f*l*r + a*j*l*r + b*f*o*r - a*g*o*r - c*g*k*t + b*h*k*t + c*f*l*t - a*h*l*t - b*f*m*t + a*g*m*t, e*i*l*p - d*j*l*p - e*g*n*p + b*j*n*p + d*g*o*p - b*i*o*p - e*i*k*q + d*j*k*q + e*f*n*q - a*j*n*q - d*f*o*q + a*i*o*q + e*g*k*s - b*j*k*s - e*f*l*s + a*j*l*s + b*f*o*s - a*g*o*s - d*g*k*t + b*i*k*t + d*f*l*t - a*i*l*t - b*f*n*t + a*g*n*t, e*i*m*p - d*j*m*p - e*h*n*p + c*j*n*p + d*h*o*p - c*i*o*p - e*i*k*r + d*j*k*r + e*f*n*r - a*j*n*r - d*f*o*r + a*i*o*r + e*h*k*s - c*j*k*s - e*f*m*s + a*j*m*s + c*f*o*s - a*h*o*s - d*h*k*t + c*i*k*t + d*f*m*t - a*i*m*t - c*f*n*t + a*h*n*t, e*i*m*q - d*j*m*q - e*h*n*q + c*j*n*q + d*h*o*q - c*i*o*q - e*i*l*r + d*j*l*r + e*g*n*r - b*j*n*r - d*g*o*r + b*i*o*r + e*h*l*s - c*j*l*s - e*g*m*s + b*j*m*s + c*g*o*s - b*h*o*s - d*h*l*t + c*i*l*t + d*g*m*t - b*i*m*t - c*g*n*t + b*h*n*t, d*h*l*u - c*i*l*u - d*g*m*u + b*i*m*u + c*g*n*u - b*h*n*u - d*h*k*v + c*i*k*v + d*f*m*v - a*i*m*v - c*f*n*v + a*h*n*v + d*g*k*w - b*i*k*w - d*f*l*w + a*i*l*w + b*f*n*w - a*g*n*w - c*g*k*x + b*h*k*x + c*f*l*x - a*h*l*x - b*f*m*x + a*g*m*x, e*h*l*u - c*j*l*u - e*g*m*u + b*j*m*u + c*g*o*u - b*h*o*u - e*h*k*v + c*j*k*v + e*f*m*v - a*j*m*v - c*f*o*v + a*h*o*v + e*g*k*w - b*j*k*w - e*f*l*w + a*j*l*w + b*f*o*w - a*g*o*w - c*g*k*y + b*h*k*y + c*f*l*y - a*h*l*y - b*f*m*y + a*g*m*y, e*i*l*u - d*j*l*u - e*g*n*u + b*j*n*u + d*g*o*u - b*i*o*u - e*i*k*v + d*j*k*v + e*f*n*v - a*j*n*v - d*f*o*v + a*i*o*v + e*g*k*x - b*j*k*x - e*f*l*x + a*j*l*x + b*f*o*x - a*g*o*x - d*g*k*y + b*i*k*y + d*f*l*y - a*i*l*y - b*f*n*y + a*g*n*y, e*i*m*u - d*j*m*u - e*h*n*u + c*j*n*u + d*h*o*u - c*i*o*u - e*i*k*w + d*j*k*w + e*f*n*w - a*j*n*w - d*f*o*w + a*i*o*w + e*h*k*x - c*j*k*x - e*f*m*x + a*j*m*x + c*f*o*x - a*h*o*x - d*h*k*y + c*i*k*y + d*f*m*y - a*i*m*y - c*f*n*y + a*h*n*y, e*i*m*v - d*j*m*v - e*h*n*v + c*j*n*v + d*h*o*v - c*i*o*v - e*i*l*w + d*j*l*w + e*g*n*w - b*j*n*w - d*g*o*w + b*i*o*w + e*h*l*x - c*j*l*x - e*g*m*x + b*j*m*x + c*g*o*x - b*h*o*x - d*h*l*y + c*i*l*y + d*g*m*y - b*i*m*y - c*g*n*y + b*h*n*y, d*h*q*u - c*i*q*u - d*g*r*u + b*i*r*u + c*g*s*u - b*h*s*u - d*h*p*v + c*i*p*v + d*f*r*v - a*i*r*v - c*f*s*v + a*h*s*v + d*g*p*w - b*i*p*w - d*f*q*w + a*i*q*w + b*f*s*w - a*g*s*w - c*g*p*x + b*h*p*x + c*f*q*x - a*h*q*x - b*f*r*x + a*g*r*x, e*h*q*u - c*j*q*u - e*g*r*u + b*j*r*u + c*g*t*u - b*h*t*u - e*h*p*v + c*j*p*v + e*f*r*v - a*j*r*v - c*f*t*v + a*h*t*v + e*g*p*w - b*j*p*w - e*f*q*w + a*j*q*w + b*f*t*w - a*g*t*w - c*g*p*y + b*h*p*y + c*f*q*y - a*h*q*y - b*f*r*y + a*g*r*y, e*i*q*u - d*j*q*u - e*g*s*u + b*j*s*u + d*g*t*u - b*i*t*u - e*i*p*v + d*j*p*v + e*f*s*v - a*j*s*v - d*f*t*v + a*i*t*v + e*g*p*x - b*j*p*x - e*f*q*x + a*j*q*x + b*f*t*x - a*g*t*x - d*g*p*y + b*i*p*y + d*f*q*y - a*i*q*y - b*f*s*y + a*g*s*y, e*i*r*u - d*j*r*u - e*h*s*u + c*j*s*u + d*h*t*u - c*i*t*u - e*i*p*w + d*j*p*w + e*f*s*w - a*j*s*w - d*f*t*w + a*i*t*w + e*h*p*x - c*j*p*x - e*f*r*x + a*j*r*x + c*f*t*x - a*h*t*x - d*h*p*y + c*i*p*y + d*f*r*y - a*i*r*y - c*f*s*y + a*h*s*y, e*i*r*v - d*j*r*v - e*h*s*v + c*j*s*v + d*h*t*v - c*i*t*v - e*i*q*w + d*j*q*w + e*g*s*w - b*j*s*w - d*g*t*w + b*i*t*w + e*h*q*x - c*j*q*x - e*g*r*x + b*j*r*x + c*g*t*x - b*h*t*x - d*h*q*y + c*i*q*y + d*g*r*y - b*i*r*y - c*g*s*y + b*h*s*y, d*m*q*u - c*n*q*u - d*l*r*u + b*n*r*u + c*l*s*u - b*m*s*u - d*m*p*v + c*n*p*v + d*k*r*v - a*n*r*v - c*k*s*v + a*m*s*v + d*l*p*w - b*n*p*w - d*k*q*w + a*n*q*w + b*k*s*w - a*l*s*w - c*l*p*x + b*m*p*x + c*k*q*x - a*m*q*x - b*k*r*x + a*l*r*x, e*m*q*u - c*o*q*u - e*l*r*u + b*o*r*u + c*l*t*u - b*m*t*u - e*m*p*v + c*o*p*v + e*k*r*v - a*o*r*v - c*k*t*v + a*m*t*v + e*l*p*w - b*o*p*w - e*k*q*w + a*o*q*w + b*k*t*w - a*l*t*w - c*l*p*y + b*m*p*y + c*k*q*y - a*m*q*y - b*k*r*y + a*l*r*y, e*n*q*u - d*o*q*u - e*l*s*u + b*o*s*u + d*l*t*u - b*n*t*u - e*n*p*v + d*o*p*v + e*k*s*v - a*o*s*v - d*k*t*v + a*n*t*v + e*l*p*x - b*o*p*x - e*k*q*x + a*o*q*x + b*k*t*x - a*l*t*x - d*l*p*y + b*n*p*y + d*k*q*y - a*n*q*y - b*k*s*y + a*l*s*y, e*n*r*u - d*o*r*u - e*m*s*u + c*o*s*u + d*m*t*u - c*n*t*u - e*n*p*w + d*o*p*w + e*k*s*w - a*o*s*w - d*k*t*w + a*n*t*w + e*m*p*x - c*o*p*x - e*k*r*x + a*o*r*x + c*k*t*x - a*m*t*x - d*m*p*y + c*n*p*y + d*k*r*y - a*n*r*y - c*k*s*y + a*m*s*y, e*n*r*v - d*o*r*v - e*m*s*v + c*o*s*v + d*m*t*v - c*n*t*v - e*n*q*w + d*o*q*w + e*l*s*w - b*o*s*w - d*l*t*w + b*n*t*w + e*m*q*x - c*o*q*x - e*l*r*x + b*o*r*x + c*l*t*x - b*m*t*x - d*m*q*y + c*n*q*y + d*l*r*y - b*n*r*y - c*l*s*y + b*m*s*y, i*m*q*u - h*n*q*u - i*l*r*u + g*n*r*u + h*l*s*u - g*m*s*u - i*m*p*v + h*n*p*v + i*k*r*v - f*n*r*v - h*k*s*v + f*m*s*v + i*l*p*w - g*n*p*w - i*k*q*w + f*n*q*w + g*k*s*w - f*l*s*w - h*l*p*x + g*m*p*x + h*k*q*x - f*m*q*x - g*k*r*x + f*l*r*x, j*m*q*u - h*o*q*u - j*l*r*u + g*o*r*u + h*l*t*u - g*m*t*u - j*m*p*v + h*o*p*v + j*k*r*v - f*o*r*v - h*k*t*v + f*m*t*v + j*l*p*w - g*o*p*w - j*k*q*w + f*o*q*w + g*k*t*w - f*l*t*w - h*l*p*y + g*m*p*y + h*k*q*y - f*m*q*y - g*k*r*y + f*l*r*y, j*n*q*u - i*o*q*u - j*l*s*u + g*o*s*u + i*l*t*u - g*n*t*u - j*n*p*v + i*o*p*v + j*k*s*v - f*o*s*v - i*k*t*v + f*n*t*v + j*l*p*x - g*o*p*x - j*k*q*x + f*o*q*x + g*k*t*x - f*l*t*x - i*l*p*y + g*n*p*y + i*k*q*y - f*n*q*y - g*k*s*y + f*l*s*y, j*n*r*u - i*o*r*u - j*m*s*u + h*o*s*u + i*m*t*u - h*n*t*u - j*n*p*w + i*o*p*w + j*k*s*w - f*o*s*w - i*k*t*w + f*n*t*w + j*m*p*x - h*o*p*x - j*k*r*x + f*o*r*x + h*k*t*x - f*m*t*x - i*m*p*y + h*n*p*y + i*k*r*y - f*n*r*y - h*k*s*y + f*m*s*y, j*n*r*v - i*o*r*v - j*m*s*v + h*o*s*v + i*m*t*v - h*n*t*v - j*n*q*w + i*o*q*w + j*l*s*w - g*o*s*w - i*l*t*w + g*n*t*w + j*m*q*x - h*o*q*x - j*l*r*x + g*o*r*x + h*l*t*x - g*m*t*x - i*m*q*y + h*n*q*y + i*l*r*y - g*n*r*y - h*l*s*y + g*m*s*y) { (1,0,2,3,4,6,5,7,8,9,11,10,12,13,14,16,15,17,18,19,21,20,22,23,24), (1,2,3,4,0,6,7,8,9,5,11,12,13,14,10,16,17,18,19,15,21,22,23,24,20), (0,5,10,15,20,1,6,11,16,21,2,7,12,17,22,3,8,13,18,23,4,9,14,19,24), (5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,0,1,2,3,4), (0,5,10,15,20,1,6,11,16,21,2,7,12,17,22,3,8,13,18,23,4,9,14,19,24)} (5,6,7,8,9,0,1,2,3,4,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24), gfan-0.5+dfsg/examples/6x6-subPfaffians000066400000000000000000000013641207563005400200070ustar00rootroot00000000000000{c*i*n - a*l*s+a*m*q-a*n*p+b*h*s-b*i*q+b* j*p-c*g*s-c*j*m+d*g*q-d*h*n+d*j*l-e*g*p +e*h*m-e*i*l, c*i*o - a*l*t+a*m*r-a*o*p+b*h*t-b*i*r+b* k*p-c*g*t-c*k*m+d*g*r-d*h*o+d*k*l-f*g*p +f*h*m-f*i*l, c*j*o - a*l*u+a*n*r-a*o*q+b*h*u-b*j*r+b* k*q-c*g*u-c*k*n+e*g*r-e*h*o+e*k*l-f*g*q +f*h*n-f*j*l, d*j*o + a*m*u-a*n*t+a*o*s-b*i*u+b*j*t-b* k*s+d*g*u-2*d*j*o+d*k*n-e*g*t+e*i*o-e*k* m+f*g*s-f*i*n+f*j*m, d*j*r + a*p*u-a*q*t+a*r*s-c*i*u+c*j*t-c* k*s+d*h*u-2*d*j*r+d*k*q-e*h*t+e*i*r-e*k* p+f*h*s-f*i*q+f*j*p, d*n*r + b*p*u-b*q*t+b*r*s-c*m*u+c*n*t-c* o*s+d*l*u-2*d*n*r+d*o*q-e*l*t+e*m*r-e*o* p+f*l*s-f*m*q+f*n*p, i*n*r - g*p*u+g*q*t-g*r*s+h*m*u-h*n*t+h* o*s-i*l*u-i*o*q+j*l*t-j*m*r+j*o*p-k*l*s +k*m*q-k*n*p } { (1,2,3,4,5,0,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) } gfan-0.5+dfsg/examples/commat2x2000066400000000000000000000000421207563005400165630ustar00rootroot00000000000000{cf-bg, ce-ag+dg-ch, be-af+df-bh} gfan-0.5+dfsg/examples/commat2x2.cone000066400000000000000000000001121207563005400175040ustar00rootroot00000000000000{ c*f-b*g, a*g-d*g, a*f-d*f} { c*f-b*g, a*g-d*g+c*h-c*e, a*f-d*f+b*h-b*e} gfan-0.5+dfsg/examples/cyclic4000066400000000000000000000000721207563005400163040ustar00rootroot00000000000000{a+b+c+d, ab+bc+cd+da, abc+bcd+cda+dab, abcd-1} (1,1,1,1) gfan-0.5+dfsg/examples/cyclic5000066400000000000000000000001411207563005400163020ustar00rootroot00000000000000{a+b+c+d+e, ab+bc+cd+de+ea, abc+bcd+cde+dea+eab, abcd+bcde+cdea+deab+eabc, abcde-1} (1,1,1,1,1) gfan-0.5+dfsg/examples/examplePaper000066400000000000000000000000221207563005400173700ustar00rootroot00000000000000{a+b+c,aaac+a+bb} gfan-0.5+dfsg/examples/grassmann2_5000066400000000000000000000001461207563005400172530ustar00rootroot00000000000000{ bf-ah-ce, bg-ai-de, cg-aj-df, ci-bj-dh, fi-ej-gh } { (3,6,8,9,0,1,2,4,5,7), (0,6,5,4,3,2,1,9,8,7) } gfan-0.5+dfsg/examples/grassmann2_5.cone000066400000000000000000000002431207563005400201740ustar00rootroot00000000000000{ f*i-e*j, d*h-c*i, d*f+a*j, d*e+a*i, c*e+a*h} { f*i-g*h-e*j, d*h-c*i+b*j, d*f-c*g+a*j, d*e-b*g+a*i, c*e-b*f+a*h} { (3,6,8,9,0,1,2,4,5,7), (0,6,5,4,3,2,1,9,8,7) } gfan-0.5+dfsg/examples/grassmann2_6000066400000000000000000000006471207563005400172620ustar00rootroot00000000000000{bg-aj-cf, bh-ak-df, bi-al-ef, ck-bm-dj, ch-am-dg, cl-ej-bn, ci-eg-an, dn-co-em, dl-bo-ek, di-ao-eh, gk-fm-jh, gl-fn-ij, hl-fo-ik, kn-jo-lm, hn-im-go } { (0,8,7,6,5,4,3,2,1,14,13,11,12,10,9), (5,6,7,8,0,9,10,11,1,12,13,2,14,3,4) } { (0,8,7,6,5,4,3,2,1,14,13,11,12,10,9), (5,6,7,8,0,9,10,11,1,12,13,2,14,3,4)}, (0,5,7,6,8,1,3,2,4,10,9,11,12,14,13) } (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14) a b c d e f g h i j k l m n o gfan-0.5+dfsg/examples/grassmann2_6.cone000066400000000000000000000005631207563005400202020ustar00rootroot00000000000000Q[a,b,c,d,e,f,g,h,i,j,k,l,m,n,o] {bg-cf, bh-df, bi-fe, ch-dg, ci-eg, di-eh, ck-dj, cl-ej, dl-ek, dn-em, gk-hj, gl-ij, hl-ik, hn-im, kn-lm} {bg-aj-cf, bh-ak-df, bi-al-ef, ck-bm-dj, ch-am-dg, cl-ej-bn, ci-eg-an, dn-co-em, dl-bo-ek, di-ao-eh, gk-fm-jh, gl-fn-ij, hl-fo-ik, kn-jo-lm, hn-im-go } { (0,8,7,6,5,4,3,2,1,14,13,11,12,10,9), (5,6,7,8,0,9,10,11,1,12,13,2,14,3,4) } gfan-0.5+dfsg/examples/grassmann3_6000066400000000000000000000026461207563005400172640ustar00rootroot00000000000000Q[p123,p124,p134,p234,p125,p135,p235,p145,p245,p345,p126,p136,p236,p146,p246,p346,p156,p256,p356,p456] {p346*p256 - p246*p356 + p236*p456, p346*p156 - p146*p356 + p136*p456, p246*p156 - p146*p256 + p126*p456, p236*p156 - p136*p256 + p126*p356, p236*p146 - p136*p246 + p126*p346, p345*p256 - p245*p356 + p235*p456, p345*p246 - p245*p346 + p234*p456, p345*p236 - p235*p346 + p234*p356, p245*p236 - p235*p246 + p234*p256, p345*p156 - p145*p356 + p135*p456, p345*p146 - p145*p346 + p134*p456, p345*p136 - p135*p346 + p134*p356, p145*p136 - p135*p146 + p134*p156, p245*p156 - p145*p256 + p125*p456, p235*p156 - p135*p256 + p125*p356, p245*p146 - p145*p246 + p124*p456, p245*p126 - p125*p246 + p124*p256, p145*p126 - p125*p146 + p124*p156, p235*p136 - p135*p236 + p123*p356, p235*p126 - p125*p236 + p123*p256, p135*p126 - p125*p136 + p123*p156, p234*p146 - p134*p246 + p124*p346, p234*p136 - p134*p236 + p123*p346, p234*p126 - p124*p236 + p123*p246, p134*p126 - p124*p136 + p123*p146, p235*p145 - p135*p245 + p125*p345, p234*p145 - p134*p245 + p124*p345, p234*p135 - p134*p235 + p123*p345, p234*p125 - p124*p235 + p123*p245, p134*p125 - p124*p135 + p123*p145, p235*p146 - p135*p246 + p125*p346 + p123*p456, p345*p126 - p125*p346 + p124*p356 - p123*p456, p234*p156 - p134*p256 + p124*p356 - p123*p456, p245*p136 - p135*p246 + p134*p256 + p123*p456, p145*p236 - p135*p246 + p125*p346 + p134*p256 - p124*p356 + p123*p456} gfan-0.5+dfsg/examples/grassmann3_6.cone000066400000000000000000000026701207563005400202040ustar00rootroot00000000000000{ p*r-o*s, p*q+l*t, o*q+k*t, l*r-k*s, l*o-k*p, j*r+g*t, j*q-h*s, j*o+d*t, j*l+c*s, j*k-a*t, h*r-e*t, h*p-c*t, h*o-b*t, h*l+c*q, h*k+b*q, g*q+e*s, g*p-d*s, g*o-d*r, g*l+a*s, g*k+a*r, g*h+e*j, e*p+a*t, e*o-b*r, e*l-a*q, d*q-a*t, d*l+a*p, d*k+a*o, d*h+b*j, d*e-b*g, c*r+a*t, c*o-b*p, c*k-b*l, c*g-a*j, c*e+a*h, b*s+a*t, b*q*r+e*k*t, b*j*p+c*d*t, a*q*r-e*k*s, a*j*p-c*d*s} { p*r-o*s+m*t, p*q-n*s+l*t, o*q-n*r+k*t, l*r-m*q-k*s, l*o-m*n-k*p, j*r-i*s+g*t, j*q-h*s+f*t, j*o-i*p+d*t, j*l-f*p+c*s, j*k-i*l+h*m-a*t, h*r-i*q-e*t, h*p-j*n-c*t, h*o-i*n-b*t, h*l-f*n+c*q, h*k-e*n+b*q, g*q-f*r+e*s, g*p-j*m-d*s, g*o-i*m-d*r, g*l-f*m+a*s, g*k-e*m+a*r, g*h-f*i+e*j, e*p+g*n-f*o+a*t, e*o-i*k-b*r, e*l-f*k-a*q, d*q+h*m-g*n-a*t, d*l-c*m+a*p, d*k-b*m+a*o, d*h-c*i+b*j, d*e-b*g+a*i, c*r+i*l-f*o+a*t, c*o-d*n-b*p, c*k-b*l+a*n, c*g-d*f-a*j, c*e-b*f+a*h, b*s+i*l-h*m+g*n-f*o+a*t, b*q*r+i*k*q-e*n*r+e*k*t, b*j*p+d*j*n-c*i*p+c*d*t, a*q*r+f*k*r-e*m*q-e*k*s, a*j*p+d*f*p-c*j*m-c*d*s} { (0 , 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19), (3 , 6, 8, 9, 12, 14, 15, 17, 18, 19, 0, 1, 2, 4, 5, 7, 10, 11, 13, 16), (19, 18, 15, 9, 17, 14, 8, 12, 6, 3, 16, 13, 7, 11, 5, 2, 10, 4, 1, 0)} Just comments: (0 , 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19), 123,124,134,234,125,135,235,145,245,345,126,136,236,146,246,346,156,256,356,456 , (0 , 3, 1, 2, 6, 4, 5, 8, 9, 7, 12, 10, 11, 14, 15, 13, 17, 18, 16, 19) gfan-0.5+dfsg/examples/hankel3x3of4x4000066400000000000000000000014601207563005400174410ustar00rootroot00000000000000(x0,x1,x2,x3,x4,x5,x6) {-x2^3+2*x1*x2*x3-x0*x3^2-x1^2*x4+x0*x2*x4, -x2^2*x3+x1*x3^2+x1*x2*x4-x0*x3*x4-x1^2*x5+x0*x2*x5, -x2*x3^2+x2^2*x4+x1*x3*x4-x0*x4^2-x1*x2*x5+x0*x3*x5, -x3^3+2*x2*x3*x4-x1*x4^2-x2^2*x5+x1*x3*x5, -x2^2*x3+x1*x3^2+x1*x2*x4-x0*x3*x4-x1^2*x5+x0*x2*x5, -x2*x3^2+2*x1*x3*x4-x0*x4^2-x1^2*x6+x0*x2*x6, -x3^3+x2*x3*x4+x1*x3*x5-x0*x4*x5-x1*x2*x6+x0*x3*x6, -x3^2*x4+x2*x4^2+x2*x3*x5-x1*x4*x5-x2^2*x6+x1*x3*x6, -x2*x3^2+x2^2*x4+x1*x3*x4-x0*x4^2-x1*x2*x5+x0*x3*x5, -x3^3+x2*x3*x4+x1*x3*x5-x0*x4*x5-x1*x2*x6+x0*x3*x6, -x3^2*x4+2*x2*x3*x5-x0*x5^2-x2^2*x6+x0*x4*x6, -x3*x4^2+x3^2*x5+x2*x4*x5-x1*x5^2-x2*x3*x6+x1*x4*x6, -x3^3+2*x2*x3*x4-x1*x4^2-x2^2*x5+x1*x3*x5, -x3^2*x4+x2*x4^2+x2*x3*x5-x1*x4*x5-x2^2*x6+x1*x3*x6, -x3*x4^2+x3^2*x5+x2*x4*x5-x1*x5^2-x2*x3*x6+x1*x4*x6, -x4^3+2*x3*x4*x5-x2*x5^2-x3^2*x6+x2*x4*x6} gfan-0.5+dfsg/examples/hankel3x3of4x4.cone000066400000000000000000000010011207563005400203530ustar00rootroot00000000000000{ c*f^2-c*e*g, b*f^2-b*e*g, b*e*f+c^2*g, b*e^2+c^2*f, b^2*g-a*c*g, b^2*f-a*c*f, b^2*e-a*c*e, a*f^2-a*e*g, a*e*f+b*c*g, a*e^2+b*c*f} { c*f^2+e^3-2d*e*f+d^2*g-c*e*g, b*f^2+d*e^2-d^2*f-c*e*f+c*d*g-b*e*g, b*e*f+d^2*e-c*e^2-c*d*f+c^2*g-b*d*g, b*e^2+d^3-2c*d*e+c^2*f-b*d*f, b^2*g+c^2*e-b*d*e-b*c*f+a*d*f-a*c*g, b^2*f+c^2*d-b*d^2-b*c*e+a*d*e-a*c*f, b^2*e+c^3-2b*c*d+a*d^2-a*c*e, a*f^2+d^2*e-2c*d*f+c^2*g-a*e*g, a*e*f+d^3-c*d*e-b*d*f+b*c*g-a*d*g, a*e^2+c*d^2-c^2*e-b*d*e+b*c*f-a*d*f} { (0,1,2,3,4,5,6), (6,5,4,3,2,1,0) } gfan-0.5+dfsg/examples/hankel3x3of4x5000066400000000000000000000040231207563005400174400ustar00rootroot00000000000000(x0,x1,x2,x3,x4,x5,x6,x7) {-x2^3+2*x1*x2*x3-x0*x3^2-x1^2*x4+x0*x2*x4, -x2^2*x3+x1*x3^2+x1*x2*x4-x0*x3*x4-x1^2*x5+x0*x2*x5, -x2*x3^2+x2^2*x4+x1*x3*x4-x0*x4^2-x1*x2*x5+x0*x3*x5, -x3^3+2*x2*x3*x4-x1*x4^2-x2^2*x5+x1*x3*x5, -x2^2*x3+x1*x3^2+x1*x2*x4-x0*x3*x4-x1^2*x5+x0*x2*x5, -x2*x3^2+2*x1*x3*x4-x0*x4^2-x1^2*x6+x0*x2*x6, -x3^3+x2*x3*x4+x1*x3*x5-x0*x4*x5-x1*x2*x6+x0*x3*x6, -x3^2*x4+x2*x4^2+x2*x3*x5-x1*x4*x5-x2^2*x6+x1*x3*x6, -x2*x3^2+x2^2*x4+x1*x3*x4-x0*x4^2-x1*x2*x5+x0*x3*x5, -x3^3+x2*x3*x4+x1*x3*x5-x0*x4*x5-x1*x2*x6+x0*x3*x6, -x3^2*x4+2*x2*x3*x5-x0*x5^2-x2^2*x6+x0*x4*x6, -x3*x4^2+x3^2*x5+x2*x4*x5-x1*x5^2-x2*x3*x6+x1*x4*x6, -x3^3+2*x2*x3*x4-x1*x4^2-x2^2*x5+x1*x3*x5, -x3^2*x4+x2*x4^2+x2*x3*x5-x1*x4*x5-x2^2*x6+x1*x3*x6, -x3*x4^2+x3^2*x5+x2*x4*x5-x1*x5^2-x2*x3*x6+x1*x4*x6, -x4^3+2*x3*x4*x5-x2*x5^2-x3^2*x6+x2*x4*x6, -x2^2*x4+x1*x3*x4+x1*x2*x5-x0*x3*x5-x1^2*x6+x0*x2*x6, -x2*x3*x4+x1*x4^2+x1*x3*x5-x0*x4*x5-x1^2*x7+x0*x2*x7, -x3^2*x4+x2*x4^2+x1*x3*x6-x0*x4*x6-x1*x2*x7+x0*x3*x7, -x3^2*x5+x2*x4*x5+x2*x3*x6-x1*x4*x6-x2^2*x7+x1*x3*x7, -x2*x3*x4+x1*x4^2+x2^2*x5-x0*x4*x5-x1*x2*x6+x0*x3*x6, -x3^2*x4+x2*x3*x5+x1*x4*x5-x0*x5^2-x1*x2*x7+x0*x3*x7, -x3*x4^2+x2*x4*x5+x2*x3*x6-x0*x5*x6-x2^2*x7+x0*x4*x7, -x3*x4*x5+x2*x5^2+x3^2*x6-x1*x5*x6-x2*x3*x7+x1*x4*x7, -x3^2*x4+x2*x4^2+x2*x3*x5-x1*x4*x5-x2^2*x6+x1*x3*x6, -x3*x4^2+2*x2*x4*x5-x1*x5^2-x2^2*x7+x1*x3*x7, -x4^3+x3*x4*x5+x2*x4*x6-x1*x5*x6-x2*x3*x7+x1*x4*x7, -x4^2*x5+x3*x5^2+x3*x4*x6-x2*x5*x6-x3^2*x7+x2*x4*x7, -x2*x4^2+x2*x3*x5+x1*x4*x5-x0*x5^2-x1*x3*x6+x0*x4*x6, -x3*x4^2+x3^2*x5+x1*x4*x6-x0*x5*x6-x1*x3*x7+x0*x4*x7, -x3*x4*x5+x3^2*x6+x2*x4*x6-x0*x6^2-x2*x3*x7+x0*x5*x7, -x3*x5^2+x3*x4*x6+x2*x5*x6-x1*x6^2-x2*x4*x7+x1*x5*x7, -x3*x4^2+x3^2*x5+x2*x4*x5-x1*x5^2-x2*x3*x6+x1*x4*x6, -x4^3+x3*x4*x5+x2*x4*x6-x1*x5*x6-x2*x3*x7+x1*x4*x7, -x4^2*x5+2*x3*x4*x6-x1*x6^2-x3^2*x7+x1*x5*x7, -x4*x5^2+x4^2*x6+x3*x5*x6-x2*x6^2-x3*x4*x7+x2*x5*x7, -x4^3+2*x3*x4*x5-x2*x5^2-x3^2*x6+x2*x4*x6, -x4^2*x5+x3*x5^2+x3*x4*x6-x2*x5*x6-x3^2*x7+x2*x4*x7, -x4*x5^2+x4^2*x6+x3*x5*x6-x2*x6^2-x3*x4*x7+x2*x5*x7, -x5^3+2*x4*x5*x6-x3*x6^2-x4^2*x7+x3*x5*x7} gfan-0.5+dfsg/examples/hankel3x3of4x5.cone000066400000000000000000000021231207563005400203620ustar00rootroot00000000000000{ e^2*h-d*f*h, e^3-2d*e*f+c*f^2, d*e*h-c*f*h, d*e^2-d^2*f-c*e*f+b*f^2, d^2*h-b*f*h, d^2*e-2c*d*f+a*f^2, d^3-c^2*f-b*e^2-b*d*f+2a*e*f, c*e*h-b*f*h, c*e^2-c*d*f-b*e*f+a*f^2, c*d*h-a*f*h, c*d*e-c^2*f-b*e^2+a*e*f, c*d^2-2b*d*e+a*e^2, c^2*h-a*e*h, c^2*e-b*d*e-b*c*f+a*d*f, c^2*d-b*d^2-b*c*e+b^2*f+a*d*e-a*c*f, c^3-2b*c*d+b^2*e+a*d^2-a*c*e, b*e*h-a*f*h, b*d*h-a*e*h, b*c*h-a*d*h, b^2*h-a*c*h} { e^2*h+f^3-2e*f*g+d*g^2-d*f*h, e^3-2d*e*f+d^2*g+c*f^2-c*e*g, d*e*h+e*f^2-e^2*g-d*f*g+c*g^2-c*f*h, d*e^2-d^2*f-c*e*f+c*d*g+b*f^2-b*e*g, d^2*h+e^2*f-2d*e*g+b*g^2-b*f*h, d^2*e-2c*d*f+c^2*g+a*f^2-a*e*g, d^3-c^2*f-b*e^2-b*d*f+2b*c*g+2a*e*f-2a*d*g, c*e*h+d*f^2-d*e*g-c*f*g+b*g^2-b*f*h, c*e^2-c*d*f-b*e*f+b*d*g+a*f^2-a*e*g, c*d*h+d*e*f-d^2*g-c*e*g+a*g^2-a*f*h, c*d*e-c^2*f-b*e^2+b*c*g+a*e*f-a*d*g, c*d^2-2b*d*e+b^2*g+a*e^2-a*c*g, c^2*h+d^2*f-2c*d*g-b*f^2+b*e*g+a*f*g-a*e*h, c^2*e-b*d*e-b*c*f+b^2*g+a*d*f-a*c*g, c^2*d-b*d^2-b*c*e+b^2*f+a*d*e-a*c*f, c^3-2b*c*d+b^2*e+a*d^2-a*c*e, b*e*h+c*f^2-c*e*g-b*f*g+a*g^2-a*f*h, b*d*h+c*e*f-c*d*g-b*f^2+a*f*g-a*e*h, b*c*h+c*d*f-c^2*g-b*e*f+a*e*g-a*d*h, b^2*h+c^2*f-b*d*f-b*c*g+a*d*g-a*c*h} gfan-0.5+dfsg/examples/linhyper5_2000066400000000000000000000002231207563005400171100ustar00rootroot00000000000000{ a+h-b-f, a+h-c-e, a+i-b-g, a+i-d-e, a+j-c-g, a+j-d-f, b+j-c-i, b+j-d-h, e+j-f-i, e+j-g-h } { (3,6,8,9,0,1,2,4,5,7), (0,4,5,6,1,2,3,7,8,9) } gfan-0.5+dfsg/examples/linhyper5_2.cone000066400000000000000000000001771207563005400200430ustar00rootroot00000000000000{ f+i, e+j, c+i, b+j, a+j} { f+i-h-g, e+j-h-g, c+i-h-d, b+j-h-d, a+j+i-h-g-d} { (3,6,8,9,0,1,2,4,5,7), (0,4,5,6,1,2,3,7,8,9) } gfan-0.5+dfsg/examples/pablo000066400000000000000000000000671207563005400160530ustar00rootroot00000000000000{4a^3-4bc+1, 4b^3-4ac+1, 4c^3-4ab+1} {(1,2,0),(1,0,2)} gfan-0.5+dfsg/examples/sturmfels3.9000066400000000000000000000000651207563005400172320ustar00rootroot00000000000000Q[a,b,c] {a^5+b^3+c^2-1, b^2+a^2+c-1, c^3+a^6+b^5-1} gfan-0.5+dfsg/examples/symmetryTest000066400000000000000000000000331207563005400175000ustar00rootroot00000000000000(aa-b,bb-c,cc-a} ((1,2,0)) gfan-0.5+dfsg/field.cpp000066400000000000000000000215341207563005400150060ustar00rootroot00000000000000#include "field.h" #include #include #include /* Always include cstdio before gmp.h.*/ #include #include "printer.h" #include "log.h" // The following macro is used for logging of field creation. Note that the usual "log1" does not work since the logLevel might not be initialized at the point of field construction #define flog1 if(0) #define flog2 if(0) FieldElement::FieldElement(Field const &f)//: // theField(f) { assert(f.implementingObject); implementingObject=f.zHomomorphismImplementation(0);//create object with refCount 1 // f.implementingObject->refCount++; flog2 fprintf(Stderr,"FieldElement - constructing1\n"); } FieldElement::FieldElement(class FieldElementImplementation *implementingObject_): implementingObject(implementingObject_) { } FieldElement::FieldElement(const FieldElement &a) // theField(a.theField) { // assert(a.implementingObject); if(a.implementingObject) { implementingObject=a.implementingObject; implementingObject->refCount++; } else { implementingObject=0; } flog2 fprintf(Stderr,"FieldElement - constructing2\n"); } mpq_t const *FieldElement::getGmpRationalTemporaryPointer()const { return implementingObject->getGmpRationalTemporaryPointer(); } double FieldElement::floatingPointApproximation()const { mpq_t const *p=getGmpRationalTemporaryPointer(); return mpq_get_d(*p);//LEAK?? } bool FieldElement::isInteger()const { return implementingObject->isInteger(); } FieldElement::~FieldElement() { if(implementingObject && 0==(--(implementingObject->refCount))) { //implementingObject->refCount=0x8000; delete implementingObject; // fprintf(Stderr,"DELETE\n"); flog2 fprintf(Stderr,"Deleting implementing object\n"); } flog2 fprintf(Stderr,"FieldElement - destructing\n"); } FieldElement& FieldElement::operator=(const FieldElement& a) { if(this==&a) { flog2 fprintf(Stderr,"FieldElement - selfassignment\n"); return *this; } if(implementingObject&& 0==(--(implementingObject->refCount))) { delete implementingObject; // fprintf(Stderr,"DELETE\n"); flog2 fprintf(Stderr,"FieldElement - deleting old implementing\n"); } //assert(a.implementingObject); if(a.implementingObject) { implementingObject=a.implementingObject; implementingObject->refCount++; } else { implementingObject=0; } flog2 fprintf(Stderr,"FieldElement - assignment\n"); return *this; } class FieldImplementation *FieldElement::getField()const { return implementingObject->getField(); } FieldElement FieldElement::one() const//change this implementation { assert(implementingObject); return FieldElement(implementingObject->one()); } bool FieldElement::isZero()const { assert(implementingObject); return implementingObject->isZero(); } bool FieldElement::isOne()const { if(!implementingObject)return false; return (*this-one()).isZero(); } FieldElement operator+(const FieldElement &a,const FieldElement &b) { assert(a.implementingObject); assert(b.implementingObject); return FieldElement(a.implementingObject->sum(*(b.implementingObject))); } FieldElement operator-(const FieldElement &a,const FieldElement &b) { assert(a.implementingObject); assert(b.implementingObject); return FieldElement(a.implementingObject->difference(*(b.implementingObject))); } FieldElement operator-(const FieldElement &b) { assert(b.implementingObject); return FieldElement(b.implementingObject->negation()); } FieldElement FieldElement::inverse()const { assert(implementingObject); return FieldElement(implementingObject->inverse()); } int FieldElement::sign()const { assert(implementingObject); return implementingObject->sign(); } int FieldElement::pAdicValuation(int p)const { assert(implementingObject); return implementingObject->pAdicValuation(p); } FieldElement FieldElement::pAdicRemainder(class Field const &ZModPZ)const { assert(implementingObject); return FieldElement(implementingObject->pAdicRemainder(ZModPZ)); } int FieldElement::integerRepresentative()const { assert(implementingObject); return implementingObject->integerRepresentative(); } std::string FieldElement::toString(bool writeIfOne, bool alwaysWriteSign, bool latexMode) const { assert(implementingObject); return implementingObject->toString(writeIfOne,alwaysWriteSign,latexMode); } void FieldElement::operator*=(const FieldElement &a) { assert(a.implementingObject); assert(implementingObject); if(implementingObject->refCount!=1) { implementingObject->refCount--; implementingObject=implementingObject->copy(); } (*implementingObject)*=(*a.implementingObject); } void FieldElement::operator+=(const FieldElement &a) { assert(a.implementingObject); assert(implementingObject); if(implementingObject->refCount!=1) { implementingObject->refCount--; implementingObject=implementingObject->copy(); } (*implementingObject)+=(*a.implementingObject); } void FieldElement::madd(const FieldElement &a, const FieldElement &b) { assert(a.implementingObject); assert(b.implementingObject); assert(implementingObject); if(implementingObject->refCount!=1) { implementingObject->refCount--; implementingObject=implementingObject->copy(); } (*implementingObject).madd(*a.implementingObject,*b.implementingObject); } FieldElement operator*(const FieldElement &a,const FieldElement &b) { FieldElement c=a; c*=b; return c; } FieldElement Field::zHomomorphism(int n)const { return implementingObject->zHomomorphism(n); } FieldElementImplementation::FieldElementImplementation(FieldImplementation &a): refCount(1), theFieldImplementation(a) { a.refCount++; numberOfLivingFieldElementImplementations++; }; FieldElementImplementation::~FieldElementImplementation() { numberOfLivingFieldElementImplementations--; if(0==(--(theFieldImplementation.refCount))) { delete &theFieldImplementation;//NOW THE REFERENCE IS INVALID.... flog2 fprintf(Stderr,"Deleting field implementation\n"); } }; class FieldImplementation *FieldElementImplementation::getField()const { return &theFieldImplementation; } FieldElementImplementation *Field::zHomomorphismImplementation(int n)const { return implementingObject->zHomomorphismImplementation(n); } const char *Field::name() { return implementingObject->name(); } bool Field::isRationals()const { return implementingObject->isRationals(); } std::string Field::toString()const{ return implementingObject->toString(); } Field::Field(FieldImplementation *implObj) { implObj->refCount++; implementingObject=implObj; flog1 fprintf(Stderr,"Constructing Field\n"); } Field::~Field() { assert(implementingObject); implementingObject->refCount--; assert(implementingObject->refCount>=0); if(implementingObject->refCount==0) { flog1 fprintf(Stderr,"Deleting implementing object\n"); delete implementingObject; } implementingObject=0; flog1 fprintf(Stderr,"Destructing Field\n"); } Field::Field(Field const &a)//copy constructor :implementingObject(a.implementingObject) { implementingObject->refCount++; flog1 fprintf(Stderr,"Copying field\n"); } Field& Field::operator=(const Field& a) { flog1 fprintf(Stderr,"Assigning Field\n"); if(this==&a) { flog1 fprintf(Stderr,"---selfassigning\n"); return *this; } if(implementingObject&& 0==(--(implementingObject->refCount)))delete implementingObject; //assert(a.implementingObject); if(a.implementingObject) { implementingObject=a.implementingObject; implementingObject->refCount++; } else implementingObject=0; return *this; } //Field *Field::list; //Field *Field::currentField; //Field::Field() //{ /* if(addToList) { next=list; list=this; } */ //} /*Field *Field::find(const char *name) { Field *l=list; while(l) { fprintf(Stderr,"testC\n"); if(std::string(l->name())==std::string(name))break; l=l->next; } fprintf(Stderr,"testD\n"); return l; } */ /* void Field::printList(FILE *f) { fprintf(f,"List of linked field classes:\n"); Field *l=list; while(l) { fprintf(f," %s\n",l->name()); l=l->next; } } */ /*void Field::checkInitialized() { if(!currentField) { fprintf(Stderr,"test2323\n"); setField(find("GmpRationals")); } } */ /*void Field::setField(Field *field) { assert(field); currentField=field; fprintf(Stderr,"Field class being used: \"%s\".\n",currentField->name()); }*/ /*FieldElement Field::staticZHomomorphism(int n) { fprintf(Stderr,"test"); // checkInitialized(); return currentField->zHomomorphism(n); }*/ int FieldImplementation::numberOfLivingFieldImplementations; int FieldElementImplementation::numberOfLivingFieldElementImplementations; gfan-0.5+dfsg/field.h000066400000000000000000000172141207563005400144530ustar00rootroot00000000000000#ifndef FIELD_H_INCLUDED #define FIELD_H_INCLUDED #include #include #include #include #include /* Always include cstdio before gmp.h.*/ #include //SHOULD BE REMOVED /** A FieldElement is an element of a Field in the algebraic sense. A FieldElement always knows its associated Field to which it belongs. We may perform arithmetic operations on a FieldElement and a FieldElement is passed around by value. Thus in C++ it makes no sense to derive classes from the FieldElement class. The actual data is contained in an object of the class FieldElementImplementation and the FieldElement serves as a smart pointer with reference counting to this implementation. */ class FieldElement { public: class FieldElementImplementation *implementingObject; FieldElement(class FieldElementImplementation *implementingObject_); public: class FieldImplementation *getField()const; /* Returns a pointer to the FieldImplementation which does NOT get its refCount increased. The pointer should immediately be cast to a Field object, there by incresing the refCount. This allows code like this void test(FieldElement a){Field b=a.getField();...}. Would it also work for this (a+a).getField(); or could the ref count get 0 before it is increased? */ /* * The following two are only supported for rationals. */ mpq_t const *getGmpRationalTemporaryPointer()const; double floatingPointApproximation()const; bool isInteger()const; void setImplementingObject(FieldElementImplementation *implementingObject_){implementingObject=implementingObject_;assert(0);} FieldElement one() const; bool isZero()const; virtual bool isOne()const; friend FieldElement operator+(const FieldElement &a,const FieldElement &b); friend FieldElement operator-(const FieldElement &a,const FieldElement &b); friend FieldElement operator-(const FieldElement &b); FieldElement inverse()const; int sign()const; // Only allowed for ordered field. Asserts otherwise. int pAdicValuation(int p)const; // Only allowed for the field Q. FieldElement pAdicRemainder(class Field const &ZModPZ)const; // Only allowed for the field Q. int integerRepresentative()const; // Only allowed for Z/pZ std::string toString(bool writeIfOne=true, bool alwaysWriteSign=false ,bool latexMode=false) const; void operator*=(const FieldElement &a); void operator+=(const FieldElement &a); /** Adds a*b to the value of the object. */ void madd(const FieldElement &a, const FieldElement &b); friend FieldElement operator*(const FieldElement &a,const FieldElement &b); // Constructors: FieldElement(class Field const &f);//Initializes to zero FieldElement() // This constructor causes a lot of trouble { // Having a legal FieldElement without an implementing object implementingObject=0; // we must check for each assignment (copy constructor/assignment operator) } // if the pointer is zero. - And some operation will be illegal on // on this element ( one(),..... ) FieldElement(const FieldElement &a); FieldElement& operator=(const FieldElement& a); virtual ~FieldElement(); }; /** The Field class describes an object which has as its value a field (in the algebraic sense). The value/object can be copied around as a value. The Field object serves as a smart pointer with reference counting to a FieldImplementation which is hidden for the user of the Field class. In C++ it makes no sense to derive classes from this class because the object must be passable by value. */ class Field { friend class FieldElement; // protected: public: class FieldImplementation *implementingObject; public: FieldElementImplementation *zHomomorphismImplementation(int n)const; /** @return The image of the integer n under the unique ring homomorphism from the integers Z to the Field taking 1 to the multiplicative neutral element. */ FieldElement zHomomorphism(int n)const; bool isRationals()const; const char *name(); std::string toString()const; Field(Field const &a);//copy constructor Field(FieldImplementation *implObj);//constructor Field& operator=(const Field& a);//assignment ~Field();//destructor }; class FieldElementImplementation { static int numberOfLivingFieldElementImplementations; class FieldImplementation &theFieldImplementation; /* Ideally FieldElement would contain a Field object. However, since methods of a Field should be able to return FieldElements this seems impossible because of the stupid one-pass convention of C++. Instead FieldElement contains a FieldImplementation pointer and FieldElement must thus do the reference counting for this pointer on its own ???*/ public: class FieldImplementation *getField()const; static int getNumberOfLivingFieldElementImplementations(){return numberOfLivingFieldElementImplementations;}; int refCount; FieldElementImplementation(FieldImplementation &a);//ref count = 1?? virtual ~FieldElementImplementation(); virtual FieldElementImplementation *one() const=0; virtual FieldElementImplementation *copy()const=0; virtual bool isZero()const=0; virtual FieldElementImplementation *sum(const FieldElementImplementation &b)const=0; virtual FieldElementImplementation *difference(const FieldElementImplementation &b)const=0; virtual FieldElementImplementation *negation()const=0; virtual FieldElementImplementation *inverse()const=0; virtual std::string toString(bool writeIfOne=true, bool alwaysWriteSign=false, bool latexMode=false) const=0; virtual void operator*=(const FieldElementImplementation &a)=0; virtual void operator+=(const FieldElementImplementation &a)=0; virtual void madd(const FieldElementImplementation &a,const FieldElementImplementation &b)=0; virtual int sign()const { assert(0); return 0; } virtual int pAdicValuation(int p)const { assert(0); return 0; } virtual FieldElement pAdicRemainder(Field const &ZModPZ)const { assert(0); return pAdicRemainder(ZModPZ); } virtual int integerRepresentative()const { assert(0); return 0; } virtual mpq_t const *getGmpRationalTemporaryPointer()const { fprintf(stderr,"*this object is not implemented using GMP\n"); assert(0); return 0; } virtual bool isInteger()const { assert(0); return false; } Field& operator=(const Field& a) { assert(0); }//assignment }; extern int FieldElementRationalsLiving; class FieldImplementation { public: int refCount; // static class Field *currentField; // ?? // static void checkInitialized(); // ?? protected: // class Field *next; // static class Field *list; static int numberOfLivingFieldImplementations; public: virtual FieldElementImplementation *zHomomorphismImplementation(int n)=0;/* Creates FieldElementImplementation object with refcount1 */ public: static int getNumberOfLivingFieldImplementations(){return numberOfLivingFieldImplementations;}; FieldImplementation():refCount(0) { numberOfLivingFieldImplementations++; } virtual ~FieldImplementation() { numberOfLivingFieldImplementations--; } virtual bool isRationals()const { return false; } // static Field *find(const char *name); // static void printList(FILE *f); virtual FieldElement zHomomorphism(int n)=0; virtual const char *name()=0; virtual std::string toString()const=0; // static void setField(Field *f); // Do we really want these // static FieldElement staticZHomomorphism(int n); // two procedures? }; #endif gfan-0.5+dfsg/field_rationalfunctions.cpp000066400000000000000000000267231207563005400206350ustar00rootroot00000000000000#include "field_rationalfunctions.h" #include #include #include /* Always include cstdio before gmp.h.*/ #include #include #include #include "termorder.h" #include "division.h" #include "buchberger.h" #include "printer.h" #include "log.h" int FieldElementRationalFunctionsLiving; class FieldElementRationalFunction : public FieldElementImplementation { public: Polynomial p,q; FieldElementRationalFunction(FieldImplementation &a): FieldElementImplementation(a), p(((FieldRationalFunctionsImplementation*)&a)->getPolynomialRing()), q(Term(((FieldRationalFunctionsImplementation*)&a)->getPolynomialRing().getField().zHomomorphism(1),Monomial(((FieldRationalFunctionsImplementation*)&a)->getPolynomialRing(),IntegerVector(1)))) { FieldElementRationalFunctionsLiving++; } FieldElementRationalFunction(FieldImplementation &a,int n_): FieldElementImplementation(a), p(Term(((FieldRationalFunctionsImplementation*)&a)->getPolynomialRing().getField().zHomomorphism(n_),Monomial(((FieldRationalFunctionsImplementation*)&a)->getPolynomialRing(),IntegerVector(1)))), q(Term(((FieldRationalFunctionsImplementation*)&a)->getPolynomialRing().getField().zHomomorphism(1),Monomial(((FieldRationalFunctionsImplementation*)&a)->getPolynomialRing(),IntegerVector(1)))) { if(n_==0)p=Polynomial(((FieldRationalFunctionsImplementation*)&a)->getPolynomialRing()); /* fprintf(stderr,"constructing\n"); AsciiPrinter(Stderr).printPolynomial(p); AsciiPrinter(Stderr).printPolynomial(q); fprintf(stderr,"\n");*/ FieldElementRationalFunctionsLiving++; } void normalize() { PolynomialSet g(p.getRing()); g.push_back(p); g.push_back(q); LexicographicTermOrder T; buchberger(&g,T); minimize(&g); assert(g.size()==1); Polynomial r=g.front(); PolynomialSet Q(p.getRing()); PolynomialSet P(p.getRing()); division(p,g,T,&P); division(q,g,T,&Q); p=*P.begin(); q=*Q.begin(); assert(!q.isZero()); // FieldElement a=q.terms.begin()->second; // TermMap temp=q.terms.end(); FieldElement a=q.terms.rbegin()->second; p*=a; q*=a.inverse(); // assert(0);//make q's leading coefficient 1 } FieldElementRationalFunction(FieldImplementation &a, Polynomial const &p_, Polynomial const &q_): FieldElementImplementation(a), p(p_), q(q_) { FieldElementRationalFunctionsLiving++; } /* FieldElementRationalFunction(FieldImplementation &a, mpq_t *n_):FieldElementImplementation(a) { FieldElementRationalsLiving++; mpq_init(value); mpq_set(value,*n_); }*/ virtual ~FieldElementRationalFunction() { FieldElementRationalsLiving--; // mpq_clear(value); } FieldElementRationalFunction& operator=(const FieldElementRationalFunction& a) { assert(0); /* const FieldElementRational *A=(const FieldElementRational*)&a; if (this != A) { mpq_clear(value); mpz_init_set(mpq_numref(value), mpq_numref(a.value)); mpz_init_set(mpq_denref(value), mpq_denref(a.value)); } */ return *this; } void operator*=(const FieldElementImplementation &a) { const FieldElementRationalFunction *A=(const FieldElementRationalFunction*)&a; assert(A); // TimerScope ts(&rationalTimer); p*=A->p; q*=A->q; normalize(); // mpq_mul(value,value,A->value); } void operator+=(const FieldElementImplementation &a) { const FieldElementRationalFunction *A=(const FieldElementRationalFunction*)&a; assert(A); p=p*A->q+A->p*q; q=A->q*q; normalize(); } void madd(const FieldElementImplementation &a,const FieldElementImplementation &b) { const FieldElementRationalFunction *A=(const FieldElementRationalFunction*)&a; const FieldElementRationalFunction *B=(const FieldElementRationalFunction*)&b; assert(A); assert(B); p=p*(A->q*B->q)+(A->p*B->p)*q; q=A->q*B->q*q; normalize(); } FieldElementRationalFunction *one() const; bool isZero() const { return p.isZero(); } FieldElementRationalFunction *sum(const FieldElementImplementation &b)const { const FieldElementRationalFunction *B=(const FieldElementRationalFunction*)&b; FieldElementRationalFunction *r= new FieldElementRationalFunction(*getField(),p*B->q+B->p*q,B->q*q); return r; } FieldElementRationalFunction *difference(const FieldElementImplementation &b)const { const FieldElementRationalFunction *B=(const FieldElementRationalFunction*)&b; FieldElementRationalFunction *r= new FieldElementRationalFunction(*getField(),p*B->q-B->p*q,B->q*q); return r; } FieldElementRationalFunction *negation()const { FieldElementRationalFunction *r= new FieldElementRationalFunction(*getField(),p-p-p,q); return r; } FieldElementImplementation *inverse()const { if(isZero()) { AsciiPrinter P(Stderr); P.printString("Error inverting FieldElement: "); // P.printFieldElement(*this); P.printString("\n"); assert(0); } FieldElementRationalFunction *r= new FieldElementRationalFunction(*getField(),q,p); return r; } int sign()const { if(isZero())return 0; return p.terms.rbegin()->second.sign(); } static string LaTeXTranslator(const string &s) { int startIndex=0; string sign; if(s[0]=='-') { sign=string("-"); startIndex=1; } int slashIndex=-1; for(int i=startIndex;iisZero(); //fprintf(Stderr,"DELETE\n"); delete temp; temp=sum(*tempOne); bool isMinusOne=temp->isZero(); //fprintf(Stderr,"DELETE\n"); delete temp; //fprintf(Stderr,"DELETE\n"); delete tempOne; if(!writeIfOne && isOne) { if(alwaysWriteSign)return std::string("+"); return std::string(""); } if(!writeIfOne && isMinusOne) return std::string("-"); static char s[1290*1000]; // mpq_get_str(s,10,value); //// CHECK BUFFER SIZE!!!! // Changed to make code gmp 3.1.1 compatible mpz_get_str(s,10,mpq_numref(value)); //CHECK BUFFER SIZE!!!! string S(s); if(mpz_cmp_ui(mpq_denref(value),1)!=0) { mpz_get_str(s,10,mpq_denref(value)); //CHECK BUFFER SIZE!!!! S=S+string("/")+string(s); } if(latexMode)S=LaTeXTranslator(S); if(alwaysWriteSign && mpq_sgn(value)!=-1) return std::string("+")+S; return S; */ return s.str(); } FieldElementRationalFunction *copy()const { FieldElementRationalFunction *r= new FieldElementRationalFunction(*getField()); // fprintf(Stderr,"NEW\n"); /* mpq_clear(r->value); mpz_init_set(mpq_numref(r->value), mpq_numref(value)); mpz_init_set(mpq_denref(r->value), mpq_denref(value)); */ r->p=p; r->q=q; return r; } }; PolynomialRing FieldRationalFunctionsImplementation::getPolynomialRing()const { return thePolynomialRing; } bool FieldRationalFunctionsImplementation::isRationals()const { return false; } FieldRationalFunctionsImplementation::FieldRationalFunctionsImplementation(Field const &f_, string const ¶meterName_): coefficientField(f_), parameterName(parameterName_), thePolynomialRing(f_,1) { vector l; l.push_back(parameterName_); thePolynomialRing= PolynomialRing(f_,l); } std::string FieldRationalFunctionsImplementation::toString()const { stringstream s; s<< coefficientField.toString() << "(" << parameterName << ")"; return s.str(); } FieldElementImplementation *FieldRationalFunctionsImplementation::zHomomorphismImplementation(int n) { /* if(n==0) { static FieldElementImplementation *p; if(p==0)p=new FieldElementRational(*this,0); p->refCount++; return p; } else if(n==1) { static FieldElementImplementation *p; if(p==0)p=new FieldElementRational(*this,1); p->refCount++; return p; } else if(n==-1) { static FieldElementImplementation *p; if(p==0)p=new FieldElementRational(*this,-1); p->refCount++; return p; } */ FieldElementImplementation *ret=new FieldElementRationalFunction(*this,n); // fprintf(Stderr,"NEW\n"); // ret->refCount++; return ret; } FieldElement FieldRationalFunctionsImplementation::zHomomorphism(int n) { // fprintf(Stderr,"NEW\n"); // return FieldElement(new FieldElementRational(*this,n)); return FieldElement(zHomomorphismImplementation(n)); } const char *FieldRationalFunctionsImplementation::name() { return "Rational functions"; } FieldElementRationalFunction *FieldElementRationalFunction::one() const { // fprintf(Stderr,"NEW\n"); return new FieldElementRationalFunction(*getField(),1); } FieldRationalFunctions::FieldRationalFunctions(Field const &coefficientField, string const ¶meterName): Field(new FieldRationalFunctionsImplementation(coefficientField,parameterName)) { } FieldElement FieldRationalFunctions::exponent(int power) { FieldRationalFunctionsImplementation *imp=dynamic_cast(implementingObject); IntegerVector v(1); v[0]=power; Polynomial p=Term(imp->getPolynomialRing().getField().zHomomorphism(1),Monomial(imp->getPolynomialRing(),v)); Polynomial q=Term(imp->getPolynomialRing().getField().zHomomorphism(1),Monomial(imp->getPolynomialRing(),IntegerVector(1))); return new FieldElementRationalFunction(*imp, p, q); } FieldElement FieldRationalFunctions::fromCoefficientField(FieldElement const &c) { FieldRationalFunctionsImplementation *imp=dynamic_cast(implementingObject); IntegerVector v(1); Polynomial p=Term(c,Monomial(imp->getPolynomialRing(),v)); Polynomial q=Term(imp->getPolynomialRing().getField().zHomomorphism(1),Monomial(imp->getPolynomialRing(),IntegerVector(1))); return new FieldElementRationalFunction(*imp, p, q); } FieldElement FieldRationalFunctions::substitute(FieldElement const &e, FieldElement const &tvalue)const { FieldElementRationalFunction *eimp=dynamic_cast(e.implementingObject); FieldElement p=eimp->p.evaluate(tvalue); FieldElement q=eimp->q.evaluate(tvalue); assert(!q.isZero()); return p*q.inverse(); } #include "field_rationals.h" #include void testRationalFunctionField() { FieldRationalFunctions F(Q,string("t")); AsciiPrinter(Stderr).printField(F); FieldElement a=F.zHomomorphism(2); FieldElement b=F.exponent(3); a=b*a; AsciiPrinter(Stderr).printPolynomial(((dynamic_cast((a.implementingObject)))->p)); /* // cerr<< ((FieldElementRationalFunction*)&(a.implementingObject))-> p.toString(false); cerr<< (dynamic_cast(a.implementingObject))-> p.toString(false); */ cerr<toString(); } gfan-0.5+dfsg/field_rationalfunctions.h000066400000000000000000000025231207563005400202720ustar00rootroot00000000000000#ifndef FIELD_RATIONALFUNCTIONS_H_INCLUDED #define FIELD_RATIONALFUNCTIONS_H_INCLUDED #include "field.h" #include #include "polynomial.h" using namespace std; class FieldRationalFunctionsImplementation : public FieldImplementation { Field coefficientField; string parameterName; PolynomialRing thePolynomialRing; FieldElementImplementation *zHomomorphismImplementation(int n);/* Creates FieldElementImplementation object with refcount1 */ FieldElement zHomomorphism(int n); const char *name(); std::string toString()const; public: virtual bool isRationals()const; FieldRationalFunctionsImplementation(Field const &f_, string const ¶meterName_); PolynomialRing getPolynomialRing()const; }; // Let's see how inheritance and slicing work together class FieldRationalFunctions : public Field { public: FieldRationalFunctions(Field const &coefficientField, string const ¶meterName); FieldElement exponent(int power); FieldElement fromCoefficientField(FieldElement const &c); /** This function gives a value in the coefficient field by substituting the perturbation variable by tvalue. In case the denominator becomes zero during this process the routine asserts. */ FieldElement substitute(FieldElement const &e, FieldElement const &tvalue)const; }; void testRationalFunctionField();//test routine #endif gfan-0.5+dfsg/field_rationalfunctions2.cpp000066400000000000000000000221251207563005400207070ustar00rootroot00000000000000#include "field_rationalfunctions2.h" #include #include #include #include #include #include "termorder.h" #include "division.h" #include "buchberger.h" #include "saturation.h" #include "printer.h" #include "log.h" int FieldElementRationalFunctions2Living; class FieldElementRationalFunction2 : public FieldElementImplementation { public: Polynomial p,q; FieldElementRationalFunction2(FieldImplementation &a): FieldElementImplementation(a), p(((FieldRationalFunctions2Implementation*)&a)->getPolynomialRing()), q(Term(((FieldRationalFunctions2Implementation*)&a)->getPolynomialRing().getField().zHomomorphism(1),Monomial(((FieldRationalFunctions2Implementation*)&a)->getPolynomialRing()))) { FieldElementRationalFunctions2Living++; } FieldElementRationalFunction2(FieldImplementation &a,int n_): FieldElementImplementation(a), p(Term(((FieldRationalFunctions2Implementation*)&a)->getPolynomialRing().getField().zHomomorphism(n_),Monomial(((FieldRationalFunctions2Implementation*)&a)->getPolynomialRing()))), q(Term(((FieldRationalFunctions2Implementation*)&a)->getPolynomialRing().getField().zHomomorphism(1),Monomial(((FieldRationalFunctions2Implementation*)&a)->getPolynomialRing()))) { if(n_==0)p=Polynomial(((FieldRationalFunctions2Implementation*)&a)->getPolynomialRing()); FieldElementRationalFunctions2Living++; } void normalize() { /* PolynomialSet g(p.getRing()); g.push_back(p); g.push_back(q); // LexicographicTermOrder T; LexicographicTermOrder T; buchberger(&g,T); minimize(&g); // assert(g.size()==1); if(g.size()==1) { Polynomial r=g.front(); PolynomialSet Q(p.getRing()); PolynomialSet P(p.getRing()); division(p,g,T,&P); division(q,g,T,&Q); p=*P.begin(); q=*Q.begin(); assert(!q.isZero()); FieldElement a=q.terms.rbegin()->second; p*=a; q*=a.inverse(); }*/ } FieldElementRationalFunction2(FieldImplementation &a, Polynomial const &p_, Polynomial const &q_): FieldElementImplementation(a), p(p_), q(q_) { FieldElementRationalFunctions2Living++; } virtual ~FieldElementRationalFunction2() { FieldElementRationalFunctions2Living--; } FieldElementRationalFunction2& operator=(const FieldElementRationalFunction2& a) { assert(0); return *this; } void operator*=(const FieldElementImplementation &a) { const FieldElementRationalFunction2 *A=(const FieldElementRationalFunction2*)&a; assert(A); p*=A->p; q*=A->q; normalize(); } void operator+=(const FieldElementImplementation &a) { const FieldElementRationalFunction2 *A=(const FieldElementRationalFunction2*)&a; assert(A); p=p*A->q+A->p*q; q=A->q*q; normalize(); } void madd(const FieldElementImplementation &a,const FieldElementImplementation &b) { const FieldElementRationalFunction2 *A=(const FieldElementRationalFunction2*)&a; const FieldElementRationalFunction2 *B=(const FieldElementRationalFunction2*)&b; assert(A); assert(B); p=p*(A->q*B->q)+(A->p*B->p)*q; q=A->q*B->q*q; normalize(); } FieldElementRationalFunction2 *one() const; bool isZero() const { return p.isZero(); } FieldElementRationalFunction2 *sum(const FieldElementImplementation &b)const { const FieldElementRationalFunction2 *B=(const FieldElementRationalFunction2*)&b; FieldElementRationalFunction2 *r= new FieldElementRationalFunction2(*getField(),p*B->q+B->p*q,B->q*q); return r; } FieldElementRationalFunction2 *difference(const FieldElementImplementation &b)const { const FieldElementRationalFunction2 *B=(const FieldElementRationalFunction2*)&b; FieldElementRationalFunction2 *r= new FieldElementRationalFunction2(*getField(),p*B->q-B->p*q,B->q*q); return r; } FieldElementRationalFunction2 *negation()const { FieldElementRationalFunction2 *r= new FieldElementRationalFunction2(*getField(),p-p-p,q); return r; } FieldElementImplementation *inverse()const { if(isZero()) { AsciiPrinter P(Stderr); P.printString("Error inverting FieldElement: "); // P.printFieldElement(*this); P.printString("\n"); assert(0); } FieldElementRationalFunction2 *r= new FieldElementRationalFunction2(*getField(),q,p); return r; } int sign()const { assert(0);//not an ordered field (yet) if(isZero())return 0; return p.terms.rbegin()->second.sign(); } static string LaTeXTranslator(const string &s) { assert(0);//not supported yet /* int startIndex=0; string sign; if(s[0]=='-') { sign=string("-"); startIndex=1; } int slashIndex=-1; for(int i=startIndex;ip=p; r->q=q; return r; } }; PolynomialRing FieldRationalFunctions2Implementation::getPolynomialRing()const { return thePolynomialRing; } bool FieldRationalFunctions2Implementation::isRationals()const { return false; } FieldRationalFunctions2Implementation::FieldRationalFunctions2Implementation(PolynomialRing const &r): thePolynomialRing(r) { } std::string FieldRationalFunctions2Implementation::toString()const { stringstream s; s<< thePolynomialRing.getField().toString() << "("<(implementingObject); Polynomial q=Term(imp->getPolynomialRing().getField().zHomomorphism(1),Monomial(imp->getPolynomialRing())); return new FieldElementRationalFunction2(*imp, p, q); } /***************************************************** * Conversion functions *****************************************************/ PolynomialRing makeVariablesParameters(PolynomialRing const &r, int numberOfParameters) { assert(numberOfParameters>=0); assert(numberOfParameters<=r.getNumberOfVariables()); vector names(numberOfParameters); for(int i=0;i names2(r.getNumberOfVariables()-numberOfParameters); for(int i=0;i(genericRing.getField().implementingObject); FieldRationalFunctions2 &DANGER=(FieldRationalFunctions2&)genericRing.getField(); PolynomialRing coefRing=coefficientField->getPolynomialRing(); for(TermMap::const_iterator i=p.terms.begin();i!=p.terms.end();i++) { FieldElement c=i->second; IntegerVector v=i->first.exponent; IntegerVector coefficientExponent=v.subvector(0,p.getRing().getNumberOfVariables()-genericRing.getNumberOfVariables()); IntegerVector monomialExponent=v.subvector(p.getRing().getNumberOfVariables()-genericRing.getNumberOfVariables(),v.size()); FieldElement c2=DANGER.polynomialToFraction(Term( c,Monomial(coefRing, coefficientExponent)));//does the numerator not belong to a field? ret+=Polynomial(Term(c2,Monomial(genericRing,monomialExponent))); } return ret; } PolynomialSet makeVariablesParameters(PolynomialRing const &genericRing, PolynomialSet const &p) { PolynomialSet ret(genericRing); for(PolynomialSet::const_iterator i=p.begin();i!=p.end();i++) ret.push_back(makeVariablesParameters(genericRing,*i)); return ret; } gfan-0.5+dfsg/field_rationalfunctions2.h000066400000000000000000000023701207563005400203540ustar00rootroot00000000000000#ifndef FIELD_RATIONALFUNCTIONS2_INCLUDED #define FIELD_RATIONALFUNCTIONS2_INCLUDED #include "field.h" #include #include "polynomial.h" using namespace std; class FieldRationalFunctions2Implementation : public FieldImplementation { PolynomialRing thePolynomialRing; FieldElementImplementation *zHomomorphismImplementation(int n);/* Creates FieldElementImplementation object with refcount1 */ FieldElement zHomomorphism(int n); const char *name(); std::string toString()const; public: virtual bool isRationals()const; PolynomialRing getPolynomialRing()const; FieldRationalFunctions2Implementation(PolynomialRing const &r); // PolynomialRing getPolynomialRing()const; }; // Let's see how inheritance and slicing works together class FieldRationalFunctions2 : public Field { public: FieldRationalFunctions2(PolynomialRing const &r); FieldElement polynomialToFraction(Polynomial const &p); }; /** * Creates a polynomial ring where * After having */ PolynomialRing makeVariablesParameters(PolynomialRing const &r, int numberOfParameters); Polynomial makeVariablesParameters(PolynomialRing const &genericRing, Polynomial const &p); PolynomialSet makeVariablesParameters(PolynomialRing const &genericRing, PolynomialSet const &p); #endif gfan-0.5+dfsg/field_rationals.cpp000066400000000000000000000335101207563005400170570ustar00rootroot00000000000000#include "field_rationals.h" #include #include #include /* Always include cstdio before gmp.h.*/ #include #include #include "lp_cdd.h" #include "printer.h" #include "timer.h" #include "log.h" #include "field_zmodpz.h" //static Timer rationalTimer("Rational",1); int FieldElementRationalsLiving; class FieldElementRational : public FieldElementImplementation { public: mpq_t value; FieldElementRational(FieldImplementation &a):FieldElementImplementation(a) { FieldElementRationalsLiving++; mpq_init(value); } FieldElementRational(FieldImplementation &a,int n_):FieldElementImplementation(a) { FieldElementRationalsLiving++; mpz_init_set_si(mpq_numref(value), n_); mpz_init_set_ui(mpq_denref(value), 1); } FieldElementRational(FieldImplementation &a, mpq_t *n_):FieldElementImplementation(a) { FieldElementRationalsLiving++; mpq_init(value); mpq_set(value,*n_); } virtual ~FieldElementRational() { FieldElementRationalsLiving--; mpq_clear(value); } FieldElementRational& operator=(const FieldElementRational& a) { assert(0); const FieldElementRational *A=(const FieldElementRational*)&a; if (this != A) { mpq_clear(value); mpz_init_set(mpq_numref(value), mpq_numref(a.value)); mpz_init_set(mpq_denref(value), mpq_denref(a.value)); } return *this; } mpq_t const *getGmpRationalTemporaryPointer()const { return &value; } bool isInteger()const { return mpz_cmp_si(mpq_denref(value),1)==0; } void operator*=(const FieldElementImplementation &a) { const FieldElementRational *A=(const FieldElementRational*)&a; assert(A); // TimerScope ts(&rationalTimer); mpq_mul(value,value,A->value); } void operator+=(const FieldElementImplementation &a) { const FieldElementRational *A=(const FieldElementRational*)&a; assert(A); // TimerScope ts(&rationalTimer); mpq_add(value,value,A->value); } void madd(const FieldElementImplementation &a,const FieldElementImplementation &b) { const FieldElementRational *A=(const FieldElementRational*)&a; assert(A); const FieldElementRational *B=(const FieldElementRational*)&b; assert(B); // TimerScope ts(&rationalTimer); mpq_t temp; mpq_init(temp); mpq_mul(temp,A->value,B->value); mpq_add(value,value,temp); mpq_clear(temp); } FieldElementRational *one() const; bool isZero() const { return mpq_sgn(value)==0; } FieldElementRational *sum(const FieldElementImplementation &b)const { // TimerScope ts(&rationalTimer); const FieldElementRational *B=(const FieldElementRational*)&b; FieldElementRational *r= new FieldElementRational(*getField()); // fprintf(Stderr,"NEW\n"); mpq_add(r->value,value,B->value); return r; } FieldElementRational *difference(const FieldElementImplementation &b)const { // TimerScope ts(&rationalTimer); const FieldElementRational *B=(const FieldElementRational*)&b; FieldElementRational *r= new FieldElementRational(*getField()); // fprintf(Stderr,"NEW\n"); mpq_sub(r->value,value,B->value); return r; } FieldElementRational *negation()const { FieldElementRational *r= new FieldElementRational(*getField()); // fprintf(Stderr,"NEW\n"); mpq_neg(r->value,value); return r; } FieldElementImplementation *inverse()const { FieldElementRational *r= new FieldElementRational(*getField()); // fprintf(Stderr,"NEW\n"); if(isZero()) { AsciiPrinter P(Stderr); P.printString("Error inverting FieldElement: "); // P.printFieldElement(*this); P.printString("\n"); assert(0); } mpq_inv(r->value,value); return r; } int sign()const { return mpq_sgn(value); } static int val(mpz_t m, int p) { int ret=0; if(p==2) { int p2Val=mpz_scan1(m,0); // assert(0); // assert(p2Val==ret); return p2Val; } while(mpz_divisible_ui_p(m,p)) { mpz_divexact_ui(m,m,p); ret++; } return ret; } int pAdicValuation(int p)const { mpq_t temp; mpq_init(temp); mpq_set(temp,value); int ret=val(mpq_numref(temp),p)-val(mpq_denref(temp),p); mpq_clear(temp); return ret; } FieldElement pAdicRemainder(Field const &ZModPZ)const { int p=(dynamic_cast(ZModPZ.implementingObject))->getP(); mpz_t temp; mpz_init(temp); mpz_set(temp,mpq_numref(value)); int v=pAdicValuation(p); while(v>0){mpz_divexact_ui(temp,temp,p);v--;} FieldElement A=ZModPZ.zHomomorphism(mpz_fdiv_ui(temp,p)); mpz_set(temp,mpq_denref(value)); while(v<0){mpz_divexact_ui(temp,temp,p);v++;} FieldElement B=ZModPZ.zHomomorphism(mpz_fdiv_ui(temp,p)); mpz_clear(temp); // FieldElement A=ZModPZ.zHomomorphism(mpz_fdiv_ui(mpq_numref(value),p)); // FieldElement B=ZModPZ.zHomomorphism(mpz_fdiv_ui(mpq_denref(value),p)); assert(!B.isZero()); return A*(B.inverse()); } static string LaTeXTranslator(const string &s) { int startIndex=0; string sign; if(s[0]=='-') { sign=string("-"); startIndex=1; } int slashIndex=-1; for(int i=startIndex;iisZero(); //fprintf(Stderr,"DELETE\n"); delete temp; temp=sum(*tempOne); bool isMinusOne=temp->isZero(); //fprintf(Stderr,"DELETE\n"); delete temp; //fprintf(Stderr,"DELETE\n"); delete tempOne; if(!writeIfOne && isOne) { if(alwaysWriteSign)return std::string("+"); return std::string(""); } if(!writeIfOne && isMinusOne) return std::string("-"); static char s[1290*1000]; // mpq_get_str(s,10,value); //// CHECK BUFFER SIZE!!!! // Changed to make code gmp 3.1.1 compatible mpz_get_str(s,10,mpq_numref(value)); //CHECK BUFFER SIZE!!!! string S(s); if(mpz_cmp_ui(mpq_denref(value),1)!=0) { mpz_get_str(s,10,mpq_denref(value)); //CHECK BUFFER SIZE!!!! S=S+string("/")+string(s); } if(latexMode)S=LaTeXTranslator(S); if(alwaysWriteSign && mpq_sgn(value)!=-1) return std::string("+")+S; return S; } FieldElementRational *copy()const { FieldElementRational *r= new FieldElementRational(*getField()); // fprintf(Stderr,"NEW\n"); mpq_clear(r->value); mpz_init_set(mpq_numref(r->value), mpq_numref(value)); mpz_init_set(mpq_denref(r->value), mpq_denref(value)); return r; } }; bool FieldRationalsImplementation::isRationals()const { return true; } FieldRationalsImplementation::FieldRationalsImplementation() { } std::string FieldRationalsImplementation::toString()const { return std::string("Q"); } FieldElementImplementation *FieldRationalsImplementation::zHomomorphismImplementation(int n) { if(n==0) { static FieldElementImplementation *p; if(p==0)p=new FieldElementRational(*this,0); p->refCount++; return p; } else if(n==1) { static FieldElementImplementation *p; if(p==0)p=new FieldElementRational(*this,1); p->refCount++; return p; } else if(n==-1) { static FieldElementImplementation *p; if(p==0)p=new FieldElementRational(*this,-1); p->refCount++; return p; } FieldElementImplementation *ret=new FieldElementRational(*this,n); // fprintf(Stderr,"NEW\n"); // ret->refCount++; return ret; } FieldElement FieldRationalsImplementation::zHomomorphism(int n) { // fprintf(Stderr,"NEW\n"); // return FieldElement(new FieldElementRational(*this,n)); return FieldElement(zHomomorphismImplementation(n)); } const char *FieldRationalsImplementation::name() { return "GmpRationals"; } /*FieldRationals::FieldRationals(): Field(new FieldRationalsImplementation()) { /* fprintf(Stderr,"Adding field rationals\n"); next=list; list=this; */ /* log2 fprintf(Stderr,"Initializing field Rationals\n"); } */ //FieldRationals Q; Field Q(new FieldRationalsImplementation()); FieldElementRational *FieldElementRational::one() const { // fprintf(Stderr,"NEW\n"); return new FieldElementRational(*getField(),1); } void printMpq(mpq_t value) { char s[1000]; char t[1000]; mpz_get_str(s,10,mpq_numref(value)); //CHECK BUFFER SIZE!!!! mpz_get_str(t,10,mpq_denref(value)); //CHECK BUFFER SIZE!!!! fprintf(stderr,"%s/%s ",s,t); } IntegerVector primitiveVectorOld(vector const &v) { int n=v.size(); mpq_t *point = new mpq_t [n]; for(int i=0;i const &v) { int n=v.size(); IntegerVector ret(n); mpz_t lcm; mpz_t gcd; mpz_init_set_ui(lcm, 1); mpz_init_set_ui(gcd, 0); for(int j=0;j(i); assert(i2); return &(i2->value); } double fieldElementToFloatingPoint(FieldElement const&c) { return mpq_get_d(*fieldElementToGmp(c)); } FieldElement fieldElementFromGmp(mpq_t *c) { FieldElement ret=FieldElement(new FieldElementRational(*(Q.implementingObject),c)); return ret; } FieldElement gcd(FieldElement const &a, FieldElement const &b, FieldElement &s, FieldElement &t) { mpz_t G; mpz_t S; mpz_t T; mpz_init(G); mpz_init(S); mpz_init(T); mpz_gcdext(G, S, T, mpq_numref(*fieldElementToGmp(a)), mpq_numref(*fieldElementToGmp(b))); mpq_t Grat; mpq_init(Grat); mpq_set_z(Grat, G); mpq_t Srat; mpq_init(Srat); mpq_set_z(Srat, S); mpq_t Trat; mpq_init(Trat); mpq_set_z(Trat, T); FieldElement ret=fieldElementFromGmp(&Grat); s=fieldElementFromGmp(&Srat); t=fieldElementFromGmp(&Trat); mpq_clear(Trat); mpq_clear(Srat); mpq_clear(Grat); mpz_clear(T); mpz_clear(S); mpz_clear(G); return ret; } IntegerVector toIntegerVector(vector const &v) { int n=v.size(); mpq_t *point = new mpq_t [n]; for(int i=0;i #include /* Always include cstdio before gmp.h.*/ #include //remove? #include "vektor.h" #include "field.h" class FieldRationalsImplementation : public FieldImplementation { FieldElementImplementation *zHomomorphismImplementation(int n);/* Creates FieldElementImplementation object with refcount1 */ FieldElement zHomomorphism(int n); const char *name(); std::string toString()const; public: virtual bool isRationals()const; FieldRationalsImplementation(); }; /* class FieldRationals : public Field { public: FieldRationals(); }; */ //extern FieldRationals Q; extern Field Q; IntegerVector primitiveVector(vector const &v); IntegerVector toIntegerVector(vector const &v);// MUST HAVE INTEGER ENTRIES int toInteger(FieldElement const &a);// MUST BE INTEGER mpq_t *fieldElementToGmp(FieldElement const &c); double fieldElementToFloatingPoint(FieldElement const&c); /** * Will create a new FieldElement containing the value of c. The gmp representation of c is copied, * so c must be destructed by the caller. */ FieldElement fieldElementFromGmp(mpq_t *c); /** * Will create a new FieldElement containing the value of c. The gmp representation of c is copied, * so c must be destructed by the caller. */ FieldElement fieldElementFromGmpZ(const mpz_t *c); FieldElement gcd(FieldElement const &a, FieldElement const &b, FieldElement &s, FieldElement &t); /** * Assumes that a and b are integers in the field of rational numbers. * Assumes that b is non-zero. * The remainder (if pointer is non-zero) is set to the remainder * of a divided by b in the interval [0,B[, where B=abs(b)=max(b,-b). * The return value equals the integer (a-remainder)/b. */ FieldElement integerDivision(FieldElement const &a, FieldElement const &b, FieldElement *remainder=0); #endif gfan-0.5+dfsg/field_zmodpz.cpp000066400000000000000000000140431207563005400164060ustar00rootroot00000000000000#include "field.h" #include "field_zmodpz.h" #include #include #include "printer.h" static int modP(int a, int p) { return ((a%p)+p)%p; } static void swap(int &a,int &b) { int temp=a; a=b; b=temp; } static int gcd(int a, int b, int &r, int &s) { int A=a; int B=b; assert(a>0); assert(b>0); int aA=1; int aB=0; int bA=0; int bB=1; while(0!=b) { // fprintf(Stderr,"a:%i b:%i aA:%i aB:%i bA:%i bB:%i\n",a,b,aA,aB,bA,bB); assert(a==aA*A+aB*B); assert(b==bA*A+bB*B); if(a>b) { swap(a,b); swap(aA,bA); swap(aB,bB); } int n=b/a; assert(n!=0); b-=n*a; bA-=n*aA; bB-=n*aB; } // fprintf(Stderr,"a:%i b:%i aA:%i aB:%i bA:%i bB:%i\n",a,b,aA,aB,bA,bB); assert(a==aA*A+aB*B); assert(b==bA*A+bB*B); r=aA; s=aB; return a; } const char *FieldZModPZImplementation::name() { static char s[20]; sprintf(s,"Zmod%iZ",p); return s; // return "Zmod2Z"; } static bool isPrime(int p) { for(int i=2;i*i<=p;i++) { if(p%i ==0)return false; } return true; } FieldZModPZImplementation::FieldZModPZImplementation(int p_): p(p_) { if(p>=32768 || p<2) { fprintf(Stderr,"Prime %i out of range!\n",p_); assert(0); } if(!isPrime(p_)) { fprintf(Stderr,"%i is not a prime.\n",p_); assert(0); } } FieldZModPZ::FieldZModPZ(int p_): Field(new FieldZModPZImplementation(p_)) { } int FieldZModPZ::getP() { return ((FieldZModPZImplementation*)(implementingObject))->getP(); } int FieldZModPZImplementation::getP()const { return p; } std::string FieldZModPZImplementation::toString()const { // return std::string("Z/")+string(p)+string("Z"); // return std::string("Z/")+string("Z"); static char s[20]; sprintf(s,"Z/%iZ",p); return std::string(s); } class FieldElementZModPZ : public FieldElementImplementation { int value; // class FieldZModPZImplementation &theFieldImplementation; public: FieldZModPZImplementation &getF()const { return *(FieldZModPZImplementation*)getField(); } FieldElementZModPZ(class FieldZModPZImplementation &theField_): FieldElementImplementation(theField_), value(0) { } FieldElementZModPZ(class FieldZModPZImplementation &theField_, int n_): FieldElementImplementation(theField_) { value=modP(n_,getF().getP()); } virtual ~FieldElementZModPZ() //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! { } FieldElementZModPZ& operator=(const FieldElementZModPZ& a) { assert(0); const FieldElementZModPZ *A=(const FieldElementZModPZ*)&a; if (this != A) { value=A->value; } return *this; } void operator*=(const FieldElementImplementation &a) { const FieldElementZModPZ *A=(const FieldElementZModPZ*)&a; assert(A); value=modP(value*A->value,getF().getP()); } void operator+=(const FieldElementImplementation &a) { const FieldElementZModPZ *A=(const FieldElementZModPZ*)&a; assert(A); value=modP(value+(A->value),getF().getP()); } void madd(const FieldElementImplementation &a,const FieldElementImplementation &b) { const FieldElementZModPZ *A=(const FieldElementZModPZ*)&a; const FieldElementZModPZ *B=(const FieldElementZModPZ*)&b; assert(A); assert(B); value=modP(value+modP(A->value*B->value,getF().getP()),getF().getP()); } FieldElementZModPZ *one()const { return new FieldElementZModPZ(getF(),1); } bool isZero() const { return value==0; } FieldElementZModPZ *sum(const FieldElementImplementation &b)const { const FieldElementZModPZ *B=(const FieldElementZModPZ*)&b; FieldElementZModPZ *r= new FieldElementZModPZ(getF()); r->value=modP(value+B->value,getF().getP()); return r; } FieldElementZModPZ *difference(const FieldElementImplementation &b)const { const FieldElementZModPZ *B=(const FieldElementZModPZ*)&b; FieldElementZModPZ *r= new FieldElementZModPZ(getF()); r->value=modP(value-B->value,getF().getP()); return r; } FieldElementZModPZ *negation()const { FieldElementZModPZ *r= new FieldElementZModPZ(getF()); r->value=modP(-value,getF().getP()); return r; } FieldElementZModPZ *inverse()const { FieldElementZModPZ *r= new FieldElementZModPZ(getF()); if(isZero()) { AsciiPrinter P_(Stderr); P_.printString("Error inverting FieldElement: "); // P.printFieldElement(*this); P_.printString("\n"); assert(0); } //r->value=value; // Very simple when P=2 int R,S; int d=gcd(value,getF().getP(),R,S); R=modP(R,getF().getP()); assert(d==1); r->value=R; if(!(modP(R*value,getF().getP())==1)) { fprintf(Stderr,"%i, %i\n",R,value); } assert(modP(R*value,getF().getP())==1); return r; } static string intToString(int v) { char s[20]; sprintf(s,"%i",v); return string(s); } std::string toString(bool writeIfOne=true, bool alwaysWriteSign=false, bool latexMode=false) const { bool isOne=(value==1); bool isMinusOne=false;//... isMinusOne=(value==getF().getP()-1) && (value!=1); if(!writeIfOne && isOne) { if(alwaysWriteSign)return std::string("+"); return std::string(""); } if(!writeIfOne && isMinusOne) return std::string("-"); if(alwaysWriteSign ) return std::string("+")+intToString(value); return intToString(value); } FieldElementZModPZ *copy()const { FieldElementZModPZ *r= new FieldElementZModPZ(getF()); r->value=value; return r; } int integerRepresentative()const { return value; } }; FieldElementImplementation *FieldZModPZImplementation::zHomomorphismImplementation(int n) { FieldElementImplementation *ret=new FieldElementZModPZ(*this,n); // ret->refCount++; //!!!!!!!!!!! return ret; } FieldElement FieldZModPZImplementation::zHomomorphism(int n) { return FieldElement(new FieldElementZModPZ(*this,n)); } //static FieldZModPZ theField(2); //static FieldZModPZ theField(32003); /*Field *theZMod2ZField() { return &theField; }*/ gfan-0.5+dfsg/field_zmodpz.h000066400000000000000000000007751207563005400160620ustar00rootroot00000000000000#ifndef FIELD_ZMODPZ_H_INCLUDED #define FIELD_ZMODPZ_H_INCLUDED #include "field.h" class FieldZModPZImplementation : public FieldImplementation { FieldElementImplementation *zHomomorphismImplementation(int n); FieldElement zHomomorphism(int n); std::string toString()const; const char *name(); const int p; public: FieldZModPZImplementation(int p_); int getP()const; }; class FieldZModPZ : public Field { public: FieldZModPZ(int p_); int getP(); }; Field *theZMod2ZField(); #endif gfan-0.5+dfsg/fieldlp.cpp000066400000000000000000000165101207563005400153400ustar00rootroot00000000000000#include "fieldlp.h" FieldVector FieldLP::subvector(FieldVector const &v, set const &b) { FieldVector ret(v.getField(),b.size()); int I=0; for(set::const_iterator i=b.begin();i!=b.end();i++,I++) ret[I]=v[*i]; return ret; } FieldMatrix FieldLP::submatrix(FieldMatrix const &m, set const &b) { FieldMatrix ret(m.getField(),b.size(),m.getWidth()); int I=0; for(set::const_iterator i=b.begin();i!=b.end();i++,I++) ret[I]=m[*i]; return ret; } FieldVector FieldLP::edgeDirection(int i)const { set basis2=basis; assert(basis2.count(i)); basis2.erase(i); FieldMatrix A2=submatrix(A,basis2); FieldMatrix ker=A2.reduceAndComputeKernel(); assert(ker.getHeight()==1); FieldVector e=ker[0]; if(dot(A[i],e).sign()<0)return e; return theField.zHomomorphism(-1)*e; } bool FieldLP::isImprovingDirection(int i)const { return dot(edgeDirection(i),w).sign()>0; } FieldElement FieldLP::improvement(int i, int &newBasisMember)const { FieldVector e=edgeDirection(i); FieldElement ew=dot(e,w); FieldElement ret(theField); bool first=true; newBasisMember=-1; for(int s=0;s=0;s--)//This is _the_ line where an anticycling rule is implemented { FieldElement denominator=dot(A[s],e); if(denominator.sign()>0) { FieldElement imp=(b[s]-dot(A[s],x))*denominator.inverse()*ew; if(first){ret=imp;newBasisMember=s;first=false;} if((imp-ret).sign()<=0){newBasisMember=s;ret=imp;} } } return ret; } int FieldLP::step() { FieldElement impBest(theField); int bestIndex=-1; int bestNewElement=-1; for(set::const_iterator i=basis.begin();i!=basis.end();i++) { // AsciiPrinter P(Stderr); // edgeDirection(*i).print(P); if(isImprovingDirection(*i)) { //fprintf(Stderr,"IMPROVING DIRECTION\n"); int newBasisElement; FieldElement imp=improvement(*i,newBasisElement); //P.printFieldElement(imp); //P.printNewLine(); if(newBasisElement==-1)return -1; //UNBOUNDED if((imp-impBest).sign()>=0)//needed for perturbation { impBest=imp; bestIndex=*i; bestNewElement=newBasisElement; } } } if(bestIndex==-1) return 0; //OPTIMAL set basis2=basis; //fprintf(Stderr,"REMOVING %i INSERTING %i\n",bestIndex,bestNewElement); basis2.erase(bestIndex); basis2.insert(bestNewElement); setCurrentBasis(basis2); return 1; } FieldLP::FieldLP(FieldMatrix const &A_, FieldVector const &b_): A(A_), b(b_), theField(A_.getField()), x(A_.getField(),0), w(A.getField(),A_.getWidth()) { // if(A.getHeight()!=b.size())fprintf(Stderr,"%i %i",A.getHeight(),b.size()); assert(A.getHeight()==b.size()); } void FieldLP::setObjectiveFunction(FieldVector const &w_) { w=w_; assert(A.getWidth()==w.size()); } FieldVector FieldLP::basisToPoint(set const &basis)const { AsciiPrinter P(Stdout); // FieldMatrix AT=A.transposed(); // AT.printMatrix(P); FieldMatrix A2(A.getField(),basis.size(),A.getWidth()); FieldVector b2(A.getField(),basis.size()); int I=0; for(set::const_iterator i=basis.begin();i!=basis.end();i++,I++) { A2[I]=A[*i]; b2[I]=b[*i]; } //A2.printMatrix(P); //b2.print(P); FieldMatrix s=A2.solver(); //fprintf(Stderr,"%i %i\n",s.getWidth(),b2.size()+A.getHeight()); //s.printMatrix(P); //concatenation(b2,FieldVector(b2.getField(),A.getWidth())).print(P); FieldVector r=s.canonicalize(concatenation(b2,FieldVector(b2.getField(),A.getWidth()))); //r.print(P); assert(r.subvector(0,basis.size()).isZero()); return r.subvector(basis.size(),r.size()); } void FieldLP::setCurrentBasis(set const &basis_) { basis=basis_; x=basisToPoint(basis); } void FieldLP::print(Printer &P)const { P.printString("LPprogram\n"); P.printString("A:\n"); A.printMatrix(P); P.printString("w:\n"); w.print(P); P.printString("b:\n"); b.print(P); P.printString("current basis:\n"); for(set::const_iterator i=basis.begin();i!=basis.end();i++)P.printInteger(*i); P.printString("x:\n"); x.print(P); } FieldMatrix FieldLP::computeLinealitySpace() { FieldMatrix temp=A; return temp.reduceAndComputeKernel(); } FieldLP FieldLP::buildLPForFeasibilityCheck() { assert(computeLinealitySpace().getHeight()==0); set S; { FieldMatrix temp=A.flipped().transposed();//important that inequalities which do not appear in basis set are temp.reduce(); int i=-1; int j=-1; while(temp.nextPivot(i,j)) { S.insert(A.getHeight()-1-j);//perturbed furthest //fprintf(Stderr,"INSERTING %i\n",A.getHeight()-1-j); } } FieldMatrix AS=submatrix(A,S); FieldMatrix ASSolver=AS.solver(); FieldVector xs2=ASSolver.canonicalize(concatenation(subvector(b,S),FieldVector(b.getField(),A.getWidth()))).subvector(S.size(),S.size()+A.getWidth()); set inequalitiesWithSlack; for(int i=0;i0) { inequalitiesWithSlack.insert(i); //fprintf(Stderr,"adding slack variable\n"); } } FieldMatrix newA=combineOnTop( combineLeftRight( A, FieldMatrix( theField, A.getHeight(), inequalitiesWithSlack.size() ) ), FieldMatrix( theField, inequalitiesWithSlack.size(), A.getWidth()+inequalitiesWithSlack.size() ) ); FieldVector newW(theField,inequalitiesWithSlack.size()+A.getWidth()); int I=0; for(set::const_iterator i=inequalitiesWithSlack.begin();i!=inequalitiesWithSlack.end();i++,I++) { newA[*i][I+A.getWidth()]=theField.zHomomorphism(-1); // int sign=dot(A[*i],xs2).sign(); newA[I+A.getHeight()][I+A.getWidth()]=theField.zHomomorphism(-1);//(sign>0)?-1:1); newW[I+A.getWidth()]=theField.zHomomorphism(-1);//(sign>0)?-1:1); } set newBasis; // for(int i=0;i::const_iterator i=S.begin();i!=S.end();i++)newBasis.insert(*i); for(set::const_iterator i=inequalitiesWithSlack.begin();i!=inequalitiesWithSlack.end();i++)newBasis.insert(*i); FieldLP ret(newA,concatenation(b,FieldVector(theField,inequalitiesWithSlack.size()))); ret.setObjectiveFunction(newW); ret.setCurrentBasis(newBasis); return ret; } bool FieldLP::findFeasibleBasis() { FieldLP A2=buildLPForFeasibilityCheck(); AsciiPrinter Q(Stdout); int status; do { //A2.print(Q); status=A2.step(); } while(status==1); fprintf(Stderr,status?"LP is unbounded.\n":"Optimal solution found.\n"); //A2.print(Q); set newBasis; for(set::const_iterator i=A2.basis.begin();i!=A2.basis.end();i++) { if(*i S; { FieldMatrix temp=A; temp.reduce(); int i=-1; int j=-1; while(temp.nextPivot(i,j))S.insert(j); } // FieldMatrix(theField,A.getHeight(),S.size()); FieldLP ret(submatrix(A.transposed(),S).transposed(),b); //fprintf(Stderr,"New height=%i New width=%i\n",ret.A.getHeight(),ret.A.getWidth()); // AsciiPrinter P(Stderr); //ret.print(P); if(w.size())ret.setObjectiveFunction(subvector(w,S)); return ret; } gfan-0.5+dfsg/fieldlp.h000066400000000000000000000031071207563005400150030ustar00rootroot00000000000000#ifndef FIELDLP_H_INCLUDED #define FIELDLP_H_INCLUDED #include "linalg.h" #include /** @brief A linear programming problem. This class represents linear programming problems of the form max(w,x) subject to Ax<=b. Or rather subject to A_ix<=b_i + epsilon^i. Notice that such perturbed system, if feassible, is fulldimensional. The problems can be stated over any ordered Field. The class has a state represented by the basis basis and vector x which first must be set by calling setCurrentBasis() or... A basis can only be set if the system is feassible. Afterwards step() can be called repeatedly until an optimal solution is found or the problem turns out to be unbounded. TODO: Anti-cycling rule goes wrong in this implementation. Fix this. */ class FieldLP { Field theField; FieldMatrix A; FieldVector b; FieldVector w; FieldVector x; set basis; static FieldVector subvector(FieldVector const &v, set const &b); static FieldMatrix submatrix(FieldMatrix const &m, set const &b); FieldVector edgeDirection(int i)const; bool isImprovingDirection(int i)const; FieldElement improvement(int i, int &newBasisMember)const; public: FieldLP(FieldMatrix const &A_, FieldVector const &b_); FieldVector basisToPoint(set const &basis)const; void setObjectiveFunction(FieldVector const &w_); void setCurrentBasis(set const &basis_); FieldMatrix computeLinealitySpace(); FieldLP buildLPForFeasibilityCheck(); void print(Printer &P)const; int step(); bool findFeasibleBasis(); FieldLP withNoLineality(); }; #endif gfan-0.5+dfsg/ge_gfan.cpp000066400000000000000000000013671207563005400153130ustar00rootroot00000000000000#include "groebnerengine.h" #include "buchberger.h" #include "printer.h" class GroebnerEngineGfan : public GroebnerEngine { virtual PolynomialSet groebnerBasis(bool &success, PolynomialSet const &idealGenerators, TermOrder const &termOrder, bool autoreduce) { success=true; PolynomialSet ret=idealGenerators; buchberger(&ret,termOrder); return ret; } virtual PolynomialSet autoReduce(bool &success, PolynomialSet const &idealGenerators) { success=true; PolynomialSet ret=idealGenerators; autoReduce_(&ret,LexicographicTermOrder());//term order is ignored in autoReduce_() but this could change return ret; } virtual const char* name() { return "gfan"; } }; static GroebnerEngineGfan groebnerEngineGfan; gfan-0.5+dfsg/genericwalk.cpp000066400000000000000000000124411207563005400162130ustar00rootroot00000000000000#include "genericwalk.h" #include "division.h" #include "buchberger.h" #include "wallideal.h" #include "printer.h" //----------------------------------------------------------------- // Generic Groebner Walk //----------------------------------------------------------------- static bool isCandidate(IntegerVector const &v, const TermOrder &source, const TermOrder &target) { return !source(v,v,1,0) && target(v,v,1,0); } static bool compareInequalities(IntegerVector const &a, IntegerVector const &b, TermOrder const &source, TermOrder const &target) { int n=a.size(); for(int i=0;i0)return true; if(tdb<0)return false; continue; } if(tdb==0) { if(tda<0)return true; if(tda>0)return false; continue; } if(source(b,a,tda,tdb))return true; if(source(a,b,tdb,tda))return false; } return false; } IntegerVectorList::const_iterator shootGenericRay(IntegerVectorList const &g, const TermOrder &source, const TermOrder &target) { IntegerVectorList::const_iterator candidate=g.end(); for(IntegerVectorList::const_iterator i=g.begin();i!=g.end();i++) if(isCandidate(*i,source,target)) { if(candidate==g.end()||compareInequalities(*i,*candidate,source,target)) candidate=i; } return candidate; } PolynomialSet genericWalk(PolynomialSet const &start, const TermOrder &source, const TermOrder &target) { int nflips=0; PolynomialSet g=start; assert(start.checkMarkings(source)); while(1) { IntegerVectorList w=wallInequalities(g); IntegerVectorList::const_iterator i=shootGenericRay(w,source,target); if(i==w.end())break; g=flip(g,*i); nflips++; } fprintf(Stderr,"Number of flips:%i\n",nflips); return g; } class PreOrder { TermOrder const &source; TermOrder const ⌖ int sourceDegree; int targetDegree; public: PreOrder(TermOrder const &source_, TermOrder const &target_, int sourceDegree_, int targetDegree_): source(source_), target(target_), sourceDegree(sourceDegree_), targetDegree(targetDegree_) { } bool isCandidate(IntegerVector const &v) { /* AsciiPrinter(Stderr).printVector(v); AsciiPrinter(Stderr).printNewLine(); AsciiPrinter(Stderr).printTermOrder(source); AsciiPrinter(Stderr).printTermOrder(target);*/ return !source(v,v,1,0) && target(v,v,1,0); // Should this depend on the perturbation degree?? } bool operator()(IntegerVector const &a, IntegerVector const &b) { int n=a.size(); for(int i=0;i0)return true; if(tdb<0)return false; continue; } if(tdb==0) { if(tda<0)return true; if(tda>0)return false; continue; } if(source(b,a,tda,tdb,sourceDegree))return true; if(source(a,b,tdb,tda,sourceDegree))return false; } return false; } }; PolynomialSet genericWalkPerturbation(PolynomialSet const &start, const TermOrder &source, const TermOrder &target, int sourceDegree, int targetDegree) { PolynomialRing theRing=start.getRing(); PreOrder p(source,target,sourceDegree,targetDegree); int nflips=0; PolynomialSet g=start; assert(start.checkMarkings(source)); while(1) { IntegerVectorList inequalities=wallInequalities(g); assert(!inequalities.empty()); IntegerVectorList::const_iterator optimal=inequalities.end(); for(IntegerVectorList::const_iterator i=inequalities.begin();i!=inequalities.end();i++) { // fprintf(Stderr,"%i %i\n",!source(*i,*i,1,0),target(*i,*i,1,0)); if(p.isCandidate(*i)) { if(optimal==inequalities.end() || p(*i,*optimal)) optimal=i; } } if(optimal==inequalities.end()) break; else AsciiPrinter(Stderr).printVector(*optimal); PolynomialSet faceIdeal(theRing); for(PolynomialSet::const_iterator j=g.begin();j!=g.end();j++) { IntegerVector markedExponent=j->getMarked().m.exponent; Polynomial r(theRing); for(TermMap::const_iterator i=j->terms.begin();i!=j->terms.end();i++) { IntegerVector dif=markedExponent-i->first.exponent; if( ((!p(dif,*optimal))&&(!p(*optimal,dif)))|| dif.isZero()) r+=Polynomial(Term(i->second,i->first)); } faceIdeal.push_back(r); } faceIdeal.markAndScale(source); // AsciiPrinter(Stderr).printPolynomialSet(faceIdeal); PolynomialSet oldFaceIdeal=faceIdeal; buchberger(&faceIdeal,target); fprintf(Stderr,"Lifting\n"); PolynomialSet newG(theRing); for(PolynomialSet::const_iterator j=faceIdeal.begin();j!=faceIdeal.end();j++) { newG.push_back(divisionLift(*j, oldFaceIdeal, g, LexicographicTermOrder())); } { PolynomialSet::const_iterator k=faceIdeal.begin(); for(PolynomialSet::iterator j=newG.begin();j!=newG.end();j++) { j->mark(k->getMarked().m); k++; } } fprintf(Stderr,"Autoreducing\n"); autoReduce(&newG,StandardGradedLexicographicTermOrder()); g=newG; nflips++; fprintf(Stderr,"Flip %i, new size %i\n",nflips,g.size()); } fprintf(Stderr,"Number of flips:%i\n",nflips); autoReduce(&g,StandardGradedLexicographicTermOrder()); return g; } gfan-0.5+dfsg/genericwalk.h000066400000000000000000000010161207563005400156540ustar00rootroot00000000000000#ifndef GENERICWALK_H_INCLUDED #define GENERICWALK_H_INCLUDED #include "vektor.h" #include "polynomial.h" #include "termorder.h" IntegerVectorList::const_iterator shootGenericRay(IntegerVectorList const &g, const TermOrder &source, const TermOrder &target); PolynomialSet genericWalk(PolynomialSet const &start, const TermOrder &source, const TermOrder &target); PolynomialSet genericWalkPerturbation(PolynomialSet const &start, const TermOrder &source, const TermOrder &target, int sourceDegree, int targetDegree); #endif gfan-0.5+dfsg/gfanapplication.cpp000066400000000000000000000157341207563005400170670ustar00rootroot00000000000000#include "gfanapplication.h" #include #include #include "field.h" #include "field_rationals.h" #include "field_zmodpz.h" #include "division.h" #include "printer.h" #include "symmetry.h" #include "log.h" #include "linalg.h" #include "polymakefile.h" GFanApplication::FieldOption::FieldOption(): IntegerOption("--mod","Set the field to Z / pZ. The value must be a prime number p between 2 and 32749.\n") { } void GFanApplication::FieldOption::onOptionsParsed() { if(getValue()) { fprintf(Stderr,"CANNOT CHANGE FIELD\n"); assert(0); // Field::setField(new FieldZModPZ(getValue())); // Field::setField(Field::find("Zmod2Z")); } } GFanApplication::LogLevelOption::LogLevelOption(): IntegerOption("--log","Set the logging level.\n") { hide(); } GFanApplication::XmlOption::XmlOption(): SimpleOption("--xml","Switch to XML polyhedral data format output.\n") { hide(); } GFanApplication::StdinFileOption::StdinFileOption(): StringOption("--stdin","Set a file to be read as stdin.\n","") { hide(); } void GFanApplication::StdinFileOption::onOptionsParsed() { if(strlen(getValue())>0)freopen(getValue(),"r",stdin); } GFanApplication::StdoutFileOption::StdoutFileOption(): StringOption("--stdout","Set a file to be read as stdin.\n","") { hide(); } void GFanApplication::StdoutFileOption::onOptionsParsed() { if(strlen(getValue())>0)freopen(getValue(),"w",stdout); } void GFanApplication::LogLevelOption::onOptionsParsed() { if(getValue()==9) { Printer::setAssertOnPrinting(true); } else if(getValue()) { setLogLevel(getValue()); } } void GFanApplication::XmlOption::onOptionsParsed() { if(getValue())PolymakeFile::forceXml(); } void GFanApplication::assertSymmetriesMatch(IntegerVectorList const &g, class PolynomialSet &markedGroebnerBasis, FieldMatrix const *torusActions, bool asPolynomials) { PolynomialSet markedGroebnerBasis2=markedGroebnerBasis; markedGroebnerBasis2.sort_(); int n=markedGroebnerBasis2.numberOfVariablesInRing(); int I=0; for(IntegerVectorList::const_iterator i=g.begin();i!=g.end();i++) { if(i->size()!=n) { fprintf(Stderr,"PERMUTATION "); AsciiPrinter(Stderr).printVector(*i); fprintf(Stderr," HAS WRONG LENGTH.\n"); assert(0); } if(!SymmetryGroup::isPermutation(*i)) { fprintf(Stderr,"VECTOR "); AsciiPrinter(Stderr).printVector(*i); fprintf(Stderr," DOES NOT REPRESENT A PERMUTATION.\n"); assert(0); } //log0 AsciiPrinter(Stderr).printPolynomialSet(markedGroebnerBasis); PolynomialSet b2=SymmetryGroup::permutePolynomialSet(markedGroebnerBasis2,*i); //log0 AsciiPrinter(Stderr).printPolynomialSet(b2); if(torusActions)b2=b2.torusAct((*torusActions)[I]); //log0 AsciiPrinter(Stderr).printPolynomialSet(b2); if(!asPolynomials) { if(!areIdealsEqual(markedGroebnerBasis2,b2)) { fprintf(Stderr,"PERMUTATION "); AsciiPrinter(Stderr).printVector(*i); fprintf(Stderr," DOES NOT KEEP THE IDEAL FIXED.\n"); log1 fprintf(Stderr,"Original ideal:\n"); log1 AsciiPrinter(Stderr).printPolynomialSet(markedGroebnerBasis2); log1 fprintf(Stderr,"Permuted ideal:\n"); log1 AsciiPrinter(Stderr).printPolynomialSet(b2); log1 { for(PolynomialSet::const_iterator i=b2.begin();i!=b2.end();i++) { Polynomial remainder=division(*i,markedGroebnerBasis2,LexicographicTermOrder()); log1 AsciiPrinter(Stderr).printString("Remainder: "); log1 AsciiPrinter(Stderr).printPolynomial(remainder); log1 AsciiPrinter(Stderr).printNewLine(); if(!remainder.isZero()) { log1 AsciiPrinter(Stderr).printString("Polynomial not in ideal: "); log1 AsciiPrinter(Stderr).printPolynomial(*i); log1 AsciiPrinter(Stderr).printNewLine(); break; } } } assert(0); } } else { b2.markAndScale(LexicographicTermOrder()); markedGroebnerBasis2.markAndScale(LexicographicTermOrder()); b2.sort_(); if(!(markedGroebnerBasis2==b2)) { fprintf(Stderr,"PERMUTATION "); AsciiPrinter(Stderr).printVector(*i); fprintf(Stderr," DOES NOT KEEP POLYNOMIAL SET FIXED.\n"); log1 { AsciiPrinter(Stderr).printPolynomialSet(markedGroebnerBasis2); AsciiPrinter(Stderr).printPolynomialSet(b2); PolynomialSet::const_iterator j=markedGroebnerBasis2.begin(); for(PolynomialSet::const_iterator i=b2.begin();i!=b2.end();i++) { if(!(*j-*i).isZero()) { fprintf(Stderr,"Polynomials are different:\n"); AsciiPrinter(Stderr).printPolynomial(*i); fprintf(Stderr,"\n"); AsciiPrinter(Stderr).printPolynomial(*j); fprintf(Stderr,"\nDifference:\n"); AsciiPrinter(Stderr).printPolynomial(*i-*j); fprintf(Stderr,"\n"); break; } j++; } } assert(0); } } I++; } } void GFanApplication::onExit() { log1 { fprintf(Stderr,"Number of living FieldImplementation objects:%i\n",FieldImplementation::getNumberOfLivingFieldImplementations()); fprintf(Stderr,"Number of living FieldElementImplementation objects:%i\n",FieldElementImplementation::getNumberOfLivingFieldElementImplementations()); } } #include "gmp.h" #include "versioninfo.h" #include "lp.h" #include "groebnerengine.h" class VersionApplication : public Application { bool includeInDefaultInstallation() { return true; } const char *helpText() { return "This program writes out version information of the Gfan installation.\n"; } const char *name() { return "_version"; } int main() { cout<<"Gfan version:\n"<