From 487b0eb4d12b3c3d36316c1c076ed61cb3c78f98 Mon Sep 17 00:00:00 2001 From: Tommy Hofmann Date: Tue, 25 Aug 2020 12:21:23 +0200 Subject: [PATCH 01/95] bla --- deps/{ => src}/build.jl | 0 deps/{ => src}/xcodetypeinfo/CMakeLists.txt | 0 deps/{ => src}/xcodetypeinfo/hello.cpp | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename deps/{ => src}/build.jl (100%) rename deps/{ => src}/xcodetypeinfo/CMakeLists.txt (100%) rename deps/{ => src}/xcodetypeinfo/hello.cpp (100%) diff --git a/deps/build.jl b/deps/src/build.jl similarity index 100% rename from deps/build.jl rename to deps/src/build.jl diff --git a/deps/xcodetypeinfo/CMakeLists.txt b/deps/src/xcodetypeinfo/CMakeLists.txt similarity index 100% rename from deps/xcodetypeinfo/CMakeLists.txt rename to deps/src/xcodetypeinfo/CMakeLists.txt diff --git a/deps/xcodetypeinfo/hello.cpp b/deps/src/xcodetypeinfo/hello.cpp similarity index 100% rename from deps/xcodetypeinfo/hello.cpp rename to deps/src/xcodetypeinfo/hello.cpp From f8b2c0a706bf31b2e1c244227251b09026c11ded Mon Sep 17 00:00:00 2001 From: Tommy Hofmann Date: Tue, 25 Aug 2020 16:52:01 +0200 Subject: [PATCH 02/95] Cleanup --- deps/src/CMakeLists.txt | 42 +- deps/src/LICENSE.md | 674 ++++++++++++++++++++++++++ deps/src/build.jl | 128 ----- deps/src/xcodetypeinfo/CMakeLists.txt | 12 - deps/src/xcodetypeinfo/hello.cpp | 14 - 5 files changed, 707 insertions(+), 163 deletions(-) create mode 100644 deps/src/LICENSE.md delete mode 100644 deps/src/build.jl delete mode 100644 deps/src/xcodetypeinfo/CMakeLists.txt delete mode 100644 deps/src/xcodetypeinfo/hello.cpp diff --git a/deps/src/CMakeLists.txt b/deps/src/CMakeLists.txt index 7e8e2d1a4..13c0be7a1 100644 --- a/deps/src/CMakeLists.txt +++ b/deps/src/CMakeLists.txt @@ -1,30 +1,54 @@ -project(Singular) - cmake_minimum_required(VERSION 3.01) +# I don't know why I need the following, but it works +if(POLICY CMP0025) + cmake_policy(SET CMP0025 NEW) +endif() + +project(libsingular_julia) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") find_package(JlCxx REQUIRED) +include(CheckCXXCompilerFlag) + +set(CMAKE_CXX_STANDARD 14) + +set(JLSINGULAR_TARGET singular_julia) + +# avoid gcc 9 internal compiler error, +# see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90998 +if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0 + AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.3) + SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-conversion" ) +endif() + +SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++14" ) + +# to avoid lib64 dirs as binarybuilder uses lib everywhere +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") +set(CMAKE_INSTALL_LIBDIR "lib") + get_target_property(JlCxx_location JlCxx::cxxwrap_julia LOCATION) get_filename_component(JlCxx_location ${JlCxx_location} DIRECTORY) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${JlCxx_location}") message(STATUS "Found JlCxx at ${JlCxx_location}") -include_directories(${singular_includes}) -include_directories(${singular_includes}/singular) +include_directories(${CMAKE_INSTALL_PREFIX}) +include_directories(${CMAKE_INSTALL_PREFIX}/singular) -SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g ${extra_cppflags} -I${gmp_dir}/include -I${mpfr_dir}/include" ) -SET( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -v -L${singular_libdir} -L${gmp_dir}/lib -L${mpfr_dir}/lib -Wl,-rpath,${singular_libdir} -Wl,-rpath,${gmp_dir}/lib -Wl,-rpath,${mpfr_dir}/lib" ) +SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g ${extra_cppflags} -I${CMAKE_INSTALL_PREFIX}/include -I${CMAKE_INSTALL_PREFIX}/include/singular" ) +SET( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -v -L${CMAKE_INSTALL_PREFIX}/lib -Wl,-rpath,${CMAKE_INSTALL_PREFIX}/lib" ) -add_library(singularwrap SHARED singular.cpp rings.cpp coeffs.cpp ideals.cpp matrices.cpp caller.cpp coeff_rings.cpp threading.cpp) +add_library(${JLSINGULAR_TARGET} SHARED singular.cpp rings.cpp coeffs.cpp ideals.cpp matrices.cpp caller.cpp coeff_rings.cpp threading.cpp) -target_link_libraries(singularwrap JlCxx::cxxwrap_julia -lSingular -lpolys -lsingular_resources -lfactory -lomalloc -ldl -lgmp) +target_link_libraries(${JLSINGULAR_TARGET} JlCxx::cxxwrap_julia -lSingular -lpolys -lsingular_resources -lfactory -lomalloc -ldl -lgmp) install(TARGETS - singularwrap + ${JLSINGULAR_TARGET} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/deps/src/LICENSE.md b/deps/src/LICENSE.md new file mode 100644 index 000000000..7f74e1971 --- /dev/null +++ b/deps/src/LICENSE.md @@ -0,0 +1,674 @@ +############################################################################### + + IMPORTANT NOTE + + The Singular.jl package is licensed OVERALL under the GNU Public License, + Version 3.0+. See below for full details of the GPL license. + +############################################################################### + +All INDIVIDUAL Julia (.jl) files in the Singular.jl package are licensed +under the BSD license, unless explicitly noted in the file: + +> Copyright (c) 2015-2016: Oleksandr Motsak. +> Copyright (c) 2016: William Hart. +> All rights reserved. +> +> Redistribution and use in source and binary forms, with or without +> modification, are permitted provided that the following conditions are met: +> +> * Redistributions of source code must retain the above copyright notice, this +> list of conditions and the following disclaimer. +> +> * Redistributions in binary form must reproduce the above copyright notice, +> this list of conditions and the following disclaimer in the documentation +> and/or other materials provided with the distribution. +> +> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +> AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +> DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +> DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +> SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +> CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +> OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +> OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +> + + +> Copyright (c) 2015-2016: Oleksandr Motsak. +> Copyright (c) 2016: William Hart. +> This program is free software: you can redistribute it and/or modify +> it under the terms of the GNU General Public License as published by +> the Free Software Foundation, either version 3 of the License, or +> (at your option) any later version. +> +> This program is distributed in the hope that it will be useful, +> but WITHOUT ANY WARRANTY; without even the implied warranty of +> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +> GNU General Public License for more details. +> +> +> GNU GENERAL PUBLIC LICENSE +> Version 3, 29 June 2007 +> +> Copyright (C) 2007 Free Software Foundation, Inc. +> Everyone is permitted to copy and distribute verbatim copies +> of this license document, but changing it is not allowed. +> +> Preamble +> +> The GNU General Public License is a free, copyleft license for +> software and other kinds of works. +> +> The licenses for most software and other practical works are designed +> to take away your freedom to share and change the works. By contrast, +> the GNU General Public License is intended to guarantee your freedom to +> share and change all versions of a program--to make sure it remains free +> software for all its users. We, the Free Software Foundation, use the +> GNU General Public License for most of our software; it applies also to +> any other work released this way by its authors. You can apply it to +> your programs, too. +> +> When we speak of free software, we are referring to freedom, not +> price. Our General Public Licenses are designed to make sure that you +> have the freedom to distribute copies of free software (and charge for +> them if you wish), that you receive source code or can get it if you +> want it, that you can change the software or use pieces of it in new +> free programs, and that you know you can do these things. +> +> To protect your rights, we need to prevent others from denying you +> these rights or asking you to surrender the rights. Therefore, you have +> certain responsibilities if you distribute copies of the software, or if +> you modify it: responsibilities to respect the freedom of others. +> +> For example, if you distribute copies of such a program, whether +> gratis or for a fee, you must pass on to the recipients the same +> freedoms that you received. You must make sure that they, too, receive +> or can get the source code. And you must show them these terms so they +> know their rights. +> +> Developers that use the GNU GPL protect your rights with two steps: +> (1) assert copyright on the software, and (2) offer you this License +> giving you legal permission to copy, distribute and/or modify it. +> +> For the developers' and authors' protection, the GPL clearly explains +> that there is no warranty for this free software. For both users' and +> authors' sake, the GPL requires that modified versions be marked as +> changed, so that their problems will not be attributed erroneously to +> authors of previous versions. +> +> Some devices are designed to deny users access to install or run +> modified versions of the software inside them, although the manufacturer +> can do so. This is fundamentally incompatible with the aim of +> protecting users' freedom to change the software. The systematic +> pattern of such abuse occurs in the area of products for individuals to +> use, which is precisely where it is most unacceptable. Therefore, we +> have designed this version of the GPL to prohibit the practice for those +> products. If such problems arise substantially in other domains, we +> stand ready to extend this provision to those domains in future versions +> of the GPL, as needed to protect the freedom of users. +> +> Finally, every program is threatened constantly by software patents. +> States should not allow patents to restrict development and use of +> software on general-purpose computers, but in those that do, we wish to +> avoid the special danger that patents applied to a free program could +> make it effectively proprietary. To prevent this, the GPL assures that +> patents cannot be used to render the program non-free. +> +> The precise terms and conditions for copying, distribution and +> modification follow. +> +> TERMS AND CONDITIONS +> +> 0. Definitions. +> +> "This License" refers to version 3 of the GNU General Public License. +> +> "Copyright" also means copyright-like laws that apply to other kinds of +> works, such as semiconductor masks. +> +> "The Program" refers to any copyrightable work licensed under this +> License. Each licensee is addressed as "you". "Licensees" and +> "recipients" may be individuals or organizations. +> +> To "modify" a work means to copy from or adapt all or part of the work +> in a fashion requiring copyright permission, other than the making of an +> exact copy. The resulting work is called a "modified version" of the +> earlier work or a work "based on" the earlier work. +> +> A "covered work" means either the unmodified Program or a work based +> on the Program. +> +> To "propagate" a work means to do anything with it that, without +> permission, would make you directly or secondarily liable for +> infringement under applicable copyright law, except executing it on a +> computer or modifying a private copy. Propagation includes copying, +> distribution (with or without modification), making available to the +> public, and in some countries other activities as well. +> +> To "convey" a work means any kind of propagation that enables other +> parties to make or receive copies. Mere interaction with a user through +> a computer network, with no transfer of a copy, is not conveying. +> +> An interactive user interface displays "Appropriate Legal Notices" +> to the extent that it includes a convenient and prominently visible +> feature that (1) displays an appropriate copyright notice, and (2) +> tells the user that there is no warranty for the work (except to the +> extent that warranties are provided), that licensees may convey the +> work under this License, and how to view a copy of this License. If +> the interface presents a list of user commands or options, such as a +> menu, a prominent item in the list meets this criterion. +> +> 1. Source Code. +> +> The "source code" for a work means the preferred form of the work +> for making modifications to it. "Object code" means any non-source +> form of a work. +> +> A "Standard Interface" means an interface that either is an official +> standard defined by a recognized standards body, or, in the case of +> interfaces specified for a particular programming language, one that +> is widely used among developers working in that language. +> +> The "System Libraries" of an executable work include anything, other +> than the work as a whole, that (a) is included in the normal form of +> packaging a Major Component, but which is not part of that Major +> Component, and (b) serves only to enable use of the work with that +> Major Component, or to implement a Standard Interface for which an +> implementation is available to the public in source code form. A +> "Major Component", in this context, means a major essential component +> (kernel, window system, and so on) of the specific operating system +> (if any) on which the executable work runs, or a compiler used to +> produce the work, or an object code interpreter used to run it. +> +> The "Corresponding Source" for a work in object code form means all +> the source code needed to generate, install, and (for an executable +> work) run the object code and to modify the work, including scripts to +> control those activities. However, it does not include the work's +> System Libraries, or general-purpose tools or generally available free +> programs which are used unmodified in performing those activities but +> which are not part of the work. For example, Corresponding Source +> includes interface definition files associated with source files for +> the work, and the source code for shared libraries and dynamically +> linked subprograms that the work is specifically designed to require, +> such as by intimate data communication or control flow between those +> subprograms and other parts of the work. +> +> The Corresponding Source need not include anything that users +> can regenerate automatically from other parts of the Corresponding +> Source. +> +> The Corresponding Source for a work in source code form is that +> same work. +> +> 2. Basic Permissions. +> +> All rights granted under this License are granted for the term of +> copyright on the Program, and are irrevocable provided the stated +> conditions are met. This License explicitly affirms your unlimited +> permission to run the unmodified Program. The output from running a +> covered work is covered by this License only if the output, given its +> content, constitutes a covered work. This License acknowledges your +> rights of fair use or other equivalent, as provided by copyright law. +> +> You may make, run and propagate covered works that you do not +> convey, without conditions so long as your license otherwise remains +> in force. You may convey covered works to others for the sole purpose +> of having them make modifications exclusively for you, or provide you +> with facilities for running those works, provided that you comply with +> the terms of this License in conveying all material for which you do +> not control copyright. Those thus making or running the covered works +> for you must do so exclusively on your behalf, under your direction +> and control, on terms that prohibit them from making any copies of +> your copyrighted material outside their relationship with you. +> +> Conveying under any other circumstances is permitted solely under +> the conditions stated below. Sublicensing is not allowed; section 10 +> makes it unnecessary. +> +> 3. Protecting Users' Legal Rights From Anti-Circumvention Law. +> +> No covered work shall be deemed part of an effective technological +> measure under any applicable law fulfilling obligations under article +> 11 of the WIPO copyright treaty adopted on 20 December 1996, or +> similar laws prohibiting or restricting circumvention of such +> measures. +> +> When you convey a covered work, you waive any legal power to forbid +> circumvention of technological measures to the extent such circumvention +> is effected by exercising rights under this License with respect to +> the covered work, and you disclaim any intention to limit operation or +> modification of the work as a means of enforcing, against the work's +> users, your or third parties' legal rights to forbid circumvention of +> technological measures. +> +> 4. Conveying Verbatim Copies. +> +> You may convey verbatim copies of the Program's source code as you +> receive it, in any medium, provided that you conspicuously and +> appropriately publish on each copy an appropriate copyright notice; +> keep intact all notices stating that this License and any +> non-permissive terms added in accord with section 7 apply to the code; +> keep intact all notices of the absence of any warranty; and give all +> recipients a copy of this License along with the Program. +> +> You may charge any price or no price for each copy that you convey, +> and you may offer support or warranty protection for a fee. +> +> 5. Conveying Modified Source Versions. +> +> You may convey a work based on the Program, or the modifications to +> produce it from the Program, in the form of source code under the +> terms of section 4, provided that you also meet all of these conditions: +> +> a) The work must carry prominent notices stating that you modified +> it, and giving a relevant date. +> +> b) The work must carry prominent notices stating that it is +> released under this License and any conditions added under section +> 7. This requirement modifies the requirement in section 4 to +> "keep intact all notices". +> +> c) You must license the entire work, as a whole, under this +> License to anyone who comes into possession of a copy. This +> License will therefore apply, along with any applicable section 7 +> additional terms, to the whole of the work, and all its parts, +> regardless of how they are packaged. This License gives no +> permission to license the work in any other way, but it does not +> invalidate such permission if you have separately received it. +> +> d) If the work has interactive user interfaces, each must display +> Appropriate Legal Notices; however, if the Program has interactive +> interfaces that do not display Appropriate Legal Notices, your +> work need not make them do so. +> +> A compilation of a covered work with other separate and independent +> works, which are not by their nature extensions of the covered work, +> and which are not combined with it such as to form a larger program, +> in or on a volume of a storage or distribution medium, is called an +> "aggregate" if the compilation and its resulting copyright are not +> used to limit the access or legal rights of the compilation's users +> beyond what the individual works permit. Inclusion of a covered work +> in an aggregate does not cause this License to apply to the other +> parts of the aggregate. +> +> 6. Conveying Non-Source Forms. +> +> You may convey a covered work in object code form under the terms +> of sections 4 and 5, provided that you also convey the +> machine-readable Corresponding Source under the terms of this License, +> in one of these ways: +> +> a) Convey the object code in, or embodied in, a physical product +> (including a physical distribution medium), accompanied by the +> Corresponding Source fixed on a durable physical medium +> customarily used for software interchange. +> +> b) Convey the object code in, or embodied in, a physical product +> (including a physical distribution medium), accompanied by a +> written offer, valid for at least three years and valid for as +> long as you offer spare parts or customer support for that product +> model, to give anyone who possesses the object code either (1) a +> copy of the Corresponding Source for all the software in the +> product that is covered by this License, on a durable physical +> medium customarily used for software interchange, for a price no +> more than your reasonable cost of physically performing this +> conveying of source, or (2) access to copy the +> Corresponding Source from a network server at no charge. +> +> c) Convey individual copies of the object code with a copy of the +> written offer to provide the Corresponding Source. This +> alternative is allowed only occasionally and noncommercially, and +> only if you received the object code with such an offer, in accord +> with subsection 6b. +> +> d) Convey the object code by offering access from a designated +> place (gratis or for a charge), and offer equivalent access to the +> Corresponding Source in the same way through the same place at no +> further charge. You need not require recipients to copy the +> Corresponding Source along with the object code. If the place to +> copy the object code is a network server, the Corresponding Source +> may be on a different server (operated by you or a third party) +> that supports equivalent copying facilities, provided you maintain +> clear directions next to the object code saying where to find the +> Corresponding Source. Regardless of what server hosts the +> Corresponding Source, you remain obligated to ensure that it is +> available for as long as needed to satisfy these requirements. +> +> e) Convey the object code using peer-to-peer transmission, provided +> you inform other peers where the object code and Corresponding +> Source of the work are being offered to the general public at no +> charge under subsection 6d. +> +> A separable portion of the object code, whose source code is excluded +> from the Corresponding Source as a System Library, need not be +> included in conveying the object code work. +> +> A "User Product" is either (1) a "consumer product", which means any +> tangible personal property which is normally used for personal, family, +> or household purposes, or (2) anything designed or sold for incorporation +> into a dwelling. In determining whether a product is a consumer product, +> doubtful cases shall be resolved in favor of coverage. For a particular +> product received by a particular user, "normally used" refers to a +> typical or common use of that class of product, regardless of the status +> of the particular user or of the way in which the particular user +> actually uses, or expects or is expected to use, the product. A product +> is a consumer product regardless of whether the product has substantial +> commercial, industrial or non-consumer uses, unless such uses represent +> the only significant mode of use of the product. +> +> "Installation Information" for a User Product means any methods, +> procedures, authorization keys, or other information required to install +> and execute modified versions of a covered work in that User Product from +> a modified version of its Corresponding Source. The information must +> suffice to ensure that the continued functioning of the modified object +> code is in no case prevented or interfered with solely because +> modification has been made. +> +> If you convey an object code work under this section in, or with, or +> specifically for use in, a User Product, and the conveying occurs as +> part of a transaction in which the right of possession and use of the +> User Product is transferred to the recipient in perpetuity or for a +> fixed term (regardless of how the transaction is characterized), the +> Corresponding Source conveyed under this section must be accompanied +> by the Installation Information. But this requirement does not apply +> if neither you nor any third party retains the ability to install +> modified object code on the User Product (for example, the work has +> been installed in ROM). +> +> The requirement to provide Installation Information does not include a +> requirement to continue to provide support service, warranty, or updates +> for a work that has been modified or installed by the recipient, or for +> the User Product in which it has been modified or installed. Access to a +> network may be denied when the modification itself materially and +> adversely affects the operation of the network or violates the rules and +> protocols for communication across the network. +> +> Corresponding Source conveyed, and Installation Information provided, +> in accord with this section must be in a format that is publicly +> documented (and with an implementation available to the public in +> source code form), and must require no special password or key for +> unpacking, reading or copying. +> +> 7. Additional Terms. +> +> "Additional permissions" are terms that supplement the terms of this +> License by making exceptions from one or more of its conditions. +> Additional permissions that are applicable to the entire Program shall +> be treated as though they were included in this License, to the extent +> that they are valid under applicable law. If additional permissions +> apply only to part of the Program, that part may be used separately +> under those permissions, but the entire Program remains governed by +> this License without regard to the additional permissions. +> +> When you convey a copy of a covered work, you may at your option +> remove any additional permissions from that copy, or from any part of +> it. (Additional permissions may be written to require their own +> removal in certain cases when you modify the work.) You may place +> additional permissions on material, added by you to a covered work, +> for which you have or can give appropriate copyright permission. +> +> Notwithstanding any other provision of this License, for material you +> add to a covered work, you may (if authorized by the copyright holders of +> that material) supplement the terms of this License with terms: +> +> a) Disclaiming warranty or limiting liability differently from the +> terms of sections 15 and 16 of this License; or +> +> b) Requiring preservation of specified reasonable legal notices or +> author attributions in that material or in the Appropriate Legal +> Notices displayed by works containing it; or +> +> c) Prohibiting misrepresentation of the origin of that material, or +> requiring that modified versions of such material be marked in +> reasonable ways as different from the original version; or +> +> d) Limiting the use for publicity purposes of names of licensors or +> authors of the material; or +> +> e) Declining to grant rights under trademark law for use of some +> trade names, trademarks, or service marks; or +> +> f) Requiring indemnification of licensors and authors of that +> material by anyone who conveys the material (or modified versions of +> it) with contractual assumptions of liability to the recipient, for +> any liability that these contractual assumptions directly impose on +> those licensors and authors. +> +> All other non-permissive additional terms are considered "further +> restrictions" within the meaning of section 10. If the Program as you +> received it, or any part of it, contains a notice stating that it is +> governed by this License along with a term that is a further +> restriction, you may remove that term. If a license document contains +> a further restriction but permits relicensing or conveying under this +> License, you may add to a covered work material governed by the terms +> of that license document, provided that the further restriction does +> not survive such relicensing or conveying. +> +> If you add terms to a covered work in accord with this section, you +> must place, in the relevant source files, a statement of the +> additional terms that apply to those files, or a notice indicating +> where to find the applicable terms. +> +> Additional terms, permissive or non-permissive, may be stated in the +> form of a separately written license, or stated as exceptions; +> the above requirements apply either way. +> +> 8. Termination. +> +> You may not propagate or modify a covered work except as expressly +> provided under this License. Any attempt otherwise to propagate or +> modify it is void, and will automatically terminate your rights under +> this License (including any patent licenses granted under the third +> paragraph of section 11). +> +> However, if you cease all violation of this License, then your +> license from a particular copyright holder is reinstated (a) +> provisionally, unless and until the copyright holder explicitly and +> finally terminates your license, and (b) permanently, if the copyright +> holder fails to notify you of the violation by some reasonable means +> prior to 60 days after the cessation. +> +> Moreover, your license from a particular copyright holder is +> reinstated permanently if the copyright holder notifies you of the +> violation by some reasonable means, this is the first time you have +> received notice of violation of this License (for any work) from that +> copyright holder, and you cure the violation prior to 30 days after +> your receipt of the notice. +> +> Termination of your rights under this section does not terminate the +> licenses of parties who have received copies or rights from you under +> this License. If your rights have been terminated and not permanently +> reinstated, you do not qualify to receive new licenses for the same +> material under section 10. +> +> 9. Acceptance Not Required for Having Copies. +> +> You are not required to accept this License in order to receive or +> run a copy of the Program. Ancillary propagation of a covered work +> occurring solely as a consequence of using peer-to-peer transmission +> to receive a copy likewise does not require acceptance. However, +> nothing other than this License grants you permission to propagate or +> modify any covered work. These actions infringe copyright if you do +> not accept this License. Therefore, by modifying or propagating a +> covered work, you indicate your acceptance of this License to do so. +> +> 10. Automatic Licensing of Downstream Recipients. +> +> Each time you convey a covered work, the recipient automatically +> receives a license from the original licensors, to run, modify and +> propagate that work, subject to this License. You are not responsible +> for enforcing compliance by third parties with this License. +> +> An "entity transaction" is a transaction transferring control of an +> organization, or substantially all assets of one, or subdividing an +> organization, or merging organizations. If propagation of a covered +> work results from an entity transaction, each party to that +> transaction who receives a copy of the work also receives whatever +> licenses to the work the party's predecessor in interest had or could +> give under the previous paragraph, plus a right to possession of the +> Corresponding Source of the work from the predecessor in interest, if +> the predecessor has it or can get it with reasonable efforts. +> +> You may not impose any further restrictions on the exercise of the +> rights granted or affirmed under this License. For example, you may +> not impose a license fee, royalty, or other charge for exercise of +> rights granted under this License, and you may not initiate litigation +> (including a cross-claim or counterclaim in a lawsuit) alleging that +> any patent claim is infringed by making, using, selling, offering for +> sale, or importing the Program or any portion of it. +> +> 11. Patents. +> +> A "contributor" is a copyright holder who authorizes use under this +> License of the Program or a work on which the Program is based. The +> work thus licensed is called the contributor's "contributor version". +> +> A contributor's "essential patent claims" are all patent claims +> owned or controlled by the contributor, whether already acquired or +> hereafter acquired, that would be infringed by some manner, permitted +> by this License, of making, using, or selling its contributor version, +> but do not include claims that would be infringed only as a +> consequence of further modification of the contributor version. For +> purposes of this definition, "control" includes the right to grant +> patent sublicenses in a manner consistent with the requirements of +> this License. +> +> Each contributor grants you a non-exclusive, worldwide, royalty-free +> patent license under the contributor's essential patent claims, to +> make, use, sell, offer for sale, import and otherwise run, modify and +> propagate the contents of its contributor version. +> +> In the following three paragraphs, a "patent license" is any express +> agreement or commitment, however denominated, not to enforce a patent +> (such as an express permission to practice a patent or covenant not to +> sue for patent infringement). To "grant" such a patent license to a +> party means to make such an agreement or commitment not to enforce a +> patent against the party. +> +> If you convey a covered work, knowingly relying on a patent license, +> and the Corresponding Source of the work is not available for anyone +> to copy, free of charge and under the terms of this License, through a +> publicly available network server or other readily accessible means, +> then you must either (1) cause the Corresponding Source to be so +> available, or (2) arrange to deprive yourself of the benefit of the +> patent license for this particular work, or (3) arrange, in a manner +> consistent with the requirements of this License, to extend the patent +> license to downstream recipients. "Knowingly relying" means you have +> actual knowledge that, but for the patent license, your conveying the +> covered work in a country, or your recipient's use of the covered work +> in a country, would infringe one or more identifiable patents in that +> country that you have reason to believe are valid. +> +> If, pursuant to or in connection with a single transaction or +> arrangement, you convey, or propagate by procuring conveyance of, a +> covered work, and grant a patent license to some of the parties +> receiving the covered work authorizing them to use, propagate, modify +> or convey a specific copy of the covered work, then the patent license +> you grant is automatically extended to all recipients of the covered +> work and works based on it. +> +> A patent license is "discriminatory" if it does not include within +> the scope of its coverage, prohibits the exercise of, or is +> conditioned on the non-exercise of one or more of the rights that are +> specifically granted under this License. You may not convey a covered +> work if you are a party to an arrangement with a third party that is +> in the business of distributing software, under which you make payment +> to the third party based on the extent of your activity of conveying +> the work, and under which the third party grants, to any of the +> parties who would receive the covered work from you, a discriminatory +> patent license (a) in connection with copies of the covered work +> conveyed by you (or copies made from those copies), or (b) primarily +> for and in connection with specific products or compilations that +> contain the covered work, unless you entered into that arrangement, +> or that patent license was granted, prior to 28 March 2007. +> +> Nothing in this License shall be construed as excluding or limiting +> any implied license or other defenses to infringement that may +> otherwise be available to you under applicable patent law. +> +> 12. No Surrender of Others' Freedom. +> +> If conditions are imposed on you (whether by court order, agreement or +> otherwise) that contradict the conditions of this License, they do not +> excuse you from the conditions of this License. If you cannot convey a +> covered work so as to satisfy simultaneously your obligations under this +> License and any other pertinent obligations, then as a consequence you may +> not convey it at all. For example, if you agree to terms that obligate you +> to collect a royalty for further conveying from those to whom you convey +> the Program, the only way you could satisfy both those terms and this +> License would be to refrain entirely from conveying the Program. +> +> 13. Use with the GNU Affero General Public License. +> +> Notwithstanding any other provision of this License, you have +> permission to link or combine any covered work with a work licensed +> under version 3 of the GNU Affero General Public License into a single +> combined work, and to convey the resulting work. The terms of this +> License will continue to apply to the part which is the covered work, +> but the special requirements of the GNU Affero General Public License, +> section 13, concerning interaction through a network will apply to the +> combination as such. +> +> 14. Revised Versions of this License. +> +> The Free Software Foundation may publish revised and/or new versions of +> the GNU General Public License from time to time. Such new versions will +> be similar in spirit to the present version, but may differ in detail to +> address new problems or concerns. +> +> Each version is given a distinguishing version number. If the +> Program specifies that a certain numbered version of the GNU General +> Public License "or any later version" applies to it, you have the +> option of following the terms and conditions either of that numbered +> version or of any later version published by the Free Software +> Foundation. If the Program does not specify a version number of the +> GNU General Public License, you may choose any version ever published +> by the Free Software Foundation. +> +> If the Program specifies that a proxy can decide which future +> versions of the GNU General Public License can be used, that proxy's +> public statement of acceptance of a version permanently authorizes you +> to choose that version for the Program. +> +> Later license versions may give you additional or different +> permissions. However, no additional obligations are imposed on any +> author or copyright holder as a result of your choosing to follow a +> later version. +> +> 15. Disclaimer of Warranty. +> +> THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +> APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +> HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +> OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +> THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +> PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +> IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +> ALL NECESSARY SERVICING, REPAIR OR CORRECTION. +> +> 16. Limitation of Liability. +> +> IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +> WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +> THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +> GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +> USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +> DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +> PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +> EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +> SUCH DAMAGES. +> +> 17. Interpretation of Sections 15 and 16. +> +> If the disclaimer of warranty and limitation of liability provided +> above cannot be given local legal effect according to their terms, +> reviewing courts shall apply local law that most closely approximates +> an absolute waiver of all civil liability in connection with the +> Program, unless a warranty or assumption of liability accompanies a +> copy of the Program in return for a fee. +> +> END OF TERMS AND CONDITIONS +> diff --git a/deps/src/build.jl b/deps/src/build.jl deleted file mode 100644 index 559c4a2f1..000000000 --- a/deps/src/build.jl +++ /dev/null @@ -1,128 +0,0 @@ -using BinaryProvider - -using Singular_jll - -import CxxWrap -import Libdl -import CMake - -using GMP_jll -using MPFR_jll - -localprefixpath = joinpath(@__DIR__, "usr") - -prefixpath = Singular_jll.artifact_dir - -gmp_dir = GMP_jll.artifact_dir -mpfr_dir = MPFR_jll.artifact_dir - -# add shell scripts that startup another julia for some lib4ti2 programs -# singular and libsingular are supposed to at least look in -# $prefixpath/lib/singular/MOD - -mkpath("$prefixpath/lib/singular/MOD") - -write("$prefixpath/lib/singular/MOD/graver", """ -#!/bin/sh -julia --startup-file=no -O0 -e 'import lib4ti2_jll -lib4ti2_jll.zsolve() do x - p=run(ignorestatus(`\$x -G \$ARGS`)) - exit(p.exitcode) -end' -- "\$@" -""") - -write("$prefixpath/lib/singular/MOD/hilbert", """ -#!/bin/sh -julia --startup-file=no -O0 -e 'import lib4ti2_jll -lib4ti2_jll.zsolve() do x - p=run(ignorestatus(`\$x -H \$ARGS`)) - exit(p.exitcode) -end' -- "\$@" -""") - -write("$prefixpath/lib/singular/MOD/markov", """ -#!/bin/sh -julia --startup-file=no -O0 -e 'import lib4ti2_jll -lib4ti2_jll.exe4ti2gmp() do x - p=run(ignorestatus(`\$x markov \$ARGS`)) - exit(p.exitcode) -end' -- "\$@" -""") - -chmod("$prefixpath/lib/singular/MOD/graver", 0o777) -chmod("$prefixpath/lib/singular/MOD/hilbert", 0o777) -chmod("$prefixpath/lib/singular/MOD/markov", 0o777) - - -push!(Libdl.DL_LOAD_PATH, joinpath(prefixpath, "lib")) - -@show libcxxwrap_prefix = CxxWrap.prefix_path() -@show julia_exec = joinpath(Sys.BINDIR, "julia") - -extra_cppflags = "" - -if Sys.isapple() - # Work around a bug in Xcode 11.4 that causes SIGABRT, at least until - # https://github.com/llvm/llvm-project/commit/2464d8135e - # arrives. - # - # We build a jlcxx library that uses std::string which will - # abort with a failed assertion has_julia_type if we are building - # with xcode 11.4 but libcxxwrap-julia was built with an older libc++. - # - # Read the above LLVM commit message for some details; the effect of merged - # vs non-merged type_info is that for the former memory addresses are - # used as hash_code(), for the latter the type_info.name() string is - # hashed. - - xcodetypeinfo_build_path = joinpath(@__DIR__, "xcodetypeinfo", "build") - rm(xcodetypeinfo_build_path, recursive = true, force = true) - mkpath(xcodetypeinfo_build_path) - cd(xcodetypeinfo_build_path) - run(`$(CMake.cmake) - -DJulia_EXECUTABLE=$julia_exec - -DCMAKE_PREFIX_PATH=$libcxxwrap_prefix - ..`) - run(`$(CMake.cmake) --build .`) - libpath = joinpath(xcodetypeinfo_build_path, "libhello.$(Libdl.dlext)") - res = run(pipeline(Cmd(`$(Base.julia_cmd()) --project - -e "using CxxWrap; @wrapmodule(\"$libpath\", :define_module_hello); @initcxx;"`, - ignorestatus = true), - stdout=devnull, - stderr=devnull)) - if res.termsignal == 6 - println("Applying Xcode type_info.hash_code() workaround") - global extra_cppflags *= " -DFORCE_XCODE_TYPEINFO_MERGED" - end -end - -cmake_src_path = joinpath(@__DIR__, "src") -cmake_build_path = joinpath(@__DIR__, "build") - -rm(cmake_build_path, recursive = true, force = true) -mkpath(cmake_build_path) -cd(cmake_build_path) - -@show "$mpfr_dir/lib" -@show "$gmp_dir/lib" - -println("Initializing cmake") -run(`$(CMake.cmake) - -DJulia_EXECUTABLE=$julia_exec - -DCMAKE_PREFIX_PATH=$libcxxwrap_prefix - -Dextra_cppflags=$extra_cppflags - -Dsingular_includes=$prefixpath/include - -Dsingular_libdir=$prefixpath/lib - -DCMAKE_INSTALL_LIBDIR=$localprefixpath/lib - -Dgmp_dir=$gmp_dir - -Dmpfr_dir=$mpfr_dir - $cmake_src_path`) - -println("Running cmake") -run(`$(CMake.cmake) --build .`) - -rm(localprefixpath, recursive = true, force = true) -run(`$(CMake.cmake) --install .`) - -include("parselibs.jl") - diff --git a/deps/src/xcodetypeinfo/CMakeLists.txt b/deps/src/xcodetypeinfo/CMakeLists.txt deleted file mode 100644 index 2c397b4db..000000000 --- a/deps/src/xcodetypeinfo/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -project(xcodetypeinfo) - -cmake_minimum_required(VERSION 3.01) - -find_package(JlCxx REQUIRED) - -get_target_property(JlCxx_location JlCxx::cxxwrap_julia LOCATION) -get_filename_component(JlCxx_location ${JlCxx_location} DIRECTORY) -set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${JlCxx_location}") - -add_library(hello SHARED hello.cpp) -target_link_libraries(hello JlCxx::cxxwrap_julia) diff --git a/deps/src/xcodetypeinfo/hello.cpp b/deps/src/xcodetypeinfo/hello.cpp deleted file mode 100644 index a19dbd18d..000000000 --- a/deps/src/xcodetypeinfo/hello.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include - -#include "jlcxx/jlcxx.hpp" - -std::string greet(const std::string& str) -{ - return "hello, world"; -} - -JLCXX_MODULE define_module_hello(jlcxx::Module& mod) -{ - mod.method("greet", &greet); -} From 2a2028dd110578c97832ff55adb0bbcc2e8b5a4d Mon Sep 17 00:00:00 2001 From: thofma Date: Sat, 29 Aug 2020 11:46:45 +0200 Subject: [PATCH 03/95] Create README.md --- deps/src/README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 deps/src/README.md diff --git a/deps/src/README.md b/deps/src/README.md new file mode 100644 index 000000000..c77b0bb79 --- /dev/null +++ b/deps/src/README.md @@ -0,0 +1,41 @@ +# libsingular-julia + +This is the C++ library accompanying [Singular.jl](https://github.com/oscar-system/Singular.jl). +It implements the C++ interface from julia to Singular using [CxxWrap.jl](https://github.com/JuliaInterop/CxxWrap.jl) and [libcxxwrap-julia](https://github.com/JuliaInterop/libcxxwrap-julia). + +For Singular.jl versions less than 0.3.2 this was included in Singular.jl but version 0.4 will probably use this library as a separate artifact. + +## Building + +Compiling `libsingular-julia` from source requires a C++ enabled compiler, a `libcxxwrap-julia` installation and a Singular installation. + +```bash +git clone https://github.com/oscar-system/libsingular-julia \ +cmake -DJulia_PREFIX=/home/user/path/to/julia \ + -DSingular_PREFIX=/home/user/path/to/singular + -DCMAKE_INSTALL_PREFIX=home/user/prefix/for/libsingular-julia \ + -DJlCxx_DIR=/home/user/path/to/libcxxwrap-julia/lib/cmake/JlCxx \ + -DCMAKE_BUILD_TYPE=Release \ + -S libsingular-julia -B build \ + +cmake --build build --config Release --target install -- -j${nproc} +``` + +### Overriding the default artifacts for Singular.jl + +Put the following into `~/.julia/artifacts/Overrides.toml` to replace the `libsingular-julia` artifact: + +```toml +[ae4fbd8f-ecdb-54f8-bbce-35570499b30e] +libingular_julia = "/home/user/prefix/for/libsingular-julia" +``` + +Overrides for `Singular` and `libcxxwrap-julia` with the directories used during the build need to be added as well, e.g.: + +```toml +[bcd08a7b-43d2-5ff7-b6d4-c458787f915c] +Singular = "/home/user/path/to/Singular" + +[3eaa8342-bff7-56a5-9981-c04077f7cee7] +libcxxwrap_julia = "/home/user/path/to/libcxxwrap-julia" +``` From ae99dde6a0b727761f756ed82f03c4de4d84c2c7 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 16 Oct 2020 21:53:37 +0200 Subject: [PATCH 04/95] Fix some signatures: use int64 instead of long --- deps/src/rings.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index 7496541e1..ac903d6cc 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -278,11 +278,11 @@ void singular_define_rings(jlcxx::Module & Singular) return p_Content(p, r); }); Singular.method("p_GetExpVL_internal", - [](spolyrec * p, long * ev, ip_sring * r) { + [](spolyrec * p, int64 * ev, ip_sring * r) { return p_GetExpVL(p, ev, r); }); Singular.method("p_GetExpVLV_internal", - [](spolyrec * p, long * ev, ip_sring * r) { + [](spolyrec * p, int64 * ev, ip_sring * r) { return p_GetExpVLV(p, ev, r); }); Singular.method("p_SetExpV_internal", @@ -290,11 +290,11 @@ void singular_define_rings(jlcxx::Module & Singular) return p_SetExpV(p, ev, r); }); Singular.method("p_SetExpVL_internal", - [](spolyrec * p, long * ev, ip_sring * r) { + [](spolyrec * p, int64 * ev, ip_sring * r) { return p_SetExpVL(p, ev, r); }); Singular.method("p_SetExpVLV_internal", - [](spolyrec * p, long * ev, long c, ip_sring * r) { + [](spolyrec * p, int64 * ev, int64 c, ip_sring * r) { return p_SetExpVLV(p, ev, c, r); }); Singular.method("p_Reduce", From 2bd593dae5ec1d7802bf0b03a7d501aa07d8dbd4 Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Mon, 30 Nov 2020 15:29:57 +0100 Subject: [PATCH 05/95] add id_LiftStd --- deps/src/ideals.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index c94c3db14..5cc01c201 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -227,6 +227,16 @@ void singular_define_ideals(jlcxx::Module & Singular) return std::make_tuple(res, rest); }); + Singular.method("id_LiftStd", [](ideal m, ring o) { + const ring origin = currRing; + rChangeCurrRing(o); + matrix ma=mpInit(1,1); + ideal syz=idInit(1,1); + ideal res = idLift(m, &ma, testHomog, &syz); + rChangeCurrRing(origin); + return std::make_tuple(res, ma, syz); + }); + Singular.method("id_Modulo", [](ideal a, ideal b, ring o) { const ring origin = currRing; rChangeCurrRing(o); From 2c3e5ff64dfc773a52d9d09a44b7e970452d7fa4 Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Tue, 1 Dec 2020 11:38:16 +0100 Subject: [PATCH 06/95] fix: id_LiftStd --- deps/src/ideals.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index 5cc01c201..5ebd6c925 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -230,9 +230,9 @@ void singular_define_ideals(jlcxx::Module & Singular) Singular.method("id_LiftStd", [](ideal m, ring o) { const ring origin = currRing; rChangeCurrRing(o); - matrix ma=mpInit(1,1); + matrix ma=mpNew(1,1); ideal syz=idInit(1,1); - ideal res = idLift(m, &ma, testHomog, &syz); + ideal res = idLiftStd(m, &ma, testHomog, &syz); rChangeCurrRing(origin); return std::make_tuple(res, ma, syz); }); From a34fae181b0a882ed619decb5fb35cbecf1ff529 Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Fri, 4 Dec 2020 20:42:00 +0100 Subject: [PATCH 07/95] Lift std (#4) * add id_LiftStd * fix: id_LiftStd Co-authored-by: thofma From 9d71a347d9b47d6736e3bd23a5e9db06e8f30e65 Mon Sep 17 00:00:00 2001 From: Claus Fieker Date: Mon, 7 Dec 2020 11:49:47 +0100 Subject: [PATCH 08/95] "fix" CmakeFile and add a build.jl (#5) * "fix" CmakeFile and add a build.jl which is not perfect (I don;t know what the conventions are) but it illustrates what to do * Update build.jl Co-authored-by: thofma --- deps/src/CMakeLists.txt | 6 +++--- deps/src/build.jl | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 deps/src/build.jl diff --git a/deps/src/CMakeLists.txt b/deps/src/CMakeLists.txt index 13c0be7a1..eb8d46470 100644 --- a/deps/src/CMakeLists.txt +++ b/deps/src/CMakeLists.txt @@ -37,10 +37,10 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${JlCxx_location}") message(STATUS "Found JlCxx at ${JlCxx_location}") include_directories(${CMAKE_INSTALL_PREFIX}) -include_directories(${CMAKE_INSTALL_PREFIX}/singular) +include_directories(${Singular_PREFIX}/include/singular) -SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g ${extra_cppflags} -I${CMAKE_INSTALL_PREFIX}/include -I${CMAKE_INSTALL_PREFIX}/include/singular" ) -SET( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -v -L${CMAKE_INSTALL_PREFIX}/lib -Wl,-rpath,${CMAKE_INSTALL_PREFIX}/lib" ) +SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g ${extra_cppflags} -I${CMAKE_INSTALL_PREFIX}/include -I${Singular_PREFIX}/include/ " ) +SET( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -v -L${CMAKE_INSTALL_PREFIX}/lib -Wl,-rpath,${CMAKE_INSTALL_PREFIX}/lib -L${Singular_PREFIX}/lib -Wl,-rpath,${Singular_PREFIX}/lib" ) add_library(${JLSINGULAR_TARGET} SHARED singular.cpp rings.cpp coeffs.cpp ideals.cpp matrices.cpp caller.cpp coeff_rings.cpp threading.cpp) diff --git a/deps/src/build.jl b/deps/src/build.jl new file mode 100644 index 000000000..0f48c1403 --- /dev/null +++ b/deps/src/build.jl @@ -0,0 +1,13 @@ +#cmake -DJulia_EXECUTABLE=/home/bla/Downloads/julia-1.5.3/bin/julia -DSingular_PREFIX=/home/bla/.julia/dev/Singular/deps/usr/ -DCMAKE_INSTALL_PREFIX=/tmp -DJlCxx_DIR=/home/bla/.julia/artifacts/860a8b2216bd059600ed7c44cdaa3bb81b23ff1c/lib/cmake/JlCxx -DCMAKE_BUILD_TYPE=Release -S libsingular-julia -B /tmp/build + +import Singular, CxxWrap + +Julia_EXECUTABLE = joinpath(Sys.BINDIR, Base.julia_exename()) +Singular_PREFIX = joinpath(dirname(pathof(Singular)), "..", "deps", "usr") +JlCxx_DIR = joinpath(CxxWrap.CxxWrapCore.libcxxwrap_julia_jll.artifact_dir, "lib", "cmake", "JlCxx") + +cm = `cmake -DJulia_EXECUTABLE=$(Julia_EXECUTABLE) -DSingular_PREFIX=$(Singular_PREFIX) -DCMAKE_INSTALL_PREFIX=/tmp -DJlCxx_DIR=$(JlCxx_DIR) -DCMAKE_BUILD_TYPE=Release -S libsingular-julia -B /tmp/build` + +run(cm) + +run(`cmake --build /tmp/build --config Release --target install`) From 4bef5663f1be6933252b43a661171fd5c53ee5d0 Mon Sep 17 00:00:00 2001 From: Claus Fieker Date: Tue, 8 Dec 2020 09:31:32 +0100 Subject: [PATCH 09/95] better support fro lift_std (#6) - version with/out syzygies - add complete_reduction --- deps/src/ideals.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index 5ebd6c925..c54c3759b 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -227,12 +227,38 @@ void singular_define_ideals(jlcxx::Module & Singular) return std::make_tuple(res, rest); }); - Singular.method("id_LiftStd", [](ideal m, ring o) { + Singular.method("id_LiftStd", [](ideal m, ring o, bool complete_reduction = false) { + const ring origin = currRing; + rChangeCurrRing(o); + matrix ma=mpNew(1,1); + unsigned int crbit; + if (complete_reduction) + crbit = Sy_bit(OPT_REDSB); + else + crbit = 0; + unsigned int save_opt = si_opt_1; + si_opt_1 |= crbit; + ideal res = idLiftStd(m, &ma, testHomog, NULL); + si_opt_1 = save_opt; + rChangeCurrRing(origin); + return std::make_tuple(res, ma); + }); + + Singular.method("id_LiftStdSyz", [](ideal m, ring o, bool complete_reduction = false) { const ring origin = currRing; rChangeCurrRing(o); matrix ma=mpNew(1,1); ideal syz=idInit(1,1); + unsigned int crbit; + if (complete_reduction) + crbit = Sy_bit(OPT_REDSB); + else + crbit = 0; + unsigned int save_opt = si_opt_1; + si_opt_1 |= crbit; ideal res = idLiftStd(m, &ma, testHomog, &syz); + si_opt_1 = save_opt; + rChangeCurrRing(origin); return std::make_tuple(res, ma, syz); }); From 17ac86ee8ffd53b0fca7d18e70822ce09179faa5 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 21 Dec 2020 23:10:04 +0100 Subject: [PATCH 10/95] Improve build.jl --- deps/src/CMakeLists.txt | 6 ++---- deps/src/README.md | 2 +- deps/src/build.jl | 27 ++++++++++++++++++--------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/deps/src/CMakeLists.txt b/deps/src/CMakeLists.txt index eb8d46470..61be461cf 100644 --- a/deps/src/CMakeLists.txt +++ b/deps/src/CMakeLists.txt @@ -24,8 +24,6 @@ if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0 SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-conversion" ) endif() -SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++14" ) - # to avoid lib64 dirs as binarybuilder uses lib everywhere set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") set(CMAKE_INSTALL_LIBDIR "lib") @@ -39,8 +37,8 @@ message(STATUS "Found JlCxx at ${JlCxx_location}") include_directories(${CMAKE_INSTALL_PREFIX}) include_directories(${Singular_PREFIX}/include/singular) -SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g ${extra_cppflags} -I${CMAKE_INSTALL_PREFIX}/include -I${Singular_PREFIX}/include/ " ) -SET( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -v -L${CMAKE_INSTALL_PREFIX}/lib -Wl,-rpath,${CMAKE_INSTALL_PREFIX}/lib -L${Singular_PREFIX}/lib -Wl,-rpath,${Singular_PREFIX}/lib" ) +SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g ${extra_cppflags} -I${CMAKE_INSTALL_PREFIX}/include -I${Singular_PREFIX}/include/" ) +SET( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -v ${extra_ldflags} -L${CMAKE_INSTALL_PREFIX}/lib -Wl,-rpath,${CMAKE_INSTALL_PREFIX}/lib -L${Singular_PREFIX}/lib -Wl,-rpath,${Singular_PREFIX}/lib" ) add_library(${JLSINGULAR_TARGET} SHARED singular.cpp rings.cpp coeffs.cpp ideals.cpp matrices.cpp caller.cpp coeff_rings.cpp threading.cpp) diff --git a/deps/src/README.md b/deps/src/README.md index c77b0bb79..34a50ede6 100644 --- a/deps/src/README.md +++ b/deps/src/README.md @@ -27,7 +27,7 @@ Put the following into `~/.julia/artifacts/Overrides.toml` to replace the `libsi ```toml [ae4fbd8f-ecdb-54f8-bbce-35570499b30e] -libingular_julia = "/home/user/prefix/for/libsingular-julia" +libsingular_julia = "/home/user/prefix/for/libsingular-julia" ``` Overrides for `Singular` and `libcxxwrap-julia` with the directories used during the build need to be added as well, e.g.: diff --git a/deps/src/build.jl b/deps/src/build.jl index 0f48c1403..f9e8a9b4b 100644 --- a/deps/src/build.jl +++ b/deps/src/build.jl @@ -1,13 +1,22 @@ -#cmake -DJulia_EXECUTABLE=/home/bla/Downloads/julia-1.5.3/bin/julia -DSingular_PREFIX=/home/bla/.julia/dev/Singular/deps/usr/ -DCMAKE_INSTALL_PREFIX=/tmp -DJlCxx_DIR=/home/bla/.julia/artifacts/860a8b2216bd059600ed7c44cdaa3bb81b23ff1c/lib/cmake/JlCxx -DCMAKE_BUILD_TYPE=Release -S libsingular-julia -B /tmp/build +import Singular_jll, CxxWrap -import Singular, CxxWrap +# TODO: use ARGS to specify custom build dir? +builddir = "build" +installdir = abspath("install") +JlCxx_DIR = joinpath(CxxWrap.prefix_path(), "lib", "cmake", "JlCxx") -Julia_EXECUTABLE = joinpath(Sys.BINDIR, Base.julia_exename()) -Singular_PREFIX = joinpath(dirname(pathof(Singular)), "..", "deps", "usr") -JlCxx_DIR = joinpath(CxxWrap.CxxWrapCore.libcxxwrap_julia_jll.artifact_dir, "lib", "cmake", "JlCxx") +rm(builddir; force=true, recursive=true) -cm = `cmake -DJulia_EXECUTABLE=$(Julia_EXECUTABLE) -DSingular_PREFIX=$(Singular_PREFIX) -DCMAKE_INSTALL_PREFIX=/tmp -DJlCxx_DIR=$(JlCxx_DIR) -DCMAKE_BUILD_TYPE=Release -S libsingular-julia -B /tmp/build` +run(`cmake + -DJulia_EXECUTABLE=$(joinpath(Sys.BINDIR, Base.julia_exename())) + -Dextra_cppflags=-I$(Singular_jll.GMP_jll.artifact_dir)/include + -Dextra_ldflags=-L$(Singular_jll.GMP_jll.artifact_dir)/lib + -DSingular_PREFIX=$(Singular_jll.artifact_dir) + -DCMAKE_INSTALL_PREFIX=$(installdir) + -DJlCxx_DIR=$(JlCxx_DIR) + -DCMAKE_BUILD_TYPE=Release + -S . + -B $(builddir) +`) -run(cm) - -run(`cmake --build /tmp/build --config Release --target install`) +run(`cmake --build $(builddir) --config Release --target install -- -j$(Sys.CPU_THREADS)`) From a90c03eaea98de12ab5420e282d782f411d7eed7 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 9 Jan 2021 11:04:47 +0100 Subject: [PATCH 11/95] Remove n_Delete_Q (#7) ... it is identical to n_Delete --- deps/src/coeffs.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/deps/src/coeffs.cpp b/deps/src/coeffs.cpp index 2f00e9f28..e5777db80 100644 --- a/deps/src/coeffs.cpp +++ b/deps/src/coeffs.cpp @@ -81,12 +81,6 @@ void singular_define_coeffs(jlcxx::Module & Singular) } }); - Singular.method("n_Delete_Q", [](snumber * n, coeffs cf) { - if (n != NULL) { - n_Delete(&n, cf); - } - }); - Singular.method("n_Write_internal", [](snumber * x, coeffs cf, const int d) { return n_Write(x, cf, d); From 98eac5cf8b7291d0baa51448ec2d71330aab073a Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 9 Jan 2021 11:06:03 +0100 Subject: [PATCH 12/95] Make n_InpMult actually useful (#8) ... by letting it return its result, instead of void. --- deps/src/coeffs.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/deps/src/coeffs.cpp b/deps/src/coeffs.cpp index e5777db80..851236837 100644 --- a/deps/src/coeffs.cpp +++ b/deps/src/coeffs.cpp @@ -170,15 +170,14 @@ void singular_define_coeffs(jlcxx::Module & Singular) }); Singular.method("n_InpAdd", [](snumber * x, snumber * y, const coeffs n) { - snumber * xx = x; - n_InpAdd(xx, y, n); - return xx; + n_InpAdd(x, y, n); + return x; }); - Singular.method("n_InpMult", - [](snumber * x, snumber * y, const coeffs n) { - return n_InpMult(x, y, n); - }); + Singular.method("n_InpMult", [](snumber * x, snumber * y, const coeffs n) { + n_InpMult(x, y, n); + return x; + }); Singular.method("n_QuotRem_internal", [](snumber * x, snumber * y, void * p, const coeffs n) { From c5299a8c1c3312f331a639e74644668bd9cc7012 Mon Sep 17 00:00:00 2001 From: tthsqe12 Date: Wed, 13 Jan 2021 16:35:14 +0100 Subject: [PATCH 13/95] more functions for ring identification (#9) --- deps/src/coeffs.cpp | 27 +++++++++++++++++++++++++++ deps/src/rings.cpp | 10 ++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/deps/src/coeffs.cpp b/deps/src/coeffs.cpp index 851236837..f517f3afc 100644 --- a/deps/src/coeffs.cpp +++ b/deps/src/coeffs.cpp @@ -39,6 +39,25 @@ void singular_define_coeffs(jlcxx::Module & Singular) /* get the characteristic of a coefficient domain */ Singular.method("n_GetChar", [](coeffs n) { return n_GetChar(n); }); + /* only used to get the order of a N_GField */ + Singular.method("nfCharQ", [](coeffs n) {return n->m_nfCharQ;}); + + Singular.method("nCoeff_is_Zp", [](coeffs n) { + return bool(nCoeff_is_Zp(n)); + }); + + Singular.method("nCoeff_is_Q", [](coeffs n) { + return bool(nCoeff_is_Q(n)); + }); + + Singular.method("nCoeff_is_GF", [](coeffs n) { + return bool(nCoeff_is_GF(n)); + }); + + Singular.method("nCoeff_is_transExt", [](coeffs n) { + return bool(nCoeff_is_transExt(n)); + }); + /* make a copy of a coefficient domain (actually just increments a * reference count) */ Singular.method("nCopyCoeff", &nCopyCoeff); @@ -204,6 +223,14 @@ void singular_define_coeffs(jlcxx::Module & Singular) Singular.method("n_Param", [](int x, const coeffs n) { return n_Param(x, n); }); + Singular.method("n_NumberOfParameters", [](coeffs r) { + return n_NumberOfParameters(r); + }); + + Singular.method("n_ParameterName", [](int i, coeffs r) { + return std::string(n_ParameterNames(r)[i]); + }); + Singular.method("StringSetS_internal", [](std::string m) { return StringSetS(m.c_str()); }); diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index ac903d6cc..c47a21b75 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -91,15 +91,21 @@ void singular_define_rings(jlcxx::Module & Singular) Singular.method("rChar", &rChar); Singular.method("rGetVar", &rGetVar); Singular.method("rVar", &rVar); + Singular.method("rRingVar", [](short i, const ring r) { + return std::string(rRingVar(i, r)); + }); Singular.method("rGetExpSize", [](unsigned long bitmask, int N) { int bits; return static_cast(rGetExpSize(bitmask, bits, N)); }); + Singular.method("rCoeffPtr", [](ring r){return r->cf;}); Singular.method("rHasGlobalOrdering", &rHasGlobalOrdering); Singular.method("rHasMixedOrdering", &rHasMixedOrdering); + Singular.method("rRing_ord_pure_dp", &rRing_ord_pure_dp); + Singular.method("rRing_ord_pure_Dp", &rRing_ord_pure_Dp); + Singular.method("rRing_ord_pure_lp", &rRing_ord_pure_lp); Singular.method("rIsQuotientRing", [](ring r) { - - return r->qideal != NULL; + return r->qideal != NULL; }); Singular.method("rQuotientRing", [](ideal i, ring r) { ring Q = rCopy(r); From 181691e8cb21ab97fed9a0bf3e8bfac33cfc7e86 Mon Sep 17 00:00:00 2001 From: raulepure Date: Wed, 10 Feb 2021 19:32:22 +0100 Subject: [PATCH 14/95] First try on conversion of Singular.jl arrays to Singular lists (#10) * First try on conversion of Singular.jl arrays to Singular lists Added a first try on conversion of Singular.jl arrays to Singular lists in order to be able to call more Singular libraries in Singular.jl * Fixed type. Changed name of function. --- deps/src/caller.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/deps/src/caller.cpp b/deps/src/caller.cpp index 5672cda07..b580ebe8e 100644 --- a/deps/src/caller.cpp +++ b/deps/src/caller.cpp @@ -160,6 +160,21 @@ void * jl_array_to_intmat(jl_value_t * array_val) return reinterpret_cast(result); } +lists jl_array_to_list_helper(jl_value_t * args_val, jl_value_t * types_val) +{ + jl_array_t * args = reinterpret_cast(args_val); + jl_array_t * types = reinterpret_cast(types_val); + int size = jl_array_len(args); + lists result = (lists)omAllocBin(slists_bin); + result->Init(size); + + for (int i = 0; i < size; i++) { + result->m[i].rtyp = static_cast(jl_unbox_int64(jl_arrayref(types, i))); + result->m[i].data = jl_unbox_voidpointer(jl_arrayref(args, i)); + } + return result; +} + static void * get_ring_ref(ring r) { // Since a call to a Singular library function destroys its arguments, @@ -374,6 +389,15 @@ void singular_define_caller(jlcxx::Module & Singular) Singular.method("jl_array_to_intvec", &jl_array_to_intvec); Singular.method("jl_array_to_intmat", &jl_array_to_intmat); Singular.method("copy_string_to_void", ©_string_to_void); + Singular.method("jl_array_to_void", [] (jl_value_t * args_val, + jl_value_t * types_val, + ring R) { + auto origin = currRing; + rChangeCurrRing(R); + lists l = jl_array_to_list_helper(args_val, types_val); + rChangeCurrRing(origin); + return (void *) l; + }); Singular.method("create_syStrategy_data", &create_syStrategy_data); From 46b689814e513aba0c04d05c1a8ee8e17a6d41d6 Mon Sep 17 00:00:00 2001 From: tthsqe12 Date: Wed, 10 Feb 2021 19:32:50 +0100 Subject: [PATCH 15/95] getting and setting the minpoly (#11) * getting and setting the minpoly * fix minpoly functions --- deps/src/coeffs.cpp | 127 ++++++++++++++++++++++++++++++++++++++++++++ deps/src/rings.cpp | 3 ++ 2 files changed, 130 insertions(+) diff --git a/deps/src/coeffs.cpp b/deps/src/coeffs.cpp index f517f3afc..6683bac23 100644 --- a/deps/src/coeffs.cpp +++ b/deps/src/coeffs.cpp @@ -39,6 +39,129 @@ void singular_define_coeffs(jlcxx::Module & Singular) /* get the characteristic of a coefficient domain */ Singular.method("n_GetChar", [](coeffs n) { return n_GetChar(n); }); + /* + given F = R(x), a univariate function field over R = QQ or Fp, + construct the number field R[x]/minpoly. + Return a new coefficient ring or a copy of the old one in case of error. + Thus, the return should be checked to see if it is a number field + (nCoeff_is_algExt) before use. + + TODO: this will be in the kernel soon + */ + Singular.method("transExt_SetMinpoly", [](coeffs F, number a) { + + if (!nCoeff_is_transExt(F) || rVar(F->extRing) != 1) + { + WerrorS("cannot set minpoly for these coeffients"); + return nCopyCoeff(F); + } + + BOOLEAN redefine_from_algext = FALSE; + + number p = n_Copy(a, F); + n_Normalize(p, F); + + if (n_IsZero(p, F)) + { + n_Delete(&p, F); + return nCopyCoeff(F); + } + + AlgExtInfo A; + + A.r = rCopy(F->extRing); // Copy ground field! + // if minpoly was already set: + if (F->extRing->qideal != NULL) + id_Delete(&A.r->qideal, A.r); + ideal q = idInit(1,1); + if (p == NULL || NUM((fraction)p) == NULL) + { + WerrorS("Could not construct the alg. extension: minpoly==0"); + // cleanup A: TODO + rDelete( A.r ); + return nCopyCoeff(F); + } + if (!redefine_from_algext && (DEN((fraction)(p)) != NULL)) // minpoly must be a fraction with poly numerator...!! + { + poly n = DEN((fraction)(p)); + if (!p_IsConstantPoly(n, F->extRing)) + { + WarnS("denominator must be constant - ignoring it"); + } + p_Delete(&n, F->extRing); + DEN((fraction)(p)) = NULL; + } + + if (redefine_from_algext) + q->m[0] = (poly)p; + else + q->m[0] = NUM((fraction)p); + A.r->qideal = q; + + // :( + // NUM((fractionObject *)p) = NULL; // makes 0/ NULL fraction - which should not happen! + // n_Delete(&p, r->F); // doesn't expect 0/ NULL :( + if (!redefine_from_algext) + { + EXTERN_VAR omBin fractionObjectBin; + NUM((fractionObject *)p) = NULL; // not necessary, but still... + omFreeBin((ADDRESS)p, fractionObjectBin); + } + + coeffs K = nInitChar(n_algExt, &A); + if (K == NULL) + { + WerrorS("Could not construct the alg. extension: llegal minpoly?"); + // cleanup A: TODO + rDelete(A.r); + return nCopyCoeff(F); + } + else + { + return K; + } + }); + + /* + if K = R[x]/minpoly(x) (with nCoeff_is_algExt(cf) = true), + return the corresponding transcendental extension R(x): this is the + parent of minpoly. + */ + Singular.method("algExt_UnsetMinpoly", [](coeffs K) { + if (nCoeff_is_algExt(K) && !nCoeff_is_GF(K)) + { + ring K0 = rCopy0(K->extRing, FALSE, TRUE); + rComplete(K0); + TransExtInfo e; + e.r = K0; + coeffs F = nInitChar(n_transExt, &e); + return F; + } + else + { + WerrorS("cannot unset minpoly for these coeffients"); + return nCopyCoeff(K); + } + }); + + /* + Given K = R[x]/minpoly(x) and the corresponding F = R(x) return + the minpoly as an element of F. + */ + Singular.method("algExt_GetMinpoly", [](coeffs K, coeffs F) { + if (nCoeff_is_algExt(K) && !nCoeff_is_GF(K)) + { + nMapFunc nMap = n_SetMap(K, F); + number minpoly = reinterpret_cast(K->extRing->qideal->m[0]); + return nMap(minpoly, K, F); + } + else + { + WerrorS("cannot get minpoly for these coeffients"); + return n_Init(0, F); + } + }); + /* only used to get the order of a N_GField */ Singular.method("nfCharQ", [](coeffs n) {return n->m_nfCharQ;}); @@ -58,6 +181,10 @@ void singular_define_coeffs(jlcxx::Module & Singular) return bool(nCoeff_is_transExt(n)); }); + Singular.method("nCoeff_is_algExt", [](coeffs n) { + return bool(nCoeff_is_algExt(n)); + }); + /* make a copy of a coefficient domain (actually just increments a * reference count) */ Singular.method("nCopyCoeff", &nCopyCoeff); diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index c47a21b75..a6eeb76f6 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -107,6 +107,9 @@ void singular_define_rings(jlcxx::Module & Singular) Singular.method("rIsQuotientRing", [](ring r) { return r->qideal != NULL; }); + Singular.method("rCopy", [](ring r) { + return rCopy(r); + }); Singular.method("rQuotientRing", [](ideal i, ring r) { ring Q = rCopy(r); Q->qideal = id_Copy(i, r); From cf08dd2e2e09ad32bb4f450f046d366ac3cbd3a0 Mon Sep 17 00:00:00 2001 From: thofma Date: Thu, 11 Feb 2021 15:11:25 +0100 Subject: [PATCH 16/95] Update README.md From fa0073d3df495bca6f145d6c1107f5d400278f15 Mon Sep 17 00:00:00 2001 From: tthsqe12 Date: Fri, 5 Mar 2021 13:10:19 +0100 Subject: [PATCH 17/95] Update README.md From 0e0e88a09cca7c99b0a29a0b868c2b3d5077476d Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Thu, 11 Mar 2021 13:19:59 +0100 Subject: [PATCH 18/95] add irrCharSeries (#13) --- deps/src/matrices.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deps/src/matrices.cpp b/deps/src/matrices.cpp index 4271a2a50..2761e85fa 100644 --- a/deps/src/matrices.cpp +++ b/deps/src/matrices.cpp @@ -46,6 +46,8 @@ void singular_define_matrices(jlcxx::Module & Singular) return mp_InitP(n, n, p_Copy(p, R), R); }); + Singular.method("irrCharSeries", &singclap_irrCharSeries); + Singular.method("iiStringMatrix", [](matrix I, int d, ring o) { auto str_ptr = iiStringMatrix(I, d, o); std::string s(iiStringMatrix(I, d, o)); From 1bf7e1923b1d91c9bb78d71a18df052801f933c1 Mon Sep 17 00:00:00 2001 From: tthsqe12 Date: Fri, 12 Mar 2021 15:41:18 +0100 Subject: [PATCH 19/95] add some options capabilities (#12) --- deps/src/singular.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/deps/src/singular.cpp b/deps/src/singular.cpp index 0bdc4b963..61ea7b4ff 100644 --- a/deps/src/singular.cpp +++ b/deps/src/singular.cpp @@ -75,6 +75,68 @@ JLCXX_MODULE define_julia_module(jlcxx::Module & Singular) return SINGULAR_VERSION; }); +#define SETTER(A, B) \ + else if (opt == #B) \ + A = value ? (A | Sy_bit(B)) : (A & ~Sy_bit(B)); + + Singular.method("set_option", [](std::string opt, bool value) { + if (false); + SETTER(si_opt_2, V_QUIET) + SETTER(si_opt_2, V_QRING) + SETTER(si_opt_2, V_SHOW_MEM) + SETTER(si_opt_2, V_YACC) + SETTER(si_opt_2, V_REDEFINE) + SETTER(si_opt_2, V_LOAD_LIB) + SETTER(si_opt_2, V_DEBUG_LIB) + SETTER(si_opt_2, V_LOAD_PROC) + SETTER(si_opt_2, V_DEF_RES) + SETTER(si_opt_2, V_SHOW_USE) + SETTER(si_opt_2, V_IMAP) + SETTER(si_opt_2, V_PROMPT) + SETTER(si_opt_2, V_NSB) + SETTER(si_opt_2, V_CONTENTSB) + SETTER(si_opt_2, V_CANCELUNIT) + SETTER(si_opt_2, V_MODPSOLVSB) + SETTER(si_opt_2, V_UPTORADICAL) + SETTER(si_opt_2, V_FINDMONOM) + SETTER(si_opt_2, V_COEFSTRAT) + SETTER(si_opt_2, V_IDLIFT) + SETTER(si_opt_2, V_LENGTH) + SETTER(si_opt_2, V_ALLWARN) + SETTER(si_opt_2, V_INTERSECT_ELIM) + SETTER(si_opt_2, V_INTERSECT_SYZ) + SETTER(si_opt_2, V_DEG_STOP) + + SETTER(si_opt_1, OPT_PROT) + SETTER(si_opt_1, OPT_REDSB) + SETTER(si_opt_1, OPT_NOT_BUCKETS) + SETTER(si_opt_1, OPT_NOT_SUGAR) + SETTER(si_opt_1, OPT_INTERRUPT) + SETTER(si_opt_1, OPT_SUGARCRIT) + SETTER(si_opt_1, OPT_DEBUG) + SETTER(si_opt_1, OPT_REDTHROUGH) + SETTER(si_opt_1, OPT_NO_SYZ_MINIM) + SETTER(si_opt_1, OPT_RETURN_SB) + SETTER(si_opt_1, OPT_FASTHC) + SETTER(si_opt_1, OPT_OLDSTD) + SETTER(si_opt_1, OPT_STAIRCASEBOUND) + SETTER(si_opt_1, OPT_MULTBOUND) + SETTER(si_opt_1, OPT_DEGBOUND) + SETTER(si_opt_1, OPT_REDTAIL) + SETTER(si_opt_1, OPT_INTSTRATEGY) + SETTER(si_opt_1, OPT_FINDET) + SETTER(si_opt_1, OPT_INFREDTAIL) + SETTER(si_opt_1, OPT_SB_1) + SETTER(si_opt_1, OPT_NOTREGULARITY) + SETTER(si_opt_1, OPT_WEIGHTM) + }); + +#undef SETTER + + Singular.method("set_printlevel", [](int level) { + printlevel = level; + }); + singular_define_coeffs(Singular); singular_define_rings(Singular); singular_define_ideals(Singular); From b8128eb7ec9d729484adca0ed726327c22f99ec8 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 12 Mar 2021 14:15:45 +0100 Subject: [PATCH 20/95] Add very simple CI test --- deps/src/.github/workflows/CI.yml | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 deps/src/.github/workflows/CI.yml diff --git a/deps/src/.github/workflows/CI.yml b/deps/src/.github/workflows/CI.yml new file mode 100644 index 000000000..7ebc03ae6 --- /dev/null +++ b/deps/src/.github/workflows/CI.yml @@ -0,0 +1,42 @@ +name: Run tests + +# Trigger the workflow on push or pull request +on: [push, pull_request] + +jobs: + test: + # Don't run this twice on PRs for branches pushed to the same repository + if: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) }} + + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + julia-version: + - '1.3' + - '1.4' + - '1.5' + - '1.6-nightly' + - 'nightly' + os: + - ubuntu-latest + - macOS-latest + + steps: + - uses: actions/checkout@v2 + - name: "Set up Julia" + uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.julia-version }} + - name: "Install dependencies" + run: | + if [ "$RUNNER_OS" == "Linux" ]; then + sudo apt install cmake + elif [ "$RUNNER_OS" == "macOS" ]; then + brew install cmake libgmp-dev + else + echo "$RUNNER_OS not supported" + exit 1 + fi + - run: julia -e 'using Pkg ; Pkg.add(["Singular_jll", "CxxWrap"])' + - run: julia build.jl From c625dd967454d1e35b4024fc19fa84f3b66809ff Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 12 Mar 2021 17:21:48 +0100 Subject: [PATCH 21/95] Fix the CI on macOS (oops) --- deps/src/.github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/src/.github/workflows/CI.yml b/deps/src/.github/workflows/CI.yml index 7ebc03ae6..b7f3d049a 100644 --- a/deps/src/.github/workflows/CI.yml +++ b/deps/src/.github/workflows/CI.yml @@ -33,7 +33,7 @@ jobs: if [ "$RUNNER_OS" == "Linux" ]; then sudo apt install cmake elif [ "$RUNNER_OS" == "macOS" ]; then - brew install cmake libgmp-dev + brew install cmake gmp else echo "$RUNNER_OS not supported" exit 1 From b4770e24988a4b395723f71ed44c147c0aa0d944 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 12 Mar 2021 17:29:02 +0100 Subject: [PATCH 22/95] Use CMake.jl to get cmake --- deps/src/.github/workflows/CI.yml | 7 ++++--- deps/src/.gitignore | 2 ++ deps/src/build.jl | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 deps/src/.gitignore diff --git a/deps/src/.github/workflows/CI.yml b/deps/src/.github/workflows/CI.yml index b7f3d049a..24ef58ad5 100644 --- a/deps/src/.github/workflows/CI.yml +++ b/deps/src/.github/workflows/CI.yml @@ -31,12 +31,13 @@ jobs: - name: "Install dependencies" run: | if [ "$RUNNER_OS" == "Linux" ]; then - sudo apt install cmake + : elif [ "$RUNNER_OS" == "macOS" ]; then - brew install cmake gmp + # In Julia >= 1.6, GMP_jll does not include the GMP headers anymore... + brew install gmp else echo "$RUNNER_OS not supported" exit 1 fi - - run: julia -e 'using Pkg ; Pkg.add(["Singular_jll", "CxxWrap"])' + - run: julia -e 'using Pkg ; Pkg.add(["Singular_jll", "CxxWrap", "CMake"])' - run: julia build.jl diff --git a/deps/src/.gitignore b/deps/src/.gitignore new file mode 100644 index 000000000..0ba45dd34 --- /dev/null +++ b/deps/src/.gitignore @@ -0,0 +1,2 @@ +/build/ +/install/ diff --git a/deps/src/build.jl b/deps/src/build.jl index f9e8a9b4b..a43a923e7 100644 --- a/deps/src/build.jl +++ b/deps/src/build.jl @@ -1,4 +1,4 @@ -import Singular_jll, CxxWrap +import Singular_jll, CxxWrap, CMake # TODO: use ARGS to specify custom build dir? builddir = "build" @@ -7,7 +7,7 @@ JlCxx_DIR = joinpath(CxxWrap.prefix_path(), "lib", "cmake", "JlCxx") rm(builddir; force=true, recursive=true) -run(`cmake +run(`$(CMake.cmake) -DJulia_EXECUTABLE=$(joinpath(Sys.BINDIR, Base.julia_exename())) -Dextra_cppflags=-I$(Singular_jll.GMP_jll.artifact_dir)/include -Dextra_ldflags=-L$(Singular_jll.GMP_jll.artifact_dir)/lib @@ -19,4 +19,4 @@ run(`cmake -B $(builddir) `) -run(`cmake --build $(builddir) --config Release --target install -- -j$(Sys.CPU_THREADS)`) +run(`$(CMake.cmake) --build $(builddir) --config Release --target install -- -j$(Sys.CPU_THREADS)`) From a268a38a6c0f11454694d60ba961278a130afcce Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 12 Mar 2021 17:33:18 +0100 Subject: [PATCH 23/95] CI: allow errors with nightly Julia versions --- deps/src/.github/workflows/CI.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/deps/src/.github/workflows/CI.yml b/deps/src/.github/workflows/CI.yml index 24ef58ad5..25674f1f5 100644 --- a/deps/src/.github/workflows/CI.yml +++ b/deps/src/.github/workflows/CI.yml @@ -9,6 +9,7 @@ jobs: if: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) }} runs-on: ${{ matrix.os }} + continue-on-error: ${{ endsWith(matrix.julia-version, 'nightly') }} strategy: fail-fast: false matrix: From 71bf7d08973d044cc6b491fe553938eee4f51feb Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 12 Mar 2021 17:42:35 +0100 Subject: [PATCH 24/95] Add run.jl helper: run Julia with artifacts override To use this, you can start it inside the `libsingular-julia` directory via julia --project=. run.jl and it will first install a few Julia packages, then build all C++ code, and finally start a Julia session with an artifact override in place which ensures that `libsingular_julia_jll` picks up the copy of the C++ code that was just compiled. To verify the override is in effect, check the value of `libsingular_julia_jll.artifact_dir`. You can now e.g. `Pkg.add("Singular")` and then `Pkg.test("Singular")`; or do `using Singular` to test Singular interactively. --- deps/src/.github/workflows/CI.yml | 5 +++- deps/src/README.md | 47 +++++++++++++++++++++++++++++-- deps/src/run.jl | 35 +++++++++++++++++++++++ 3 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 deps/src/run.jl diff --git a/deps/src/.github/workflows/CI.yml b/deps/src/.github/workflows/CI.yml index 25674f1f5..111d8ec50 100644 --- a/deps/src/.github/workflows/CI.yml +++ b/deps/src/.github/workflows/CI.yml @@ -41,4 +41,7 @@ jobs: exit 1 fi - run: julia -e 'using Pkg ; Pkg.add(["Singular_jll", "CxxWrap", "CMake"])' - - run: julia build.jl + # TODO: install development version of Singular instead of master... + - run: julia -e 'using Pkg ; Pkg.add(PackageSpec(url="https://github.com/oscar-system/Singular.jl", rev="master"))' + - run: julia run.jl -e 'using Pkg ; Pkg.test("Singular")' + # TODO: could collect coverage data and upload it to Codecov diff --git a/deps/src/README.md b/deps/src/README.md index 34a50ede6..f0aeda51f 100644 --- a/deps/src/README.md +++ b/deps/src/README.md @@ -3,11 +3,47 @@ This is the C++ library accompanying [Singular.jl](https://github.com/oscar-system/Singular.jl). It implements the C++ interface from julia to Singular using [CxxWrap.jl](https://github.com/JuliaInterop/CxxWrap.jl) and [libcxxwrap-julia](https://github.com/JuliaInterop/libcxxwrap-julia). -For Singular.jl versions less than 0.3.2 this was included in Singular.jl but version 0.4 will probably use this library as a separate artifact. +This library is compiled into a Julia artifact and shipped to the user via +the Julia JLL package +[libsingular_julia_jll](https://github.com/JuliaBinaryWrappers/libsingular_julia_jll.jl). +This JLL package in turn is generated from the sources in this repository and +the build recipe at +. + + +## Quick way to test changes in here + +To test changes you make to the C++ code here, the quickest way is to use the +`run.jl` script bundled in this repository. As a prerequisite, you need a +working C++ compiler and of course Julia. + +Start Julia from this repository as follows: + + julia --project=. run.jl + +This will install a few required Julia packages then build all C++ code, and +finally start a Julia session with an artifact override in place which ensures +that libsingular_julia_jll picks up the copy of the C++ code that was just +compiled. + +To verify the override works, check `libsingular_julia_jll.artifact_dir`; it +should point at a subdirectory of the current directory. + +You can then use the Julia package manager to install or dev `Singular.jl`, +and run its test suite or perform other tests. + ## Building -Compiling `libsingular-julia` from source requires a C++ enabled compiler, a `libcxxwrap-julia` installation and a Singular installation. +Compiling `libsingular-julia` from source requires a C++ enabled compiler. + +The easiest way to build it is to execute the Julia script `build.jl` (which +in turn is also used by `run.jl`). For this you need to execute it in a Julia +environment in which `Singular_jll` and `CxxWrap` are installed. + +Alternatively, you can also link it against your own `libcxxwrap-julia` +installation and a Singular installation, but this is more work; an +incantation like the following will do it: ```bash git clone https://github.com/oscar-system/libsingular-julia \ @@ -21,8 +57,12 @@ cmake -DJulia_PREFIX=/home/user/path/to/julia \ cmake --build build --config Release --target install -- -j${nproc} ``` + ### Overriding the default artifacts for Singular.jl +The `run.jl` script takes care of everything described below, but we document +it in case you need to do any of this manually for some reason. + Put the following into `~/.julia/artifacts/Overrides.toml` to replace the `libsingular-julia` artifact: ```toml @@ -30,7 +70,8 @@ Put the following into `~/.julia/artifacts/Overrides.toml` to replace the `libsi libsingular_julia = "/home/user/prefix/for/libsingular-julia" ``` -Overrides for `Singular` and `libcxxwrap-julia` with the directories used during the build need to be added as well, e.g.: +If you were using custom versions of `Singular` and/or `libcxxwrap-julia`, +then their directories used during the build need to be added as well, e.g.: ```toml [bcd08a7b-43d2-5ff7-b6d4-c458787f915c] diff --git a/deps/src/run.jl b/deps/src/run.jl new file mode 100644 index 000000000..cccec1244 --- /dev/null +++ b/deps/src/run.jl @@ -0,0 +1,35 @@ +# This script builds libsingular-julia, then starts a fresh Julia instances +# with an appropriate override set for e.g. running the test suite or whatever +# else you'd like. Arguments are passed on verbatim to the subprocess julia, +# so you can invokes this kinda like you'd invoke Julia + +@info "Install needed packages" +using Pkg +Pkg.add(["Singular_jll", "CxxWrap", "CMake", "libsingular_julia_jll"]) + +@info "Build libsingular-julia" +include("build.jl") + + +mktempdir() do tmpdepot + @info "Created temporary depot at $(tmpdepot)" + + # create override file for libsingular_julia_jll + uuid = string(Base.identify_package("libsingular_julia_jll").uuid) + mkpath(joinpath(tmpdepot, "artifacts")) + open(joinpath(tmpdepot, "artifacts", "Overrides.toml"), "w") do f + write(f, """ + [$(uuid)] + libsingular_julia = "$(installdir)" + """) + end + + # prepend our temporary depot to the depot list... + withenv("JULIA_DEPOT_PATH"=>tmpdepot*":") do + # ... and start Julia, by default with the same project environment + run(`$(Base.julia_cmd()) --project=$(Base.active_project()) $(ARGS)`) + + # TODO: perform some additional steps here, e.g. perhaps + # verify that `libsingular_julia_jll.artifact_dir` is set right? + end +end From f991094a7c7dd9f9cb375473d6c4b2778e4ff4e9 Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Thu, 6 May 2021 11:14:44 +0200 Subject: [PATCH 25/95] oscarci: add github_token to avoid rate limit --- deps/src/.github/workflows/oscar.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deps/src/.github/workflows/oscar.yml b/deps/src/.github/workflows/oscar.yml index c0b5e15e8..d71bb7c2e 100644 --- a/deps/src/.github/workflows/oscar.yml +++ b/deps/src/.github/workflows/oscar.yml @@ -12,6 +12,7 @@ jobs: matrix: ${{ steps.set-matrix.outputs.matrix }} env: PR_NUMBER: ${{github.event.number}} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v2.1.0 - name: "Set up Julia" @@ -47,6 +48,7 @@ jobs: continue-on-error: ${{ matrix.julia-version == 'nightly' }} env: PR_NUMBER: ${{github.event.number}} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} strategy: matrix: ${{fromJSON(needs.generatematrix.outputs.matrix)}} fail-fast: false From 0b0a4d8e3eeb5fc86b615ed1c3a258e8b52e9e1e Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 19 Mar 2021 15:27:05 +0100 Subject: [PATCH 26/95] Fix for Julia 1.6: ensure gmp.h is available --- deps/src/.github/workflows/CI.yml | 11 ----------- deps/src/build.jl | 30 +++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/deps/src/.github/workflows/CI.yml b/deps/src/.github/workflows/CI.yml index 111d8ec50..f64d11e1c 100644 --- a/deps/src/.github/workflows/CI.yml +++ b/deps/src/.github/workflows/CI.yml @@ -29,17 +29,6 @@ jobs: uses: julia-actions/setup-julia@v1 with: version: ${{ matrix.julia-version }} - - name: "Install dependencies" - run: | - if [ "$RUNNER_OS" == "Linux" ]; then - : - elif [ "$RUNNER_OS" == "macOS" ]; then - # In Julia >= 1.6, GMP_jll does not include the GMP headers anymore... - brew install gmp - else - echo "$RUNNER_OS not supported" - exit 1 - fi - run: julia -e 'using Pkg ; Pkg.add(["Singular_jll", "CxxWrap", "CMake"])' # TODO: install development version of Singular instead of master... - run: julia -e 'using Pkg ; Pkg.add(PackageSpec(url="https://github.com/oscar-system/Singular.jl", rev="master"))' diff --git a/deps/src/build.jl b/deps/src/build.jl index a43a923e7..7dec05f43 100644 --- a/deps/src/build.jl +++ b/deps/src/build.jl @@ -1,17 +1,41 @@ import Singular_jll, CxxWrap, CMake +using Singular_jll.GMP_jll, Pkg.Artifacts # TODO: use ARGS to specify custom build dir? builddir = "build" installdir = abspath("install") JlCxx_DIR = joinpath(CxxWrap.prefix_path(), "lib", "cmake", "JlCxx") +# In Julia >= 1.6, there is a "fake" GMP_jll which does not include header files; +# see +function gmp_artifact_dir() + artifacts_toml = joinpath(dirname(dirname(Base.pathof(GMP_jll))), "StdlibArtifacts.toml") + + # If this file exists, it's a stdlib JLL and we must download the artifact ourselves + if isfile(artifacts_toml) + meta = artifact_meta("GMP", artifacts_toml) + hash = Base.SHA1(meta["git-tree-sha1"]) + if !artifact_exists(hash) + dl_info = first(meta["download"]) + download_artifact(hash, dl_info["url"], dl_info["sha256"]) + end + return artifact_path(hash) + end + + # Otherwise, we can just use the artifact directory given to us by GMP_jll + return GMP_jll.find_artifact_dir() +end + +const gmp_prefix = gmp_artifact_dir() +const singular_prefix = Singular_jll.artifact_dir + rm(builddir; force=true, recursive=true) run(`$(CMake.cmake) -DJulia_EXECUTABLE=$(joinpath(Sys.BINDIR, Base.julia_exename())) - -Dextra_cppflags=-I$(Singular_jll.GMP_jll.artifact_dir)/include - -Dextra_ldflags=-L$(Singular_jll.GMP_jll.artifact_dir)/lib - -DSingular_PREFIX=$(Singular_jll.artifact_dir) + -Dextra_cppflags=-I$(gmp_prefix)/include + -Dextra_ldflags=-L$(gmp_prefix)/lib + -DSingular_PREFIX=$(singular_prefix) -DCMAKE_INSTALL_PREFIX=$(installdir) -DJlCxx_DIR=$(JlCxx_DIR) -DCMAKE_BUILD_TYPE=Release From ff3ac5a4eeeb0bb43fc557a72316c991abcf43d5 Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Thu, 6 May 2021 11:23:58 +0200 Subject: [PATCH 27/95] run.jl: show which libsingular_julia is in use --- deps/src/run.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/deps/src/run.jl b/deps/src/run.jl index cccec1244..49794afde 100644 --- a/deps/src/run.jl +++ b/deps/src/run.jl @@ -27,6 +27,7 @@ mktempdir() do tmpdepot # prepend our temporary depot to the depot list... withenv("JULIA_DEPOT_PATH"=>tmpdepot*":") do # ... and start Julia, by default with the same project environment + run(`$(Base.julia_cmd()) --project=$(Base.active_project()) -e "using Pkg; Pkg.instantiate(); using libsingular_julia_jll; println(\"using \"*libsingular_julia_jll.libsingular_julia);"`) run(`$(Base.julia_cmd()) --project=$(Base.active_project()) $(ARGS)`) # TODO: perform some additional steps here, e.g. perhaps From 889e2d90c61e7c06a23283865de7e3c446b84cd3 Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Fri, 19 Mar 2021 14:01:43 +0100 Subject: [PATCH 28/95] run OscarCI for downstream testing put all julia 1.6 tests to includes to avoid weird matrix-includes mixup --- deps/src/.github/workflows/oscar.yml | 88 ++++++++++++++++++++++++++++ deps/src/OscarCI.toml | 54 +++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 deps/src/.github/workflows/oscar.yml create mode 100644 deps/src/OscarCI.toml diff --git a/deps/src/.github/workflows/oscar.yml b/deps/src/.github/workflows/oscar.yml new file mode 100644 index 000000000..b6045f909 --- /dev/null +++ b/deps/src/.github/workflows/oscar.yml @@ -0,0 +1,88 @@ +name: OscarCI + +on: + pull_request: + branches: + - master + +jobs: + generatematrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + env: + PR_NUMBER: ${{github.event.number}} + steps: + - uses: actions/checkout@v2.1.0 + - name: "Set up Julia" + uses: julia-actions/setup-julia@v1 + with: + version: '~1.6.0-0' + - name: OscarDevTools - CI + if: github.repository == 'oscar-system/OscarDevTools.jl' + run: | + julia --project=oscar-dev -e "using Pkg; + Pkg.develop(PackageSpec(path=\".\")); + Pkg.instantiate();" + - name: fetch OscarDevTools + if: github.repository != 'oscar-system/OscarDevTools.jl' + run: | + julia --project=oscar-dev -e "using Pkg; + Pkg.add(PackageSpec(name=\"OscarDevTools\",version=\"0.2\")); + Pkg.instantiate();" + - id: set-matrix + run: | + julia --project=oscar-dev -e "using OscarDevTools.OscarCI; + ciprefs = parse_meta(\"OscarCI.toml\"); + cimat = ci_matrix(ciprefs; + pr=${PR_NUMBER}, + active_repo=\"${GITHUB_REPOSITORY}\"); + @show cimat; + println(github_json(cimat));" + + test-oscar: + needs: generatematrix + name: ${{ join(matrix.*.name) }} - ${{ matrix.os }}, julia ${{ matrix.julia-version}} + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.julia-version == 'nightly' }} + env: + PR_NUMBER: ${{github.event.number}} + strategy: + matrix: ${{fromJSON(needs.generatematrix.outputs.matrix)}} + fail-fast: false + + steps: + - uses: actions/checkout@v2.1.0 + - name: "Set up Julia" + uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.julia-version }} + - name: re-using OscarDevTools checkout + if: github.repository == 'oscar-system/OscarDevTools.jl' + run: | + julia --project=oscar-dev -e "using Pkg; + Pkg.develop(PackageSpec(path=\".\")); + Pkg.instantiate();" + - name: fetch OscarDevTools + if: github.repository != 'oscar-system/OscarDevTools.jl' + run: | + julia --project=oscar-dev -e "using Pkg; + Pkg.add(PackageSpec(name=\"OscarDevTools\",version=\"0.2\")); + Pkg.instantiate();" + - name: "Set up Oscar-dev configuration" + env: + MATRIX_CONTEXT: ${{ toJSON(matrix) }} + run: | + echo "$MATRIX_CONTEXT" + julia --project=oscar-dev -e "using OscarDevTools, OscarDevTools.OscarCI; + meta = job_meta_env(\"MATRIX_CONTEXT\"); + oscar_develop(job_pkgs(meta); + dir=\"oscar-dev\", + active_repo=\"${GITHUB_REPOSITORY}\"); + github_env_runtests(meta; + varname=\"oscar_run_tests\", + filename=\"${GITHUB_ENV}\");" + - name: "Run tests" + run: | + echo '${{ env.oscar_run_tests }}' + julia --project=oscar-dev/project/ run.jl -e '${{ env.oscar_run_tests }}' diff --git a/deps/src/OscarCI.toml b/deps/src/OscarCI.toml new file mode 100644 index 000000000..6655e2174 --- /dev/null +++ b/deps/src/OscarCI.toml @@ -0,0 +1,54 @@ +title = "metadata for oscar CI run" + +[env] +os = [ "ubuntu-latest", "macos-latest" ] +# 1.6 is done with some extra combinations in include +# also to avoid some weird behaviour by github actions which seems to merge +# the includes with the normal matrix entries +julia-version = [ "1.3", "1.4", "1.5", "nightly" ] +branches = [ "" ] + +[pkgs] + [pkgs.Singular] + test = true + testoptions = [] + + # will not add it to the matrix but enable testing for includes + [pkgs.Oscar] + test = true + branches = [] + +[include] + [include.matching] + Singular = "" + julia-version = "~1.6.0-0" + os = "ubuntu-latest" + + [include.matchingmac] + Singular = "" + julia-version = "~1.6.0-0" + os = "macos-latest" + + [include.oscar] + Oscar = "" + Singular = "" + julia-version = "~1.6.0-0" + os = "ubuntu-latest" + + [include.oscarmac] + Oscar = "" + Singular = "" + julia-version = "~1.6.0-0" + os = "macos-latest" + + [include.oscarstable] + Oscar = "release" + Singular = "release" + julia-version = "~1.6.0-0" + os = "ubuntu-latest" + + [include.oscarstablemac] + Oscar = "release" + Singular = "release" + julia-version = "~1.6.0-0" + os = "macos-latest" From 8ed31ca77f7c822691579727d2a4b56d9c104eea Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 24 Mar 2021 09:23:33 +0100 Subject: [PATCH 29/95] Avoid trivial wrappers --- deps/src/rings.cpp | 88 ++++++++++++---------------------------------- 1 file changed, 23 insertions(+), 65 deletions(-) diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index a6eeb76f6..6c8f0f998 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -107,9 +107,7 @@ void singular_define_rings(jlcxx::Module & Singular) Singular.method("rIsQuotientRing", [](ring r) { return r->qideal != NULL; }); - Singular.method("rCopy", [](ring r) { - return rCopy(r); - }); + Singular.method("rCopy", rCopy); Singular.method("rQuotientRing", [](ideal i, ring r) { ring Q = rCopy(r); Q->qideal = id_Copy(i, r); @@ -125,12 +123,9 @@ void singular_define_rings(jlcxx::Module & Singular) }); Singular.method("p_Copy", [](spolyrec * p, ip_sring * r) { return p_Copy(p, r); }); - Singular.method("p_IsOne", - [](spolyrec * p, ip_sring * r) { return p_IsOne(p, r); }); - Singular.method("p_One", [](ip_sring * r) { return p_One(r); }); - Singular.method("p_IsUnit", [](spolyrec * p, ip_sring * r) { - return p_IsUnit(p, r); - }); + Singular.method("p_IsOne", p_IsOne); + Singular.method("p_One", p_One); + Singular.method("p_IsUnit", p_IsUnit); Singular.method("p_GetExp", [](spolyrec * p, int i, ip_sring * r) { return p_GetExp(p, i, r); }); @@ -143,14 +138,12 @@ void singular_define_rings(jlcxx::Module & Singular) omFree(s_ptr); return s; }); - Singular.method("p_ISet", - [](long i, ip_sring * r) { return p_ISet(i, r); }); - Singular.method("p_NSet", - [](snumber * p, ip_sring * r) { return p_NSet(p, r); }); + Singular.method("p_ISet", p_ISet); + Singular.method("p_NSet", p_NSet); Singular.method("p_NSet", [](void * p, ip_sring * r) { return p_NSet(reinterpret_cast(p), r); } ); - Singular.method("pLength", [](spolyrec * p) { return pLength(p); }); + Singular.method("pLength", pLength); Singular.method("SetpNext", [](spolyrec * p, spolyrec * q) { p->next = q; }); Singular.method("pNext", [](spolyrec * a) { @@ -168,12 +161,9 @@ void singular_define_rings(jlcxx::Module & Singular) pNext(a) = m; }); Singular.method("p_SortMerge", [](spolyrec * a, ip_sring * r) { return p_SortMerge(a, r); }); - Singular.method("p_SortAdd", [](spolyrec * a, ip_sring * r) { - return p_SortAdd(a, r); }); - Singular.method("p_Setm", [](spolyrec * a, ip_sring * r) { - p_Setm(a, r); }); - Singular.method("p_Neg", - [](spolyrec * p, ip_sring * r) { return p_Neg(p, r); }); + Singular.method("p_SortAdd", p_SortAdd); + Singular.method("p_Setm", p_Setm); + Singular.method("p_Neg", p_Neg); Singular.method("pGetCoeff", [](spolyrec * p) { return pGetCoeff(p); }); Singular.method("pSetCoeff", [](spolyrec * p, long c, ip_sring * r) { number n = n_Init(c, r); @@ -197,33 +187,21 @@ void singular_define_rings(jlcxx::Module & Singular) Singular.method("p_Add_q", [](spolyrec * p, spolyrec * q, ip_sring * r) { return p_Add_q(p, q, r); }); - Singular.method("p_Sub", [](spolyrec * p, spolyrec * q, ip_sring * r) { - return p_Sub(p, q, r); - }); - Singular.method("p_Mult_q", [](spolyrec * p, spolyrec * q, ip_sring * r) { - return p_Mult_q(p, q, r); - }); - Singular.method("pp_Mult_qq", [](spolyrec * p, spolyrec * q, ip_sring * r) { - return pp_Mult_qq(p, q, r); - }); - Singular.method("p_Power", [](spolyrec * p, int q, ip_sring * r) { - return p_Power(p, q, r); - }); + Singular.method("p_Sub", p_Sub); + Singular.method("p_Mult_q", p_Mult_q); + Singular.method("pp_Mult_qq", pp_Mult_qq); + Singular.method("p_Power", p_Power); Singular.method("p_EqualPolys", [](spolyrec * p, spolyrec * q, ip_sring * r) { return p_EqualPolys(p, q, r); }); - Singular.method("p_Divide", [](spolyrec * p, spolyrec * q, ip_sring * r) { - return p_Divide(p, q, r); - }); + Singular.method("p_Divide", p_Divide); Singular.method("p_DivRem", [](spolyrec * a, spolyrec * b, ip_sring * r) { poly rest; poly q = p_DivRem(a, b, rest, r); return std::make_tuple(reinterpret_cast(q), reinterpret_cast(rest)); }); - Singular.method("p_Div_nn", [](spolyrec * p, snumber * n, ip_sring * r) { - return p_Div_nn(p, n, r); - }); + Singular.method("p_Div_nn", p_Div_nn); Singular.method("p_IsDivisibleBy", [](spolyrec * p, spolyrec * q, ip_sring * r) { poly res; ideal I = idInit(1, 1); @@ -242,10 +220,7 @@ void singular_define_rings(jlcxx::Module & Singular) return false; } }); - Singular.method("singclap_gcd", - [](spolyrec * p, spolyrec * q, ip_sring * r) { - return singclap_gcd(p, q, r); - }); + Singular.method("singclap_gcd", singclap_gcd); Singular.method("p_ExtGcd_internal", [](spolyrec * a, spolyrec * b, void * res, void * s, void * t, ip_sring * r) { @@ -283,29 +258,12 @@ void singular_define_rings(jlcxx::Module & Singular) delete v; return I; }); - Singular.method("p_Content", [](spolyrec * p, ip_sring * r) { - return p_Content(p, r); - }); - Singular.method("p_GetExpVL_internal", - [](spolyrec * p, int64 * ev, ip_sring * r) { - return p_GetExpVL(p, ev, r); - }); - Singular.method("p_GetExpVLV_internal", - [](spolyrec * p, int64 * ev, ip_sring * r) { - return p_GetExpVLV(p, ev, r); - }); - Singular.method("p_SetExpV_internal", - [](spolyrec * p, int * ev, ip_sring * r) { - return p_SetExpV(p, ev, r); - }); - Singular.method("p_SetExpVL_internal", - [](spolyrec * p, int64 * ev, ip_sring * r) { - return p_SetExpVL(p, ev, r); - }); - Singular.method("p_SetExpVLV_internal", - [](spolyrec * p, int64 * ev, int64 c, ip_sring * r) { - return p_SetExpVLV(p, ev, c, r); - }); + Singular.method("p_Content", p_Content); + Singular.method("p_GetExpVL_internal", p_GetExpVL); + Singular.method("p_GetExpVLV_internal", p_GetExpVLV); + Singular.method("p_SetExpV_internal", p_SetExpV); + Singular.method("p_SetExpVL_internal", p_SetExpVL); + Singular.method("p_SetExpVLV_internal", p_SetExpVLV); Singular.method("p_Reduce", [](spolyrec * p, sip_sideal * G, ip_sring * R) { const ring origin = currRing; From 08e82e6629997346f55b02a54e303f42268a7b6b Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Thu, 6 May 2021 12:07:43 +0200 Subject: [PATCH 30/95] test: try if adding 1.6 to the list works now --- deps/src/OscarCI.toml | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/deps/src/OscarCI.toml b/deps/src/OscarCI.toml index 6655e2174..0700347ef 100644 --- a/deps/src/OscarCI.toml +++ b/deps/src/OscarCI.toml @@ -5,7 +5,7 @@ os = [ "ubuntu-latest", "macos-latest" ] # 1.6 is done with some extra combinations in include # also to avoid some weird behaviour by github actions which seems to merge # the includes with the normal matrix entries -julia-version = [ "1.3", "1.4", "1.5", "nightly" ] +julia-version = [ "1.3", "1.4", "1.5", "1.6", "nightly" ] branches = [ "" ] [pkgs] @@ -19,36 +19,26 @@ branches = [ "" ] branches = [] [include] - [include.matching] - Singular = "" - julia-version = "~1.6.0-0" - os = "ubuntu-latest" - - [include.matchingmac] - Singular = "" - julia-version = "~1.6.0-0" - os = "macos-latest" - [include.oscar] Oscar = "" Singular = "" - julia-version = "~1.6.0-0" + julia-version = "1.6" os = "ubuntu-latest" [include.oscarmac] Oscar = "" Singular = "" - julia-version = "~1.6.0-0" + julia-version = "1.6" os = "macos-latest" [include.oscarstable] Oscar = "release" Singular = "release" - julia-version = "~1.6.0-0" + julia-version = "1.6" os = "ubuntu-latest" [include.oscarstablemac] Oscar = "release" Singular = "release" - julia-version = "~1.6.0-0" + julia-version = "1.6" os = "macos-latest" From 9bcfed3faf941c76dca19c4d39333e0a03a7a546 Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Wed, 21 Apr 2021 15:27:31 +0200 Subject: [PATCH 31/95] Update .github/workflows/oscar.yml Explicitly set merge option. --- deps/src/.github/workflows/oscar.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/deps/src/.github/workflows/oscar.yml b/deps/src/.github/workflows/oscar.yml index b6045f909..c0b5e15e8 100644 --- a/deps/src/.github/workflows/oscar.yml +++ b/deps/src/.github/workflows/oscar.yml @@ -78,6 +78,7 @@ jobs: meta = job_meta_env(\"MATRIX_CONTEXT\"); oscar_develop(job_pkgs(meta); dir=\"oscar-dev\", + merge=true, active_repo=\"${GITHUB_REPOSITORY}\"); github_env_runtests(meta; varname=\"oscar_run_tests\", From a7372ee412397a01cd02e1a0b2a9dd90f9c1b370 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 26 Mar 2021 14:43:33 +0100 Subject: [PATCH 32/95] CI: test with Julia 1.6 --- deps/src/.github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/src/.github/workflows/CI.yml b/deps/src/.github/workflows/CI.yml index f64d11e1c..ad2b6802c 100644 --- a/deps/src/.github/workflows/CI.yml +++ b/deps/src/.github/workflows/CI.yml @@ -17,7 +17,7 @@ jobs: - '1.3' - '1.4' - '1.5' - - '1.6-nightly' + - '1.6' - 'nightly' os: - ubuntu-latest From 897751d4e9cf31d016ae1852e4502cc4d4d9aee2 Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Thu, 6 May 2021 12:13:57 +0200 Subject: [PATCH 33/95] test: separate 1.6 again --- deps/src/OscarCI.toml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/deps/src/OscarCI.toml b/deps/src/OscarCI.toml index 0700347ef..0972bc845 100644 --- a/deps/src/OscarCI.toml +++ b/deps/src/OscarCI.toml @@ -5,7 +5,7 @@ os = [ "ubuntu-latest", "macos-latest" ] # 1.6 is done with some extra combinations in include # also to avoid some weird behaviour by github actions which seems to merge # the includes with the normal matrix entries -julia-version = [ "1.3", "1.4", "1.5", "1.6", "nightly" ] +julia-version = [ "1.3", "1.4", "1.5", "nightly" ] branches = [ "" ] [pkgs] @@ -19,6 +19,16 @@ branches = [ "" ] branches = [] [include] + [include.matching] + Singular = "" + julia-version = "1.6" + os = "ubuntu-latest" + + [include.matchingmac] + Singular = "" + julia-version = "1.6" + os = "macos-latest" + [include.oscar] Oscar = "" Singular = "" From 4b2f8e902ae5d5b3e0cffd658e9af15cdd9d6cba Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Thu, 6 May 2021 23:57:46 +0200 Subject: [PATCH 34/95] run.jl: make sure that precompilation is run again with the override in place --- deps/src/run.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/deps/src/run.jl b/deps/src/run.jl index 49794afde..60c8de30e 100644 --- a/deps/src/run.jl +++ b/deps/src/run.jl @@ -6,6 +6,8 @@ @info "Install needed packages" using Pkg Pkg.add(["Singular_jll", "CxxWrap", "CMake", "libsingular_julia_jll"]) +using libsingular_julia_jll + @info "Build libsingular-julia" include("build.jl") @@ -26,8 +28,10 @@ mktempdir() do tmpdepot # prepend our temporary depot to the depot list... withenv("JULIA_DEPOT_PATH"=>tmpdepot*":") do + # we need to make sure that precompilation is run again with the override in place + # (just running Pkg.precompile() does not seem to suffice) + run(`touch $(pathof(libsingular_julia_jll))`) # ... and start Julia, by default with the same project environment - run(`$(Base.julia_cmd()) --project=$(Base.active_project()) -e "using Pkg; Pkg.instantiate(); using libsingular_julia_jll; println(\"using \"*libsingular_julia_jll.libsingular_julia);"`) run(`$(Base.julia_cmd()) --project=$(Base.active_project()) $(ARGS)`) # TODO: perform some additional steps here, e.g. perhaps From 992954a18e9c9c0c609f017378000d6251fd4751 Mon Sep 17 00:00:00 2001 From: tthsqe12 Date: Wed, 21 Apr 2021 16:35:46 +0200 Subject: [PATCH 35/95] add ideal version of mp_MultP (#23) * add ideal version of mp_MultP * wrap idMultSect --- deps/src/ideals.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index c54c3759b..750de1344 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -169,6 +169,10 @@ void singular_define_ideals(jlcxx::Module & Singular) Singular.method("id_Mult", &id_Mult); + Singular.method("id_MultP", [](ideal i, poly p, ring r) { + return (ideal) mp_MultP((matrix) i, p, r); + }); + Singular.method("id_Power", &id_Power); Singular.method("id_IsEqual", [](ideal m, ideal n, ring o) { @@ -199,6 +203,14 @@ void singular_define_ideals(jlcxx::Module & Singular) return id; }); + Singular.method("id_MultSect", [](void * ids, int len, ring r) { + const ring origin = currRing; + rChangeCurrRing(r); + ideal id = idMultSect(reinterpret_cast(ids), len); + rChangeCurrRing(origin); + return id; + }); + Singular.method("id_Syzygies", &id_Syzygies_internal); Singular.method("id_sres", &id_sres_helper); From 2dc7825f4093c21facab62c6855052065bf4d6ad Mon Sep 17 00:00:00 2001 From: tthsqe12 Date: Fri, 7 May 2021 19:10:32 +0200 Subject: [PATCH 36/95] fix transExt_to_poly nullptr (#30) --- deps/src/coeffs.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/deps/src/coeffs.cpp b/deps/src/coeffs.cpp index 6683bac23..98a0d37b3 100644 --- a/deps/src/coeffs.cpp +++ b/deps/src/coeffs.cpp @@ -15,15 +15,18 @@ auto transExt_helper(coeffs cf, jlcxx::ArrayRef param) return nInitChar(n_transExt, &extParam); } -auto transExt_to_poly(number a, coeffs cf, ring r) +poly transExt_to_poly(number a, coeffs cf, ring r) { + // zero is represented by nullptr + if (a == NULL || NUM((fraction)a) == NULL) + return NULL; + assume(cf->extRing != NULL); ring ext = cf->extRing; - fraction f = (fraction)a; nMapFunc nMap = n_SetMap(ext->cf, r->cf); const ring origin = currRing; rChangeCurrRing(r); - poly p = p_PermPoly(f->numerator, NULL, ext, r, nMap, NULL); + poly p = p_PermPoly(NUM((fraction)a), NULL, ext, r, nMap, NULL); rChangeCurrRing(origin); return p; } From b758f006a5a51212edcdbb3fe0ea170e2b853985 Mon Sep 17 00:00:00 2001 From: tthsqe12 Date: Mon, 10 May 2021 16:45:07 +0200 Subject: [PATCH 37/95] reset errorreported + use singular_error + tweaks (#29) --- deps/src/singular.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/deps/src/singular.cpp b/deps/src/singular.cpp index 61ea7b4ff..204e1369f 100644 --- a/deps/src/singular.cpp +++ b/deps/src/singular.cpp @@ -13,6 +13,7 @@ static std::string singular_warning; // Internal singular interpreter variable extern int inerror; +// these are the temporary callbacks for calls to the interpreter static void WerrorS_for_julia(const char * s) { singular_error += s; @@ -28,6 +29,25 @@ static void WarningS_for_julia(const char * s) singular_warning += s; } +/* + This is the non-temporary callback for all errors (unless the temporary + ones are in use by call_interpreter). It is probably safest to log the error + to both singular_error and stderr, so that a missing libSingular.check_error + does not cause error to go completely unnoticed. +*/ +static void WerrorS_and_reset(const char * s) +{ + errorreported = 0; + if (!singular_error.empty()) + singular_error += ". "; + singular_error += s; + /* and, copied from WerrorS in Singular:*/ + fwrite(" singular error: ", 1, 20, stderr); + fwrite(s, 1, strlen(s), stderr); + fwrite("\n", 1, 1, stderr); + fflush(stderr); +} + JLCXX_MODULE define_julia_module(jlcxx::Module & Singular) { Singular.add_type("coeffs"); @@ -67,6 +87,7 @@ JLCXX_MODULE define_julia_module(jlcxx::Module & Singular) Singular.method("siInit", [](const char * path) { siInit(const_cast(path)); + WerrorS_callback = WerrorS_and_reset; }); Singular.method("versionString", []() { return const_cast(versionString()); @@ -75,6 +96,16 @@ JLCXX_MODULE define_julia_module(jlcxx::Module & Singular) return SINGULAR_VERSION; }); + Singular.method("have_error", []() { + return !singular_error.empty(); + }); + + Singular.method("get_and_clear_error", []() { + std::string s(std::move(singular_error)); + singular_error.clear(); + return s; + }); + #define SETTER(A, B) \ else if (opt == #B) \ A = value ? (A | Sy_bit(B)) : (A & ~Sy_bit(B)); From db6a529908e8f69ea562bf88b4f2041cb6f6278a Mon Sep 17 00:00:00 2001 From: tthsqe12 Date: Mon, 10 May 2021 16:45:16 +0200 Subject: [PATCH 38/95] n_algExt -> n_transExt conversion (#31) --- deps/src/coeffs.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/deps/src/coeffs.cpp b/deps/src/coeffs.cpp index 98a0d37b3..cb01a4850 100644 --- a/deps/src/coeffs.cpp +++ b/deps/src/coeffs.cpp @@ -165,6 +165,23 @@ void singular_define_coeffs(jlcxx::Module & Singular) } }); + /* + Given an element a of K = R[x]/minpoly(x) and the corresponding + F = R(x), return the element a as an element of F. + */ + Singular.method("algExt_to_transExt", [](number a, coeffs K, coeffs F) { + if (nCoeff_is_algExt(K) && !nCoeff_is_GF(K)) + { + nMapFunc nMap = n_SetMap(K, F); + return nMap(a, K, F); + } + else + { + WerrorS("cannot use algExt_to_transExt for these coeffients"); + return n_Init(0, F); + } + }); + /* only used to get the order of a N_GField */ Singular.method("nfCharQ", [](coeffs n) {return n->m_nfCharQ;}); From ffb3b9d68efd142677328405a94fb074838c193d Mon Sep 17 00:00:00 2001 From: tthsqe12 Date: Mon, 10 May 2021 16:45:31 +0200 Subject: [PATCH 39/95] proper num/den and gcdx + normalize for QQ (#25) * proper num/den and gcdx + normalize for QQ * n_Rem is not used and the implementation is completely broken anyways --- deps/src/coeffs.cpp | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/deps/src/coeffs.cpp b/deps/src/coeffs.cpp index cb01a4850..342687929 100644 --- a/deps/src/coeffs.cpp +++ b/deps/src/coeffs.cpp @@ -283,12 +283,24 @@ void singular_define_coeffs(jlcxx::Module & Singular) return z; }); - Singular.method("n_GetNumerator", [](snumber * a, coeffs c) { + /* return the numerator of a, possibly modifying a in the process */ + Singular.method("n_GetNumerator", [](number & a, coeffs c) { return n_GetNumerator(a, c); }); - Singular.method("n_GetDenom", - [](snumber * a, coeffs c) { return n_GetDenom(a, c); }); + /* return the denominator of a, possibly modifying a in the process */ + Singular.method("n_GetDenom", [](number & a, coeffs c) { + return n_GetDenom(a, c); + }); + + /* + since references are such a pain on the julia side, + n_Normalize takes a non-reference and returns the modifed result + */ + Singular.method("n_Normalize", [](number a, coeffs c) { + n_Normalize(a, c); + return a; + }); Singular.method("n_Power", [](snumber * a, int b, coeffs c) { number res; @@ -308,10 +320,9 @@ void singular_define_coeffs(jlcxx::Module & Singular) return n_Lcm(a, b, c); }); - Singular.method("n_ExtGcd_internal", [](snumber * a, snumber * b, - void * s, void * t, coeffs c) { - return n_ExtGcd(a, b, reinterpret_cast(s), - reinterpret_cast(t), c); + Singular.method("n_ExtGcd", [](number a, number b, + number * s, number * t, const coeffs c) { + return n_ExtGcd(a, b, s, t, c); }); Singular.method("n_IsZero", [](snumber * x, const coeffs n) { @@ -345,14 +356,9 @@ void singular_define_coeffs(jlcxx::Module & Singular) return x; }); - Singular.method("n_QuotRem_internal", [](snumber * x, snumber * y, - void * p, const coeffs n) { - return n_QuotRem(x, y, reinterpret_cast(p), n); - }); - - Singular.method("n_Rem", [](snumber * x, snumber * y, const coeffs n) { - number qq; - return n_QuotRem(x, y, &qq, n); + Singular.method("n_QuotRem", [](number x, number y, + number * r, const coeffs n) { + return n_QuotRem(x, y, r, n); }); Singular.method("n_IntMod", &n_IntMod); From 5b7c90ab29421fbada671b77ca0874a988cb3993 Mon Sep 17 00:00:00 2001 From: tthsqe12 Date: Mon, 10 May 2021 16:45:43 +0200 Subject: [PATCH 40/95] add some functions for communicating orderings (#26) * add some functions for communicating orderings * add p_Compare * clarify comment --- deps/src/rings.cpp | 94 +++++++++++++++++++++++++++++++++++++++++++ deps/src/singular.cpp | 16 ++++++++ 2 files changed, 110 insertions(+) diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index 6c8f0f998..c2a7c83bf 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -16,6 +16,97 @@ auto rDefault_helper(coeffs cf, return r; } +/* + calling rDefault with a non-null wvhdl argument: + All ordering data should be passed in a serialized ord_data array. It is + then deserialized into the rDefault arguments. +*/ +auto rDefault_wvhdl_helper(coeffs cf, + jlcxx::ArrayRef vars, + jlcxx::ArrayRef ord_data, + unsigned long bitmask) +{ + int nvars = vars.size(); + char ** vars_ptr = new char *[nvars]; + + for (int i = 0; i < nvars; i++) + vars_ptr[i] = reinterpret_cast(vars[i]); + + size_t j = 0; + int nord = ord_data[j++]; + + // rDefault is going to take ownership of all 4 of these pointers + rRingOrder_t * ord = (rRingOrder_t *) omAlloc0((nord + 1) * sizeof(rRingOrder_t)); + int * blk0 = (int *) omAlloc0((nord + 1) * sizeof(int)); + int * blk1 = (int *) omAlloc0((nord + 1) * sizeof(int)); + int ** wvhdl = (int **) omAlloc0((nord + 1) * sizeof(int *)); + + for (int i = 0; i < nord; i++) + { + ord[i] = (rRingOrder_t) ord_data[j++]; + blk0[i] = ord_data[j++]; + blk1[i] = ord_data[j++]; + int len = ord_data[j++]; + if (len > 0) + { + wvhdl[i] = (int *) omAlloc0(len * sizeof(int)); + for (int k = 0; k < len; k++) + wvhdl[i][k] = ord_data[j++]; + } + else + { + wvhdl[i] = nullptr; + } + } + + auto r = rDefault(cf, nvars, vars_ptr, nord, ord, blk0, blk1, wvhdl, bitmask); + delete[] vars_ptr; + r->ShortOut = 0; + + return r; +} + +/* + Serialize the ord, blk0, blk1, wvhdl data + call with ord_data.size() == 0 since ArrayRef doesn't support resize +*/ +void rOrdering_helper(jlcxx::ArrayRef ord_data, const ring r) +{ + int l; + size_t initial_size = ord_data.size(); + + ord_data.push_back(0); + + for (l = 0; r->order[l]; l++) + { + rRingOrder_t ord = r->order[l]; + ord_data.push_back(static_cast(ord)); + ord_data.push_back(r->block0[l]); + ord_data.push_back(r->block1[l]); + if (r->wvhdl[l] == nullptr) + { + ord_data.push_back(0); + } + else if (ord == ringorder_wp || ord == ringorder_Wp || + ord == ringorder_ws || ord == ringorder_Ws || + ord == ringorder_a || ord == ringorder_am || ord == ringorder_M) + { + int n = r->block1[l] - r->block0[l] + 1; + if (ord == ringorder_M) + n = n*n; + ord_data.push_back(n); + for (int i = 0; i < n; i++) + ord_data.push_back(r->wvhdl[l][i]); + } + else + { + ord_data.push_back(0); + } + } + + ord_data[initial_size] = l; +} + auto rDefault_long_helper(coeffs cf, jlcxx::ArrayRef vars, jlcxx::ArrayRef ord, @@ -78,6 +169,8 @@ void singular_define_rings(jlcxx::Module & Singular) return reinterpret_cast(ptr); }); Singular.method("rDefault_helper", &rDefault_helper); + Singular.method("rDefault_wvhdl_helper", &rDefault_wvhdl_helper); + Singular.method("rOrdering_helper", &rOrdering_helper); // inverse of rDefault_wvhdl_helper Singular.method("rDefault_long_helper", &rDefault_long_helper); Singular.method("rDefault_Weyl_helper", &rDefault_Weyl_helper); Singular.method("rDefault_Exterior_helper", &rDefault_Exterior_helper); @@ -191,6 +284,7 @@ void singular_define_rings(jlcxx::Module & Singular) Singular.method("p_Mult_q", p_Mult_q); Singular.method("pp_Mult_qq", pp_Mult_qq); Singular.method("p_Power", p_Power); + Singular.method("p_Compare", p_Compare); Singular.method("p_EqualPolys", [](spolyrec * p, spolyrec * q, ip_sring * r) { return p_EqualPolys(p, q, r); diff --git a/deps/src/singular.cpp b/deps/src/singular.cpp index 204e1369f..0c1e8e4c3 100644 --- a/deps/src/singular.cpp +++ b/deps/src/singular.cpp @@ -78,12 +78,28 @@ JLCXX_MODULE define_julia_module(jlcxx::Module & Singular) Singular.set_const("ringorder_rp", ringorder_rp); Singular.set_const("ringorder_dp", ringorder_dp); Singular.set_const("ringorder_Dp", ringorder_Dp); + Singular.set_const("ringorder_wp", ringorder_wp); + Singular.set_const("ringorder_Wp", ringorder_Wp); Singular.set_const("ringorder_ls", ringorder_ls); Singular.set_const("ringorder_rs", ringorder_rs); Singular.set_const("ringorder_ds", ringorder_ds); Singular.set_const("ringorder_Ds", ringorder_Ds); + Singular.set_const("ringorder_ws", ringorder_ws); + Singular.set_const("ringorder_Ws", ringorder_Ws); + Singular.set_const("ringorder_a", ringorder_a); + Singular.set_const("ringorder_M", ringorder_M); Singular.set_const("ringorder_c", ringorder_c); Singular.set_const("ringorder_C", ringorder_C); + Singular.set_const("ringorder_s", ringorder_s); + Singular.set_const("ringorder_S", ringorder_S); + Singular.set_const("ringorder_IS", ringorder_IS); + + Singular.method("ringorder_to_int", [](rRingOrder_t a) { + return static_cast(a); + }); + Singular.method("ringorder_from_int", [](int a) { + return static_cast(a); + }); Singular.method("siInit", [](const char * path) { siInit(const_cast(path)); From 3dbf51c39d72e6c0a69fec967f1876e02e49fb82 Mon Sep 17 00:00:00 2001 From: tthsqe12 Date: Wed, 9 Jun 2021 17:49:49 +0200 Subject: [PATCH 41/95] add scDimIntRing (#32) --- deps/src/ideals.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index 750de1344..375a54376 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -383,6 +383,13 @@ void singular_define_ideals(jlcxx::Module & Singular) rChangeCurrRing(origin); return k; }); + Singular.method("scDimIntRing", [](ideal I, ring R) { + const ring origin = currRing; + rChangeCurrRing(R); + int k = scDimIntRing(I, R->qideal); + rChangeCurrRing(origin); + return k; + }); Singular.method("fglmzero", [](ideal Isrc, ring Rsrc, ring Rdest ) { const ring origin = currRing; rChangeCurrRing(Rdest); From eae2b9a5035e0d11fb43dc6d7c36bbe0e686a2a4 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Tue, 29 Jun 2021 13:59:45 +0200 Subject: [PATCH 42/95] missing matrix cmds --- deps/src/caller.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deps/src/caller.cpp b/deps/src/caller.cpp index b580ebe8e..ad210d41c 100644 --- a/deps/src/caller.cpp +++ b/deps/src/caller.cpp @@ -28,6 +28,7 @@ static jl_value_t * get_type_mapper() {RING_CMD, "RING_CMD"}, {POLY_CMD, "POLY_CMD"}, {IDEAL_CMD, "IDEAL_CMD"}, + {MATRIX_CMD, "MATRIX_CMD"}, {INT_CMD, "INT_CMD"}, {STRING_CMD, "STRING_CMD"}, {LIST_CMD, "LIST_CMD"}, @@ -357,6 +358,8 @@ void singular_define_caller(jlcxx::Module & Singular) [](void * obj) { return reinterpret_cast(obj); }); Singular.method("IDEAL_CMD_CASTER", [](void * obj) { return reinterpret_cast(obj); }); + Singular.method("MATRIX_CMD_CASTER", + [](void * obj) { return reinterpret_cast(obj); }); Singular.method("INT_CMD_CASTER", [](void * obj) { return jl_box_int64(reinterpret_cast(obj)); }); From 07f830b9816e3446b73699cf7e947abca6a92e10 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Tue, 13 Jul 2021 13:12:20 +0200 Subject: [PATCH 43/95] transExt_to_algExt conversion --- deps/src/coeffs.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/deps/src/coeffs.cpp b/deps/src/coeffs.cpp index 342687929..bb21d8eb9 100644 --- a/deps/src/coeffs.cpp +++ b/deps/src/coeffs.cpp @@ -182,6 +182,27 @@ void singular_define_coeffs(jlcxx::Module & Singular) } }); + /* + Given an element a of F = R(x) and K = R[x]/minpoly(x), + return a as an element of K. + */ + Singular.method("transExt_to_algExt", [](number a, coeffs K, coeffs F) { + if (nCoeff_is_algExt(K) && !nCoeff_is_GF(K)) + { + // naCopyTrans2AlgExt has a bug with zero input + if (a == NULL || NUM((fraction)a) == NULL) + return reinterpret_cast(NULL); + + nMapFunc nMap = n_SetMap(F, K); + return nMap(a, F, K); + } + else + { + WerrorS("cannot use transExt_to_algExt for these coeffients"); + return n_Init(0, F); + } + }); + /* only used to get the order of a N_GField */ Singular.method("nfCharQ", [](coeffs n) {return n->m_nfCharQ;}); From 8655347da9e84cd58dfd3223891c3e3146a0046f Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Tue, 13 Jul 2021 15:17:43 +0200 Subject: [PATCH 44/95] add second lift and a correct gcdx --- deps/src/ideals.cpp | 12 ++++++++++++ deps/src/rings.cpp | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index 375a54376..210134941 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -239,6 +239,18 @@ void singular_define_ideals(jlcxx::Module & Singular) return std::make_tuple(res, rest); }); + Singular.method("id_Lift", [](ideal m, ideal sm, bool goodShape, + bool isSB, bool divide, ring o) { + const ring origin = currRing; + rChangeCurrRing(o); + ideal rest; + matrix unit; + ideal res = idLift(m, sm, &rest, BOOLEAN(goodShape), BOOLEAN(isSB), + BOOLEAN(divide), &unit, GbDefault); + rChangeCurrRing(origin); + return std::make_tuple(res, rest, unit); + }); + Singular.method("id_LiftStd", [](ideal m, ring o, bool complete_reduction = false) { const ring origin = currRing; rChangeCurrRing(o); diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index c2a7c83bf..f786492cd 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -315,6 +315,14 @@ void singular_define_rings(jlcxx::Module & Singular) } }); Singular.method("singclap_gcd", singclap_gcd); + + Singular.method("singclap_extgcd", [](spolyrec * a, spolyrec * b, ip_sring * r) { + poly res, s, t; + singclap_extgcd(a, b, res, s, t, r); + return std::make_tuple(res, s, t); + }); + + /* TODO check if we can get rid of this nonsensical function */ Singular.method("p_ExtGcd_internal", [](spolyrec * a, spolyrec * b, void * res, void * s, void * t, ip_sring * r) { From 971a8bfe71908795baad6db69b2e6f606eef1cf7 Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Tue, 27 Jul 2021 23:07:45 +0200 Subject: [PATCH 45/95] add id_InterRed --- deps/src/ideals.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index 210134941..6a9dc2600 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -105,6 +105,19 @@ auto id_StdHilb_helper(ideal a, ring b, jlcxx::ArrayRef h, bool complete_re return id; } +auto id_InterRed_helper(ideal a, ring b) +{ + ideal id = NULL; + if (!idIs0(a)) { + const ring origin = currRing; + rChangeCurrRing(b); + id = kInterRed(a, b->qideal); + rChangeCurrRing(origin); + } + else + id = idInit(0, a->rank); + return id; +} auto id_Std_helper(ideal a, ring b, bool complete_reduction = false) { @@ -222,6 +235,8 @@ void singular_define_ideals(jlcxx::Module & Singular) Singular.method("id_Std", &id_Std_helper); Singular.method("id_StdHilb", &id_StdHilb_helper); + Singular.method("id_InterRed", &id_InterRed_helper); + Singular.method("id_Eliminate", [](ideal m, poly p, ring o) { const ring origin = currRing; rChangeCurrRing(o); From 52d1c5d3f3037ff7569f22db049d9b0049d03daa Mon Sep 17 00:00:00 2001 From: Tommy Hofmann Date: Wed, 28 Jul 2021 13:59:47 +0200 Subject: [PATCH 46/95] Update oscar.yml --- deps/src/.github/workflows/oscar.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/deps/src/.github/workflows/oscar.yml b/deps/src/.github/workflows/oscar.yml index d71bb7c2e..a7eb62604 100644 --- a/deps/src/.github/workflows/oscar.yml +++ b/deps/src/.github/workflows/oscar.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - master + workflow_dispatch: jobs: generatematrix: From 532e68d89bd08c2ad213e8b0eb00f43c35db9552 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Fri, 30 Jul 2021 17:59:13 +0200 Subject: [PATCH 47/95] start singular's bigint and bigintmat --- deps/src/caller.cpp | 7 +++++++ deps/src/coeff_rings.cpp | 1 + deps/src/matrices.cpp | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/deps/src/caller.cpp b/deps/src/caller.cpp index ad210d41c..d7ab021b7 100644 --- a/deps/src/caller.cpp +++ b/deps/src/caller.cpp @@ -197,6 +197,12 @@ static jl_value_t * copy_idealptr_to_void(ideal i, ring r) return jl_box_voidpointer(reinterpret_cast(i_copy)); } +static jl_value_t * copy_bigintmatptr_to_void(bigintmat * m) +{ + bigintmat * m_copy = new bigintmat(m); + return jl_box_voidpointer(reinterpret_cast(m_copy)); +} + static void * copy_string_to_void(std::string s) { return reinterpret_cast(omStrDup(s.c_str())); @@ -389,6 +395,7 @@ void singular_define_caller(jlcxx::Module & Singular) Singular.method("get_ring_ref", &get_ring_ref); Singular.method("copy_polyptr_to_void", ©_polyptr_to_void); Singular.method("copy_idealptr_to_void", ©_idealptr_to_void); + Singular.method("copy_bigintmatptr_to_void", ©_bigintmatptr_to_void); Singular.method("jl_array_to_intvec", &jl_array_to_intvec); Singular.method("jl_array_to_intmat", &jl_array_to_intmat); Singular.method("copy_string_to_void", ©_string_to_void); diff --git a/deps/src/coeff_rings.cpp b/deps/src/coeff_rings.cpp index a367716b9..c3cb25707 100644 --- a/deps/src/coeff_rings.cpp +++ b/deps/src/coeff_rings.cpp @@ -81,4 +81,5 @@ void singular_define_coeff_rings(jlcxx::Module & singular){ singular.method("get_coeff_data_void",[](void* c){ return reinterpret_cast(c)->data; }); singular.method("cast_number_to_void",[](number n){ return reinterpret_cast(n); }); singular.method("cast_void_to_number",[](void* n){ return reinterpret_cast(n); }); + singular.method("get_coeffs_BIGINT", []() {return coeffs_BIGINT;}); } diff --git a/deps/src/matrices.cpp b/deps/src/matrices.cpp index 2761e85fa..cf07cf972 100644 --- a/deps/src/matrices.cpp +++ b/deps/src/matrices.cpp @@ -54,4 +54,23 @@ void singular_define_matrices(jlcxx::Module & Singular) omFree(str_ptr); return s; }); + + Singular.method("bigintmat_init", [](int r, int c) { + return new bigintmat(r, c, coeffs_BIGINT); + }); + Singular.method("bigintmat_clear", [](bigintmat * m) { + delete m; + }); + Singular.method("bigintmat_nrows", [](bigintmat * m) { + return m->rows(); + }); + Singular.method("bigintmat_ncols", [](bigintmat * m) { + return m->cols(); + }); + Singular.method("bigintmat_viewindex", [](bigintmat * m, int i, int j) { + return m->view(i, j); + }); + Singular.method("bigintmat_rawset", [](bigintmat * m, number n, int i, int j) { + m->rawset(i, j, n, NULL); + }); } From 89896daf146127f2be42240d8eaaaf0c2aab17be Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Tue, 12 Oct 2021 19:48:11 +0200 Subject: [PATCH 48/95] fix weyl and exterior algebra constructors --- deps/src/includes.h | 1 + deps/src/rings.cpp | 148 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 140 insertions(+), 9 deletions(-) diff --git a/deps/src/includes.h b/deps/src/includes.h index ed141ce7d..671716110 100644 --- a/deps/src/includes.h +++ b/deps/src/includes.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include "polys/ext_fields/algext.h" #include "polys/ext_fields/transext.h" diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index f786492cd..b591c5755 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -142,12 +142,131 @@ auto rDefault_Weyl_helper(coeffs cf, unsigned long bitmask) { auto r = rDefault_long_helper(cf, vars, ord, blk0, blk1, bitmask); - poly p=p_One(r); - nc_CallPlural(NULL,NULL,p,p,r,true,false,true,r); - p_Delete(&p,r); - return r; + + // vars = indeterminates x1, ..., xn and then partials Dx1, ..., Dxn + int n = r->N/2; + assume(2*n == r->N); + matrix C = mpNew(2*n, 2*n); + matrix D = mpNew(2*n, 2*n); + + for (int i = 1; i <= n; i++) + for (int j = 1; j <= n; j++) + { + if (i < j) + { + // xj*xi = xi*xj + MATELEM(C,i,j) = p_One(r); + + // Dxj*Dxi = Dxi*Dxj + MATELEM(C,n+i,n+j) = p_One(r); + } + + // Dxj*xi = xi*Dxj + bool(i == j) + MATELEM(C,i,n+j) = p_One(r); + if (i == j) + MATELEM(D,i,n+j) = p_One(r); + } + + ring R = rCopy(r); + nc_CallPlural(C,D,NULL,NULL,R,true,false,true,r); + + // nc_CallPlural seems to take ownership of the matrices + //mp_Delete(&C, r); + //mp_Delete(&D, r); + + rDelete(r); + return R; } +// adapted from jiA_RING in ipassign.cc +static ring make_qring(ring r, ideal id) +{ + const ring origin = currRing; + rChangeCurrRing(r); + + coeffs newcf = currRing->cf; + + const int cpos = idPosConstant(id); + if (rField_is_Ring(currRing)) + { + if (cpos >= 0) + { + newcf = n_CoeffRingQuot1(p_GetCoeff(id->m[cpos], currRing), currRing->cf); + if (newcf == NULL) + { + rChangeCurrRing(origin); + return NULL; + } + } + } + + ring qr = rCopy(currRing); + assume(qr->cf == currRing->cf); + + if (qr->cf != newcf) + { + nKillChar(qr->cf); // ??? + qr->cf = newcf; + } + + ideal qid; + + if((rField_is_Ring(currRing)) && (cpos != -1)) + { + int i, j; + int *perm = (int *)omAlloc0((qr->N+1)*sizeof(int)); + + for(i=qr->N;i>0;i--) + perm[i]=i; + + nMapFunc nMap = n_SetMap(currRing->cf, newcf); + qid = idInit(IDELEMS(id)-1,1); + for (i = 0, j = 0; im[j++] = p_PermPoly(id->m[i], perm, currRing, qr, nMap, NULL, 0); + } + else + { + qid = idrCopyR(id,currRing,qr); + } + + idSkipZeroes(qid); + + if (currRing->qideal!=NULL) /* we are already in a qring! */ + { + ideal tmp=idSimpleAdd(qid,currRing->qideal); + // both ideals should be GB, so dSimpleAdd is sufficient + idDelete(&qid); + qid=tmp; + // delete the qr copy of quotient ideal!!! + idDelete(&qr->qideal); + } + if (idElem(qid)==0) + { + qr->qideal = NULL; + id_Delete(&qid,currRing); + } + else + { + qr->qideal = qid; + } + + // qr is a copy of currRing with the new qideal! + #ifdef HAVE_PLURAL + if (rIsPluralRing(currRing) &&(qr->qideal!=NULL)) + { + if (nc_SetupQuotient(qr, currRing)) + { + //WarnS("error in nc_SetupQuotient"); + } + } + #endif + + rChangeCurrRing(origin); + return qr; +} + + auto rDefault_Exterior_helper(coeffs cf, jlcxx::ArrayRef vars, jlcxx::ArrayRef ord, @@ -156,11 +275,21 @@ auto rDefault_Exterior_helper(coeffs cf, unsigned long bitmask) { auto r = rDefault_long_helper(cf, vars, ord, blk0, blk1, bitmask); - poly p=p_One(r); - p=p_Neg(p,r); - nc_CallPlural(NULL,NULL,p,NULL,r,true,false,true,r); - p_Delete(&p,r); - return r; + int n = rVar(r); + // first construct relations xj*xi = -xi*xj + poly p = p_Neg(p_One(r), r); + ring R = rCopy(r); + nc_CallPlural(NULL,NULL,p,NULL,R,true,false,true,r); + // then add xi^2 = 0 + ideal q = idInit(n,1); + for (int i = 1; i <= n; i++) + q->m[i-1] = p_Power(rGetVar(i, R), 2, R); + ring S = make_qring(R, q); + id_Delete(&q, R); + p_Delete(&p, r); + rDelete(R); + rDelete(r); + return S; } void singular_define_rings(jlcxx::Module & Singular) @@ -168,6 +297,7 @@ void singular_define_rings(jlcxx::Module & Singular) Singular.method("toPolyRef", [](void * ptr) { return reinterpret_cast(ptr); }); + Singular.method("freeAlgebra", &freeAlgebra); Singular.method("rDefault_helper", &rDefault_helper); Singular.method("rDefault_wvhdl_helper", &rDefault_wvhdl_helper); Singular.method("rOrdering_helper", &rOrdering_helper); // inverse of rDefault_wvhdl_helper From 232822d79ee35308b198784f35bdf45bbff75345 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Mon, 9 Aug 2021 15:18:37 +0200 Subject: [PATCH 49/95] add lookup_singular_library_symbol_wo_rng --- deps/src/caller.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/deps/src/caller.cpp b/deps/src/caller.cpp index d7ab021b7..08b252821 100644 --- a/deps/src/caller.cpp +++ b/deps/src/caller.cpp @@ -304,7 +304,26 @@ jl_value_t * call_singular_library_procedure_wo_rng( return call_singular_library_procedure(name, reinterpret_cast(rng), arguments); } - +jl_value_t * lookup_singular_library_symbol_wo_rng( + std::string pack, + std::string name) +{ + int progress = 0; + leftv u = (leftv) IDROOT->get(pack.c_str(),0); + if (u != NULL) + { + progress++; + idhdl v = ((package)(u->Data()))->idroot->get(name.c_str(), 0); + if (v != NULL) + { + sleftv x; + x.Init(); + x.Copy((leftv)v); + return get_julia_type_from_sleftv(&x); // any cleanup for x ??? + } + } + return jl_box_int64(progress); // return to julia a plain int for error +} jl_value_t * convert_nested_list(void * l_void) { @@ -348,6 +367,8 @@ void singular_define_caller(jlcxx::Module & Singular) } return jl_true; }); + Singular.method("lookup_singular_library_symbol_wo_rng", + &lookup_singular_library_symbol_wo_rng); Singular.method("call_singular_library_procedure", &call_singular_library_procedure); Singular.method("call_singular_library_procedure", From 76f01b7f5f8bc91af3ba86e9717b6e702abda57b Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Wed, 13 Oct 2021 18:56:36 +0200 Subject: [PATCH 50/95] add p_Mult_nn --- deps/src/rings.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index b591c5755..c4c8abcb7 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -426,6 +426,9 @@ void singular_define_rings(jlcxx::Module & Singular) return std::make_tuple(reinterpret_cast(q), reinterpret_cast(rest)); }); Singular.method("p_Div_nn", p_Div_nn); + Singular.method("p_Mult_nn", [](poly p, number n, ring r) { + return p_Mult_nn(p, n, r); + }); Singular.method("p_IsDivisibleBy", [](spolyrec * p, spolyrec * q, ip_sring * r) { poly res; ideal I = idInit(1, 1); From b7c275d2fea63d3a22c8eb3de4ecf64dcbd319aa Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Mon, 9 Aug 2021 16:29:50 +0200 Subject: [PATCH 51/95] apply comments --- deps/src/caller.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deps/src/caller.cpp b/deps/src/caller.cpp index 08b252821..b1d463fe7 100644 --- a/deps/src/caller.cpp +++ b/deps/src/caller.cpp @@ -317,9 +317,8 @@ jl_value_t * lookup_singular_library_symbol_wo_rng( if (v != NULL) { sleftv x; - x.Init(); x.Copy((leftv)v); - return get_julia_type_from_sleftv(&x); // any cleanup for x ??? + return get_julia_type_from_sleftv(&x); } } return jl_box_int64(progress); // return to julia a plain int for error From 8914fa2b61e7df0c42e3a639f5a107bc16ea0241 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Thu, 14 Oct 2021 19:20:44 +0200 Subject: [PATCH 52/95] add G-algebra constructor --- deps/src/rings.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index c4c8abcb7..e1eb36d96 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -304,6 +304,11 @@ void singular_define_rings(jlcxx::Module & Singular) Singular.method("rDefault_long_helper", &rDefault_long_helper); Singular.method("rDefault_Weyl_helper", &rDefault_Weyl_helper); Singular.method("rDefault_Exterior_helper", &rDefault_Exterior_helper); + Singular.method("nc_CallPlural", [](matrix C, matrix D, ring r) { + ring R = rCopy(r); + nc_CallPlural(mp_Copy(C,r), mp_Copy(D,r), NULL, NULL, R, true, false, true, r); + return R; + }); Singular.method("rDelete", &rDelete); Singular.method("rString", [](ip_sring * r) { auto s = rString(r); From 20136fb027ea6486a2ed1106087c96401ff4ee2b Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Mon, 9 Aug 2021 16:47:46 +0200 Subject: [PATCH 53/95] explain return convention --- deps/src/caller.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/deps/src/caller.cpp b/deps/src/caller.cpp index b1d463fe7..c6abaa70d 100644 --- a/deps/src/caller.cpp +++ b/deps/src/caller.cpp @@ -318,10 +318,14 @@ jl_value_t * lookup_singular_library_symbol_wo_rng( { sleftv x; x.Copy((leftv)v); + // return is a Vector so distinguishable from the Int error below return get_julia_type_from_sleftv(&x); } } - return jl_box_int64(progress); // return to julia a plain int for error + // return to julia a plain Int for error + // 0: package not found + // 1: package found but symbol not found + return jl_box_int64(progress); } jl_value_t * convert_nested_list(void * l_void) From b929aa8ae693f3e4f408471085b06be26609f59a Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Fri, 15 Oct 2021 20:24:11 +0200 Subject: [PATCH 54/95] fix some spacings --- deps/src/rings.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index e1eb36d96..c178e89ef 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -114,13 +114,13 @@ auto rDefault_long_helper(coeffs cf, int * blk1, unsigned long bitmask) { - auto len = vars.size(); + auto len = vars.size(); char ** vars_ptr = new char *[len]; for (int i = 0; i < len; i++) { vars_ptr[i] = reinterpret_cast(vars[i]); // std::strcpy(vars_ptr[i],vars[i].c_str()); } - auto len_ord = ord.size(); + auto len_ord = ord.size(); rRingOrder_t * ord_ptr = (rRingOrder_t *)omAlloc0(len_ord * sizeof(rRingOrder_t)); for (int i = 0; i < len_ord; i++) { @@ -564,12 +564,12 @@ void singular_define_rings(jlcxx::Module & Singular) par_perm.push_back(par_perm1[j]); } }); - Singular.method("p_Jet", + Singular.method("p_Jet", [](poly p, int i, ring r) { poly p_cp = p_Copy(p, r); return p_Jet(p_cp, i, r); }); - Singular.method("p_Diff", + Singular.method("p_Diff", [](poly p, int i, ring r) { poly p_cp = p_Copy(p, r); return p_Diff(p_cp, i, r); From 47fa517d08025e5c3a0f3bf5911f40c7da6ca6e1 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Mon, 9 Aug 2021 17:08:21 +0200 Subject: [PATCH 55/95] change return convention --- deps/src/caller.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/deps/src/caller.cpp b/deps/src/caller.cpp index c6abaa70d..dd4bda242 100644 --- a/deps/src/caller.cpp +++ b/deps/src/caller.cpp @@ -308,24 +308,30 @@ jl_value_t * lookup_singular_library_symbol_wo_rng( std::string pack, std::string name) { - int progress = 0; + + int err = 2; + jl_value_t * res = jl_nothing; + jl_array_t * answer = jl_alloc_array_1d(jl_array_any_type, 2); leftv u = (leftv) IDROOT->get(pack.c_str(),0); if (u != NULL) { - progress++; + err--; idhdl v = ((package)(u->Data()))->idroot->get(name.c_str(), 0); if (v != NULL) { + err--; sleftv x; x.Copy((leftv)v); - // return is a Vector so distinguishable from the Int error below - return get_julia_type_from_sleftv(&x); + res = get_julia_type_from_sleftv(&x); } } - // return to julia a plain Int for error - // 0: package not found - // 1: package found but symbol not found - return jl_box_int64(progress); + // return to julia [err, res] + // err=0: no error, res is the value of the symbol + // err=1: package found but symbol not found, res is junk + // err=2: package not found, res is junk + jl_arrayset(answer, jl_box_int64(err), 0); + jl_arrayset(answer, res, 1); + return reinterpret_cast(answer); } jl_value_t * convert_nested_list(void * l_void) From 7ab694b066f7e351b12a5fefdbb6bc0d4618b530 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Mon, 18 Oct 2021 20:24:01 +0200 Subject: [PATCH 56/95] add p_LmIsConstant --- deps/src/rings.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index c178e89ef..54c7ccf29 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -434,6 +434,12 @@ void singular_define_rings(jlcxx::Module & Singular) Singular.method("p_Mult_nn", [](poly p, number n, ring r) { return p_Mult_nn(p, n, r); }); + Singular.method("p_LmIsConstant", [](poly p, ring r) { + return p_LmIsConstant(p, r) != 0; + }); + Singular.method("p_LmIsConstantComp", [](poly p, ring r) { + return p_LmIsConstantComp(p, r) != 0; + }); Singular.method("p_IsDivisibleBy", [](spolyrec * p, spolyrec * q, ip_sring * r) { poly res; ideal I = idInit(1, 1); From 68c7fccf3df7acd74e563d705b3cb589ad973c1f Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Tue, 31 Aug 2021 13:34:59 +0200 Subject: [PATCH 57/95] add nCoeff_is_Z --- deps/src/coeffs.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/deps/src/coeffs.cpp b/deps/src/coeffs.cpp index bb21d8eb9..82606309e 100644 --- a/deps/src/coeffs.cpp +++ b/deps/src/coeffs.cpp @@ -214,6 +214,10 @@ void singular_define_coeffs(jlcxx::Module & Singular) return bool(nCoeff_is_Q(n)); }); + Singular.method("nCoeff_is_Z", [](coeffs n) { + return bool(nCoeff_is_Z(n)); + }); + Singular.method("nCoeff_is_GF", [](coeffs n) { return bool(nCoeff_is_GF(n)); }); From 072a33d6dc072013189710eab6720816a90adb57 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Mon, 9 Aug 2021 17:35:04 +0200 Subject: [PATCH 58/95] ci bump --- deps/src/caller.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/deps/src/caller.cpp b/deps/src/caller.cpp index dd4bda242..2fd547089 100644 --- a/deps/src/caller.cpp +++ b/deps/src/caller.cpp @@ -308,7 +308,6 @@ jl_value_t * lookup_singular_library_symbol_wo_rng( std::string pack, std::string name) { - int err = 2; jl_value_t * res = jl_nothing; jl_array_t * answer = jl_alloc_array_1d(jl_array_any_type, 2); From bf1f90fecbd2cb083106e4350f009fed6f0c6e42 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Tue, 19 Oct 2021 22:19:47 +0200 Subject: [PATCH 59/95] add rIsLPRing --- deps/src/rings.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index 54c7ccf29..888a7255d 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -319,6 +319,14 @@ void singular_define_rings(jlcxx::Module & Singular) Singular.method("rChar", &rChar); Singular.method("rGetVar", &rGetVar); Singular.method("rVar", &rVar); + Singular.method("rIsLPRing", [](const ring r) { + // return is 0 for not LP Ring, otherwise the number of variables for this ring + #ifdef HAVE_SHIFTBBA + return r->isLPring; + #else + return short(0); + #endif + }); Singular.method("rRingVar", [](short i, const ring r) { return std::string(rRingVar(i, r)); }); From 779598e1f3b909923ab377578ca97492aa7a2180 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Wed, 20 Oct 2021 15:09:13 +0200 Subject: [PATCH 60/95] refactor weyl and exterior algebra --- deps/src/rings.cpp | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index 888a7255d..918582c65 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -134,15 +134,10 @@ auto rDefault_long_helper(coeffs cf, return r; } -auto rDefault_Weyl_helper(coeffs cf, - jlcxx::ArrayRef vars, - jlcxx::ArrayRef ord, - int * blk0, - int * blk1, - unsigned long bitmask) +// turn a normal commutative ring into WeylAlgebra +// ownership of r is taken, so the caller doesn't have to clean up r +ring weylAlgebra(ring r) { - auto r = rDefault_long_helper(cf, vars, ord, blk0, blk1, bitmask); - // vars = indeterminates x1, ..., xn and then partials Dx1, ..., Dxn int n = r->N/2; assume(2*n == r->N); @@ -179,7 +174,7 @@ auto rDefault_Weyl_helper(coeffs cf, } // adapted from jiA_RING in ipassign.cc -static ring make_qring(ring r, ideal id) +ring make_qring(ring r, ideal id) { const ring origin = currRing; rChangeCurrRing(r); @@ -266,15 +261,10 @@ static ring make_qring(ring r, ideal id) return qr; } - -auto rDefault_Exterior_helper(coeffs cf, - jlcxx::ArrayRef vars, - jlcxx::ArrayRef ord, - int * blk0, - int * blk1, - unsigned long bitmask) +// turn a normal commutative ring into ExteriorAlgebra +// ownership of r is taken, so the caller doesn't have to clean up r +ring exteriorAlgebra(ring r) { - auto r = rDefault_long_helper(cf, vars, ord, blk0, blk1, bitmask); int n = rVar(r); // first construct relations xj*xi = -xi*xj poly p = p_Neg(p_One(r), r); @@ -298,12 +288,12 @@ void singular_define_rings(jlcxx::Module & Singular) return reinterpret_cast(ptr); }); Singular.method("freeAlgebra", &freeAlgebra); + Singular.method("weylAlgebra", &weylAlgebra); + Singular.method("exteriorAlgebra", &exteriorAlgebra); Singular.method("rDefault_helper", &rDefault_helper); Singular.method("rDefault_wvhdl_helper", &rDefault_wvhdl_helper); Singular.method("rOrdering_helper", &rOrdering_helper); // inverse of rDefault_wvhdl_helper Singular.method("rDefault_long_helper", &rDefault_long_helper); - Singular.method("rDefault_Weyl_helper", &rDefault_Weyl_helper); - Singular.method("rDefault_Exterior_helper", &rDefault_Exterior_helper); Singular.method("nc_CallPlural", [](matrix C, matrix D, ring r) { ring R = rCopy(r); nc_CallPlural(mp_Copy(C,r), mp_Copy(D,r), NULL, NULL, R, true, false, true, r); @@ -320,7 +310,8 @@ void singular_define_rings(jlcxx::Module & Singular) Singular.method("rGetVar", &rGetVar); Singular.method("rVar", &rVar); Singular.method("rIsLPRing", [](const ring r) { - // return is 0 for not LP Ring, otherwise the number of variables for this ring + // return is 0 for not letterplace Ring + // otherwise the number of variables for this letterplace ring #ifdef HAVE_SHIFTBBA return r->isLPring; #else @@ -345,10 +336,12 @@ void singular_define_rings(jlcxx::Module & Singular) }); Singular.method("rCopy", rCopy); Singular.method("rQuotientRing", [](ideal i, ring r) { + // This looks too simple, try make_qring if it doesn't work. ring Q = rCopy(r); Q->qideal = id_Copy(i, r); return Q; }); + Singular.method("make_qring", &make_qring); Singular.method("rBitmask", [](ip_sring * r) { return (unsigned int)r->bitmask; }); Singular.method("rPar", [](coeffs cf){ From 13fba1ad84cf86684faff881e863f940e3c45ead Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Tue, 14 Sep 2021 18:41:06 +0200 Subject: [PATCH 61/95] singular's degree and mult commands --- deps/src/ideals.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index 6a9dc2600..f64adb75e 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -403,6 +403,45 @@ void singular_define_ideals(jlcxx::Module & Singular) } rChangeCurrRing(origin); }); + Singular.method("scDegree", [](ideal I, ring R) + { + const ring origin = currRing; + rChangeCurrRing(R); + SPrintStart(); + scDegree(I, NULL, R->qideal); + char *s = SPrintEnd(); + s[strlen(s)-1]='\0'; + std::string res(s); + omFree(s); + rChangeCurrRing(origin); + return res; + }); + Singular.method("scDegree", [](ideal I, ring R, jlcxx::ArrayRef w) + { + const ring origin = currRing; + rChangeCurrRing(R); + int sz = w.size(); + intvec * module_w = new intvec(sz); + int * wi = module_w->ivGetVec(); + for (int i=0; iqideal); + // cleanup module_w ??? + char *s = SPrintEnd(); + s[strlen(s)-1]='\0'; + std::string res(s); + omFree(s); + rChangeCurrRing(origin); + return res; + }); + Singular.method("scMultInt", [](ideal I, ring R) { + const ring origin = currRing; + rChangeCurrRing(R); + int k = scMultInt(I, R->qideal); + rChangeCurrRing(origin); + return k; + }); Singular.method("scDimInt", [](ideal I, ring R) { const ring origin = currRing; rChangeCurrRing(R); From aa5cc7d1a3e2e1848797a8e4a3b7ea8b45c85014 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Thu, 21 Oct 2021 23:13:18 +0200 Subject: [PATCH 62/95] add twostd --- deps/src/ideals.cpp | 10 ++++++++++ deps/src/includes.h | 1 + 2 files changed, 11 insertions(+) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index f64adb75e..faa560487 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -146,6 +146,15 @@ auto id_Std_helper(ideal a, ring b, bool complete_reduction = false) return id; } +auto id_TwoStd_helper(ideal a, ring b) +{ + const ring origin = currRing; + rChangeCurrRing(b); + ideal id = twostd(a); + rChangeCurrRing(origin); + return id; +} + void singular_define_ideals(jlcxx::Module & Singular) { Singular.method("id_Delete", @@ -232,6 +241,7 @@ void singular_define_ideals(jlcxx::Module & Singular) Singular.method("id_Slimgb", &id_Slimgb_helper); + Singular.method("id_TwoStd", &id_TwoStd_helper); Singular.method("id_Std", &id_Std_helper); Singular.method("id_StdHilb", &id_StdHilb_helper); diff --git a/deps/src/includes.h b/deps/src/includes.h index 671716110..7b96e11cf 100644 --- a/deps/src/includes.h +++ b/deps/src/includes.h @@ -33,6 +33,7 @@ #include "polys/ext_fields/transext.h" #include #include +#include #include #include #include From a59f544c723ce8843c5c7923c42cb48f749512dc Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Tue, 19 Oct 2021 22:50:26 +0200 Subject: [PATCH 63/95] remove support for julia < 1.6 --- deps/src/OscarCI.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/src/OscarCI.toml b/deps/src/OscarCI.toml index 0972bc845..ca837e2cd 100644 --- a/deps/src/OscarCI.toml +++ b/deps/src/OscarCI.toml @@ -5,7 +5,7 @@ os = [ "ubuntu-latest", "macos-latest" ] # 1.6 is done with some extra combinations in include # also to avoid some weird behaviour by github actions which seems to merge # the includes with the normal matrix entries -julia-version = [ "1.3", "1.4", "1.5", "nightly" ] +julia-version = [ "nightly" ] branches = [ "" ] [pkgs] From c6879084ad79600c0c48ad8fb084d4afc60dd600 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Fri, 22 Oct 2021 14:51:51 +0200 Subject: [PATCH 64/95] add rIsPluralRing --- deps/src/rings.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index 918582c65..a00aedbec 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -309,6 +309,14 @@ void singular_define_rings(jlcxx::Module & Singular) Singular.method("rChar", &rChar); Singular.method("rGetVar", &rGetVar); Singular.method("rVar", &rVar); + Singular.method("rIsPluralRing", [](const ring r) { + // return is an honest bool + #ifdef HAVE_PLURAL + return r->GetNC() != NULL; + #else + return false; + #endif + }); Singular.method("rIsLPRing", [](const ring r) { // return is 0 for not letterplace Ring // otherwise the number of variables for this letterplace ring From 9cb04ffab4066936b4083dc27e7670c88811c159 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Wed, 20 Oct 2021 11:47:13 +0200 Subject: [PATCH 65/95] remove support for julia < 1.6 --- deps/src/.github/workflows/CI.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/deps/src/.github/workflows/CI.yml b/deps/src/.github/workflows/CI.yml index ad2b6802c..e0070157b 100644 --- a/deps/src/.github/workflows/CI.yml +++ b/deps/src/.github/workflows/CI.yml @@ -14,9 +14,6 @@ jobs: fail-fast: false matrix: julia-version: - - '1.3' - - '1.4' - - '1.5' - '1.6' - 'nightly' os: From 464d12df6c8142f284f7a61840474429b744182f Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Wed, 10 Nov 2021 18:47:12 +0100 Subject: [PATCH 66/95] don't always write to stderr --- deps/src/singular.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/deps/src/singular.cpp b/deps/src/singular.cpp index 0c1e8e4c3..00ed8065f 100644 --- a/deps/src/singular.cpp +++ b/deps/src/singular.cpp @@ -31,21 +31,26 @@ static void WarningS_for_julia(const char * s) /* This is the non-temporary callback for all errors (unless the temporary - ones are in use by call_interpreter). It is probably safest to log the error - to both singular_error and stderr, so that a missing libSingular.check_error - does not cause error to go completely unnoticed. + ones are in use by call_interpreter). We would like to simultaneously: + 1. be able to check and report errors via libSingular.check_error() + 2. know when errors have been generated but uncaught by the julia code so + that libSingular.check_error() can be inserted into the right place + Unfortunately, a single call to the Singular kernel can generate multiple + calls to WerrorS_callback, thus we don't know if previous errors were + generated as a result of a missing libSingular.check_error() or if Singular + has just called WerrorS_callback 10 times in the same function. + The compromise here is to keep the full backlog of unreported errors and + start complaining to stderr once the backlog gets too long. */ static void WerrorS_and_reset(const char * s) { errorreported = 0; - if (!singular_error.empty()) - singular_error += ". "; - singular_error += s; - /* and, copied from WerrorS in Singular:*/ - fwrite(" singular error: ", 1, 20, stderr); - fwrite(s, 1, strlen(s), stderr); - fwrite("\n", 1, 1, stderr); - fflush(stderr); + if (singular_error.length() > 99) + { + std::cerr << singular_error << std::endl; + std::cerr << "!!! Singular error(s) unhandled by julia !!!" << std::endl << std::endl; + } + singular_error.append(s); } JLCXX_MODULE define_julia_module(jlcxx::Module & Singular) From 9d0b4510777b739c8b01f11126c5f89c01c593c3 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Sat, 23 Oct 2021 13:04:16 +0200 Subject: [PATCH 67/95] avoid using n_Init with ring as second arugment --- deps/src/rings.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index a00aedbec..ed7787d52 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -402,12 +402,12 @@ void singular_define_rings(jlcxx::Module & Singular) Singular.method("p_Setm", p_Setm); Singular.method("p_Neg", p_Neg); Singular.method("pGetCoeff", [](spolyrec * p) { return pGetCoeff(p); }); - Singular.method("pSetCoeff", [](spolyrec * p, long c, ip_sring * r) { - number n = n_Init(c, r); + Singular.method("pSetCoeff", [](poly p, long c, ring r) { + number n = n_Init(c, r->cf); return p_SetCoeff(p, n, r); }); - Singular.method("pSetCoeff0", [](spolyrec * p, long c, ip_sring * r) { - number n = n_Init(c, r); + Singular.method("pSetCoeff0", [](poly p, long c, ring r) { + number n = n_Init(c, r->cf); return p_SetCoeff0(p, n, r); }); Singular.method("pLDeg", [](spolyrec * a, ip_sring * r) { From 9e3ad75293efda65930ebfaa1a8d2fe249c2a3a7 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Thu, 11 Nov 2021 10:21:55 +0100 Subject: [PATCH 68/95] threshold based on number of errors, not number of characters --- deps/src/singular.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/deps/src/singular.cpp b/deps/src/singular.cpp index 00ed8065f..2012ca711 100644 --- a/deps/src/singular.cpp +++ b/deps/src/singular.cpp @@ -9,6 +9,7 @@ static std::string singular_return; static std::string singular_error; static std::string singular_warning; +static std::vector singular_error_log; // Internal singular interpreter variable extern int inerror; @@ -45,12 +46,13 @@ static void WarningS_for_julia(const char * s) static void WerrorS_and_reset(const char * s) { errorreported = 0; - if (singular_error.length() > 99) + if (singular_error_log.size() > 9) { - std::cerr << singular_error << std::endl; + for (auto & si : singular_error_log) + std::cerr << si << std::endl; std::cerr << "!!! Singular error(s) unhandled by julia !!!" << std::endl << std::endl; } - singular_error.append(s); + singular_error_log.emplace_back(s); } JLCXX_MODULE define_julia_module(jlcxx::Module & Singular) @@ -118,13 +120,15 @@ JLCXX_MODULE define_julia_module(jlcxx::Module & Singular) }); Singular.method("have_error", []() { - return !singular_error.empty(); + return !singular_error_log.empty(); }); Singular.method("get_and_clear_error", []() { - std::string s(std::move(singular_error)); - singular_error.clear(); - return s; + std::stringstream ss; + for (auto & si : singular_error_log) + ss << si << std::endl; + singular_error_log.clear(); + return ss.str(); }); #define SETTER(A, B) \ From 4063cbfb2d4028bcb531401f8dbd6b8bcdd1f9ff Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Thu, 25 Nov 2021 16:43:29 +0100 Subject: [PATCH 69/95] add degBound and multBound setters --- deps/src/singular.cpp | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/deps/src/singular.cpp b/deps/src/singular.cpp index 2012ca711..3f00e800a 100644 --- a/deps/src/singular.cpp +++ b/deps/src/singular.cpp @@ -133,9 +133,15 @@ JLCXX_MODULE define_julia_module(jlcxx::Module & Singular) #define SETTER(A, B) \ else if (opt == #B) \ - A = value ? (A | Sy_bit(B)) : (A & ~Sy_bit(B)); + { \ + old_value = (A & Sy_bit(B)) != 0; \ + A = value ? (A | Sy_bit(B)) : (A & ~Sy_bit(B)); \ + } - Singular.method("set_option", [](std::string opt, bool value) { + // all of the global setters return the previous value + Singular.method("set_option", [](std::string opt, bool value) + { + bool old_value = false; if (false); SETTER(si_opt_2, V_QUIET) SETTER(si_opt_2, V_QRING) @@ -185,12 +191,42 @@ JLCXX_MODULE define_julia_module(jlcxx::Module & Singular) SETTER(si_opt_1, OPT_SB_1) SETTER(si_opt_1, OPT_NOTREGULARITY) SETTER(si_opt_1, OPT_WEIGHTM) + else + { + std::cerr << "unknown option " << opt << std::endl; + } + return old_value; }); #undef SETTER + // the "printlevel" system variable in Singular Singular.method("set_printlevel", [](int level) { + int old_level = printlevel; printlevel = level; + return old_level; + }); + + // the "degBound" system variable in Singular + Singular.method("set_degBound", [](int degb) { + int old_degb = Kstd1_deg; + Kstd1_deg = degb; + if (Kstd1_deg != 0) + si_opt_1 |= Sy_bit(OPT_DEGBOUND); + else + si_opt_1 &= ~Sy_bit(OPT_DEGBOUND); + return old_degb; + }); + + // the "multBound" system variable in Singular + Singular.method("set_multBound", [](int mu) { + int old_mu = Kstd1_mu; + Kstd1_mu = mu; + if (Kstd1_mu != 0) + si_opt_1 |= Sy_bit(OPT_MULTBOUND); + else + si_opt_1 &= ~Sy_bit(OPT_MULTBOUND); + return old_mu; }); singular_define_coeffs(Singular); From f6bea85e559760bdc93950240e44706424aa2cad Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Wed, 17 Nov 2021 15:11:45 +0100 Subject: [PATCH 70/95] add pMultMp --- deps/src/ideals.cpp | 4 ++++ deps/src/matrices.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index faa560487..6a83dd7be 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -195,6 +195,10 @@ void singular_define_ideals(jlcxx::Module & Singular) return (ideal) mp_MultP((matrix) i, p, r); }); + Singular.method("pMultId", [](poly p, ideal i, ring r) { + return (ideal) pMultMp(p, (matrix) i, r); + }); + Singular.method("id_Power", &id_Power); Singular.method("id_IsEqual", [](ideal m, ideal n, ring o) { diff --git a/deps/src/matrices.cpp b/deps/src/matrices.cpp index cf07cf972..5c046f019 100644 --- a/deps/src/matrices.cpp +++ b/deps/src/matrices.cpp @@ -36,6 +36,8 @@ void singular_define_matrices(jlcxx::Module & Singular) Singular.method("mp_MultP", &mp_MultP); + Singular.method("pMultMp", &pMultMp); + Singular.method("mp_Equal", &mp_Equal); Singular.method("mpNew", [](int r, int c) { From ee73db2aaa7cf7f69ac52f05409d356cf66252bf Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Fri, 18 Feb 2022 12:11:40 +0100 Subject: [PATCH 71/95] add scHilbWeighted (weighted Hilbert series) --- deps/src/ideals.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index 348feea87..0d4ef3b52 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -498,4 +498,23 @@ void singular_define_ideals(jlcxx::Module & Singular) } rChangeCurrRing(origin); }); + Singular.method("scHilbWeighted", [](ideal I, ring r, jlcxx::ArrayRef weights, jlcxx::ArrayRef a) { + int sz = weights.size(); + intvec * w = new intvec(sz); + int * hi = w->ivGetVec(); + for (int i=0; i< sz; i++) { + hi[i] = weights[i]; + } + const ring origin = currRing; + rChangeCurrRing(r); + intvec *v=hFirstSeries(I,NULL,r->qideal,w); + delete w; + int * content = v->ivGetVec(); + for(int j = 0; j < v->length(); j++) + { + a.push_back(content[j]); + } + delete v; + rChangeCurrRing(origin); + }); } From 67f54aeef5e8f0cb9a758e0992f031c381420dda Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Fri, 18 Feb 2022 15:16:30 +0100 Subject: [PATCH 72/95] fix memory leaks with intvec --- deps/src/ideals.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index 0d4ef3b52..5bcffb5f5 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -102,6 +102,7 @@ auto id_StdHilb_helper(ideal a, ring b, jlcxx::ArrayRef h, bool complete_re } else id = idInit(0, a->rank); + delete hilb; return id; } @@ -450,7 +451,7 @@ void singular_define_ideals(jlcxx::Module & Singular) wi[i] = w[i]; SPrintStart(); scDegree(I, module_w, R->qideal); - // cleanup module_w ??? + delete module_w; char *s = SPrintEnd(); s[strlen(s)-1]='\0'; std::string res(s); From 7a015c9b1549e19e137ea3cf159aa85f4f56d437 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 31 Jan 2022 09:53:28 +0100 Subject: [PATCH 73/95] add two arg kbase (#51) --- deps/src/ideals.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index 6a83dd7be..348feea87 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -365,6 +365,15 @@ void singular_define_ideals(jlcxx::Module & Singular) return res; }); + Singular.method("id_kbase", [](ideal I, int n, ring r) { + ideal res; + const ring origin = currRing; + rChangeCurrRing(r); + res = scKBase(n, I, r->qideal); + rChangeCurrRing(origin); + return res; + }); + Singular.method("id_highcorner", [](ideal I, ring r) { poly h; const ring origin = currRing; From 46f48f6ab7ef9e3178ecb040c5c89dc6bbf5ee3e Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 21 Mar 2022 12:44:25 +0100 Subject: [PATCH 74/95] Update coeffs.cpp --- deps/src/coeffs.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/deps/src/coeffs.cpp b/deps/src/coeffs.cpp index 82606309e..167c22dce 100644 --- a/deps/src/coeffs.cpp +++ b/deps/src/coeffs.cpp @@ -425,7 +425,6 @@ void singular_define_coeffs(jlcxx::Module & Singular) Singular.method("omFree_internal", [](void * m) { omFree(m); }); /* Setting a Ptr{number} to a number */ - Singular.method("setindex_internal", [](void * x, snumber * y) { *reinterpret_cast(x) = y; }); From 60a1b940f6fbc71bd4193b60a819c10973a4618a Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 6 Sep 2022 17:39:14 +0200 Subject: [PATCH 75/95] some opposite functions --- deps/src/rings.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index f8c216b4a..f76384126 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -605,4 +605,16 @@ void singular_define_rings(jlcxx::Module & Singular) { res = -1;} return res; }); + + // creates an opposite algebra of R + // ring rOpposite(ring src) + Singular.method("rOpposite", rOpposite); + + // opposes a vector p from Rop to currRing (dst!) + // poly pOppose(ring Rop, poly p, const ring dst) + Singular.method("pOppose", pOppose); + + // opposes a module I from Rop to currRing(dst) + // ideal idOppose(ring Rop, ideal I, const ring dst) + Singular.method("idOppose", idOppose); } From 8d6cbdd63b1d7eb40156b9f9d00d0bb2b5566dfb Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 28 Oct 2022 13:38:09 +0200 Subject: [PATCH 76/95] this needs to be copied --- deps/src/caller.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/deps/src/caller.cpp b/deps/src/caller.cpp index 2fd547089..e957cb51f 100644 --- a/deps/src/caller.cpp +++ b/deps/src/caller.cpp @@ -249,7 +249,10 @@ jl_value_t * get_ring_content(ring r) jl_arrayset(current, jl_box_int64(IDTYP(h)), 0); jl_arrayset(current, reinterpret_cast(jl_symbol(IDID(h))), 1); - jl_arrayset(current, jl_box_voidpointer(IDDATA(h)), 2); + { + sleftv x; x.Copy((leftv)h); + jl_arrayset(current, jl_box_voidpointer(x.data), 2); + } jl_arrayset(result, reinterpret_cast(current), nr); h = IDNEXT(h); nr++; From cec6bffa89f29a10e3c2c83a83d24d42eaf85d7c Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Wed, 26 Oct 2022 11:45:11 +0200 Subject: [PATCH 77/95] pass flag to p_Reduce --- deps/src/rings.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index f76384126..17ff06d4f 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -538,6 +538,22 @@ void singular_define_rings(jlcxx::Module & Singular) rChangeCurrRing(origin); return res; }); + Singular.method("p_Reduce", + [](spolyrec * p, sip_sideal * G, ip_sring * R, int flag) { + const ring origin = currRing; + rChangeCurrRing(R); + poly res = kNF(G, R->qideal, p, 0, flag); + rChangeCurrRing(origin); + return res; + }); + Singular.method("p_Reduce", + [](sip_sideal * p, sip_sideal * G, ip_sring * R, int flag) { + const ring origin = currRing; + rChangeCurrRing(R); + ideal res = kNF(G, R->qideal, p, 0, flag); + rChangeCurrRing(origin); + return res; + }); Singular.method("letterplace_ring_helper", [](ip_sring * r, long block_size) { From 6eb901a95afe347546dbe13628efcde222310c48 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 12 Oct 2022 14:03:00 +0200 Subject: [PATCH 78/95] CI: update some actions to latest versions GitHub warns that this is needed because they are updating from Node 12 to 16 --- deps/src/.github/workflows/CI.yml | 2 +- deps/src/.github/workflows/oscar.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deps/src/.github/workflows/CI.yml b/deps/src/.github/workflows/CI.yml index e0070157b..08080d014 100644 --- a/deps/src/.github/workflows/CI.yml +++ b/deps/src/.github/workflows/CI.yml @@ -21,7 +21,7 @@ jobs: - macOS-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: "Set up Julia" uses: julia-actions/setup-julia@v1 with: diff --git a/deps/src/.github/workflows/oscar.yml b/deps/src/.github/workflows/oscar.yml index a7eb62604..b75452429 100644 --- a/deps/src/.github/workflows/oscar.yml +++ b/deps/src/.github/workflows/oscar.yml @@ -15,7 +15,7 @@ jobs: PR_NUMBER: ${{github.event.number}} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2.1.0 + - uses: actions/checkout@v3 - name: "Set up Julia" uses: julia-actions/setup-julia@v1 with: @@ -55,7 +55,7 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@v2.1.0 + - uses: actions/checkout@v3 - name: "Set up Julia" uses: julia-actions/setup-julia@v1 with: From df0a230d09a7acfc4f16c27cdd9d5775b121f9da Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 28 Oct 2022 16:12:34 +0200 Subject: [PATCH 79/95] change basering for the copies --- deps/src/caller.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/deps/src/caller.cpp b/deps/src/caller.cpp index e957cb51f..a59d0c1c7 100644 --- a/deps/src/caller.cpp +++ b/deps/src/caller.cpp @@ -234,6 +234,9 @@ jl_value_t * get_julia_type_from_sleftv(leftv ret) jl_value_t * get_ring_content(ring r) { + ring save = currRing; + rChangeCurrRing(r); + // count elements idhdl h = r->idroot; int nr = 0; @@ -257,6 +260,8 @@ jl_value_t * get_ring_content(ring r) h = IDNEXT(h); nr++; } + + rChangeCurrRing(save); return reinterpret_cast(result); } From a7f2af35864ef5814abef4dc0b836f93857c4d1f Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 2 Nov 2022 13:16:03 +0100 Subject: [PATCH 80/95] missing intvec delete --- deps/src/ideals.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index bce12c433..88d5242be 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -497,6 +497,7 @@ void singular_define_ideals(jlcxx::Module & Singular) { a.push_back(content[j]); } + delete v; rChangeCurrRing(origin); }); Singular.method("scHilbWeighted", [](ideal I, ring r, jlcxx::ArrayRef weights, jlcxx::ArrayRef a) { From a903f0c5efe3442405561f0a4fb4d14fc3aeb6a2 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 3 Nov 2022 12:58:22 +0100 Subject: [PATCH 81/95] gc protection --- deps/src/caller.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/deps/src/caller.cpp b/deps/src/caller.cpp index a59d0c1c7..6c3fe3ebe 100644 --- a/deps/src/caller.cpp +++ b/deps/src/caller.cpp @@ -43,16 +43,19 @@ static jl_value_t * get_type_mapper() jl_array_t * return_array = jl_alloc_array_1d( jl_array_any_type, sizeof(types) / sizeof(types[0])); - + JL_GC_PUSH1(&return_array); for (int i = 0; i < sizeof(types) / sizeof(types[0]); i++) { jl_array_t * current_return = jl_alloc_array_1d(jl_array_any_type, 2); + JL_GC_PUSH1(¤t_return); jl_arrayset(current_return, jl_box_int64(types[i].cmd), 0); jl_arrayset(current_return, reinterpret_cast(jl_symbol(types[i].name)), 1); + JL_GC_POP(); jl_arrayset(return_array, reinterpret_cast(current_return), i); } + JL_GC_POP(); return reinterpret_cast(return_array); } @@ -89,20 +92,21 @@ static inline void * get_ptr_from_cxxwrap_obj(jl_value_t * obj) jl_value_t * intvec_to_jl_array(intvec * v) { - int size = v->length(); + int size = v->length(); jl_array_t * result = jl_alloc_array_1d(jl_int64_vector_type, size); - int * v_content = v->ivGetVec(); + JL_GC_PUSH1(&result); + int * content = v->ivGetVec(); for (int i = 0; i < size; i++) { - jl_arrayset(result, jl_box_int64(static_cast(v_content[i])), - i); + jl_arrayset(result, jl_box_int64(static_cast(content[i])), i); } + JL_GC_POP(); return reinterpret_cast(result); } jl_value_t * intmat_to_jl_array(intvec * v) { - int rows = v->rows(); - int cols = v->cols(); + int rows = v->rows(); + int cols = v->cols(); jl_array_t * result = jl_alloc_array_2d(jl_int64_matrix_type, rows, cols); int64_t * result_ptr = reinterpret_cast jl_array_data(result); for (int i = 0; i < rows; i++) { @@ -245,10 +249,12 @@ jl_value_t * get_ring_content(ring r) h = IDNEXT(h); } jl_array_t * result = jl_alloc_array_1d(jl_array_any_type, nr); + JL_GC_PUSH1(&result); h = r->idroot; nr = 0; while (h != NULL) { jl_array_t * current = jl_alloc_array_1d(jl_array_any_type, 3); + JL_GC_PUSH1(¤t); jl_arrayset(current, jl_box_int64(IDTYP(h)), 0); jl_arrayset(current, reinterpret_cast(jl_symbol(IDID(h))), 1); @@ -256,11 +262,12 @@ jl_value_t * get_ring_content(ring r) sleftv x; x.Copy((leftv)h); jl_arrayset(current, jl_box_voidpointer(x.data), 2); } + JL_GC_POP(); jl_arrayset(result, reinterpret_cast(current), nr); h = IDNEXT(h); nr++; } - + JL_GC_POP(); rChangeCurrRing(save); return reinterpret_cast(result); } @@ -288,6 +295,7 @@ jl_value_t * call_singular_library_procedure( if (ret->next != NULL) { int len = ret->listLength(); jl_array_t * list = jl_alloc_array_1d(jl_array_any_type, len + 1); + JL_GC_PUSH1(&list); jl_arrayset(list, jl_true, 0); for (int i = 0; i < len; ++i) { leftv next = ret->next; @@ -297,6 +305,7 @@ jl_value_t * call_singular_library_procedure( omFreeBin(ret, sleftv_bin); ret = next; } + JL_GC_POP(); retObj = reinterpret_cast(list); } else { @@ -319,6 +328,7 @@ jl_value_t * lookup_singular_library_symbol_wo_rng( int err = 2; jl_value_t * res = jl_nothing; jl_array_t * answer = jl_alloc_array_1d(jl_array_any_type, 2); + JL_GC_PUSH1(&answer); leftv u = (leftv) IDROOT->get(pack.c_str(),0); if (u != NULL) { @@ -338,6 +348,7 @@ jl_value_t * lookup_singular_library_symbol_wo_rng( // err=2: package not found, res is junk jl_arrayset(answer, jl_box_int64(err), 0); jl_arrayset(answer, res, 1); + JL_GC_POP(); return reinterpret_cast(answer); } @@ -346,6 +357,7 @@ jl_value_t * convert_nested_list(void * l_void) lists l = reinterpret_cast(l_void); int len = lSize(l) + 1; jl_array_t * result_array = jl_alloc_array_1d(jl_array_any_type, len); + JL_GC_PUSH1(&result_array); for (int i = 0; i < len; i++) { leftv current = &(l->m[i]); if (current->Typ() == LIST_CMD) { @@ -358,6 +370,7 @@ jl_value_t * convert_nested_list(void * l_void) jl_arrayset(result_array, get_julia_type_from_sleftv(current), i); } } + JL_GC_POP(); return reinterpret_cast(result_array); } From 237471ef0a51b911e06248d324a3b7072eb28809 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 5 May 2022 18:32:13 +0200 Subject: [PATCH 82/95] add homogeneous functions --- deps/src/ideals.cpp | 12 ++++++++++++ deps/src/rings.cpp | 2 ++ 2 files changed, 14 insertions(+) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index 5bcffb5f5..bce12c433 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -518,4 +518,16 @@ void singular_define_ideals(jlcxx::Module & Singular) delete v; rChangeCurrRing(origin); }); + Singular.method("id_Homogen", id_Homogen); + Singular.method("id_HomModule", [](jlcxx::ArrayRef weights, ideal I, ring r) { + intvec* w = NULL; + bool res = id_HomModule(I, r->qideal, &w, r); + if (w != NULL) + { + for (int i = 0; i < w->length(); i++) + weights.push_back((*w)[i]); + delete w; + } + return res; + }); } diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index ed7787d52..331424bf7 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -401,6 +401,8 @@ void singular_define_rings(jlcxx::Module & Singular) Singular.method("p_SortAdd", p_SortAdd); Singular.method("p_Setm", p_Setm); Singular.method("p_Neg", p_Neg); + Singular.method("p_WTotaldegree", p_WTotaldegree); + Singular.method("p_Homogen", p_Homogen); Singular.method("pGetCoeff", [](spolyrec * p) { return pGetCoeff(p); }); Singular.method("pSetCoeff", [](poly p, long c, ring r) { number n = n_Init(c, r->cf); From b235d6a27658d3feb2406009d09b2c0f1faa3d9d Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 11 Nov 2022 17:14:16 +0100 Subject: [PATCH 83/95] Don't corrupt the ring data. Also, incidentally use lex. --- deps/src/coeffs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deps/src/coeffs.cpp b/deps/src/coeffs.cpp index 167c22dce..f942f90a8 100644 --- a/deps/src/coeffs.cpp +++ b/deps/src/coeffs.cpp @@ -7,8 +7,8 @@ auto transExt_helper(coeffs cf, jlcxx::ArrayRef param) for (int i = 0; i < len; i++) { param_ptr[i] = reinterpret_cast(param[i]); } - ring r = rDefault(cf, len, param_ptr); - r->order[0] = ringorder_dp; + // use lex because the ordering doesn't matter for coefficient operations + ring r = rDefault(cf, len, param_ptr, ringorder_lp); delete[] param_ptr; TransExtInfo extParam; extParam.r = r; From ba6ac0f6191770e664a6465c6c6ed17361a0841d Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 12 Jul 2022 16:50:44 +0200 Subject: [PATCH 84/95] add getter for qideal --- deps/src/rings.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/deps/src/rings.cpp b/deps/src/rings.cpp index 331424bf7..f8c216b4a 100644 --- a/deps/src/rings.cpp +++ b/deps/src/rings.cpp @@ -343,6 +343,7 @@ void singular_define_rings(jlcxx::Module & Singular) return r->qideal != NULL; }); Singular.method("rCopy", rCopy); + Singular.method("r_get_qideal", [](ring r) {return r->qideal;}); Singular.method("rQuotientRing", [](ideal i, ring r) { // This looks too simple, try make_qring if it doesn't work. ring Q = rCopy(r); From db7ce9627560d30422a80def3c0ace151324e573 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 7 Dec 2022 16:42:18 +0100 Subject: [PATCH 85/95] add functions for std_hilbert --- deps/src/ideals.cpp | 85 +++++++++++++++++++++++++++++++-------------- 1 file changed, 59 insertions(+), 26 deletions(-) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index 88d5242be..c740bacf8 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -72,15 +72,24 @@ auto id_Slimgb_helper(ideal a, ring b, bool complete_reduction = false) id = idInit(0, a->rank); return id; } -auto id_StdHilb_helper(ideal a, ring b, jlcxx::ArrayRef h, bool complete_reduction = false) + +auto id_InterRed_helper(ideal a, ring b) { - int sz = h.size(); - intvec * hilb = new intvec(sz); - int * hi = hilb->ivGetVec(); - for (int i=0; i< sz; i++) { - hi[i] = h[i]; + ideal id = NULL; + if (!idIs0(a)) { + const ring origin = currRing; + rChangeCurrRing(b); + id = kInterRed(a, b->qideal); + rChangeCurrRing(origin); } + else + id = idInit(0, a->rank); + return id; +} +auto id_Std_helper(ideal a, ring b, bool complete_reduction = false) +{ + // bool complete_reduction= false; unsigned int crbit; if (complete_reduction) crbit = Sy_bit(OPT_REDSB); @@ -94,7 +103,7 @@ auto id_StdHilb_helper(ideal a, ring b, jlcxx::ArrayRef h, bool complete_re unsigned int save_opt = si_opt_1; si_opt_1 |= crbit; rChangeCurrRing(b); - id = kStd(a, b->qideal, h, &n, hilb ); + id = kStd(a, b->qideal, h, &n); si_opt_1 = save_opt; rChangeCurrRing(origin); if (n != NULL) @@ -102,27 +111,53 @@ auto id_StdHilb_helper(ideal a, ring b, jlcxx::ArrayRef h, bool complete_re } else id = idInit(0, a->rank); - delete hilb; return id; } -auto id_InterRed_helper(ideal a, ring b) +intvec* to_intvec(jlcxx::ArrayRef a) +{ + int sz = a.size(); + intvec * w = new intvec(sz); + int * hi = w->ivGetVec(); + for (int i=0; i h, bool complete_reduction = false) { + intvec* hilb = to_intvec(h); + + unsigned int crbit; + if (complete_reduction) + crbit = Sy_bit(OPT_REDSB); + else + crbit = 0; ideal id = NULL; if (!idIs0(a)) { + intvec * n = NULL; + tHomog h = testHomog; const ring origin = currRing; + unsigned int save_opt = si_opt_1; + si_opt_1 |= crbit; rChangeCurrRing(b); - id = kInterRed(a, b->qideal); + id = kStd(a, b->qideal, h, &n, hilb); + si_opt_1 = save_opt; rChangeCurrRing(origin); + if (n != NULL) + delete n; } else id = idInit(0, a->rank); + delete hilb; return id; } -auto id_Std_helper(ideal a, ring b, bool complete_reduction = false) +auto id_StdHilbWeighted_helper(ideal a, ring b, jlcxx::ArrayRef h, jlcxx::ArrayRef vw, bool complete_reduction = false) { - // bool complete_reduction= false; + intvec* hilb = to_intvec(h); + intvec* varweights = to_intvec(vw); + unsigned int crbit; if (complete_reduction) crbit = Sy_bit(OPT_REDSB); @@ -136,7 +171,13 @@ auto id_Std_helper(ideal a, ring b, bool complete_reduction = false) unsigned int save_opt = si_opt_1; si_opt_1 |= crbit; rChangeCurrRing(b); - id = kStd(a, b->qideal, h, &n); + id = kStd(a, + currRing->qideal, + h, + &n, // module weights + hilb, // hilbert series + 0,0, // syzComp, newIdeal + varweights); // weights of vars si_opt_1 = save_opt; rChangeCurrRing(origin); if (n != NULL) @@ -144,6 +185,8 @@ auto id_Std_helper(ideal a, ring b, bool complete_reduction = false) } else id = idInit(0, a->rank); + delete hilb; + delete varweights; return id; } @@ -249,6 +292,7 @@ void singular_define_ideals(jlcxx::Module & Singular) Singular.method("id_TwoStd", &id_TwoStd_helper); Singular.method("id_Std", &id_Std_helper); Singular.method("id_StdHilb", &id_StdHilb_helper); + Singular.method("id_StdHilbWeighted", &id_StdHilbWeighted_helper); Singular.method("id_InterRed", &id_InterRed_helper); @@ -444,11 +488,7 @@ void singular_define_ideals(jlcxx::Module & Singular) { const ring origin = currRing; rChangeCurrRing(R); - int sz = w.size(); - intvec * module_w = new intvec(sz); - int * wi = module_w->ivGetVec(); - for (int i=0; iqideal); delete module_w; @@ -494,19 +534,12 @@ void singular_define_ideals(jlcxx::Module & Singular) intvec *v=hFirstSeries(I,NULL,r->qideal); int * content = v->ivGetVec(); for(int j = 0; j < v->length(); j++) - { a.push_back(content[j]); - } delete v; rChangeCurrRing(origin); }); Singular.method("scHilbWeighted", [](ideal I, ring r, jlcxx::ArrayRef weights, jlcxx::ArrayRef a) { - int sz = weights.size(); - intvec * w = new intvec(sz); - int * hi = w->ivGetVec(); - for (int i=0; i< sz; i++) { - hi[i] = weights[i]; - } + intvec * w = to_intvec(weights); const ring origin = currRing; rChangeCurrRing(r); intvec *v=hFirstSeries(I,NULL,r->qideal,w); From 175ef19d680d8655fcc27e12d3e59a156f7a75d0 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 2 Dec 2022 13:07:19 +0100 Subject: [PATCH 86/95] field for annihilator (#66) --- deps/src/coeff_rings.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deps/src/coeff_rings.cpp b/deps/src/coeff_rings.cpp index c3cb25707..c9925a1b3 100644 --- a/deps/src/coeff_rings.cpp +++ b/deps/src/coeff_rings.cpp @@ -21,6 +21,7 @@ typedef struct __singular_coeff_ring_struct { void* cfDiv; void* cfDivBy; void* cfInvers; + void* cfAnn; void* cfGcd; void* cfSubringGcd; void* cfExtGcd; @@ -59,6 +60,7 @@ void fill_coeffs_with_function_data(jl_value_t* coeff_struct, void* cf_void){ cf->cfDiv = (numberfunc) cf_input->cfDiv; cf->cfDivBy = (BOOLEAN (*)(number, number, const coeffs)) cf_input->cfDivBy; cf->cfInvers = (number (*)(number, const coeffs)) cf_input->cfInvers; + cf->cfAnn = (number (*)(number, const coeffs)) cf_input->cfAnn; cf->cfGcd = (numberfunc) cf_input->cfGcd; cf->cfSubringGcd = (numberfunc) cf_input->cfSubringGcd; cf->cfExtGcd = (number (*)(number, number, number *, number *, const coeffs)) cf_input->cfExtGcd; From dc6a5752ee9428a95e0c998dd81b59cc5289b306 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 20 Jul 2022 15:22:52 +0200 Subject: [PATCH 87/95] Update caller.cpp --- deps/src/caller.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/deps/src/caller.cpp b/deps/src/caller.cpp index 2fd547089..50087648d 100644 --- a/deps/src/caller.cpp +++ b/deps/src/caller.cpp @@ -6,6 +6,9 @@ #include #include +// Internal singular interpreter variable +extern int inerror; + static jl_value_t * jl_int64_vector_type; static jl_value_t * jl_int64_matrix_type; static jl_value_t * jl_singular_number_type; @@ -275,6 +278,8 @@ jl_value_t * call_singular_library_procedure( jl_value_t * retObj; leftv ret = ii_CallLibProcM(s.c_str(), args, argtypes, r, err); if (err) { + inerror = 0; + errorreported = 0; jl_error("Could not call function"); } if (ret->next != NULL) { From 5c60e60f685c47fed59faffa86a63a8584c9664d Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Fri, 17 Feb 2023 16:09:45 +0100 Subject: [PATCH 88/95] access to mp_Wedge --- deps/src/matrices.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/deps/src/matrices.cpp b/deps/src/matrices.cpp index 5c046f019..a1832b7bb 100644 --- a/deps/src/matrices.cpp +++ b/deps/src/matrices.cpp @@ -48,6 +48,10 @@ void singular_define_matrices(jlcxx::Module & Singular) return mp_InitP(n, n, p_Copy(p, R), R); }); + Singular.method("mp_Wedge", [](matrix M,int n, ring R) { + return mp_Wedge(M, n, R); + }); + Singular.method("irrCharSeries", &singclap_irrCharSeries); Singular.method("iiStringMatrix", [](matrix I, int d, ring o) { From 6e26f940f223ae3403752944ceed6e7f5b794393 Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Tue, 18 Apr 2023 11:40:44 +0200 Subject: [PATCH 89/95] dd flag to id_DivRem, id_DivRem_Unit --- deps/src/ideals.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index c60e0f8bd..5cc447668 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -343,6 +343,15 @@ void singular_define_ideals(jlcxx::Module & Singular) return std::make_tuple(res, factors); }); + Singular.method("id_DivRem", [](ideal m, ideal sm, ring o, int flag) { + const ring origin = currRing; + rChangeCurrRing(o); + ideal factors; + ideal res = idDivRem(sm, m, factors, NULL,flag); + rChangeCurrRing(origin); + return std::make_tuple(res, factors); + }); + Singular.method("id_DivRem_Unit", [](ideal m, ideal sm, ring o) { const ring origin = currRing; rChangeCurrRing(o); @@ -353,6 +362,16 @@ void singular_define_ideals(jlcxx::Module & Singular) return std::make_tuple(res, factors, unit); }); + Singular.method("id_DivRem_Unit", [](ideal m, ideal sm, ring o, int flag) { + const ring origin = currRing; + rChangeCurrRing(o); + ideal factors; + ideal unit; + ideal res = idDivRem(sm, m, factors, &unit, flag); + rChangeCurrRing(origin); + return std::make_tuple(res, factors, unit); + }); + Singular.method("id_Lift", [](ideal m, ideal sm, ring o) { const ring origin = currRing; rChangeCurrRing(o); From 42224dbc6ca1cf58091e165ba3031d30f8fd7b60 Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Fri, 17 Mar 2023 16:05:57 +0100 Subject: [PATCH 90/95] add id_MinStd --- deps/src/ideals.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index c740bacf8..54116c485 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -114,6 +114,35 @@ auto id_Std_helper(ideal a, ring b, bool complete_reduction = false) return id; } +auto id_MinStd_helper(ideal a, ring b, bool complete_reduction = false) +{ + // bool complete_reduction= false; + unsigned int crbit; + if (complete_reduction) + crbit = Sy_bit(OPT_REDSB); + else + crbit = 0; + ideal id = NULL; + ideal m = NULL; + if (!idIs0(a)) + { + tHomog h = testHomog; + const ring origin = currRing; + unsigned int save_opt = si_opt_1; + si_opt_1 |= crbit; + rChangeCurrRing(b); + id = kMin_std(a, b->qideal, h, NULL, m); + si_opt_1 = save_opt; + rChangeCurrRing(origin); + } + else + { + id = idInit(0, a->rank); + m = idInit(0, a->rank); + } + return std::make_tuple(id, m); +} + intvec* to_intvec(jlcxx::ArrayRef a) { int sz = a.size(); @@ -289,6 +318,7 @@ void singular_define_ideals(jlcxx::Module & Singular) Singular.method("id_Slimgb", &id_Slimgb_helper); + Singular.method("id_MinStd", &id_MinStd_helper); Singular.method("id_TwoStd", &id_TwoStd_helper); Singular.method("id_Std", &id_Std_helper); Singular.method("id_StdHilb", &id_StdHilb_helper); From 37d251d5b62358e30fc2966cb7f9f9802fee627d Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Mon, 8 May 2023 15:40:41 +0200 Subject: [PATCH 91/95] scHilbWeighted for modules --- deps/src/ideals.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index 5cc447668..3eeb3df15 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -620,6 +620,22 @@ void singular_define_ideals(jlcxx::Module & Singular) delete v; rChangeCurrRing(origin); }); +    Singular.method("scHilbWeighted", [](ideal I, ring r, jlcxx::ArrayRef weights, jlcxx::ArrayRef shifts, jlcxx::ArrayRef a) { +        intvec * w = to_intvec(weights); +        intvec * sh = to_intvec(shifts); +        const ring origin = currRing; +        rChangeCurrRing(r); +        intvec *v=hFirstSeries(I,sh,r->qideal,w); +        delete sh; +        delete w; +        int * content = v->ivGetVec(); +        for(int j = 0; j < v->length(); j++) +        { +          a.push_back(content[j]); +        } +        delete v; +        rChangeCurrRing(origin); +    }); Singular.method("id_Homogen", id_Homogen); Singular.method("id_HomModule", [](jlcxx::ArrayRef weights, ideal I, ring r) { intvec* w = NULL; From a12204ab51d4a8ddc14cee7e1f5a17b18bd462df Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Fri, 17 Mar 2023 14:26:13 +0100 Subject: [PATCH 92/95] add id_DivRem, id_DivRem_Unit --- deps/src/ideals.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index c740bacf8..53477e21d 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -304,6 +304,25 @@ void singular_define_ideals(jlcxx::Module & Singular) return res; }); + Singular.method("id_DivRem", [](ideal m, ideal sm, ring o) { + const ring origin = currRing; + rChangeCurrRing(o); + ideal factors; + ideal res = idDivRem(sm, m, factors, NULL); + rChangeCurrRing(origin); + return std::make_tuple(res, factors); + }); + + Singular.method("id_DivRem_Unit", [](ideal m, ideal sm, ring o) { + const ring origin = currRing; + rChangeCurrRing(o); + ideal factors; + ideal unit; + ideal res = idDivRem(sm, m, factors, &unit); + rChangeCurrRing(origin); + return std::make_tuple(res, factors, unit); + }); + Singular.method("id_Lift", [](ideal m, ideal sm, ring o) { const ring origin = currRing; rChangeCurrRing(o); From be1ac81ba744149ee30c836990c1a6e5a3f6110e Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Thu, 11 May 2023 14:29:07 +0200 Subject: [PATCH 93/95] add nres/mres: id_res --- deps/src/ideals.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index 3cd9dff9e..9268286dd 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -31,6 +31,20 @@ auto id_fres_helper(sip_sideal * I, int n, std::string method, ring R) return std::make_tuple(s, minimal); } +auto id_res_helper(sip_sideal * I, int n, int minimize, ring R) +{ + auto origin = currRing; + rChangeCurrRing(R); + syStrategy s = syResolution(I, n, minimize); + rChangeCurrRing(origin); + auto r = s->minres; + bool minimal = true; + if (r == NULL) { + r = s->fullres; + minimal = false; + } + return std::make_tuple(s, minimal); +} ideal id_Syzygies_internal(ideal m, ring o) { @@ -316,6 +330,8 @@ void singular_define_ideals(jlcxx::Module & Singular) Singular.method("id_fres", &id_fres_helper); + Singular.method("id_res", &id_res_helper); + Singular.method("id_Slimgb", &id_Slimgb_helper); Singular.method("id_MinStd", &id_MinStd_helper); From b6b5d075d9e721f4665249c5b7482d55fcb5ae49 Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Mon, 8 May 2023 15:50:57 +0200 Subject: [PATCH 94/95] fix extended characters --- deps/src/ideals.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index 3eeb3df15..3cd9dff9e 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -620,22 +620,22 @@ void singular_define_ideals(jlcxx::Module & Singular) delete v; rChangeCurrRing(origin); }); -    Singular.method("scHilbWeighted", [](ideal I, ring r, jlcxx::ArrayRef weights, jlcxx::ArrayRef shifts, jlcxx::ArrayRef a) { -        intvec * w = to_intvec(weights); -        intvec * sh = to_intvec(shifts); -        const ring origin = currRing; -        rChangeCurrRing(r); -        intvec *v=hFirstSeries(I,sh,r->qideal,w); -        delete sh; -        delete w; -        int * content = v->ivGetVec(); -        for(int j = 0; j < v->length(); j++) -        { -          a.push_back(content[j]); -        } -        delete v; -        rChangeCurrRing(origin); -    }); + Singular.method("scHilbWeighted", [](ideal I, ring r, jlcxx::ArrayRef weights, jlcxx::ArrayRef shifts, jlcxx::ArrayRef a) { + intvec * w = to_intvec(weights); + intvec * sh = to_intvec(shifts); + const ring origin = currRing; + rChangeCurrRing(r); + intvec *v=hFirstSeries(I,sh,r->qideal,w); + delete sh; + delete w; + int * content = v->ivGetVec(); + for(int j = 0; j < v->length(); j++) + { + a.push_back(content[j]); + } + delete v; + rChangeCurrRing(origin); + }); Singular.method("id_Homogen", id_Homogen); Singular.method("id_HomModule", [](jlcxx::ArrayRef weights, ideal I, ring r) { intvec* w = NULL; From 73af1a6b0f99c11f00837c535db818ca2de7d9a2 Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Thu, 11 May 2023 14:41:52 +0200 Subject: [PATCH 95/95] fix syResolvente --- deps/src/ideals.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index 9268286dd..78a9339c7 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -35,7 +35,7 @@ auto id_res_helper(sip_sideal * I, int n, int minimize, ring R) { auto origin = currRing; rChangeCurrRing(R); - syStrategy s = syResolution(I, n, minimize); + syStrategy s = syResolution(I, n, NULL, (BOOLEAN)minimize); rChangeCurrRing(origin); auto r = s->minres; bool minimal = true;