pax_global_header00006660000000000000000000000064127470732430014523gustar00rootroot0000000000000052 comment=b6b4b8685c28d312e7e1a4576848a8bd7f96d45b givaro-4.0.2/000077500000000000000000000000001274707324300130155ustar00rootroot00000000000000givaro-4.0.2/.gitignore000066400000000000000000000160351274707324300150120ustar00rootroot00000000000000ARCHIVES *Makefile Makefile.in config.h.in *.o *.lo *.la *~ *.libs *.trs *log *status *cache *aux docs/Doxyfile docs/DoxyfileDev aclocal.m4 benchmarks/benchmark-recint_exp benchmarks/benchmark-recint_inv_arazi benchmarks/benchmark-recint_inv_naive benchmarks/benchmark-recint_mul config.h configure examples/FiniteField/GF128 examples/FiniteField/GFirreducible examples/FiniteField/GaloisFields examples/FiniteField/Test_Extension examples/FiniteField/all_field examples/FiniteField/domain_to_operatorstyle examples/FiniteField/exponentiation examples/FiniteField/ff_arith examples/FiniteField/gfq_atomic examples/FiniteField/zpz_atomic examples/Integer/ModularSquareRoot examples/Integer/ProbLucas examples/Integer/RSA_breaking examples/Integer/RSA_decipher examples/Integer/RSA_encipher examples/Integer/RSA_keys_generator examples/Integer/iexponentiation examples/Integer/ifactor examples/Integer/ifactor_lenstra examples/Integer/igcd examples/Integer/igcdext examples/Integer/ilcm examples/Integer/ispower examples/Integer/isprime examples/Integer/isproot examples/Integer/lambda examples/Integer/lambda_inv examples/Integer/nb_primes examples/Integer/nextprime examples/Integer/order examples/Integer/phi examples/Integer/prevprime examples/Integer/primitiveelement examples/Integer/primitiveroot examples/Integer/probable_primroot examples/Polynomial/PolynomialCRT examples/Polynomial/bivariate examples/Polynomial/highorder examples/Polynomial/interpolate examples/Polynomial/isirred examples/Polynomial/isprimitive examples/Polynomial/pol_arith examples/Polynomial/pol_eval examples/Polynomial/pol_factor examples/Polynomial/trunc_arith examples/Rational/iratrecon examples/Rational/polydouble examples/RecInt/recint-iterator examples/RecInt/rsa givaro-config givaro-config.h givaro-makefile givaro.pc libtool macros/libtool.m4 macros/ltoptions.m4 macros/ltsugar.m4 macros/ltversion.m4 macros/lt~obsolete.m4 src/kernel/bstruct/givaro src/kernel/field/givaro src/kernel/gmp++/gmp++ src/kernel/integer/givaro src/kernel/memory/givaro src/kernel/rational/givaro src/kernel/recint/recint src/kernel/ring/givaro src/kernel/system/givaro src/library/matrix/givaro src/library/poly1/givaro src/library/tools/givaro src/library/vector/givaro stamp-h1 tests/test-conversion tests/test-crt tests/test-ffarith tests/test-geom tests/test-ifactor tests/test-integer tests/test-mod tests/test-modsqroot tests/test-poly tests/test-random tests/test-ratrecon tests/test-recint_cast tests/test-recint_convert tests/test-recint_convert_mg tests/test-recint_exp tests/test-recint_exp_mg tests/test-recint_extra tests/test-recint_extra_mg tests/test-recint_rand tests/test-recint_rand_mg tests/test-ringarith tests/test-rint_arith_add tests/test-rint_arith_mod tests/test-rint_arith_mul tests/test-rint_arith_sub tests/test-rmint_arith_add tests/test-rmint_arith_add_mg tests/test-rmint_arith_addmul tests/test-rmint_arith_addmul_mg tests/test-rmint_arith_mod tests/test-rmint_arith_mod_mg tests/test-rmint_arith_mul tests/test-rmint_arith_mul_mg tests/test-rmint_arith_sub tests/test-rmint_arith_sub_mg tests/test-rmint_comparisons tests/test-rmint_comparisons_mg tests/test-rmint_complex tests/test-rmint_complex_mg tests/test-rmint_constructors tests/test-rmint_constructors_mg tests/test-rmint_inv_div tests/test-rmint_inv_div_mg tests/test-rmint_montgomery tests/test-rmint_neg tests/test-rmint_neg_mg tests/test-ruint_arazi tests/test-ruint_arith_add tests/test-ruint_arith_addmul tests/test-ruint_arith_div tests/test-ruint_arith_mul tests/test-ruint_arith_sub tests/test-ruint_comparisons tests/test-ruint_complex tests/test-ruint_constructors tests/test-ruint_fiddling tests/test-ruint_lmul tests/test-ruint_operators tests/test-ruint_shift tests/test-ruint_square tests/test-trunc examples/FiniteField/GF128.exe examples/FiniteField/GFirreducible.exe examples/FiniteField/GaloisFields.exe examples/FiniteField/Test_Extension.exe examples/FiniteField/all_field.exe examples/FiniteField/domain_to_operatorstyle.exe examples/FiniteField/exponentiation.exe examples/FiniteField/ff_arith.exe examples/FiniteField/gfq_atomic.exe examples/FiniteField/zpz_atomic.exe examples/Integer/ModularSquareRoot.exe examples/Integer/ProbLucas.exe examples/Integer/RSA_breaking.exe examples/Integer/RSA_decipher.exe examples/Integer/RSA_encipher.exe examples/Integer/RSA_keys_generator.exe examples/Integer/iexponentiation.exe examples/Integer/ifactor.exe examples/Integer/ifactor_lenstra.exe examples/Integer/igcd.exe examples/Integer/igcdext.exe examples/Integer/ilcm.exe examples/Integer/ispower.exe examples/Integer/isprime.exe examples/Integer/isproot.exe examples/Integer/lambda.exe examples/Integer/lambda_inv.exe examples/Integer/nb_primes.exe examples/Integer/nextprime.exe examples/Integer/order.exe examples/Integer/phi.exe examples/Integer/prevprime.exe examples/Integer/primitiveelement.exe examples/Integer/primitiveroot.exe examples/Integer/probable_primroot.exe examples/Polynomial/PolynomialCRT.exe examples/Polynomial/bivariate.exe examples/Polynomial/highorder.exe examples/Polynomial/interpolate.exe examples/Polynomial/isirred.exe examples/Polynomial/isprimitive.exe examples/Polynomial/pol_arith.exe examples/Polynomial/pol_eval.exe examples/Polynomial/pol_factor.exe examples/Polynomial/trunc_arith.exe examples/Rational/iratrecon.exe examples/Rational/polydouble.exe examples/RecInt/iterator.exe examples/RecInt/rsa.exe tests/test-conversion.exe tests/test-crt.exe tests/test-ffarith.exe tests/test-geom.exe tests/test-ifactor.exe tests/test-integer.exe tests/test-mod.exe tests/test-modsqroot.exe tests/test-poly.exe tests/test-random.exe tests/test-ratrecon.exe tests/test-recint_cast.exe tests/test-recint_convert.exe tests/test-recint_convert_mg.exe tests/test-recint_exp.exe tests/test-recint_exp_mg.exe tests/test-recint_extra.exe tests/test-recint_extra_mg.exe tests/test-recint_rand.exe tests/test-recint_rand_mg.exe tests/test-ringarith.exe tests/test-rint_arith_add.exe tests/test-rint_arith_mod.exe tests/test-rint_arith_mul.exe tests/test-rint_arith_sub.exe tests/test-rmint_arith_add.exe tests/test-rmint_arith_add_mg.exe tests/test-rmint_arith_addmul.exe tests/test-rmint_arith_addmul_mg.exe tests/test-rmint_arith_mod.exe tests/test-rmint_arith_mod_mg.exe tests/test-rmint_arith_mul.exe tests/test-rmint_arith_mul_mg.exe tests/test-rmint_arith_sub.exe tests/test-rmint_arith_sub_mg.exe tests/test-rmint_comparisons.exe tests/test-rmint_comparisons_mg.exe tests/test-rmint_complex.exe tests/test-rmint_complex_mg.exe tests/test-rmint_constructors.exe tests/test-rmint_constructors_mg.exe tests/test-rmint_inv_div.exe tests/test-rmint_inv_div_mg.exe tests/test-rmint_montgomery.exe tests/test-rmint_neg.exe tests/test-rmint_neg_mg.exe tests/test-ruint_arazi.exe tests/test-ruint_arith_add.exe tests/test-ruint_arith_addmul.exe tests/test-ruint_arith_div.exe tests/test-ruint_arith_mul.exe tests/test-ruint_arith_sub.exe tests/test-ruint_comparisons.exe tests/test-ruint_complex.exe tests/test-ruint_constructors.exe tests/test-ruint_fiddling.exe tests/test-ruint_lmul.exe tests/test-ruint_operators.exe tests/test-ruint_shift.exe tests/test-ruint_square.exe tests/test-trunc.exe givaro-4.0.2/.travis.yml000066400000000000000000000015601274707324300151300ustar00rootroot00000000000000sudo: required dist: trusty language: cpp matrix: include: - compiler: gcc env: COMPILER=g++-4.9 addons: apt: sources: - ubuntu-toolchain-r-test packages: - g++-4.9 - libgmp-dev - libgmpxx4ldbl - compiler: gcc env: COMPILER=g++-5 addons: apt: sources: - ubuntu-toolchain-r-test packages: - g++-5 - libgmp-dev - libgmpxx4ldbl - compiler: clang env: COMPILER=clang++ addons: apt: packages: - libgmp-dev - libgmpxx4ldbl install: export CXX="$COMPILER" before_script: - ./autogen.sh script: - make - make check - make benchmarks - make examples - make dist notifications: on_success: change on_failure: alwaysgivaro-4.0.2/AUTHORS000066400000000000000000000002721274707324300140660ustar00rootroot00000000000000Authors of the Givaro library Brice Boyer Alexis Breust Jean-Guillaume Dumas Thierry Gautier Pascal Giorgi Romain Lebreton Clément Pernet Jean-Louis Roch Bastien Vialla Gilles Villard givaro-4.0.2/COPYING000077700000000000000000000000001274707324300203532Licence_CeCILL-B_V1-fr.txtustar00rootroot00000000000000givaro-4.0.2/COPYRIGHT000066400000000000000000000033671274707324300143210ustar00rootroot00000000000000Copyright The Givaro Group 1994-2009 Main contributors: - Jean-Guillaume.Dumas@imag.fr - Thierry.Gautier@imag.fr - Pascal.Giorgi@lirmm.fr - Clement.Pernet@imag.fr - Jean-Louis.Roch@imag.fr - Gilles.Villard@ens-lyon.fr Givaro is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL-B license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info" ; the full CeCILL-B license can also be found in english and in french (Licence_CeCILL-B_V1-en.txt and Licence_CeCILL-B_V1-fr.txt) in the root directory of this distribution. As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL-B license and that you accept its terms. givaro-4.0.2/ChangeLog000066400000000000000000000002451274707324300145700ustar00rootroot000000000000002003-12-11 Pascal Giorgi * /src/kernel/zpz/givzpz.h add struct Std64 with some definition and redefine in the ggod way int64 & uint64 givaro-4.0.2/INSTALL000066400000000000000000000002101274707324300140370ustar00rootroot00000000000000make ; make install should be good enough. Don't forget to configure with --prefix so your installation goes to the intented location ! givaro-4.0.2/Licence_CeCILL-B_V1-en.txt000066400000000000000000000516241274707324300173300ustar00rootroot00000000000000 CeCILL-B FREE SOFTWARE LICENSE AGREEMENT Notice This Agreement is a Free Software license agreement that is the result of discussions between its authors in order to ensure compliance with the two main principles guiding its drafting: * firstly, compliance with the principles governing the distribution of Free Software: access to source code, broad rights granted to users, * secondly, the election of a governing law, French law, with which it is conformant, both as regards the law of torts and intellectual property law, and the protection that it offers to both authors and holders of the economic rights over software. The authors of the CeCILL-B (for Ce[a] C[nrs] I[nria] L[ogiciel] L[ibre]) license are: Commissariat à l'Energie Atomique - CEA, a public scientific, technical and industrial research establishment, having its principal place of business at 25 rue Leblanc, immeuble Le Ponant D, 75015 Paris, France. Centre National de la Recherche Scientifique - CNRS, a public scientific and technological establishment, having its principal place of business at 3 rue Michel-Ange, 75794 Paris cedex 16, France. Institut National de Recherche en Informatique et en Automatique - INRIA, a public scientific and technological establishment, having its principal place of business at Domaine de Voluceau, Rocquencourt, BP 105, 78153 Le Chesnay cedex, France. Preamble This Agreement is an open source software license intended to give users significant freedom to modify and redistribute the software licensed hereunder. The exercising of this freedom is conditional upon a strong obligation of giving credits for everybody that distributes a software incorporating a software ruled by the current license so as all contributions to be properly identified and acknowledged. In consideration of access to the source code and the rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors only have limited liability. In this respect, the risks associated with loading, using, modifying and/or developing or reproducing the software by the user are brought to the user's attention, given its Free Software status, which may make it complicated to use, with the result that its use is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the suitability of the software as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions of security. This Agreement may be freely reproduced and published, provided it is not altered, and that no provisions are either added or removed herefrom. This Agreement may apply to any or all software for which the holder of the economic rights decides to submit the use thereof to its provisions. Article 1 - DEFINITIONS For the purpose of this Agreement, when the following expressions commence with a capital letter, they shall have the following meaning: Agreement: means this license agreement, and its possible subsequent versions and annexes. Software: means the software in its Object Code and/or Source Code form and, where applicable, its documentation, "as is" when the Licensee accepts the Agreement. Initial Software: means the Software in its Source Code and possibly its Object Code form and, where applicable, its documentation, "as is" when it is first distributed under the terms and conditions of the Agreement. Modified Software: means the Software modified by at least one Contribution. Source Code: means all the Software's instructions and program lines to which access is required so as to modify the Software. Object Code: means the binary files originating from the compilation of the Source Code. Holder: means the holder(s) of the economic rights over the Initial Software. Licensee: means the Software user(s) having accepted the Agreement. Contributor: means a Licensee having made at least one Contribution. Licensor: means the Holder, or any other individual or legal entity, who distributes the Software under the Agreement. Contribution: means any or all modifications, corrections, translations, adaptations and/or new functions integrated into the Software by any or all Contributors, as well as any or all Internal Modules. Module: means a set of sources files including their documentation that enables supplementary functions or services in addition to those offered by the Software. External Module: means any or all Modules, not derived from the Software, so that this Module and the Software run in separate address spaces, with one calling the other when they are run. Internal Module: means any or all Module, connected to the Software so that they both execute in the same address space. Parties: mean both the Licensee and the Licensor. These expressions may be used both in singular and plural form. Article 2 - PURPOSE The purpose of the Agreement is the grant by the Licensor to the Licensee of a non-exclusive, transferable and worldwide license for the Software as set forth in Article 5 hereinafter for the whole term of the protection granted by the rights over said Software. Article 3 - ACCEPTANCE 3.1 The Licensee shall be deemed as having accepted the terms and conditions of this Agreement upon the occurrence of the first of the following events: * (i) loading the Software by any or all means, notably, by downloading from a remote server, or by loading from a physical medium; * (ii) the first time the Licensee exercises any of the rights granted hereunder. 3.2 One copy of the Agreement, containing a notice relating to the characteristics of the Software, to the limited warranty, and to the fact that its use is restricted to experienced users has been provided to the Licensee prior to its acceptance as set forth in Article 3.1 hereinabove, and the Licensee hereby acknowledges that it has read and understood it. Article 4 - EFFECTIVE DATE AND TERM 4.1 EFFECTIVE DATE The Agreement shall become effective on the date when it is accepted by the Licensee as set forth in Article 3.1. 4.2 TERM The Agreement shall remain in force for the entire legal term of protection of the economic rights over the Software. Article 5 - SCOPE OF RIGHTS GRANTED The Licensor hereby grants to the Licensee, who accepts, the following rights over the Software for any or all use, and for the term of the Agreement, on the basis of the terms and conditions set forth hereinafter. Besides, if the Licensor owns or comes to own one or more patents protecting all or part of the functions of the Software or of its components, the Licensor undertakes not to enforce the rights granted by these patents against successive Licensees using, exploiting or modifying the Software. If these patents are transferred, the Licensor undertakes to have the transferees subscribe to the obligations set forth in this paragraph. 5.1 RIGHT OF USE The Licensee is authorized to use the Software, without any limitation as to its fields of application, with it being hereinafter specified that this comprises: 1. permanent or temporary reproduction of all or part of the Software by any or all means and in any or all form. 2. loading, displaying, running, or storing the Software on any or all medium. 3. entitlement to observe, study or test its operation so as to determine the ideas and principles behind any or all constituent elements of said Software. This shall apply when the Licensee carries out any or all loading, displaying, running, transmission or storage operation as regards the Software, that it is entitled to carry out hereunder. 5.2 ENTITLEMENT TO MAKE CONTRIBUTIONS The right to make Contributions includes the right to translate, adapt, arrange, or make any or all modifications to the Software, and the right to reproduce the resulting software. The Licensee is authorized to make any or all Contributions to the Software provided that it includes an explicit notice that it is the author of said Contribution and indicates the date of the creation thereof. 5.3 RIGHT OF DISTRIBUTION In particular, the right of distribution includes the right to publish, transmit and communicate the Software to the general public on any or all medium, and by any or all means, and the right to market, either in consideration of a fee, or free of charge, one or more copies of the Software by any means. The Licensee is further authorized to distribute copies of the modified or unmodified Software to third parties according to the terms and conditions set forth hereinafter. 5.3.1 DISTRIBUTION OF SOFTWARE WITHOUT MODIFICATION The Licensee is authorized to distribute true copies of the Software in Source Code or Object Code form, provided that said distribution complies with all the provisions of the Agreement and is accompanied by: 1. a copy of the Agreement, 2. a notice relating to the limitation of both the Licensor's warranty and liability as set forth in Articles 8 and 9, and that, in the event that only the Object Code of the Software is redistributed, the Licensee allows effective access to the full Source Code of the Software at a minimum during the entire period of its distribution of the Software, it being understood that the additional cost of acquiring the Source Code shall not exceed the cost of transferring the data. 5.3.2 DISTRIBUTION OF MODIFIED SOFTWARE If the Licensee makes any Contribution to the Software, the resulting Modified Software may be distributed under a license agreement other than this Agreement subject to compliance with the provisions of Article 5.3.4. 5.3.3 DISTRIBUTION OF EXTERNAL MODULES When the Licensee has developed an External Module, the terms and conditions of this Agreement do not apply to said External Module, that may be distributed under a separate license agreement. 5.3.4 CREDITS Any Licensee who may distribute a Modified Software hereby expressly agrees to: 1. indicate in the related documentation that it is based on the Software licensed hereunder, and reproduce the intellectual property notice for the Software, 2. ensure that written indications of the Software intended use, intellectual property notice and license hereunder are included in easily accessible format from the Modified Software interface, 3. mention, on a freely accessible website describing the Modified Software, at least throughout the distribution term thereof, that it is based on the Software licensed hereunder, and reproduce the Software intellectual property notice, 4. where it is distributed to a third party that may distribute a Modified Software without having to make its source code available, make its best efforts to ensure that said third party agrees to comply with the obligations set forth in this Article . If the Software, whether or not modified, is distributed with an External Module designed for use in connection with the Software, the Licensee shall submit said External Module to the foregoing obligations. 5.3.5 COMPATIBILITY WITH THE CeCILL AND CeCILL-C LICENSES Where a Modified Software contains a Contribution subject to the CeCILL license, the provisions set forth in Article 5.3.4 shall be optional. A Modified Software may be distributed under the CeCILL-C license. In such a case the provisions set forth in Article 5.3.4 shall be optional. Article 6 - INTELLECTUAL PROPERTY 6.1 OVER THE INITIAL SOFTWARE The Holder owns the economic rights over the Initial Software. Any or all use of the Initial Software is subject to compliance with the terms and conditions under which the Holder has elected to distribute its work and no one shall be entitled to modify the terms and conditions for the distribution of said Initial Software. The Holder undertakes that the Initial Software will remain ruled at least by this Agreement, for the duration set forth in Article 4.2. 6.2 OVER THE CONTRIBUTIONS The Licensee who develops a Contribution is the owner of the intellectual property rights over this Contribution as defined by applicable law. 6.3 OVER THE EXTERNAL MODULES The Licensee who develops an External Module is the owner of the intellectual property rights over this External Module as defined by applicable law and is free to choose the type of agreement that shall govern its distribution. 6.4 JOINT PROVISIONS The Licensee expressly undertakes: 1. not to remove, or modify, in any manner, the intellectual property notices attached to the Software; 2. to reproduce said notices, in an identical manner, in the copies of the Software modified or not. The Licensee undertakes not to directly or indirectly infringe the intellectual property rights of the Holder and/or Contributors on the Software and to take, where applicable, vis-à-vis its staff, any and all measures required to ensure respect of said intellectual property rights of the Holder and/or Contributors. Article 7 - RELATED SERVICES 7.1 Under no circumstances shall the Agreement oblige the Licensor to provide technical assistance or maintenance services for the Software. However, the Licensor is entitled to offer this type of services. The terms and conditions of such technical assistance, and/or such maintenance, shall be set forth in a separate instrument. Only the Licensor offering said maintenance and/or technical assistance services shall incur liability therefor. 7.2 Similarly, any Licensor is entitled to offer to its licensees, under its sole responsibility, a warranty, that shall only be binding upon itself, for the redistribution of the Software and/or the Modified Software, under terms and conditions that it is free to decide. Said warranty, and the financial terms and conditions of its application, shall be subject of a separate instrument executed between the Licensor and the Licensee. Article 8 - LIABILITY 8.1 Subject to the provisions of Article 8.2, the Licensee shall be entitled to claim compensation for any direct loss it may have suffered from the Software as a result of a fault on the part of the relevant Licensor, subject to providing evidence thereof. 8.2 The Licensor's liability is limited to the commitments made under this Agreement and shall not be incurred as a result of in particular: (i) loss due the Licensee's total or partial failure to fulfill its obligations, (ii) direct or consequential loss that is suffered by the Licensee due to the use or performance of the Software, and (iii) more generally, any consequential loss. In particular the Parties expressly agree that any or all pecuniary or business loss (i.e. loss of data, loss of profits, operating loss, loss of customers or orders, opportunity cost, any disturbance to business activities) or any or all legal proceedings instituted against the Licensee by a third party, shall constitute consequential loss and shall not provide entitlement to any or all compensation from the Licensor. Article 9 - WARRANTY 9.1 The Licensee acknowledges that the scientific and technical state-of-the-art when the Software was distributed did not enable all possible uses to be tested and verified, nor for the presence of possible defects to be detected. In this respect, the Licensee's attention has been drawn to the risks associated with loading, using, modifying and/or developing and reproducing the Software which are reserved for experienced users. The Licensee shall be responsible for verifying, by any or all means, the suitability of the product for its requirements, its good working order, and for ensuring that it shall not cause damage to either persons or properties. 9.2 The Licensor hereby represents, in good faith, that it is entitled to grant all the rights over the Software (including in particular the rights set forth in Article 5). 9.3 The Licensee acknowledges that the Software is supplied "as is" by the Licensor without any other express or tacit warranty, other than that provided for in Article 9.2 and, in particular, without any warranty as to its commercial value, its secured, safe, innovative or relevant nature. Specifically, the Licensor does not warrant that the Software is free from any error, that it will operate without interruption, that it will be compatible with the Licensee's own equipment and software configuration, nor that it will meet the Licensee's requirements. 9.4 The Licensor does not either expressly or tacitly warrant that the Software does not infringe any third party intellectual property right relating to a patent, software or any other property right. Therefore, the Licensor disclaims any and all liability towards the Licensee arising out of any or all proceedings for infringement that may be instituted in respect of the use, modification and redistribution of the Software. Nevertheless, should such proceedings be instituted against the Licensee, the Licensor shall provide it with technical and legal assistance for its defense. Such technical and legal assistance shall be decided on a case-by-case basis between the relevant Licensor and the Licensee pursuant to a memorandum of understanding. The Licensor disclaims any and all liability as regards the Licensee's use of the name of the Software. No warranty is given as regards the existence of prior rights over the name of the Software or as regards the existence of a trademark. Article 10 - TERMINATION 10.1 In the event of a breach by the Licensee of its obligations hereunder, the Licensor may automatically terminate this Agreement thirty (30) days after notice has been sent to the Licensee and has remained ineffective. 10.2 A Licensee whose Agreement is terminated shall no longer be authorized to use, modify or distribute the Software. However, any licenses that it may have granted prior to termination of the Agreement shall remain valid subject to their having been granted in compliance with the terms and conditions hereof. Article 11 - MISCELLANEOUS 11.1 EXCUSABLE EVENTS Neither Party shall be liable for any or all delay, or failure to perform the Agreement, that may be attributable to an event of force majeure, an act of God or an outside cause, such as defective functioning or interruptions of the electricity or telecommunications networks, network paralysis following a virus attack, intervention by government authorities, natural disasters, water damage, earthquakes, fire, explosions, strikes and labor unrest, war, etc. 11.2 Any failure by either Party, on one or more occasions, to invoke one or more of the provisions hereof, shall under no circumstances be interpreted as being a waiver by the interested Party of its right to invoke said provision(s) subsequently. 11.3 The Agreement cancels and replaces any or all previous agreements, whether written or oral, between the Parties and having the same purpose, and constitutes the entirety of the agreement between said Parties concerning said purpose. No supplement or modification to the terms and conditions hereof shall be effective as between the Parties unless it is made in writing and signed by their duly authorized representatives. 11.4 In the event that one or more of the provisions hereof were to conflict with a current or future applicable act or legislative text, said act or legislative text shall prevail, and the Parties shall make the necessary amendments so as to comply with said act or legislative text. All other provisions shall remain effective. Similarly, invalidity of a provision of the Agreement, for any reason whatsoever, shall not cause the Agreement as a whole to be invalid. 11.5 LANGUAGE The Agreement is drafted in both French and English and both versions are deemed authentic. Article 12 - NEW VERSIONS OF THE AGREEMENT 12.1 Any person is authorized to duplicate and distribute copies of this Agreement. 12.2 So as to ensure coherence, the wording of this Agreement is protected and may only be modified by the authors of the License, who reserve the right to periodically publish updates or new versions of the Agreement, each with a separate number. These subsequent versions may address new issues encountered by Free Software. 12.3 Any Software distributed under a given version of the Agreement may only be subsequently distributed under the same version of the Agreement or a subsequent version. Article 13 - GOVERNING LAW AND JURISDICTION 13.1 The Agreement is governed by French law. The Parties agree to endeavor to seek an amicable solution to any disagreements or disputes that may arise during the performance of the Agreement. 13.2 Failing an amicable solution within two (2) months as from their occurrence, and unless emergency proceedings are necessary, the disagreements or disputes shall be referred to the Paris Courts having jurisdiction, by the more diligent Party. Version 1.0 dated 2006-09-05. givaro-4.0.2/Licence_CeCILL-B_V1-fr.txt000066400000000000000000000536001274707324300173310ustar00rootroot00000000000000 CONTRAT DE LICENCE DE LOGICIEL LIBRE CeCILL-B Avertissement Ce contrat est une licence de logiciel libre issue d'une concertation entre ses auteurs afin que le respect de deux grands principes préside à sa rédaction: * d'une part, le respect des principes de diffusion des logiciels libres: accès au code source, droits étendus conférés aux utilisateurs, * d'autre part, la désignation d'un droit applicable, le droit français, auquel elle est conforme, tant au regard du droit de la responsabilité civile que du droit de la propriété intellectuelle et de la protection qu'il offre aux auteurs et titulaires des droits patrimoniaux sur un logiciel. Les auteurs de la licence CeCILL-B (pour Ce[a] C[nrs] I[nria] L[ogiciel] L[ibre]) sont: Commissariat à l'Energie Atomique - CEA, établissement public de recherche à caractère scientifique, technique et industriel, dont le siège est situé 25 rue Leblanc, immeuble Le Ponant D, 75015 Paris. Centre National de la Recherche Scientifique - CNRS, établissement public à caractère scientifique et technologique, dont le siège est situé 3 rue Michel-Ange, 75794 Paris cedex 16. Institut National de Recherche en Informatique et en Automatique - INRIA, établissement public à caractère scientifique et technologique, dont le siège est situé Domaine de Voluceau, Rocquencourt, BP 105, 78153 Le Chesnay cedex. Préambule Ce contrat est une licence de logiciel libre dont l'objectif est de conférer aux utilisateurs une très large liberté de modification et de redistribution du logiciel régi par cette licence. L'exercice de cette liberté est assorti d'une obligation forte de citation à la charge de ceux qui distribueraient un logiciel incorporant un logiciel régi par la présente licence afin d'assurer que les contributions de tous soient correctement identifiées et reconnues. L'accessibilité au code source et les droits de copie, de modification et de redistribution qui découlent de ce contrat ont pour contrepartie de n'offrir aux utilisateurs qu'une garantie limitée et de ne faire peser sur l'auteur du logiciel, le titulaire des droits patrimoniaux et les concédants successifs qu'une responsabilité restreinte. A cet égard l'attention de l'utilisateur est attirée sur les risques associés au chargement, à l'utilisation, à la modification et/ou au développement et à la reproduction du logiciel par l'utilisateur étant donné sa spécificité de logiciel libre, qui peut le rendre complexe à manipuler et qui le réserve donc à des développeurs ou des professionnels avertis possédant des connaissances informatiques approfondies. Les utilisateurs sont donc invités à charger et tester l'adéquation du logiciel à leurs besoins dans des conditions permettant d'assurer la sécurité de leurs systèmes et/ou de leurs données et, plus généralement, à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. Ce contrat peut être reproduit et diffusé librement, sous réserve de le conserver en l'état, sans ajout ni suppression de clauses. Ce contrat est susceptible de s'appliquer à tout logiciel dont le titulaire des droits patrimoniaux décide de soumettre l'exploitation aux dispositions qu'il contient. Article 1 - DEFINITIONS Dans ce contrat, les termes suivants, lorsqu'ils seront écrits avec une lettre capitale, auront la signification suivante: Contrat: désigne le présent contrat de licence, ses éventuelles versions postérieures et annexes. Logiciel: désigne le logiciel sous sa forme de Code Objet et/ou de Code Source et le cas échéant sa documentation, dans leur état au moment de l'acceptation du Contrat par le Licencié. Logiciel Initial: désigne le Logiciel sous sa forme de Code Source et éventuellement de Code Objet et le cas échéant sa documentation, dans leur état au moment de leur première diffusion sous les termes du Contrat. Logiciel Modifié: désigne le Logiciel modifié par au moins une Contribution. Code Source: désigne l'ensemble des instructions et des lignes de programme du Logiciel et auquel l'accès est nécessaire en vue de modifier le Logiciel. Code Objet: désigne les fichiers binaires issus de la compilation du Code Source. Titulaire: désigne le ou les détenteurs des droits patrimoniaux d'auteur sur le Logiciel Initial. Licencié: désigne le ou les utilisateurs du Logiciel ayant accepté le Contrat. Contributeur: désigne le Licencié auteur d'au moins une Contribution. Concédant: désigne le Titulaire ou toute personne physique ou morale distribuant le Logiciel sous le Contrat. Contribution: désigne l'ensemble des modifications, corrections, traductions, adaptations et/ou nouvelles fonctionnalités intégrées dans le Logiciel par tout Contributeur, ainsi que tout Module Interne. Module: désigne un ensemble de fichiers sources y compris leur documentation qui permet de réaliser des fonctionnalités ou services supplémentaires à ceux fournis par le Logiciel. Module Externe: désigne tout Module, non dérivé du Logiciel, tel que ce Module et le Logiciel s'exécutent dans des espaces d'adressage différents, l'un appelant l'autre au moment de leur exécution. Module Interne: désigne tout Module lié au Logiciel de telle sorte qu'ils s'exécutent dans le même espace d'adressage. Parties: désigne collectivement le Licencié et le Concédant. Ces termes s'entendent au singulier comme au pluriel. Article 2 - OBJET Le Contrat a pour objet la concession par le Concédant au Licencié d'une licence non exclusive, cessible et mondiale du Logiciel telle que définie ci-après à l'article 5 pour toute la durée de protection des droits portant sur ce Logiciel. Article 3 - ACCEPTATION 3.1 L'acceptation par le Licencié des termes du Contrat est réputée acquise du fait du premier des faits suivants: * (i) le chargement du Logiciel par tout moyen notamment par téléchargement à partir d'un serveur distant ou par chargement à partir d'un support physique; * (ii) le premier exercice par le Licencié de l'un quelconque des droits concédés par le Contrat. 3.2 Un exemplaire du Contrat, contenant notamment un avertissement relatif aux spécificités du Logiciel, à la restriction de garantie et à la limitation à un usage par des utilisateurs expérimentés a été mis à disposition du Licencié préalablement à son acceptation telle que définie à l'article 3.1 ci dessus et le Licencié reconnaît en avoir pris connaissance. Article 4 - ENTREE EN VIGUEUR ET DUREE 4.1 ENTREE EN VIGUEUR Le Contrat entre en vigueur à la date de son acceptation par le Licencié telle que définie en 3.1. 4.2 DUREE Le Contrat produira ses effets pendant toute la durée légale de protection des droits patrimoniaux portant sur le Logiciel. Article 5 - ETENDUE DES DROITS CONCEDES Le Concédant concède au Licencié, qui accepte, les droits suivants sur le Logiciel pour toutes destinations et pour la durée du Contrat dans les conditions ci-après détaillées. Par ailleurs, si le Concédant détient ou venait à détenir un ou plusieurs brevets d'invention protégeant tout ou partie des fonctionnalités du Logiciel ou de ses composants, il s'engage à ne pas opposer les éventuels droits conférés par ces brevets aux Licenciés successifs qui utiliseraient, exploiteraient ou modifieraient le Logiciel. En cas de cession de ces brevets, le Concédant s'engage à faire reprendre les obligations du présent alinéa aux cessionnaires. 5.1 DROIT D'UTILISATION Le Licencié est autorisé à utiliser le Logiciel, sans restriction quant aux domaines d'application, étant ci-après précisé que cela comporte: 1. la reproduction permanente ou provisoire du Logiciel en tout ou partie par tout moyen et sous toute forme. 2. le chargement, l'affichage, l'exécution, ou le stockage du Logiciel sur tout support. 3. la possibilité d'en observer, d'en étudier, ou d'en tester le fonctionnement afin de déterminer les idées et principes qui sont à la base de n'importe quel élément de ce Logiciel; et ceci, lorsque le Licencié effectue toute opération de chargement, d'affichage, d'exécution, de transmission ou de stockage du Logiciel qu'il est en droit d'effectuer en vertu du Contrat. 5.2 DROIT D'APPORTER DES CONTRIBUTIONS Le droit d'apporter des Contributions comporte le droit de traduire, d'adapter, d'arranger ou d'apporter toute autre modification au Logiciel et le droit de reproduire le logiciel en résultant. Le Licencié est autorisé à apporter toute Contribution au Logiciel sous réserve de mentionner, de façon explicite, son nom en tant qu'auteur de cette Contribution et la date de création de celle-ci. 5.3 DROIT DE DISTRIBUTION Le droit de distribution comporte notamment le droit de diffuser, de transmettre et de communiquer le Logiciel au public sur tout support et par tout moyen ainsi que le droit de mettre sur le marché à titre onéreux ou gratuit, un ou des exemplaires du Logiciel par tout procédé. Le Licencié est autorisé à distribuer des copies du Logiciel, modifié ou non, à des tiers dans les conditions ci-après détaillées. 5.3.1 DISTRIBUTION DU LOGICIEL SANS MODIFICATION Le Licencié est autorisé à distribuer des copies conformes du Logiciel, sous forme de Code Source ou de Code Objet, à condition que cette distribution respecte les dispositions du Contrat dans leur totalité et soit accompagnée: 1. d'un exemplaire du Contrat, 2. d'un avertissement relatif à la restriction de garantie et de responsabilité du Concédant telle que prévue aux articles 8 et 9, et que, dans le cas où seul le Code Objet du Logiciel est redistribué, le Licencié permette un accès effectif au Code Source complet du Logiciel pendant au moins toute la durée de sa distribution du Logiciel, étant entendu que le coût additionnel d'acquisition du Code Source ne devra pas excéder le simple coût de transfert des données. 5.3.2 DISTRIBUTION DU LOGICIEL MODIFIE Lorsque le Licencié apporte une Contribution au Logiciel, le Logiciel Modifié peut être distribué sous un contrat de licence autre que le présent Contrat sous réserve du respect des dispositions de l'article 5.3.4. 5.3.3 DISTRIBUTION DES MODULES EXTERNES Lorsque le Licencié a développé un Module Externe les conditions du Contrat ne s'appliquent pas à ce Module Externe, qui peut être distribué sous un contrat de licence différent. 5.3.4 CITATIONS Le Licencié qui distribue un Logiciel Modifié s'engage expressément: 1. à indiquer dans sa documentation qu'il a été réalisé à partir du Logiciel régi par le Contrat, en reproduisant les mentions de propriété intellectuelle du Logiciel, 2. à faire en sorte que l'utilisation du Logiciel, ses mentions de propriété intellectuelle et le fait qu'il est régi par le Contrat soient indiqués dans un texte facilement accessible depuis l'interface du Logiciel Modifié, 3. à mentionner, sur un site Web librement accessible décrivant le Logiciel Modifié, et pendant au moins toute la durée de sa distribution, qu'il a été réalisé à partir du Logiciel régi par le Contrat, en reproduisant les mentions de propriété intellectuelle du Logiciel, 4. lorsqu'il le distribue à un tiers susceptible de distribuer lui-même un Logiciel Modifié, sans avoir à en distribuer le code source, à faire ses meilleurs efforts pour que les obligations du présent article 5.3.4 soient reprises par le dit tiers. Lorsque le Logiciel modifié ou non est distribué avec un Module Externe qui a été conçu pour l'utiliser, le Licencié doit soumettre le dit Module Externe aux obligations précédentes. 5.3.5 COMPATIBILITE AVEC LES LICENCES CeCILL et CeCILL-C Lorsqu'un Logiciel Modifié contient une Contribution soumise au contrat de licence CeCILL, les stipulations prévues à l'article 5.3.4 sont facultatives. Un Logiciel Modifié peut être distribué sous le contrat de licence CeCILL-C. Les stipulations prévues à l'article 5.3.4 sont alors facultatives. Article 6 - PROPRIETE INTELLECTUELLE 6.1 SUR LE LOGICIEL INITIAL Le Titulaire est détenteur des droits patrimoniaux sur le Logiciel Initial. Toute utilisation du Logiciel Initial est soumise au respect des conditions dans lesquelles le Titulaire a choisi de diffuser son oeuvre et nul autre n'a la faculté de modifier les conditions de diffusion de ce Logiciel Initial. Le Titulaire s'engage à ce que le Logiciel Initial reste au moins régi par le Contrat et ce, pour la durée visée à l'article 4.2. 6.2 SUR LES CONTRIBUTIONS Le Licencié qui a développé une Contribution est titulaire sur celle-ci des droits de propriété intellectuelle dans les conditions définies par la législation applicable. 6.3 SUR LES MODULES EXTERNES Le Licencié qui a développé un Module Externe est titulaire sur celui-ci des droits de propriété intellectuelle dans les conditions définies par la législation applicable et reste libre du choix du contrat régissant sa diffusion. 6.4 DISPOSITIONS COMMUNES Le Licencié s'engage expressément: 1. à ne pas supprimer ou modifier de quelque manière que ce soit les mentions de propriété intellectuelle apposées sur le Logiciel; 2. à reproduire à l'identique lesdites mentions de propriété intellectuelle sur les copies du Logiciel modifié ou non. Le Licencié s'engage à ne pas porter atteinte, directement ou indirectement, aux droits de propriété intellectuelle du Titulaire et/ou des Contributeurs sur le Logiciel et à prendre, le cas échéant, à l'égard de son personnel toutes les mesures nécessaires pour assurer le respect des dits droits de propriété intellectuelle du Titulaire et/ou des Contributeurs. Article 7 - SERVICES ASSOCIES 7.1 Le Contrat n'oblige en aucun cas le Concédant à la réalisation de prestations d'assistance technique ou de maintenance du Logiciel. Cependant le Concédant reste libre de proposer ce type de services. Les termes et conditions d'une telle assistance technique et/ou d'une telle maintenance seront alors déterminés dans un acte séparé. Ces actes de maintenance et/ou assistance technique n'engageront que la seule responsabilité du Concédant qui les propose. 7.2 De même, tout Concédant est libre de proposer, sous sa seule responsabilité, à ses licenciés une garantie, qui n'engagera que lui, lors de la redistribution du Logiciel et/ou du Logiciel Modifié et ce, dans les conditions qu'il souhaite. Cette garantie et les modalités financières de son application feront l'objet d'un acte séparé entre le Concédant et le Licencié. Article 8 - RESPONSABILITE 8.1 Sous réserve des dispositions de l'article 8.2, le Licencié a la faculté, sous réserve de prouver la faute du Concédant concerné, de solliciter la réparation du préjudice direct qu'il subirait du fait du Logiciel et dont il apportera la preuve. 8.2 La responsabilité du Concédant est limitée aux engagements pris en application du Contrat et ne saurait être engagée en raison notamment: (i) des dommages dus à l'inexécution, totale ou partielle, de ses obligations par le Licencié, (ii) des dommages directs ou indirects découlant de l'utilisation ou des performances du Logiciel subis par le Licencié et (iii) plus généralement d'un quelconque dommage indirect. En particulier, les Parties conviennent expressément que tout préjudice financier ou commercial (par exemple perte de données, perte de bénéfices, perte d'exploitation, perte de clientèle ou de commandes, manque à gagner, trouble commercial quelconque) ou toute action dirigée contre le Licencié par un tiers, constitue un dommage indirect et n'ouvre pas droit à réparation par le Concédant. Article 9 - GARANTIE 9.1 Le Licencié reconnaît que l'état actuel des connaissances scientifiques et techniques au moment de la mise en circulation du Logiciel ne permet pas d'en tester et d'en vérifier toutes les utilisations ni de détecter l'existence d'éventuels défauts. L'attention du Licencié a été attirée sur ce point sur les risques associés au chargement, à l'utilisation, la modification et/ou au développement et à la reproduction du Logiciel qui sont réservés à des utilisateurs avertis. Il relève de la responsabilité du Licencié de contrôler, par tous moyens, l'adéquation du produit à ses besoins, son bon fonctionnement et de s'assurer qu'il ne causera pas de dommages aux personnes et aux biens. 9.2 Le Concédant déclare de bonne foi être en droit de concéder l'ensemble des droits attachés au Logiciel (comprenant notamment les droits visés à l'article 5). 9.3 Le Licencié reconnaît que le Logiciel est fourni "en l'état" par le Concédant sans autre garantie, expresse ou tacite, que celle prévue à l'article 9.2 et notamment sans aucune garantie sur sa valeur commerciale, son caractère sécurisé, innovant ou pertinent. En particulier, le Concédant ne garantit pas que le Logiciel est exempt d'erreur, qu'il fonctionnera sans interruption, qu'il sera compatible avec l'équipement du Licencié et sa configuration logicielle ni qu'il remplira les besoins du Licencié. 9.4 Le Concédant ne garantit pas, de manière expresse ou tacite, que le Logiciel ne porte pas atteinte à un quelconque droit de propriété intellectuelle d'un tiers portant sur un brevet, un logiciel ou sur tout autre droit de propriété. Ainsi, le Concédant exclut toute garantie au profit du Licencié contre les actions en contrefaçon qui pourraient être diligentées au titre de l'utilisation, de la modification, et de la redistribution du Logiciel. Néanmoins, si de telles actions sont exercées contre le Licencié, le Concédant lui apportera son aide technique et juridique pour sa défense. Cette aide technique et juridique est déterminée au cas par cas entre le Concédant concerné et le Licencié dans le cadre d'un protocole d'accord. Le Concédant dégage toute responsabilité quant à l'utilisation de la dénomination du Logiciel par le Licencié. Aucune garantie n'est apportée quant à l'existence de droits antérieurs sur le nom du Logiciel et sur l'existence d'une marque. Article 10 - RESILIATION 10.1 En cas de manquement par le Licencié aux obligations mises à sa charge par le Contrat, le Concédant pourra résilier de plein droit le Contrat trente (30) jours après notification adressée au Licencié et restée sans effet. 10.2 Le Licencié dont le Contrat est résilié n'est plus autorisé à utiliser, modifier ou distribuer le Logiciel. Cependant, toutes les licences qu'il aura concédées antérieurement à la résiliation du Contrat resteront valides sous réserve qu'elles aient été effectuées en conformité avec le Contrat. Article 11 - DISPOSITIONS DIVERSES 11.1 CAUSE EXTERIEURE Aucune des Parties ne sera responsable d'un retard ou d'une défaillance d'exécution du Contrat qui serait dû à un cas de force majeure, un cas fortuit ou une cause extérieure, telle que, notamment, le mauvais fonctionnement ou les interruptions du réseau électrique ou de télécommunication, la paralysie du réseau liée à une attaque informatique, l'intervention des autorités gouvernementales, les catastrophes naturelles, les dégâts des eaux, les tremblements de terre, le feu, les explosions, les grèves et les conflits sociaux, l'état de guerre... 11.2 Le fait, par l'une ou l'autre des Parties, d'omettre en une ou plusieurs occasions de se prévaloir d'une ou plusieurs dispositions du Contrat, ne pourra en aucun cas impliquer renonciation par la Partie intéressée à s'en prévaloir ultérieurement. 11.3 Le Contrat annule et remplace toute convention antérieure, écrite ou orale, entre les Parties sur le même objet et constitue l'accord entier entre les Parties sur cet objet. Aucune addition ou modification aux termes du Contrat n'aura d'effet à l'égard des Parties à moins d'être faite par écrit et signée par leurs représentants dûment habilités. 11.4 Dans l'hypothèse où une ou plusieurs des dispositions du Contrat s'avèrerait contraire à une loi ou à un texte applicable, existants ou futurs, cette loi ou ce texte prévaudrait, et les Parties feraient les amendements nécessaires pour se conformer à cette loi ou à ce texte. Toutes les autres dispositions resteront en vigueur. De même, la nullité, pour quelque raison que ce soit, d'une des dispositions du Contrat ne saurait entraîner la nullité de l'ensemble du Contrat. 11.5 LANGUE Le Contrat est rédigé en langue française et en langue anglaise, ces deux versions faisant également foi. Article 12 - NOUVELLES VERSIONS DU CONTRAT 12.1 Toute personne est autorisée à copier et distribuer des copies de ce Contrat. 12.2 Afin d'en préserver la cohérence, le texte du Contrat est protégé et ne peut être modifié que par les auteurs de la licence, lesquels se réservent le droit de publier périodiquement des mises à jour ou de nouvelles versions du Contrat, qui posséderont chacune un numéro distinct. Ces versions ultérieures seront susceptibles de prendre en compte de nouvelles problématiques rencontrées par les logiciels libres. 12.3 Tout Logiciel diffusé sous une version donnée du Contrat ne pourra faire l'objet d'une diffusion ultérieure que sous la même version du Contrat ou une version postérieure. Article 13 - LOI APPLICABLE ET COMPETENCE TERRITORIALE 13.1 Le Contrat est régi par la loi française. Les Parties conviennent de tenter de régler à l'amiable les différends ou litiges qui viendraient à se produire par suite ou à l'occasion du Contrat. 13.2 A défaut d'accord amiable dans un délai de deux (2) mois à compter de leur survenance et sauf situation relevant d'une procédure d'urgence, les différends ou litiges seront portés par la Partie la plus diligente devant les Tribunaux compétents de Paris. Version 1.0 du 2006-09-05. givaro-4.0.2/Makefile.am000066400000000000000000000034131274707324300150520ustar00rootroot00000000000000# Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. ACLOCAL_AMFLAGS = -I macros SUBDIRS=src macros tests docs examples benchmarks include_HEADERS=givaro-config.h pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = givaro.pc docs:docs/givaro-html/index.html docs/givaro-html/index.html: (cd docs; ${MAKE} docs) .PHONY:examples benchmarks examples: (cd examples; ${MAKE} examples) benchmarks: (cd benchmarks; ${MAKE} benchmarks) perfpublisher: benchmarks/perfpublisher tests/perfpublisher benchmarks/perfpublisher: (cd benchmarks; ${MAKE} perfpublisher) tests/perfpublisher: (cd tests; ${MAKE} perfpublisher) bin_SCRIPTS=givaro-config givaro-makefile EXTRA_DIST=COPYRIGHT Licence_CeCILL-B_V1-en.txt Licence_CeCILL-B_V1-fr.txt \ givaro.doxy DIST_SUBDIRS=${SUBDIRS} DISTCLEANFILES = src/kernel/system/givaro \ src/kernel/bstruct/givaro \ src/kernel/integer/givaro \ src/kernel/memory/givaro \ src/kernel/rational/givaro \ src/kernel/recint/recint \ src/kernel/field/givaro \ src/kernel/ring/givaro \ src/kernel/gmp++/gmp++ \ src/library/matrix/givaro \ src/library/poly1/givaro \ src/library/tools/givaro \ src/library/vector/givaro uninstall-hook: (test -d "$(includedir)/givaro" && rmdir "$(includedir)/givaro") || true (test -d "$(includedir)/gmp++" && rmdir "$(includedir)/gmp++") || true (test -d "$(includedir)/recint" && rmdir "$(includedir)/recint") || true docs_dev:docs/givaro-dev-html/index.html docs/givaro-dev-html/index.html: (cd docs; ${MAKE} docs_dev) VERSION=4.0.2 git: git commit -a; git pull; git push givaro-4.0.2/NEWS000066400000000000000000000000311274707324300135060ustar00rootroot00000000000000News about givaro librarygivaro-4.0.2/README.md000066400000000000000000000030011274707324300142660ustar00rootroot00000000000000Givaro ====== [![Build Status](https://ci.inria.fr/linbox/buildStatus/icon?job=Givaro)](https://ci.inria.fr/linbox/job/Givaro/) Download and install -------------------- For lastest releases, please check out [this website](http://github.com/linbox-team/givaro); older releases can be found on [that website](https://forge.imag.fr/frs/?group_id=187). Then, you can install doing: ``` > tar -zxvf givaro-*.tar.gz > cd givaro-* > ./configure --prefix=##GIVAROROOT# > make install ``` *Configuration can be adapted. Check `configure --help` to print the parameter choices.* *In particular if GMP is not installed to the default location you might need to add for instance `--with-gmp=##GMPROOT#/gmp-x-y-z` to the configure line.* *Also, on non-Linux systems you might need to use `gmake` instead of `make`.* Compile your own files ---------------------- Givaro uses pkgconfig to expose the compilation flags it requires. You will get the compilation flags by calling ``` pkg-config --cflags givaro ``` and the linking flags by calling ``` pkg-config --libs givaro ``` If you have installed givaro in a non-standard directory (such as `/usr/local`), make sure to have added the path where to find givaro's .pc file to the PKG_CONFIG_PATH environment variable. ``` PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/lib/pkgconfig ``` An alternative option is to just add the following line to your Makefile. Then a simple call will compile your C and C++ files. ``` include ##GIVAROROOT##/bin/givaro-makefile ``` givaro-4.0.2/autogen.sh000077500000000000000000000122401274707324300150150ustar00rootroot00000000000000#!/bin/sh # Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. #/ # Run this to generate all the initial makefiles, etc. # Recover command line, with double-quotes CMDLINE="" for arg in "$@" do WHO="`echo $arg | cut -d'=' -f1`" WHAT="`echo $arg | cut -s -d'=' -f2`" if test "x$WHAT" = "x"; then CMDLINE="$CMDLINE $WHO" else CMDLINE="$CMDLINE $WHO=\"$WHAT\"" fi done echo "$0 $CMDLINE" > autogen.status chmod +x autogen.status # Starts configuring srcdir=`dirname $0` test -z "$srcdir" && srcdir=. PKG_NAME="Givaro Library" (test -f $srcdir/configure.ac \ && test -f $srcdir/src/kernel/integer/givinteger.h ) || { echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" echo " top-level "\`$PKG_NAME\'" directory" exit 1 } ORIGDIR=`pwd` cd $srcdir PROJECT=givaro TEST_TYPE=-f DIE=0 # Defaults LIBTOOL=libtool LIBTOOLIZE=libtoolize # Fix OSx problem with GNU libtool (uname -a|grep -v Darwin) < /dev/null > /dev/null 2>&1 || { echo "....Adding fix for OSX" if command -v "glibtoolize" >/dev/null; then LIBTOOL=glibtool LIBTOOLIZE=glibtoolize fi } (autoconf --version) < /dev/null > /dev/null 2>&1 || { echo echo "You must have autoconf installed to compile $PROJECT." echo "Download the appropriate package for your distribution," echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" DIE=1 } (automake --version) < /dev/null > /dev/null 2>&1 || { echo echo "You must have automake installed to compile $PROJECT." echo "Download the appropriate package for your distribution," echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" DIE=1 } (automake --version) < /dev/null > /dev/null 2>&1 || { echo echo "You must have automake installed to compile $PROJECT." echo "Get ftp://sourceware.cygnus.com/pub/automake/automake-1.4.tar.gz" echo "(or a newer version if it is available)" DIE=1 } (grep "^AC_PROG_LIBTOOL" configure.ac >/dev/null) && { ($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`libtool' installed to compile $PROJECT." echo "Download the appropriate package for your distribution," echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" DIE=1 } } grep "^AM_GNU_GETTEXT" configure.ac >/dev/null && { grep "sed.*POTFILES" $srcdir/configure.ac >/dev/null || \ (gettext --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`gettext' installed to compile $PROJECT." echo "Download the appropriate package for your distribution," echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" DIE=1 } } if test "$DIE" -eq 1; then exit 1 fi if test -z "$*"; then echo "I am going to run ./configure with no arguments - if you wish " echo "to pass any to it, please specify them on the $0 command line." fi case $CC in *xlc | *xlc\ * | *lcc | *lcc\ *) am_opt=--include-deps;; esac for coin in `find . -name configure.ac -print` do dr=`dirname $coin` if test -f $dr/NO-AUTO-GEN; then echo skipping $dr -- flagged as no auto-gen else echo processing $dr macrodirs=`sed -n -e 's,AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < $coin` ( cd $dr aclocalinclude="$ACLOCAL_FLAGS" for k in $macrodirs; do if test -d $k; then aclocalinclude="$aclocalinclude -I $k" ##else ## echo "**Warning**: No such directory \`$k'. Ignored." fi done if grep "^AM_GNU_GETTEXT" configure.ac >/dev/null; then if grep "sed.*POTFILES" configure.ac >/dev/null; then : do nothing -- we still have an old unmodified configure.ac else echo "Creating $dr/aclocal.m4 ..." test -r $dr/aclocal.m4 || touch $dr/aclocal.m4 echo "Running gettextize... Ignore non-fatal messages." echo "no" | gettextize --force --copy echo "Making $dr/aclocal.m4 writable ..." test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4 fi fi if grep "^AM_GNOME_GETTEXT" configure.ac >/dev/null; then echo "Creating $dr/aclocal.m4 ..." test -r $dr/aclocal.m4 || touch $dr/aclocal.m4 echo "Running gettextize... Ignore non-fatal messages." echo "no" | gettextize --force --copy echo "Making $dr/aclocal.m4 writable ..." test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4 fi if grep "^AC_PROG_LIBTOOL" configure.ac >/dev/null; then echo "Running libtoolize..." $LIBTOOLIZE --force --copy fi echo "Running aclocal $aclocalinclude ..." aclocal $aclocalinclude if grep "^AC_CONFIG_HEADERS" configure.ac >/dev/null; then echo "Running autoheader..." autoheader fi echo "Running automake --gnu $am_opt ..." automake -c --add-missing --gnu $am_opt echo "Running autoconf ..." autoconf ) fi done conf_flags="--enable-maintainer-mode" #--enable-iso-c cd "$ORIGDIR" if test x$NOCONFIGURE = x; then echo Running $srcdir/configure $conf_flags "$@" ... $srcdir/configure $conf_flags "$@" \ && echo "Now type \`make install' to compile $PROJECT" || exit 1 else echo Skipping configure process. fi givaro-4.0.2/benchmarks/000077500000000000000000000000001274707324300151325ustar00rootroot00000000000000givaro-4.0.2/benchmarks/Makefile.am000066400000000000000000000030171274707324300171670ustar00rootroot00000000000000# Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. SUBDIRS = benchmarks: $(EXTRA_PROGRAMS) AM_CPPFLAGS=-I$(top_srcdir) PERFPUBLISHERFILE=benchmarks-report.xml OPTFLAGS= OPTLINKS= AM_CXXFLAGS = @DEFAULT_CFLAGS@ AM_CPPFLAGS += $(OPTFLAGS) $(GMP_CFLAGS) -I$(top_srcdir)/src/kernel/system -I$(top_srcdir)/src/kernel/recint -I$(top_srcdir)/src/kernel/integer -I$(top_srcdir)/src/kernel/gmp++ -I$(top_srcdir)/src/kernel/ring LDADD = $(OPTLINKS) -L${top_srcdir}/src -L${top_srcdir}/src/.libs -lgivaro $(GMP_LIBS) $(LDFLAGS) AM_LDFLAGS=-static BENCHMARKS= \ benchmark-recint_exp \ benchmark-recint_inv_arazi \ benchmark-recint_inv_naive \ benchmark-recint_mul CLEANFILES = $(EXTRA_PROGRAMS) $(PERFPUBLISHERFILE) EXTRA_PROGRAMS = $(BENCHMARKS) benchmark_recint_exp_SOURCES = benchmark-recint_exp.C benchmark_recint_inv_arazi_SOURCES = benchmark-recint_inv_arazi.C benchmark_recint_inv_naive_SOURCES = benchmark-recint_inv_naive.C benchmark_recint_mul_SOURCES = benchmark-recint_mul.C # Perfpublisher script interaction - AB 2014/11/17 perfpublisher: +./perfpublisher.sh "$(PERFPUBLISHERFILE)" "$(BENCHMARKS)" "$(CXX)" #===== # For compilation of new benchmarks GIVARO_BIN=@bindir@ %:%.C $(CXX) $(OPTFLAGS) $(AM_CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $*.C -o $* `$(GIVARO_BIN)/givaro-config --cflags` $(LDADD) `$(GIVARO_BIN)/givaro-config --libs` givaro-4.0.2/benchmarks/Makefile.tests000066400000000000000000000037201274707324300177350ustar00rootroot00000000000000ifneq ($(origin RMOD), undefined) MODME=${RMOD} else MODME=mul mulm # exp endif ifneq ($(origin RDIR), undefined) DIRME=${RDIR} else DIRME=inmul tmul inadd endif ifneq ($(origin RTES), undefined) ORTES=${RTES} else ORTES=${MODME} ${DIRME} endif THREADS=4 ifneq ($(origin LOOPS), undefined) OLOOPS=${LOOPS} else OLOOPS=22 endif MGTES=$(filter-out ${DIRME},${ORTES}) DETES=$(filter ${DIRME},${ORTES}) SUFFIXES=mul mulm inmul tmul inadd exp inv_arazi MEANINGS=Modular_multiplication In_place_modular_multiplication In_place_multiplication Multiplication In_place_addition Modular_exponentiation Base_inverse EXEC=${ORTES:%=benchmark-recint_%} WSRC=${EXEC:%=-W %.C} OUTP=output.rint MODEL=$(shell cat /proc/cpuinfo | grep "model name" | head -1|cut -d':' -f2| tr -s ' '|sed 's/^ //') SHELL := /bin/bash index = $(words $(shell a="$(2)";echo $${a/$(1)*/$(1)} )) swap = $(word $(call index,$(1),${SUFFIXES}),${MEANINGS}) remun = $(shell a="$(1)";echo $${a}|sed 's/_/ /g') SIZES=6 7 8 9 10 11 12 13 MONTG=MG_INACTIVE PREFI= all: outclean ${SIZES:%=all_%} outcleanmg ${SIZES:%=allmg_%} plot plotmg mkplot = $(foreach fil, $(1), sed 's/FUNCTION/${PREFI}${fil}/g;s/MODEL/${MODEL}/g;s/MEANING/$(call remun,$(call swap,${fil}) $(2))/' generic.gnuplot > ${PREFI}${fil}.gnuplot; gnuplot ${PREFI}${fil}.gnuplot;) mkruns = make -j ${THREADS} "OPTFLAGS=-DSTD_RECINT_SIZE=$(1) -DMG_DEFAULT=${MONTG}" $(addprefix ./benchmark-recint_,$(2)) ${WSRC}; $(foreach fil, $(2), ./benchmark-recint_${fil} `echo '10^((${OLOOPS}-$(1))/2)'|bc` >> ${OUTP}.${PREFI}${fil};) mkocl = $(foreach fil, $(1), - rm ${OUTP}.${PREFI}${fil};) all_%: $(call mkruns,$*, ${ORTES}) plot: $(call mkplot, ${DETES}) $(call mkplot, ${MGTES}, (${MONTG})) outclean: $(call mkocl, ${ORTES}) allmg_%: MONTG=MG_ACTIVE allmg_%: PREFI=mg_ allmg_%: $(call mkruns,$*, ${MGTES}) plotmg: MONTG=MG_ACTIVE plotmg: PREFI=mg_ plotmg: $(call mkplot, ${MGTES}, (${MONTG})) outcleanmg: PREFI=mg_ outcleanmg: $(call mkocl, ${MGTES})givaro-4.0.2/benchmarks/benchmark-recint_exp.C000066400000000000000000000040561274707324300213330ustar00rootroot00000000000000#include #include #include #include #if not defined(STD_RECINT_SIZE) #define STD_RECINT_SIZE 8 #endif #if not defined(LOOPS) #define LOOPS 100000 #endif #define ALEA_MAX 64 #define ALEA_MASK 63 using namespace RecInt; int main(int argc, char ** argv) { size_t nbloops = static_cast((argc > 1)? atoi(argv[1]) : LOOPS); rmint m[ALEA_MAX]; ruint u[ALEA_MAX], module; mpz_class b[ALEA_MAX], c[ALEA_MAX], gmod; Givaro::Timer tim, gmp; // For montgomery algorithm, the module must be odd RecInt::srand(42); rand(module); if (module % 2 == 0) module++; rmint::init_module(module); ruint_to_mpz(gmod, module); // Randomness for (unsigned int i = 0; i < ALEA_MAX; i++) { rand(m[i]); ruint_to_mpz(b[i],m[i].Value); rand(u[i]); ruint_to_mpz(c[i],u[i]); } // Main loop tim.clear(); tim.start(); for (unsigned int l = 0; l < nbloops; l++) { exp(m[l & ALEA_MASK], m[(l+2) & ALEA_MASK], u[l & ALEA_MASK]); exp(m[(l+2) & ALEA_MASK], m[(l+1) & ALEA_MASK], u[l & ALEA_MASK]); } tim.stop(); gmp.clear(); gmp.start(); for (unsigned int l = 0; l < nbloops; l++) { mpz_powm(b[l & ALEA_MASK].get_mpz_t(),b[(l+2) & ALEA_MASK].get_mpz_t(),c[l & ALEA_MASK].get_mpz_t(), gmod.get_mpz_t()); mpz_powm(b[(l+2) & ALEA_MASK].get_mpz_t(),b[(l+1) & ALEA_MASK].get_mpz_t(),c[l & ALEA_MASK].get_mpz_t(), gmod.get_mpz_t()); } gmp.stop(); rand(module); // ----------- // Standard output for benchmark - Alexis Breust 2014/12/11 std::cout << "Time: " << tim.usertime() << " Mflops: " << std::scientific << (double(2*nbloops))/tim.usertime()/1000.0/1000.0 << ' ' << (double(2*nbloops))/gmp.usertime()/1000.0/1000.0 << " SIZE: " << STD_RECINT_SIZE << " GMP time: " << gmp.usertime() << ' ' << m[(int)(module )& ALEA_MASK] << ' ' << b[(int)(module)& ALEA_MASK] << std::endl ; return 0; } givaro-4.0.2/benchmarks/benchmark-recint_inadd.C000066400000000000000000000032271274707324300216150ustar00rootroot00000000000000#include #include #include #include #include #if not defined(STD_RECINT_SIZE) #define STD_RECINT_SIZE 8 #endif #if not defined(LOOPS) #define LOOPS 1000000 #endif #define ALEA_MAX 64 #define ALEA_MASK 63 using namespace RecInt; int main(int argc, char ** argv) { size_t nbloops = static_cast((argc > 1)? atoi(argv[1]) : LOOPS); // std::cerr << "nbloops: " << nbloops << std::endl; ruint a[ALEA_MAX], d[ALEA_MAX]; mpz_class b[ALEA_MAX], c[ALEA_MAX]; Givaro::Timer tim,gmp; // Randomness for (unsigned int i = 0; i < ALEA_MAX; i++) { rand(a[i]); ruint_to_mpz(b[i],a[i]); } // Main loop tim.clear(); tim.start(); for (unsigned int l = 0; l < nbloops; l++) { d[l & ALEA_MASK] = a[l & ALEA_MASK]; d[l & ALEA_MASK] += a[l & ALEA_MASK]; } tim.stop(); // Main loop gmp.clear(); gmp.start(); for (unsigned int l = 0; l < nbloops; l++) { c[l & ALEA_MASK] = b[l & ALEA_MASK]; c[l & ALEA_MASK] += b[l & ALEA_MASK]; } gmp.stop(); ruint module; rand(module); // ----------- // Standard output for benchmark - Alexis Breust 2014/12/11 std::cout << "SIZE: " << STD_RECINT_SIZE << " Time: " << tim.usertime() << ' ' << gmp.usertime() << " Mflops: " << std::scientific << (double(nbloops))/tim.usertime()/1000.0/1000.0 << ' ' << (double(nbloops))/gmp.usertime()/1000.0/1000.0 << ' ' << a[(int)( module )& ALEA_MASK] << ' ' << b[(int)(module)& ALEA_MASK] << std::endl ; return 0; } givaro-4.0.2/benchmarks/benchmark-recint_inmul.C000066400000000000000000000032251274707324300216600ustar00rootroot00000000000000#include #include #include #include #include #if not defined(STD_RECINT_SIZE) #define STD_RECINT_SIZE 8 #endif #if not defined(LOOPS) #define LOOPS 1000000 #endif #define ALEA_MAX 64 #define ALEA_MASK 63 using namespace RecInt; int main(int argc, char ** argv) { size_t nbloops = static_cast((argc > 1)? atoi(argv[1]) : LOOPS); // std::cerr << "nbloops: " << nbloops << std::endl; ruint a[ALEA_MAX], d[ALEA_MAX]; mpz_class b[ALEA_MAX], c[ALEA_MAX]; Givaro::Timer tim,gmp; // Randomness for (unsigned int i = 0; i < ALEA_MAX; i++) { rand(a[i]); ruint_to_mpz(b[i],a[i]); } // Main loop tim.clear(); tim.start(); for (unsigned int l = 0; l < nbloops; l++) { d[l & ALEA_MASK] = a[l & ALEA_MASK]; d[l & ALEA_MASK] *= a[l & ALEA_MASK]; } tim.stop(); // Main loop gmp.clear(); gmp.start(); for (unsigned int l = 0; l < nbloops; l++) { c[l & ALEA_MASK] = b[l & ALEA_MASK]; c[l & ALEA_MASK] *= b[l & ALEA_MASK]; } gmp.stop(); ruint module; rand(module); // ----------- // Standard output for benchmark - Alexis Breust 2014/12/11 std::cout << "SIZE: " << STD_RECINT_SIZE << " Time: " << tim.usertime() << ' ' << gmp.usertime() << " Mflops: " << std::scientific << (double(nbloops))/tim.usertime()/1000.0/1000.0 << ' ' << (double(nbloops))/gmp.usertime()/1000.0/1000.0 << ' ' << a[(int)(module)& ALEA_MASK] << ' ' << b[(int)(module)& ALEA_MASK] << std::endl ; return 0; } givaro-4.0.2/benchmarks/benchmark-recint_inv_arazi.C000066400000000000000000000040121274707324300225110ustar00rootroot00000000000000/* ruint_arazi.cpp - Arazi & Qi for RecInt library test file Return value. 0 No error != 0 Bad result for an operation The following constants have to be defined. STD_RECINT_SIZE size of recint (> 6) LOOPS number of loops */ #include #include /* arazi_qi() */ #include #if not defined(STD_RECINT_SIZE) #define STD_RECINT_SIZE 9 #endif #if not defined(LOOPS) #define LOOPS 1000000 #endif #define ALEA_MAX 64 #define ALEA_MASK 63 using namespace RecInt; int main(int argc, char ** argv) { size_t nbloops = static_cast((argc > 1)? atoi(argv[1]) : LOOPS); Givaro::Timer tim, gmp; ruint a[ALEA_MAX]; ruint pinv[ALEA_MAX]; mpz_class b[ALEA_MAX],c[ALEA_MAX], gmod(1); gmod <<= (1<(time(NULL))); tim.clear(); tim.start(); for (UDItype l = 0; l < nbloops; l++) { arazi_qi(pinv[l&ALEA_MASK], a[l&ALEA_MASK]); } tim.stop(); gmp.clear(); gmp.start(); for (UDItype l = 0; l < nbloops; l++) { mpz_invert(c[l & ALEA_MASK].get_mpz_t(),b[l & ALEA_MASK].get_mpz_t(), gmod.get_mpz_t()); } gmp.stop(); ruint module; rand(module); // ----------- // Standard output for benchmark - Alexis Breust 2014/12/11 std::cout << "Time: " << tim.usertime() << " Mflops: " << std::scientific << (double(nbloops))/tim.usertime()/1000.0/1000.0 << ' ' << (double(nbloops))/gmp.usertime()/1000.0/1000.0 << " SIZE: " << STD_RECINT_SIZE << " GMP time" << gmp.usertime() << ' ' << a[(int)(module)& ALEA_MASK] << ' ' << b[(int)(module)& ALEA_MASK] << std::endl ; return 0; } givaro-4.0.2/benchmarks/benchmark-recint_inv_naive.C000066400000000000000000000023671274707324300225200ustar00rootroot00000000000000/* ruint_arazi.cpp - Arazi & Qi for RecInt library test file Return value. 0 No error != 0 Bad result for an operation The following constants have to be defined. STD_RECINT_SIZE size of recint (> 6) LOOPS number of loops */ #include #include #if not defined(STD_RECINT_SIZE) #define STD_RECINT_SIZE 9 #endif #if not defined(LOOPS) #define LOOPS 10000 #endif #define ALEA_MAX 64 #define ALEA_MASK 63 using namespace RecInt; int main(int argc, char ** argv) { size_t nbloops = static_cast((argc > 1)? atoi(argv[1]) : LOOPS); ruint p, pinv; ruint P, P1, R; Givaro::Timer tim; // Random RecInt::srand(static_cast(time(NULL))); R.High = 1; tim.clear(); tim.start(); for (UDItype l = 0; l < nbloops; l++) { rand(P.Low); if (P.Low % 2 == 0) P.Low++; // P1 = inv(P) mod R inv_mod(P1, P, R); copy(pinv, P1.Low); } tim.stop(); // ----------- // Standard output for benchmark - Alexis Breust 2014/12/11 std::cout << "Time: " << tim.usertime() << " Gflops: " << "Irrelevant" << std::endl; return 0; } givaro-4.0.2/benchmarks/benchmark-recint_mul.C000077500000000000000000000036001274707324300213310ustar00rootroot00000000000000#include #include #include #include #include #if not defined(STD_RECINT_SIZE) #define STD_RECINT_SIZE 7 #endif #if not defined(LOOPS) #define LOOPS 1000000 #endif #define ALEA_MAX 64 #define ALEA_MASK 63 using namespace RecInt; int main(int argc, char ** argv) { size_t nbloops = static_cast((argc > 1)? atoi(argv[1]) : LOOPS); // std::cerr << "nbloops: " << nbloops << std::endl; rmint a[ALEA_MAX]; mpz_class b[ALEA_MAX], gmod; ruint module; Givaro::Timer tim,gmp; // For montgomery algorithm, the module must be odd RecInt::srand(42); rand(module); if (module % 2 == 0) module++; rmint::init_module(module); // std::cerr << "module: " << module << std::endl; ruint_to_mpz(gmod, module); // Randomness for (unsigned int i = 0; i < ALEA_MAX; i++) { rand(a[i]); ruint_to_mpz(b[i],a[i].Value); } // Main loop tim.clear(); tim.start(); for (unsigned int l = 0; l < nbloops; l++) { mul(a[l & ALEA_MASK], a[l & ALEA_MASK], a[(l+1) & ALEA_MASK]); } tim.stop(); // Main loop gmp.clear(); gmp.start(); for (unsigned int l = 0; l < nbloops; l++) { b[(l+1) & ALEA_MASK] = (b[l & ALEA_MASK] * b[l & ALEA_MASK]) % gmod; } gmp.stop(); // ----------- // Standard output for benchmark - Alexis Breust 2014/12/11 std::cout << "Time: " << tim.usertime() << " Mflops: " << std::scientific << (double(nbloops))/tim.usertime()/1000.0/1000.0 << ' ' << (double(nbloops))/gmp.usertime()/1000.0/1000.0 << " SIZE: " << STD_RECINT_SIZE << " GMP time: " << gmp.usertime() << ' ' << a[(int)(rand(module))& ALEA_MASK] << ' ' << b[(int)(rand(module))& ALEA_MASK] << std::endl ; return 0; } givaro-4.0.2/benchmarks/benchmark-recint_mulm.C000066400000000000000000000040231274707324300215030ustar00rootroot00000000000000#include #include #include #include #include #if not defined(STD_RECINT_SIZE) #define STD_RECINT_SIZE 8 #endif #if not defined(LOOPS) #define LOOPS 1000000 #endif #define ALEA_MAX 64 #define ALEA_MASK 63 using namespace RecInt; int main(int argc, char ** argv) { size_t nbloops = static_cast((argc > 1)? atoi(argv[1]) : LOOPS); // std::cerr << "nbloops: " << nbloops << std::endl; rmint a[ALEA_MAX],d[ALEA_MAX]; mpz_class b[ALEA_MAX],c[ALEA_MAX], gmod; ruint module; Givaro::Timer tim,gmp; // For montgomery algorithm, the module must be odd RecInt::srand(42); rand(module); if (module % 2 == 0) module++; rmint::init_module(module); // std::cerr << "module: " << module << std::endl; ruint_to_mpz(gmod, module); // Randomness for (unsigned int i = 0; i < ALEA_MAX; i++) { rand(a[i]); ruint_to_mpz(b[i],a[i].Value); } // Main loop tim.clear(); tim.start(); for (unsigned int l = 0; l < nbloops; l++) { //mul(a[l & ALEA_MASK], a[l & ALEA_MASK], a[(l+1) & ALEA_MASK]); d[l & ALEA_MASK] = a[l & ALEA_MASK]; d[l & ALEA_MASK] *= a[l & ALEA_MASK]; } tim.stop(); // Main loop gmp.clear(); gmp.start(); for (unsigned int l = 0; l < nbloops; l++) { c[l & ALEA_MASK] = b[l & ALEA_MASK]; c[l & ALEA_MASK] *= b[l & ALEA_MASK]; c[l & ALEA_MASK] %= gmod; } gmp.stop(); rand(module); // ----------- // Standard output for benchmark - Alexis Breust 2014/12/11 std::cout << "SIZE: " << STD_RECINT_SIZE << " Time: " << tim.usertime() << ' ' << gmp.usertime() << " Mflops: " << std::scientific << (double(nbloops))/tim.usertime()/1000.0/1000.0 << ' ' << (double(nbloops))/gmp.usertime()/1000.0/1000.0 << ' ' << a[(int)(module)& ALEA_MASK] << ' ' << b[(int)(module)& ALEA_MASK] << std::endl ; return 0; } givaro-4.0.2/benchmarks/benchmark-recint_tmul.C000066400000000000000000000031361274707324300215160ustar00rootroot00000000000000#include #include #include #include #include #if not defined(STD_RECINT_SIZE) #define STD_RECINT_SIZE 8 #endif #if not defined(LOOPS) #define LOOPS 1000000 #endif #define ALEA_MAX 64 #define ALEA_MASK 63 using namespace RecInt; int main(int argc, char ** argv) { size_t nbloops = static_cast((argc > 1)? atoi(argv[1]) : LOOPS); // std::cerr << "nbloops: " << nbloops << std::endl; ruint a[ALEA_MAX], d[ALEA_MAX]; mpz_class b[ALEA_MAX],c[ALEA_MAX]; Givaro::Timer tim,gmp; // Randomness for (unsigned int i = 0; i < ALEA_MAX; i++) { rand(a[i]); ruint_to_mpz(b[i],a[i]); } // Main loop tim.clear(); tim.start(); for (unsigned int l = 0; l < nbloops; l++) { d[l & ALEA_MASK] = a[l & ALEA_MASK] * a[l & ALEA_MASK]; } tim.stop(); // Main loop gmp.clear(); gmp.start(); for (unsigned int l = 0; l < nbloops; l++) { c[l & ALEA_MASK] = b[l & ALEA_MASK] * b[l & ALEA_MASK]; } gmp.stop(); ruint module; rand(module); // ----------- // Standard output for benchmark - Alexis Breust 2014/12/11 std::cout << "SIZE: " << STD_RECINT_SIZE << " Time: " << tim.usertime() << ' ' << gmp.usertime() << " Mflops: " << std::scientific << (double(nbloops))/tim.usertime()/1000.0/1000.0 << ' ' << (double(nbloops))/gmp.usertime()/1000.0/1000.0 << ' ' << d[(int)(module)& ALEA_MASK] << ' ' << c[(int)(module)& ALEA_MASK] << std::endl ; return 0; } givaro-4.0.2/benchmarks/generic.gnuplot000066400000000000000000000013411274707324300201570ustar00rootroot00000000000000set xlabel "Integer bit size" set ylabel "Speed (M. arith. op./s)" set title "MEANING on an MODEL" # tc lt 2 #set key below set logscale y 10 #set logscale x 2 #set ytics (10,1000) set xtics ("64" 6,"128" 7,"256" 8,"512" 9,"1024" 10,"2048" 11,"4096" 12, "8192" 13) #set xtics tc lt 2 #set ytics tc lt 2 #set grid noxtics ytics lt 2 set grid noxtics ytics #set border 4095 lt 7 #set style line 5 pt 2 set terminal pdf enhanced color solid lw 2 size 6,4 set output "rint_FUNCTION.pdf" plot [6:13] "output.rint.FUNCTION" using 7:($5) title "GMP-6" with linespoint lt 2 lc 1 set terminal pdf enhanced color solid lw 2 size 6,4 set output "rint_FUNCTION.pdf" replot "output.rint.FUNCTION" using 7:($4) title "RecInt" with fsteps lt 3 givaro-4.0.2/benchmarks/perfpublisher.sh000077500000000000000000000112341274707324300203440ustar00rootroot00000000000000#!/bin/bash # Script to format benchmarks results into a single xml file. # See https://wiki.jenkins-ci.org/display/JENKINS/PerfPublisher+Plugin # ----- # 2014/11/17 - Written by AB XMLFILE=$1 benchmarks=$2 COMPILER=$3 # choose gdate on OS X if command -v "gdate" >/dev/null; then DATE=gdate else DATE=date fi #=================# # Plateform infos # #=================# COMPILERVERSION=$($COMPILER --version 2>&1 | head -1) if command -v "lscpu" >/dev/null; then CPUFREQ=$(lscpu | grep "MHz" | rev | cut -f1 -d' ' | rev) else CPUFREQ=$((`sysctl -n hw.cpufrequency`/1000000)) fi ARCH=$(uname -m) OSNAME=$(uname -s) OSVERSION=$(uname -r) if hash lsb_release 2>/dev/null then DISTRIB=$(lsb_release -ds) else DISTRIB='Unknown distribution' fi #==========# # Prologue # #==========# if [[ -f $XMLFILE ]] then echo '----> WARNING: File '$XMLFILE' is not empty.' echo '----> Results will be added to its end.' fi #========# # Header # #========# echo '' >> $XMLFILE echo '' >> $XMLFILE #=======# # Start # #=======# echo '' >> $XMLFILE echo '' >> $XMLFILE echo '' >> $XMLFILE #============# # Benchmarks # #============# for benchmark in $benchmarks do if [[ ! -f $benchmark ]] then #File does not exist: compile it echo '[Compiling]' $benchmark COMPILESTART=$($DATE +%s%3N) COMPILELOG=$(make $benchmark 2>&1; echo 'Returned state: '$?) COMPILEEND=$($DATE +%s%3N) COMPILETIME=$(($COMPILEEND - $COMPILESTART)) COMPILECHECK=$(echo $COMPILELOG | grep -o '[^ ]*$') COMPILETIMERELEVANT='true' else #File does exist echo '[Already compiled]' $benchmark COMPILELOG='(Previously compiled)' COMPILETIME='0.0' COMPILECHECK='0' COMPILETIMERELEVANT='false' fi if [[ $COMPILECHECK -ne 0 ]] then #Compilation failure # EXECUTED='no' - keep it to yes so that Jenkins # uses it within its results EXECUTED='yes' PASSED='no' STATE='0' EXECUTIONLOG='(Not executed)' EXECUTIONTIME='0.0' PERFORMANCEFLOPS='0.0' COMPILETIMERELEVANT='false' EXECUTIONTIMERELEVANT='false' PERFORMANCEFLOPSRELEVANT='false' ERRORLOG='Does not compile.' echo '-> Does not compile.' else #Compilation success echo '[Executing]' $benchmark EXECUTED='yes' EXECUTIONLOG=$(./$benchmark 2>&1) if [[ ${EXECUTIONLOG} != "Time:"* ]] then #Execution failure PASSED='no' STATE='0' EXECUTIONTIME='0.0' PERFORMANCEFLOPS='0.0' EXECUTIONTIMERELEVANT='false' PERFORMANCEFLOPSRELEVANT='false' ERRORLOG='Unexpected output.' echo '-> Unexpected output.' else #Execution success PASSED='yes' STATE='100' EXECUTIONTIME=$(echo $EXECUTIONLOG | cut -d' ' -f2) PERFORMANCEFLOPS=$(echo $EXECUTIONLOG | cut -d' ' -f4) EXECUTIONTIMERELEVANT='true' if [[ ${PERFORMANCEFLOPS} != "Irrelevant" ]] then PERFORMANCEFLOPSRELEVANT='true' else PERFORMANCEFLOPSRELEVANT='false' PERFORMANCEFLOPS='0.0' fi ERRORLOG='' fi fi echo '' >> $XMLFILE echo 'BENCHMARK' >> $XMLFILE echo '' >> $XMLFILE echo '' >> $XMLFILE echo '' >> $XMLFILE echo '' >> $XMLFILE echo '' >> $XMLFILE echo '' >> $XMLFILE echo '' >> $XMLFILE echo '' >> $XMLFILE echo '' >> $XMLFILE echo '' >> $XMLFILE echo '' >> $XMLFILE echo '' >> $XMLFILE # Logs echo '' >> $XMLFILE echo '' >> $XMLFILE echo '' >> $XMLFILE echo '' >> $XMLFILE # Times echo '' >> $XMLFILE echo '' >> $XMLFILE echo '' >> $XMLFILE echo '' >> $XMLFILE echo '' >> $XMLFILE done #========# # Footer # #========# echo '' >> $XMLFILE #==========# # Epilogue # #==========# echo 'Results correctly exported to' $XMLFILE givaro-4.0.2/configure.ac000066400000000000000000000222651274707324300153120ustar00rootroot00000000000000# Copyright(c)'1994-2011 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. #/ AC_PREREQ([2.61]) AC_INIT([Givaro],[4.0.2],[Jean-Guillaume.Dumas@imag.fr],[givaro], [http://ljk.imag.fr/CASYS/LOGICIELS/givaro]) AC_CONFIG_MACRO_DIR([macros]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_HEADERS([config.h]) AC_CANONICAL_TARGET AM_INIT_AUTOMAKE([1.8 gnu no-dependencies -Wall -Wno-portability foreign]) AX_PREFIX_CONFIG_H(givaro-config.h, __GIVARO) AC_PATH_PROG(RM, rm, $FALSE) RM="$RM -f" AM_MAINTAINER_MODE AM_DEP_TRACK AM_OUTPUT_DEPENDENCY_COMMANDS AM_ACLOCAL_INCLUDE(macros) # work around to fix the backward compatibility issue of automake 1.10 with 1.9 (pb with MKDIR_P) AC_SUBST([MKDIR_P]) AC_LANG([C++]) echo "-----------------------------------------------" AC_DEBUG AC_PROFILE AC_WARNINGS AC_INLINE # DON'T TOUCH echo "-----------------------------------------------" # CFLAGS=${CFLAGS:-$DEFAULT_CFLAGS} # CXXFLAGS=${CXXFLAGS:-$DEFAULT_CXXFLAGS} ###################################################### # Try and pass different flags according to compiler # ###################################################### # disable default -g -O2 CXXFLAGS : ${CXXFLAGS=""} #set CXX AC_PROG_CXX AC_COMPILER_NAME # We need a C++11 compiler now - AB 2014-12-12 AX_CXX_COMPILE_STDCXX_11([],[mandatory]) AC_SUBST([DEFAULT_CFLAGS]) AC_SUBST([DEBUG_CFLAGS]) AC_SUBST([TESTS_CFLAGS]) TESTS_CFLAGS="-O0" DEBUG_CFLAGS="-g" DEFAULT_CFLAGS="" WARN_CFLAGS="-Wall" #TODO use -fast for icc, -ipa for eko... if test "x$DBG" = "xyes" ; then DEFAULT_CFLAGS="-O0 ${DEFAULT_CFLAGS} " #those are CXXFLAGS DEBUG_CFLAGS="${DEBUG_CFLAGS} -DDEBUG -DGIVARO_DEBUG" else DEFAULT_CFLAGS="-O2 ${DEFAULT_CFLAGS} " DEBUG_CFLAGS="${DEBUG_CFLAGS} -DNDEBUG -UGIVARO_DEBUG -UDEBUG" fi if test "x$PROF" = "xyes" ; then DEFAULT_CFLAGS="${DEFAULT_CFLAGS} -pg" fi if test "x$WARN" = "xyes" -o "x$WARN" = "xfull" ; then case x${CCNAM} in xicc) WARN_CFLAGS="${WARN_CFLAGS} -Wcheck" WARN_CFLAGS="${WARN_CFLAGS} -Wall -Wno-unused-parameter -Wuninitialized -Wconversion -Wcast-qual -pedantic -Wshadow -Wpointer-arith -Wwrite-strings -Wno-long-long" WARN_CFLAGS="${WARN_CFLAGS} -Wextra -ansi" ;; xeko) WARN_CFLAGS="${WARN_CFLAGS} -Wno-unused-parameter" ;; xgcc|xgcc44) WARN_CFLAGS="${WARN_CFLAGS} -Wextra -Wno-unused-parameter" if test "x${WARN}" = "xfull" ; then WARN_CFLAGS="${WARN_CFLAGS} -Wuninitialized -Wconversion -Wcast-qual -pedantic -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wno-long-long -Wno-variadic-macros -Wno-vla" fi if test "x${HAVE_CXX11}" = "x0" ; then WARN_CFLAGS="${WARN_CFLAGS} -ansi" fi ;; xgcc48) WARN_CFLAGS="${WARN_CFLAGS} -Wextra -Wno-unused-parameter" if test "x${WARN}" = "xfull" ; then WARN_CFLAGS="${WARN_CFLAGS} -Wuninitialized -Wconversion -Wcast-qual -pedantic -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wno-long-long -Wno-variadic-macros -Wno-vla" # WARN_CFLAGS="${WARN_CFLAGS} -fsanitize=address" fi if test "x${HAVE_CXX11}" = "x0" ; then WARN_CFLAGS="${WARN_CFLAGS} -ansi" fi ;; xclang) WARN_CFLAGS="${WARN_CFLAGS} -Wextra -Wno-unused-parameter" if test "x${WARN}" = "xfull" ; then WARN_CFLAGS="${WARN_CFLAGS} -Wuninitialized -Wconversion -Wcast-qual -pedantic -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wno-long-long -Wno-vla-extension -Wno-variadic-macros" WARN_CFLAGS="${WARN_CFLAGS} -D__STRICT_ANSI__" fi ;; xclang31) WARN_CFLAGS="${WARN_CFLAGS} -Wextra -Wno-unused-parameter" if test "x${WARN}" = "xfull" ; then WARN_CFLAGS="${WARN_CFLAGS} -Wuninitialized -Wconversion -Wcast-qual -pedantic -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wno-long-long -g -Wno-vla-extension -Wno-variadic-macros" WARN_CFLAGS="${WARN_CFLAGS} -D__STRICT_ANSI__" # WARN_CFLAGS="${WARN_CFLAGS} -fsanitize=address" fi ;; *) echo echo "*******************************************************" echo "unsupported compiler ($CCNAM). Please file a bug." echo "*******************************************************" echo WARN_CFLAGS="${WARN_CFLAGS}" esac fi DEFAULT_CFLAGS="${DEFAULT_CFLAGS} ${WARN_CFLAGS} ${DEBUG_CFLAGS}" TESTS_CFLAGS="${TESTS_CFLAGS} ${WARN_CFLAGS} ${DEBUG_CFLAGS}" AC_HEADER_STDC AC_PROG_LIBTOOL # newer libtool... LT_PREREQ([2.2]) LT_INIT echo "-----------------------------------------------" echo " START GIVARO CONFIG " echo "-----------------------------------------------" echo "-----------------------------------------------" echo "-----------------------------------------------" # checkes which SIMD instructions are available and defines HAVE_{SSE_4_1,AVX,AVX2}_INSTRUCTIONS and compiler flags CUSTOM_SIMD="no" FF_CHECK_SIMD arch=`echo $target | cut -d"-" -f1` if [[ "x$CUSTOM_SIMD" = "xno" ]] ; then AX_CHECK_X86_FEATURES([][]) else CXXFLAGS="${CXXFLAGS} ${SSEFLAGS} ${AVXFLAGS}" fi dnl forcing -mpfmath=sse flag if SSE is available: Veltkamp split would return a different result on the x87 fpu AS_IF([ test "x$SSEFLAGS" != "x" -o "x$X86_FEATURE_CFLAGS" != "x" ],[CXXFLAGS="${CXXFLAGS} -mfpmath=sse"]) dnl With GCC's default ABI version, a __m128 or __m256 are the same types and therefore we cannot dnl have overloads for both types without linking error. AS_IF([test "x$CCNAM" = "xgcc48"],[CXXFLAGS="${CXXFLAGS} -fabi-version=6"],[]) # Machine characteristics AC_CHECK_SIZEOF(char, 8) AC_CHECK_SIZEOF(short, 16) AC_CHECK_SIZEOF(int, 32) AC_CHECK_SIZEOF(long, 32) AC_CHECK_SIZEOF(long long, 64) AC_CHECK_SIZEOF(__int64_t, 64) AC_LANG_CPLUSPLUS AC_CHECK_TYPE([__int128_t], [AC_TRY_COMPILE([#include ], [std::make_unsigned<__int128_t>::type y;],[AC_DEFINE(HAVE_INT128, 1, [Define that compiler allows int128_t types])])]) # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([float.h limits.h stddef.h stdlib.h string.h sys/time.h stdint.h pthread.h]) # check endianness of the architecture AC_C_BIGENDIAN( [AC_DEFINE(HAVE_BIG_ENDIAN, 1, [Define that architecture uses big endian storage])], [AC_DEFINE(HAVE_LITTLE_ENDIAN, 1, [Define that architecture uses little endian storage])], []) echo "Creating symbolic link for compilation" if test ! -L src/kernel/system/givaro ; then ln -s . src/kernel/system/givaro ; fi if test ! -L src/kernel/bstruct/givaro ; then ln -s . src/kernel/bstruct/givaro ; fi if test ! -L src/kernel/integer/givaro ; then ln -s . src/kernel/integer/givaro ; fi if test ! -L src/kernel/memory/givaro ; then ln -s . src/kernel/memory/givaro ; fi if test ! -L src/kernel/rational/givaro; then ln -s . src/kernel/rational/givaro; fi if test ! -L src/kernel/recint/recint ; then ln -s . src/kernel/recint/recint; fi if test ! -L src/kernel/field/givaro ; then ln -s . src/kernel/field/givaro; fi if test ! -L src/kernel/ring/givaro ; then ln -s . src/kernel/ring/givaro; fi if test ! -L src/kernel/gmp++/gmp++ ; then ln -s . src/kernel/gmp++/gmp++ ; fi if test ! -L src/library/matrix/givaro ; then ln -s . src/library/matrix/givaro ; fi if test ! -L src/library/poly1/givaro ; then ln -s . src/library/poly1/givaro ; fi if test ! -L src/library/tools/givaro ; then ln -s . src/library/tools/givaro ; fi if test ! -L src/library/vector/givaro ; then ln -s . src/library/vector/givaro ; fi AC_DEFINE_UNQUOTED(INT8, $GIVARO_INT8, Canonical 8-bit data type) AC_DEFINE_UNQUOTED(INT16, $GIVARO_INT16, Canonical 16-bit data type) AC_DEFINE_UNQUOTED(INT32, $GIVARO_INT32, Canonical 32-bit data type) AC_DEFINE_UNQUOTED(INT64, $GIVARO_INT64, Canonical 64-bit data type) echo "-----------------------------------------------" # Feature checks echo "-----------------------------------------------" GIV_CHECK_GMP(,,[ echo '*******************************************************************************' echo ' ERROR: GMP not found!' echo echo ' GMP library compiled with --enable-cxx is required for this library to compile.' echo ' Please make sure GMP is installed and specify its location with the option' echo ' --with-gmp= when running configure.' echo '*******************************************************************************' exit 1 ]) GIV_DOC CXXFLAGS="${GMP_CFLAGS} ${CXXFLAGS}" LIBS="${GMP_LIBS}" AC_SUBST(CXXFLAGS) echo "-----------------------------------------------" echo " END GIVARO CONFIG " echo "-----------------------------------------------" AC_CONFIG_FILES([ Makefile givaro-config givaro-makefile src/Makefile src/kernel/Makefile src/kernel/system/Makefile src/kernel/memory/Makefile src/kernel/gmp++/Makefile src/kernel/integer/Makefile src/kernel/bstruct/Makefile src/kernel/rational/Makefile src/kernel/recint/Makefile src/kernel/field/Makefile src/kernel/ring/Makefile src/library/Makefile src/library/vector/Makefile src/library/tools/Makefile src/library/poly1/Makefile src/library/matrix/Makefile macros/Makefile benchmarks/Makefile examples/Makefile examples/FiniteField/Makefile examples/Integer/Makefile examples/Rational/Makefile examples/RecInt/Makefile examples/Polynomial/Makefile tests/Makefile docs/Makefile givaro.pc ]) AC_OUTPUT echo "-----------------------------------------------" givaro-4.0.2/docs/000077500000000000000000000000001274707324300137455ustar00rootroot00000000000000givaro-4.0.2/docs/Doxyfile.mod000077500000000000000000002276741274707324300162560ustar00rootroot00000000000000# Doxyfile 1.8.0 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" "). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or sequence of words) that should # identify the project. Note that if you do not use Doxywizard you need # to put quotes around the project name if it contains spaces. PROJECT_NAME = Givaro # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer # a quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = # With the PROJECT_LOGO tag one can specify an logo or icon that is # included in the documentation. The maximum height of the logo should not # exceed 55 pixels and the maximum width should not exceed 200 pixels. # Doxygen will copy the logo to the output directory. PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = . # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = "The $name class" \ "The $name widget" \ "The $name file" \ is \ provides \ specifies \ contains \ represents \ a \ an \ the # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = YES # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = NO # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful if your file system # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = YES # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = YES # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 4 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = "bib=\xrefitem bib \"Bibliography\" \"Bibliography\"" # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding # "class=itcl::class" will allow you to use the command class in the # itcl::class meaning. TCL_SUBST = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given extension. # Doxygen has a built-in mapping, but you can override or extend it using this # tag. The format is ext=language, where ext is a file extension, and language # is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, # C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make # doxygen treat .inc files as Fortran files (default is PHP), and .f files as C # (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions # you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. EXTENSION_MAPPING = # If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all # comments according to the Markdown format, which allows for more readable # documentation. See http://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you # can mix doxygen, HTML, and XML commands with Markdown formatting. # Disable only in case of backward compatibilities issues. MARKDOWN_SUPPORT = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also makes the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = YES # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate getter # and setter methods for a property. Setting this option to YES (the default) # will make doxygen replace the get and set methods by a property in the # documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = YES # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and # unions are shown inside the group in which they are included (e.g. using # @ingroup) instead of on a separate page (for HTML and Man pages) or # section (for LaTeX and RTF). INLINE_GROUPED_CLASSES = NO # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and # unions with only public data fields will be shown inline in the documentation # of the scope in which they are defined (i.e. file, namespace, or group # documentation), provided this scope is documented. If set to NO (the default), # structs, classes, and unions are shown on a separate page (for HTML and Man # pages) or section (for LaTeX and RTF). INLINE_SIMPLE_STRUCTS = NO # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time # causing a significant performance penalty. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on # a logarithmic scale so increasing the size by one will roughly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols. SYMBOL_CACHE_SIZE = 0 # Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be # set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given # their name and scope. Since this can be an expensive process and often the # same symbol appear multiple times in the code, doxygen keeps a cache of # pre-resolved symbols. If the cache is too small doxygen will become slower. # If the cache is too large, memory is wasted. The cache size is given by this # formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols. LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_PACKAGE tag is set to YES all members with package or internal scope will be included in the documentation. EXTRACT_PACKAGE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespaces are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = YES # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = YES # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = YES # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen # will list include files with double quotes in the documentation # rather than with sharp brackets. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = NO # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen # will sort the (brief and detailed) documentation of class members so that # constructors and destructors are listed first. If set to NO (the default) # the constructors will appear in the respective orders defined by # SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. # This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to # do proper type resolution of all parameters of a function it will reject a # match between the prototype and the implementation of a member function even # if there is only one candidate or it is obvious which candidate to choose # by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen # will still accept a match between prototype and implementation in such cases. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or macro consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and macros in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. # This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = "../givaro-config --version" # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. The create the layout file # that represents doxygen's defaults, run doxygen with the -l option. # You can optionally specify a file name after the option, if omitted # DoxygenLayout.xml will be used as the name of the layout file. LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files # containing the references data. This must be a list of .bib files. The # .bib extension is automatically appended if omitted. Using this command # requires the bibtex tool to be installed. See also # http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style # of the bibliography can be controlled using LATEX_BIB_STYLE. To use this # feature you need bibtex and perl available in the search path. CITE_BIB_FILES = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # The WARN_NO_PARAMDOC option can be enabled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = doxy.debug #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = .. \ ../src \ ../docs \ ../examples \ ../tests # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh # *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py # *.f90 *.f *.for *.vhd *.vhdl FILE_PATTERNS = *.cc \ *.cpp \ *.C \ *.h \ *.inl \ *.doxy # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. # Note that relative paths are relative to the directory from which doxygen is # run. EXCLUDE = CVS \ *_src.inl \ Attic # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = */CVS/* \ *_src.inl \ */Attic/* # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = .. # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = *.C \ *.inl \ *INSTALL \ *COPYING \ *HACKING \ *AUTHORS \ *.html # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = YES # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. # If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. # Doxygen will compare the file name with each pattern and apply the # filter if there is a match. # The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty or if # non of the patterns match the file name, INPUT_FILTER is applied. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) # and it is also possible to disable source filtering for a specific pattern # using *.ext= (so without naming a filter). This option only has effect when # FILTER_SOURCE_FILES is enabled. FILTER_SOURCE_PATTERNS = #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. # Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = NO #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = givaro-html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. Note that when using a custom header you are responsible # for the proper inclusion of any scripts and style sheets that doxygen # needs, which is dependent on the configuration options used. # It is advised to generate a default header using "doxygen -w html # header.html footer.html stylesheet.css YourConfigFile" and then modify # that header. Note that the header is subject to change so you typically # have to redo this when upgrading to a newer version of doxygen or when # changing the value of configuration settings such as GENERATE_TREEVIEW! HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # style sheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the # $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these # files. In the HTML_STYLESHEET file, use the file name only. Also note that # the files will be copied as-is; there are no commands or markers available. HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. # Doxygen will adjust the colors in the style sheet and background images # according to this color. Hue is specified as an angle on a colorwheel, # see http://en.wikipedia.org/wiki/Hue for more information. # For instance the value 0 represents red, 60 is yellow, 120 is green, # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. # The allowed range is 0 to 359. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of # the colors in the HTML output. For a value of 0 the output will use # grayscales only. A value of 255 will produce the most vivid colors. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to # the luminance component of the colors in the HTML output. Values below # 100 gradually make the output lighter, whereas values above 100 make # the output darker. The value divided by 100 is the actual gamma applied, # so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, # and 100 does not change the gamma. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting # this to NO can help when comparing the output of multiple runs. HTML_TIMESTAMP = YES # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. For this to work a browser that supports # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = YES # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify # the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated # that can be used as input for Qt's qhelpgenerator to generate a # Qt Compressed Help (.qch) of the generated HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to # add. For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see # # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's # filter section matches. # # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files # will be generated, which together with the HTML files, form an Eclipse help # plugin. To install this plugin and make it available under the help contents # menu in Eclipse, the contents of the directory containing the HTML and XML # files needs to be copied into the plugins directory of eclipse. The name of # the directory within the plugins directory should be the same as # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before # the help appears. GENERATE_ECLIPSEHELP = NO # A unique identifier for the eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have # this name. ECLIPSE_DOC_ID = org.doxygen.Project # The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) # at top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. Since the tabs have the same information as the # navigation tree you can set this option to NO if you already set # GENERATE_TREEVIEW to YES. DISABLE_INDEX = NO # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to YES, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). # Windows users are probably better off using the HTML help feature. # Since the tree basically has the same information as the tab index you # could consider to set DISABLE_INDEX to NO when enabling this option. GENERATE_TREEVIEW = NO # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values # (range [0,1..20]) that doxygen will group on one line in the generated HTML # documentation. Note that a value of 0 will completely suppress the enum # values from appearing in the overview section. ENUM_VALUES_PER_LINE = 4 # By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, # and Class Hierarchy pages using a tree view instead of an ordered list. USE_INLINE_TREES = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open # links to external symbols imported via tag files in a separate window. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are # not supported properly for IE 6.0, but are supported on all modern browsers. # Note that when changing this option you need to delete any form_*.png files # in the HTML output before the changes have effect. FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax # (see http://www.mathjax.org) which uses client side Javascript for the # rendering instead of using prerendered bitmaps. Use this if you do not # have LaTeX installed or if you want to formulas look prettier in the HTML # output. When enabled you may also need to install MathJax separately and # configure the path to it using the MATHJAX_RELPATH option. USE_MATHJAX = NO # When MathJax is enabled you need to specify the location relative to the # HTML output directory using the MATHJAX_RELPATH option. The destination # directory should contain the MathJax.js script. For instance, if the mathjax # directory is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to # the MathJax Content Delivery Network so you can quickly see the result without # installing MathJax. # However, it is strongly recommended to install a local # copy of MathJax from http://www.mathjax.org before deployment. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest # The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension # names that should be enabled during MathJax rendering. MATHJAX_EXTENSIONS = # When the SEARCHENGINE tag is enabled doxygen will generate a search box # for the HTML output. The underlying search engine uses javascript # and DHTML and should work on any modern browser. Note that when using # HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets # (GENERATE_DOCSET) there is already a search function so this one should # typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. SEARCHENGINE = NO # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a PHP enabled web server instead of at the web client # using Javascript. Doxygen will generate the search PHP script and index # file to put on the web server. The advantage of the server # based approach is that it scales better to large projects and allows # full text search. The disadvantages are that it is more difficult to setup # and does not have live searching capabilities. SERVER_BASED_SEARCH = NO #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. # Note that when enabling USE_PDFLATEX this option is only used for # generating bitmaps for formulas in the HTML output, but not in the # Makefile that is written to the output directory. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = stmaryrd \ amsmath # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for # the generated latex document. The footer should contain everything after # the last chapter. If it is left blank doxygen will generate a # standard footer. Notice: only use this tag if you know what you are doing! LATEX_FOOTER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO # If LATEX_SOURCE_CODE is set to YES then doxygen will include # source code with syntax highlighting in the LaTeX output. # Note that which sources are shown also depends on other settings # such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See # http://en.wikipedia.org/wiki/BibTeX for more info. LATEX_BIB_STYLE = plain #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load style sheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. # This is useful # if you want to understand what is going on. # On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # pointed to by INCLUDE_PATH will be searched when a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition that # overrules the definition found in the source code. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all references to function-like macros # that are alone on a line, have an all uppercase name, and do not end with a # semicolon, because these will confuse the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. For each # tag file the location of the external documentation should be added. The # format of a tag file without this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths # or URLs. Note that each tag file must have a unique name (where the name does # NOT include the path). If a tag file is not located in the directory in which # doxygen is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option also works with HAVE_DOT disabled, but it is recommended to # install and use dot, since it yields more powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is # allowed to run in parallel. When set to 0 (the default) doxygen will # base this on the number of processors available in the system. You can set it # explicitly to a value larger than 0 to get control over the balance # between CPU load and processing speed. DOT_NUM_THREADS = 0 # By default doxygen will use the Helvetica font for all dot files that # doxygen generates. When you want a differently looking font you can specify # the font name using DOT_FONTNAME. You need to make sure dot is able to find # the font, which can be done by putting it in a standard location or by setting # the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the # directory containing the font. DOT_FONTNAME = FreeSans.ttf # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the Helvetica font. # If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to # set the path where dot can find it. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If the UML_LOOK tag is enabled, the fields and methods are shown inside # the class node. If there are many fields or methods and many nodes the # graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS # threshold limits the number of items for each type to make the size more # managable. Set this to 0 for no limit. Note that the threshold may be # exceeded by 50% before the limit is enforced. UML_LIMIT_NUM_FIELDS = 10 # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will generate a graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are svg, png, jpg, or gif. # If left blank png will be used. If you choose svg you need to set # HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible in IE 9+ (other browsers do not have this requirement). DOT_IMAGE_FORMAT = png # If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to # enable generation of interactive SVG images that allow zooming and panning. # Note that this requires a modern browser other than Internet Explorer. # Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you # need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible. Older versions of IE do not have SVG support. INTERACTIVE_SVG = NO # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MSCFILE_DIRS tag can be used to specify one or more directories that # contain msc files that are included in the documentation (see the # \mscfile command). MSCFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 1000 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES givaro-4.0.2/docs/DoxyfileDev.mod000077500000000000000000002276641274707324300167140ustar00rootroot00000000000000# Doxyfile 1.8.0 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" "). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or sequence of words) that should # identify the project. Note that if you do not use Doxywizard you need # to put quotes around the project name if it contains spaces. PROJECT_NAME = Givaro # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer # a quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = # With the PROJECT_LOGO tag one can specify an logo or icon that is # included in the documentation. The maximum height of the logo should not # exceed 55 pixels and the maximum width should not exceed 200 pixels. # Doxygen will copy the logo to the output directory. PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = . # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = "The $name class" \ "The $name widget" \ "The $name file" \ is \ provides \ specifies \ contains \ represents \ a \ an \ the # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = YES # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = NO # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful if your file system # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = YES # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = YES # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 4 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = "bib=\xrefitem bib \"Bibliography\" \"Bibliography\"" # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding # "class=itcl::class" will allow you to use the command class in the # itcl::class meaning. TCL_SUBST = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given extension. # Doxygen has a built-in mapping, but you can override or extend it using this # tag. The format is ext=language, where ext is a file extension, and language # is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, # C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make # doxygen treat .inc files as Fortran files (default is PHP), and .f files as C # (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions # you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. EXTENSION_MAPPING = # If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all # comments according to the Markdown format, which allows for more readable # documentation. See http://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you # can mix doxygen, HTML, and XML commands with Markdown formatting. # Disable only in case of backward compatibilities issues. MARKDOWN_SUPPORT = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also makes the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = YES # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate getter # and setter methods for a property. Setting this option to YES (the default) # will make doxygen replace the get and set methods by a property in the # documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = YES # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and # unions are shown inside the group in which they are included (e.g. using # @ingroup) instead of on a separate page (for HTML and Man pages) or # section (for LaTeX and RTF). INLINE_GROUPED_CLASSES = NO # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and # unions with only public data fields will be shown inline in the documentation # of the scope in which they are defined (i.e. file, namespace, or group # documentation), provided this scope is documented. If set to NO (the default), # structs, classes, and unions are shown on a separate page (for HTML and Man # pages) or section (for LaTeX and RTF). INLINE_SIMPLE_STRUCTS = NO # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time # causing a significant performance penalty. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on # a logarithmic scale so increasing the size by one will roughly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols. SYMBOL_CACHE_SIZE = 0 # Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be # set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given # their name and scope. Since this can be an expensive process and often the # same symbol appear multiple times in the code, doxygen keeps a cache of # pre-resolved symbols. If the cache is too small doxygen will become slower. # If the cache is too large, memory is wasted. The cache size is given by this # formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols. LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_PACKAGE tag is set to YES all members with package or internal scope will be included in the documentation. EXTRACT_PACKAGE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespaces are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = YES # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = YES # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = YES # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = YES # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen # will list include files with double quotes in the documentation # rather than with sharp brackets. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = NO # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen # will sort the (brief and detailed) documentation of class members so that # constructors and destructors are listed first. If set to NO (the default) # the constructors will appear in the respective orders defined by # SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. # This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to # do proper type resolution of all parameters of a function it will reject a # match between the prototype and the implementation of a member function even # if there is only one candidate or it is obvious which candidate to choose # by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen # will still accept a match between prototype and implementation in such cases. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or macro consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and macros in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. # This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. The create the layout file # that represents doxygen's defaults, run doxygen with the -l option. # You can optionally specify a file name after the option, if omitted # DoxygenLayout.xml will be used as the name of the layout file. LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files # containing the references data. This must be a list of .bib files. The # .bib extension is automatically appended if omitted. Using this command # requires the bibtex tool to be installed. See also # http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style # of the bibliography can be controlled using LATEX_BIB_STYLE. To use this # feature you need bibtex and perl available in the search path. CITE_BIB_FILES = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # The WARN_NO_PARAMDOC option can be enabled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = doxydev.debug #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = .. \ ../src \ ../docs \ ../examples \ ../tests # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh # *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py # *.f90 *.f *.for *.vhd *.vhdl FILE_PATTERNS = *.cc \ *.cpp \ *.C \ *.h \ *.inl \ *.doxy # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. # Note that relative paths are relative to the directory from which doxygen is # run. EXCLUDE = CVS \ *_src.inl \ Attic # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = */CVS/* \ *_src.inl \ */Attic/* # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = *__GIVARO_* # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = .. # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = *.C \ *.inl \ *INSTALL \ *COPYING \ *HACKING \ *AUTHORS \ *.html # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = YES # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. # If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. # Doxygen will compare the file name with each pattern and apply the # filter if there is a match. # The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty or if # non of the patterns match the file name, INPUT_FILTER is applied. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) # and it is also possible to disable source filtering for a specific pattern # using *.ext= (so without naming a filter). This option only has effect when # FILTER_SOURCE_FILES is enabled. FILTER_SOURCE_PATTERNS = #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. # Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = NO #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = givaro-dev-html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. Note that when using a custom header you are responsible # for the proper inclusion of any scripts and style sheets that doxygen # needs, which is dependent on the configuration options used. # It is advised to generate a default header using "doxygen -w html # header.html footer.html stylesheet.css YourConfigFile" and then modify # that header. Note that the header is subject to change so you typically # have to redo this when upgrading to a newer version of doxygen or when # changing the value of configuration settings such as GENERATE_TREEVIEW! HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # style sheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the # $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these # files. In the HTML_STYLESHEET file, use the file name only. Also note that # the files will be copied as-is; there are no commands or markers available. HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. # Doxygen will adjust the colors in the style sheet and background images # according to this color. Hue is specified as an angle on a colorwheel, # see http://en.wikipedia.org/wiki/Hue for more information. # For instance the value 0 represents red, 60 is yellow, 120 is green, # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. # The allowed range is 0 to 359. HTML_COLORSTYLE_HUE = 110 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of # the colors in the HTML output. For a value of 0 the output will use # grayscales only. A value of 255 will produce the most vivid colors. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to # the luminance component of the colors in the HTML output. Values below # 100 gradually make the output lighter, whereas values above 100 make # the output darker. The value divided by 100 is the actual gamma applied, # so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, # and 100 does not change the gamma. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting # this to NO can help when comparing the output of multiple runs. HTML_TIMESTAMP = YES # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. For this to work a browser that supports # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = YES # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify # the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated # that can be used as input for Qt's qhelpgenerator to generate a # Qt Compressed Help (.qch) of the generated HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to # add. For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see # # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's # filter section matches. # # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files # will be generated, which together with the HTML files, form an Eclipse help # plugin. To install this plugin and make it available under the help contents # menu in Eclipse, the contents of the directory containing the HTML and XML # files needs to be copied into the plugins directory of eclipse. The name of # the directory within the plugins directory should be the same as # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before # the help appears. GENERATE_ECLIPSEHELP = NO # A unique identifier for the eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have # this name. ECLIPSE_DOC_ID = org.doxygen.Project # The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) # at top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. Since the tabs have the same information as the # navigation tree you can set this option to NO if you already set # GENERATE_TREEVIEW to YES. DISABLE_INDEX = NO # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to YES, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). # Windows users are probably better off using the HTML help feature. # Since the tree basically has the same information as the tab index you # could consider to set DISABLE_INDEX to NO when enabling this option. GENERATE_TREEVIEW = NO # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values # (range [0,1..20]) that doxygen will group on one line in the generated HTML # documentation. Note that a value of 0 will completely suppress the enum # values from appearing in the overview section. ENUM_VALUES_PER_LINE = 4 # By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, # and Class Hierarchy pages using a tree view instead of an ordered list. USE_INLINE_TREES = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open # links to external symbols imported via tag files in a separate window. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are # not supported properly for IE 6.0, but are supported on all modern browsers. # Note that when changing this option you need to delete any form_*.png files # in the HTML output before the changes have effect. FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax # (see http://www.mathjax.org) which uses client side Javascript for the # rendering instead of using prerendered bitmaps. Use this if you do not # have LaTeX installed or if you want to formulas look prettier in the HTML # output. When enabled you may also need to install MathJax separately and # configure the path to it using the MATHJAX_RELPATH option. USE_MATHJAX = NO # When MathJax is enabled you need to specify the location relative to the # HTML output directory using the MATHJAX_RELPATH option. The destination # directory should contain the MathJax.js script. For instance, if the mathjax # directory is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to # the MathJax Content Delivery Network so you can quickly see the result without # installing MathJax. # However, it is strongly recommended to install a local # copy of MathJax from http://www.mathjax.org before deployment. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest # The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension # names that should be enabled during MathJax rendering. MATHJAX_EXTENSIONS = # When the SEARCHENGINE tag is enabled doxygen will generate a search box # for the HTML output. The underlying search engine uses javascript # and DHTML and should work on any modern browser. Note that when using # HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets # (GENERATE_DOCSET) there is already a search function so this one should # typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. SEARCHENGINE = NO # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a PHP enabled web server instead of at the web client # using Javascript. Doxygen will generate the search PHP script and index # file to put on the web server. The advantage of the server # based approach is that it scales better to large projects and allows # full text search. The disadvantages are that it is more difficult to setup # and does not have live searching capabilities. SERVER_BASED_SEARCH = NO #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. # Note that when enabling USE_PDFLATEX this option is only used for # generating bitmaps for formulas in the HTML output, but not in the # Makefile that is written to the output directory. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = stmaryrd \ amsmath # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for # the generated latex document. The footer should contain everything after # the last chapter. If it is left blank doxygen will generate a # standard footer. Notice: only use this tag if you know what you are doing! LATEX_FOOTER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO # If LATEX_SOURCE_CODE is set to YES then doxygen will include # source code with syntax highlighting in the LaTeX output. # Note that which sources are shown also depends on other settings # such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See # http://en.wikipedia.org/wiki/BibTeX for more info. LATEX_BIB_STYLE = plain #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load style sheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. # This is useful # if you want to understand what is going on. # On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # pointed to by INCLUDE_PATH will be searched when a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition that # overrules the definition found in the source code. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all references to function-like macros # that are alone on a line, have an all uppercase name, and do not end with a # semicolon, because these will confuse the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. For each # tag file the location of the external documentation should be added. The # format of a tag file without this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths # or URLs. Note that each tag file must have a unique name (where the name does # NOT include the path). If a tag file is not located in the directory in which # doxygen is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option also works with HAVE_DOT disabled, but it is recommended to # install and use dot, since it yields more powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is # allowed to run in parallel. When set to 0 (the default) doxygen will # base this on the number of processors available in the system. You can set it # explicitly to a value larger than 0 to get control over the balance # between CPU load and processing speed. DOT_NUM_THREADS = 0 # By default doxygen will use the Helvetica font for all dot files that # doxygen generates. When you want a differently looking font you can specify # the font name using DOT_FONTNAME. You need to make sure dot is able to find # the font, which can be done by putting it in a standard location or by setting # the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the # directory containing the font. DOT_FONTNAME = FreeSans.ttf # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the Helvetica font. # If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to # set the path where dot can find it. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If the UML_LOOK tag is enabled, the fields and methods are shown inside # the class node. If there are many fields or methods and many nodes the # graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS # threshold limits the number of items for each type to make the size more # managable. Set this to 0 for no limit. Note that the threshold may be # exceeded by 50% before the limit is enforced. UML_LIMIT_NUM_FIELDS = 10 # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will generate a graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are svg, png, jpg, or gif. # If left blank png will be used. If you choose svg you need to set # HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible in IE 9+ (other browsers do not have this requirement). DOT_IMAGE_FORMAT = png # If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to # enable generation of interactive SVG images that allow zooming and panning. # Note that this requires a modern browser other than Internet Explorer. # Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you # need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible. Older versions of IE do not have SVG support. INTERACTIVE_SVG = NO # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MSCFILE_DIRS tag can be used to specify one or more directories that # contain msc files that are included in the documentation (see the # \mscfile command). MSCFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 1000 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES givaro-4.0.2/docs/Makefile.am000077500000000000000000000044311274707324300160060ustar00rootroot00000000000000# Copyright(c)'2010 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. if GIVARO_BUILD_DOC USE_TARGETS = docs INSTALL_TARGETS = install-doc endif docdir=$(GIVARO_DOC_PATH) #man1_MANS = givaro-config.1 all all-local: $(USE_TARGETS) install install-data-local: $(USE_TARGETS) $(INSTALL_TARGETS) if GIVARO_DOXYGEN_FOUND docs: sed -i 's/^\\version.*/\\version\ $(VERSION)/' mainpage.doxy if test -d givaro-html ; then echo exists; else mkdir givaro-html ; fi if test -d givaro-dev-html ; then echo exists; else mkdir givaro-dev-html ; fi cp ../INSTALL givaro-html/ cp ../COPYING givaro-html/ cp ../AUTHORS givaro-html/ doxygen Doxyfile # if test -d givaro-dev-html ; then echo exists; else mkdir givaro-dev-html ; fi # cp index-dev.html givaro-dev-html/index.html # cp tutorial.html givaro-html/ # cp install-dist.html givaro-html/ # cp install-dev.html givaro-html/ docs_dev: make docs cp ../INSTALL givaro-dev-html/ cp ../COPYING givaro-dev-html/ cp ../AUTHORS givaro-dev-html/ doxygen DoxyfileDev # cp tutorial.html givaro-dev-html/ # cp install-dist.html givaro-dev-html/ # cp install-dev.html givaro-dev-html/ install-doc: mkdir -p $(DESTDIR)/$(docdir) cp -rp givaro-html $(DESTDIR)/$(docdir)/givaro-html cp -rp givaro-dev-html $(DESTDIR)/$(docdir)/givaro-dev-html cp -p givaro.html $(DESTDIR)/$(docdir)/givaro.html uninstall-hook: (test -d "$(DESTDIR)/$(docdir)/givaro-html" && rm -r "$(DESTDIR)/$(docdir)/givaro-html") || true (test -d "$(DESTDIR)/$(docdir)/givaro-dev-html" && rm -r "$(DESTDIR)/$(docdir)/givaro-dev-html") || true (test -f "$(DESTDIR)/$(docdir)/givaro.html" && rm "$(DESTDIR)/$(docdir)/givaro.html") || true else docs: @echo @echo "*** ERROR ***" @echo "you need doxygen to build documentation" @echo endif EXTRA_DIST= \ Doxyfile.mod \ DoxyfileDev.mod \ mainpage.doxy \ givaro.html # \ # doc.doxy \ # tutorial.doxy \ # givaro.html \ # givaro-config.1 \ #tutorial.html \ # install-dev.html \ # index-dev.html \ # install-dist.html clean-local : rm -rf givaro-html rm -rf givaro-dev-html givaro-4.0.2/docs/givaro.html000066400000000000000000000012151274707324300161210ustar00rootroot00000000000000 Starter to Givaro documentation Givaro documentation main page: givaro-html/index.html (going there in 5 seconds). If it is a dead link, you have to build the documentation first with make docs. givaro-4.0.2/docs/mainpage.doxy000077500000000000000000000027241274707324300164430ustar00rootroot00000000000000/** @mainpage Givaro Documentation. * Givaro is a C++ library for arithmetic and algebraic computations. * * \section intro Introduction * * Givaro can do fast arithmetic computations with * - Integers. The Integer class uses GMP integers. * - Rationals. * - Rings of the form \f$\mathbf{Z}/m\mathbf{Z}\f$. * - Prime fields and extensions. * - Polynomials. * . * * Non-standard arithmetic tools include truncated arithmetic. * * \section goals Goals * * \section desig Design * * \section using Using Givaro * - \subpage copy. * - \subpage tuto. This is a brief introduction to %LinBox capabilities. * - \subpage inst. Explains how to install from sources or from the latest cvs version. * - \subpage arch. Describes how Givaro is organized * - * Documentation for Users. If everything around is blue, then you are reading * the lighter, user-oriented, documentation. * - * Documentation for Developers. If everything around is green, then you can * get to everything (not necessarily yet) documented. * . * \section contrib Contributing to Givaro, getting assistance. \version 4.0.1 */ /** * \page tuto Tutorial. * Empty. */ /** * \page copy Licence. * Empty. */ /** * \page inst Installation. * Empty. */ /** * \page arch Architecture. * Empty. */ // vim:syn=doxygen givaro-4.0.2/examples/000077500000000000000000000000001274707324300146335ustar00rootroot00000000000000givaro-4.0.2/examples/FiniteField/000077500000000000000000000000001274707324300170155ustar00rootroot00000000000000givaro-4.0.2/examples/FiniteField/GF128.C000066400000000000000000000053601274707324300176540ustar00rootroot00000000000000// ========================================================== // // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Time-stamp: <12 Jun 15 18:38:55 Jean-Guillaume.Dumas@imag.fr> // Thanks to Dieter Schuster // ========================================================== // /*! @file examples/FiniteField/GF128.C * @ingroup examples * @ingroup finitefields * @example examples/FiniteField/GF128.C * @brief NO DOC */ #include #include using namespace Givaro; int main(int argc, char** argv) { GFqDom GF128(2, 7); GFqDom::Element b, c, gen; GF128.init(b, 5U); GF128.init(c, 3); GF128.write(std::cout, b) << std::endl; GF128.write(std::cout, c) << std::endl; GFqDom::Element f,g,h,j; GFqDom F2(2); Poly1Dom< GFqDom, Dense> Pol2(F2); Poly1Dom< GFqDom, Dense>::Element P, Q, R; Pol2.init(P,Degree(1)); F2.init(P[0],1); F2.init(P[1],1); GF128.init(f, P); GF128.write(std::cout << "2-adic representation of 1+X is: ", f) << std::endl << " ... while its internal representation is: " << f << std::endl; GF128.write(std::cout << "Indeed, we are in ") <, Dense > Padic2(Pol2); // std::cout << "Irreducible (in 2-adic): " << GF128.irreducible() << std::endl; GF128.init(g, Padic2.radix( Q, Integer(5) )); GF128.write(std::cout << "2-adic representation of 1+X^2 is: ", g) << std::endl; GF128.init(h); GF128.add(h, g, f); GF128.write(std::cout << "2-adic representation of X+X^2 is: ", h) << std::endl; GF128.mul(h, g, f); GF128.write(std::cout << "2-adic representation of 1+X+X^2+X^3 is: ", h) << std::endl; GF128.div(h, g, f); GF128.write(std::cout << "2-adic representation of 1+X is: ", h) << std::endl; GF128.init(j, Padic2.radix( Q, Integer(213) )); GF128.write(std::cout << "2-adic representation of the moding out of X^7+X^6+X^4+X^2+1 by the irreducible is: ", j) << std::endl; return 0; } givaro-4.0.2/examples/FiniteField/GFirreducible.C000066400000000000000000000057361274707324300216420ustar00rootroot00000000000000// ========================================================== // // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Time-stamp: <12 Jun 15 18:47:22 Jean-Guillaume.Dumas@imag.fr> // Check of irreducible polynomial and generators of GFq // ========================================================== // // /*! @file examples/FiniteField/GFirreducible.C * @ingroup examples * @ingroup finitefields * @example examples/FiniteField/GFirreducible.C * @brief NO DOC */ #include #include #include using namespace Givaro; int main(int argc, char** argv) { int64_t p = (argc>1?atoi(argv[1]):5); int64_t e = (argc>2?atoi(argv[2]):3); typedef GFqDom::Residu_t TT ; GFqDom GFq((TT)p, (TT)e); GFqDom PrimeField((TT)p,1); std::cout << "Working in GF(" << p << '^' << e << ')' << std::endl; std::cout << "Elements are polynomials in X modulo " << p << std::endl; Poly1Dom< GFqDom, Dense > Pdom( PrimeField, Indeter("X") ); // First get the irreducible polynomial irred // via irred = X^e - mQ // and X^e = X^(e-1) * X GFqDom::Element temo, t, tmp; Poly1Dom< GFqDom, Dense >::Element G, H, J, mQ, irred, modP; Pdom.init(G, Degree((int64_t)GFq.exponent()-1)); // X^(e-1) GFq.init(temo,G); // internal representation Pdom.init(H, Degree(1) ); // X GFq.init(t,H); // internal representation GFq.init(tmp); GFq.mul(tmp, temo, t); // internal representation of X^e GFq.negin(tmp); // internal representation of -X^e, i.e. of the irreducible polynomial without the largest monomial, X^e int64_t lowerpart; // p-adic value of the lower part of the irreducible polynomial GFq.convert(lowerpart, tmp); std::cout << ' ' << p << "-adic value of the lower part of the irreducible : " << lowerpart << std::endl; int64_t ptoe = power(p,e); // p-adic value of X^e std::cout << ' ' << p << '^' << e << " is : " << ptoe << std::endl; std::cout << " --> Computed irreducible: " << ptoe+lowerpart << std::endl; std::cout << "Stored irreducible: " << GFq.irreducible() << std::endl; Poly1PadicDom< GFqDom, Dense > PAD(Pdom); Poly1PadicDom< GFqDom, Dense >::Element Polynomial; PAD.radix(Polynomial, GFq.irreducible()); std::cout << "Irreducible polynomial coefficients: "; for(Poly1PadicDom< GFqDom, Dense >::Element::iterator it = Polynomial.begin(); it != Polynomial.end(); ++it) PrimeField.write(std::cout << ' ', *it); std::cout << std::endl; PAD.write(std::cout << "The latter " << GFq.irreducible() << " represents: ", Polynomial) << " in " << p << "-adic" << std::endl; return 0; } givaro-4.0.2/examples/FiniteField/GaloisFields.C000066400000000000000000000175421274707324300214770ustar00rootroot00000000000000// Copyright(c)'1994-2011 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. #include #include #include #include #include using namespace Givaro; int main (int argc, char * * argv) { uint64_t q = (argc>1?(uint64_t)atoi(argv[1]):13); uint64_t expo = (argc>2?(uint64_t)atoi(argv[2]):8); { // This is the field with 11^2=121 elements // Using a generator representation and tables GFqDom F1(11,2); F1.write(std::cout << "This is the field with 121 elements: ") << std::endl; std::cout << " using: " << F1.irreducible() << " as irreducible polynomial" << std::endl; GFqDom::Element primroot; F1.generator(primroot); F1.write(std::cout << " represented as indexes with respect to the generator: ", primroot) << std::endl; std::cout << " represented as indexes with respect to the generator: " << F1.generator() << std::endl; } { // This is the field with q^expo elements using the best // possible base field std::cerr << "Exponent max for zech logs with characteristic " << q << " : " << FF_EXPONENT_MAX(q,expo) << std::endl; std::cerr << "Sub-Exponent max for zech logs " << q << "^" << expo << " : " << FF_SUBEXPONENT_MAX(q,expo) << std::endl; std::cout << "NEED polynomial representation : " << NEED_POLYNOMIAL_REPRESENTATION(q,expo) << std::endl; if ( NEED_POLYNOMIAL_REPRESENTATION(q,expo) ) { // The template parameter if the type of the base field // By default GFqDom is used. Extension<> Fqe(q, expo); Fqe.write(std::cout << "This is the field with " << q << '^' << expo << " elements: ") << std::endl; } else { GFqDom Fqe(q, expo); Fqe.write(std::cout << "This is the field with " << q << '^' << expo << " elements: ") << std::endl; } } // This is the field with 11^2=121 elements // Using a polynomial representation { GFqDom F11(11); Extension< GFqDom > F121(F11, 2); F121.write(std::cout << "This is the field with 121 elements: ") << std::endl; } // This is the field with 11^2=121 elements // Using a polynomial representation // And an alternative field, works only with Givaro >= 3.4.1 { Modular F11(11); Extension< Modular > F121(F11, 2); F121.write(std::cout << "This is the field with 121 elements: ") << ", using: " << F121.irreducible() << " as irreducible polynomial" << std::endl; } // This is the field with 11^2=121 elements // Using a polynomial representation // And an alternative field, works only with Givaro >= 3.4.1 { Modular F11(11); Poly1Dom< Modular, Dense > PolF11(F11,"Z"); Poly1Dom< Modular, Dense >::Element Irred; PolF11.init(Irred, Degree(2)); F11.assign(Irred[0],F11.one); F11.assign(Irred[1],F11.one); // Irred is Y^2+Y+1 Extension< Modular > F121(PolF11, Irred); F121.write(std::cout << "This is the field with 121 elements: ") << ", using: " << F121.irreducible() << " as irreducible polynomial" << std::endl; } // This is the field with 2^8 elements { GFqDom F256(2,8); F256.write(std::cout << "This is the field with 256 elements: ") << ", using: " << F256.irreducible() << " as irreducible polynomial" << std::endl; } // This is the field with 2^8 elements // Using 1 + x +x^3 +x^4 +x^8 as irreducible polynomial { std::vector< GFqDom::Residu_t > Irred(9); Irred[0] = 1; Irred[1] = 1; Irred[2] = 0; Irred[3] = 1; Irred[4] = 1; Irred[5] = 0; Irred[6] = 0; Irred[7] = 0; Irred[8] = 1; GFqDom F256(2,8, Irred); F256.write(std::cout << "This is the field with 256 elements: ") << ", using: " << F256.irreducible() << " as irreducible polynomial" << std::endl; std::cout << " this field is generated (in 2-adic) by: " << F256.generator() << std::endl; std::cout << " in this field the indeterminate is represented by: " << F256.sage_generator() << " (same as " << F256.indeterminate() << ')' << std::endl; Givaro::GFqDom F2(2); typedef Givaro::Poly1Dom< Givaro::GFqDom, Givaro::Dense> PolDomain; typedef Givaro::Poly1PadicDom< Givaro::GFqDom, Givaro::Dense> PadicDomain; PolDomain Pol2(F2,"Z"); PadicDomain Padic2(Pol2); PolDomain::Element polGen, polIrred; Padic2.radix(polGen, F256.generator() ); Padic2.radix(polIrred, F256.irreducible() ); Pol2.write(Pol2.write( std::cout << " that is with this representation, (", polGen) << ")^" << F256.indeterminate() << " == Z mod (", polIrred) << ')' << std::endl; { GFqDom::Element a, b, c; givvector Av(8); // A := X^7+X^6+X^3+X Av[0]=0; Av[1]=1; Av[2]=0; Av[3]=1; Av[4]=0; Av[5]=0; Av[6]=1; Av[7]=1; givvector Bv(8); // B:=X^6+X^4+X+1; Bv[0]=1; Bv[1]=1; Bv[2]=0; Bv[3]=0; Bv[4]=1; Bv[5]=0; Bv[6]=1; Bv[7]=0; F256.init(a, Av); F256.init(b, Bv); F256.mul(c,a,b); F256.write( std::cout, a) << '*'; F256.write( std::cout, b) << '='; F256.write( std::cout, c) << std::endl; F256.add(c,a,b); F256.write( F256.write( F256.write( std::cout, a) << '+', b) << '=' , c ) << std::endl; } { GFqDom::Element a, b, c, x; x = F256.sage_generator(); F256.add(a,x,F256.one); // X+1 F256.mulin(a,x); F256.mulin(a,x); F256.mulin(a,x); // (X+1)X^3 F256.addin(a,F256.one); // (X+1)X^3+1 F256.mulin(a,x); F256.mulin(a,x); // ((X+1)X^3+1)X^2 F256.addin(a,F256.one); // ((X+1)X^3+1)X^2+1 F256.mulin(a,x); // (((X+1)X^3+1)X^2+1)X F256.mul(b,x,x); F256.addin(b,F256.one); // X^2+1 F256.mulin(b,x); F256.mulin(b,x); F256.mulin(b,x); // (X^2+1)X^3 F256.addin(b,F256.one); // (X^2+1)X^3+1 F256.mulin(b,x); // ((X^2+1)X^3+1)X F256.addin(b,F256.one); // ((X^2+1)X^3+1)X+1 F256.mul(c,a,b); F256.write( std::cout, a) << '*'; F256.write( std::cout, b) << '='; F256.write( std::cout, c) << std::endl; F256.add(c,a,b); F256.write( F256.write( F256.write( std::cout, a) << '+', b) << '=' , c ) << std::endl; } { Modular GF2(2); Poly1PadicDom< Modular > P2(GF2,"X"); givvector vect202; P2.radixdirect(vect202, 202, 8); givvector vect83; P2.radixdirect(vect83, 83, 8); givvector< uint64_t > Irred2; P2.radixdirect(Irred2, 283, 9); GFqDom F256_(2,8, Irred2); GFqDom::Element a, b, c; F256_.init(a, vect202); F256_.init(b, vect83); F256_.mul(c,a,b); F256_.write( std::cout, a) << '*'; F256_.write( std::cout, b) << '='; F256_.write( std::cout, c) << std::endl; F256_.add(c,a,b); F256_.write( F256_.write( F256_.write( std::cout, a) << '+', b) << '=' , c ) << std::endl; } } return 0; } givaro-4.0.2/examples/FiniteField/Makefile.am000077500000000000000000000044561274707324300210650ustar00rootroot00000000000000# Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. examples: $(EXTRA_PROGRAMS) AM_CPPFLAGS=-I$(top_srcdir) OPTFLAGS= OPTLINKS= # for gcc ... #OPTFLAGS+= -O7 -funroll-all-loops -felide-constructors -fstrict-aliasing #OPTFLAGS+= -frerun-loop-opt -fexpensive-optimizations #OPTFLAGS+= -fomit-frame-pointer #OPTFLAGS+= -fprefetch-loop-arrays -floop-optimize #OPTFLAGS+= -malign-double #OPTFLAGS+= -falign-loops -falign-jumps -falign-functions -falign-labels #OPTFLAGS+= -fschedule-insns2 #OPTFLAGS+= -fforce-addr -fforce-mem -fstrength-reduce #OPTFLAGS+= -ffast-math # for icc ... #OPTFLAGS+= -fast -Ob2 -ipo_obj -unroll #OPTFLAGS+= -parallel -par_report1 #OPTLINKS+= -parallel # icc for itanium2 #OPTFLAGS+= -tpp2 -mcpu=itanium2 AM_CXXFLAGS = @DEFAULT_CFLAGS@ AM_CPPFLAGS += $(OPTFLAGS) $(GMP_CFLAGS) -I$(top_srcdir)/src/kernel/system -I$(top_srcdir)/src/kernel/memory -I$(top_srcdir)/src/kernel/field -I$(top_srcdir)/src/kernel/ring -I$(top_srcdir)/src/kernel/integer -I$(top_srcdir)/src/kernel -I$(top_srcdir)/src/library/poly1 -I$(top_srcdir)/src/kernel/bstruct -I$(top_srcdir)/src/library/tools LDADD = $(OPTLINKS) -L${top_srcdir}/src -L${top_srcdir}/src/.libs -lgivaro $(GMP_LIBS) $(LDFLAGS) AM_LDFLAGS=-static EXTRA_PROGRAMS=gfq_atomic GaloisFields Test_Extension zpz_atomic ff_arith exponentiation domain_to_operatorstyle all_field GF128 GFirreducible CLEANFILES=$(EXTRA_PROGRAMS) GFirreducible_SOURCES = GFirreducible.C GF128_SOURCES = GF128.C domain_to_operatorstyle_SOURCES = domain_to_operatorstyle.C all_field_SOURCES = all_field.C gfq_atomic_SOURCES = gfq_atomic.C GaloisFields_SOURCES = GaloisFields.C Test_Extension_SOURCES = Test_Extension.C zpz_atomic_SOURCES = zpz_atomic.C ff_arith_SOURCES = ff_arith.C exponentiation_SOURCES = exponentiation.C # for compilation of new examples GIVARO_BIN=@bindir@ examp_comp = $(CXX) $(OPTFLAGS) $(AM_CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $*.C -o $* `$(GIVARO_BIN)/givaro-config --cflags` $(LDADD) `$(GIVARO_BIN)/givaro-config --libs` %:%.C $(examp_comp) %:%.cpp $(examp_comp) givaro-4.0.2/examples/FiniteField/Test_Extension.C000066400000000000000000000035421274707324300221000ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/FiniteField/Test_Extension.C * @ingroup examples * @ingroup finitefields * @example examples/FiniteField/Test_Extension.C * @brief NO DOC */ #include "givaro/givpoly1.h" #include "givaro/extension.h" using namespace Givaro; template void FaireEssai(const FField & F) { F.write( std::cout << "Working in : " ) << std::endl; typename FField::Element a, b, r; std::cout << "Enter an Element of this field: "; F.read( std::cin , a ); // F.init( a, "1+3*X+5*X^2" ); F.init( b, (Integer)23 ); F.add(r, a, b); F.write( F.write( F.write( F.write(std::cout, a) << " + " , b ) << " = " , r) << " with ") << std::endl ; } template void FaireEssai< Extension<> >(const Extension<> & F) ; template void FaireEssai< GFqDom >(const GFqDom & F) ; int main (int argc, char * * argv) { uint64_t q = (argc>1?(uint64_t)atoi(argv[1]):13); uint64_t expo = (argc>2?(uint64_t)atoi(argv[2]):8); /* GFqDom Toto(q,1); Toto.write( std::cout << "This is ") << std::endl ; FaireEssai( Toto ); */ std::cerr << "Exponent max for zech logs with characteristic " << q << " : " << FF_EXPONENT_MAX(q,expo) << std::endl; std::cerr << "Sub-Exponent max for zech logs " << q << "^" << expo << " : " << FF_SUBEXPONENT_MAX(q,expo) << std::endl; std::cerr << "NEED polynomial representation : " << NEED_POLYNOMIAL_REPRESENTATION(q,expo) << std::endl; if ( NEED_POLYNOMIAL_REPRESENTATION(q,expo) ) FaireEssai( Extension<>(q, expo) ); else FaireEssai( GFqDom(q, expo) ); FaireEssai( EXTENSION(q, expo) ); return 0; } givaro-4.0.2/examples/FiniteField/all_field.C000066400000000000000000000067001274707324300210370ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/FiniteField/all_field.C * @ingroup examples * @ingroup finitefields * @example examples/FiniteField/all_field.C * @brief NO DOC */ #include #include #include #include #include using namespace Givaro; namespace Givaro { // Domain kind typedef Modular Field1; typedef StaticElement< Field1 > Element1; template<> Field1 Element1::_domain(2); typedef GFqDom Field2; typedef StaticElement< Field2 > Element2; template<> Field2 Element2::_domain(2); typedef Montgomery Field3; typedef StaticElement< Field3 > Element3; template<> Field3 Element3::_domain(2); typedef Modular Field4; typedef StaticElement< Field4 > Element4; template<> Field4 Element4::_domain(2); typedef Modular Field5; typedef StaticElement< Field5 > Element5; template<> Field5 Element5::_domain(2); typedef Modular Field6; typedef StaticElement< Field6 > Element6; template<> Field6 Element6::_domain(2); typedef Modular Field7; typedef StaticElement< Field7 > Element7; template<> Field7 Element7::_domain(2); #ifdef GIVARO_USE_SIXTYFOUR typedef Modular Field8; typedef StaticElement< Field8 > Element8; template<> Field8 Element8::_domain(2); #endif } template void TestField() { uint64_t P = 251; // Initialization of static member Element::setDomain( Field( typename Field::Residu_t(P)) ); // Initialisations of elements Element a(2),b(-29.8),c(33),d(Integer("123456789012345678901234567890")),e(0); e += (a = b); std::cout << a << " = " << b << " mod " << P << ";" << std::endl; e += (a = b + c); std::cout << a << " = " << b << " + " << c << " mod " << P << ";" << std::endl; e += (a = b - c); std::cout << a << " = " << b << " - " << c << " mod " << P << ";" << std::endl; e += (a = b * c); std::cout << a << " = " << b << " * " << c << " mod " << P << ";" << std::endl; e += (a = b / c); std::cout << a << " = " << b << " / " << c << " mod " << P << ";" << std::endl; std::cout << d << " + " << a << " mod " << P << " = "; e += (d += a); std::cout << d << ";" << std::endl; std::cout << d << " - " << a << " mod " << P << " = "; e += (d -= a); std::cout << d << ";" << std::endl; std::cout << d << " * " << a << " mod " << P << " = "; e += (d *= a); std::cout << d << ";" << std::endl; std::cout << d << " / " << a << " mod " << P << " = "; e += (d /= a); std::cout << d << ";" << std::endl; std::cout << a << " is non zero ? " << (a != Element(0) ) << std::endl; a = 0; std::cout << a << " is zero ? " << (a == Element(0) ) << std::endl; double dd(0.0); dd += (double)(e); dd += (float)e; dd += (uint32_t)e; Element::getDomain().write( std::cerr << "Test: " << dd << " within ") << std::endl; } int main(int argc, char ** argv) { TestField(); TestField(); TestField(); TestField(); TestField(); TestField(); TestField(); #ifdef GIVARO_USE_SIXTYFOUR TestField(); #endif return 0; } givaro-4.0.2/examples/FiniteField/domain_to_operatorstyle.C000066400000000000000000000055101274707324300240670ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/FiniteField/domain_to_operatorstyle.C * @ingroup examples * @ingroup finitefields * @example examples/FiniteField/domain_to_operatorstyle.C * @brief NO DOC */ #include #include #include using namespace Givaro; namespace Givaro { // Finite Field with Domain style typedef GFqDom Field; // Wrapper to give an operator style to the elements typedef StaticElement< Field > Element; // Mandatory declaration (because of static template) // and an actual constructed field is mandatory (the "(2)") for g++ 3.4 //! Specialisation of... template<> Field Element::_domain(2); } int main(int argc, char ** argv) { uint64_t P = (argc>1 ? (uint64_t)atoi(argv[1]) : 5009U); // Initialization of static member Element::setDomain( Field(P) ); // Initialisations of elements Element a(2),b(-29.8),c(33),d(Integer("123456789012345678901234567890")); // Computations a = b; std::cerr << a << " = " << b << " mod " << P << ";" << std::endl; a = b + c; std::cerr << a << " = " << b << " + " << c << " mod " << P << ";" << std::endl; a = b - c; std::cerr << a << " = " << b << " - " << c << " mod " << P << ";" << std::endl; a = b * c; std::cerr << a << " = " << b << " * " << c << " mod " << P << ";" << std::endl; a = b / c; std::cerr << a << " = " << b << " / " << c << " mod " << P << ";" << std::endl; // Computations in place std::cerr << d << " + " << a << " mod " << P << " = "; d += a; std::cerr << d << ";" << std::endl; std::cerr << d << " - " << a << " mod " << P << " = "; d -= a; std::cerr << d << ";" << std::endl; std::cerr << d << " * " << a << " mod " << P << " = "; d *= a; std::cerr << d << ";" << std::endl; std::cerr << d << " / " << a << " mod " << P << " = "; d /= a; std::cerr << d << ";" << std::endl; // Tests const Element zero(0); std::cerr << a << " is non zero is " << (a != zero ) << std::endl; std::cerr << a << " is non zero is " << (! Element::isZero(a)) << std::endl; std::cerr << a << " is non zero is " << (! a.isZero()) << std::endl; a = 0; std::cerr << a << " is zero is " << (a == zero ) << std::endl; std::cerr << a << " is zero is " << Element::isZero(a) << std::endl; std::cerr << a << " is zero is " << a.isZero() << std::endl; // Access to Field object const Field & F = Element::getDomain(); F.write( std::cerr << "Test: within ") << std::endl; return 0; } // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/examples/FiniteField/exponentiation.C000066400000000000000000000030331274707324300221640ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/FiniteField/exponentiation.C * @ingroup examples * @ingroup finitefields * @example examples/FiniteField/exponentiation.C * @brief NO DOC */ #include #include #include #include using namespace Givaro; int main(int argc, char ** argv) { { Modular Z13(13); // modulo 13 over 32 bits Modular::Element a, c; Z13.init(a, 7); long l = 29; dom_power(c, a, l, Z13); // c = 7^29 modulo 13 by squaring std::cerr << "Within "; Z13.write( std::cerr ); std::cerr << " : " << std::flush; // Separate output writing Z13.write( std::cout, a) << " ^ " << l << " = " << std::flush; Z13.write( std::cerr, c) << std::endl; } { typedef GFqDom::Residu_t TT; int Mod = 13; int exponent = 1; GFqDom GF13( (TT) Mod, (TT) exponent ); // finite field with 13 elements GFqDom::Element a, c; GF13.init(a, 7); // 7 modulo 13 long l = 29; dom_power(c, a, l, GF13); // c = 7^29 modulo 13 by squaring // Writing all outputs in a single command line GF13.write( std::cerr << "Within " ) << " : " << std::flush; GF13.write( GF13.write( std::cout, a) << " ^ " << l << " = ", c) << std::endl; } return 0; } givaro-4.0.2/examples/FiniteField/ff_arith.C000066400000000000000000000152251274707324300207100ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/FiniteField/ff_arith.C * @ingroup examples * @ingroup finitefields * @example examples/FiniteField/ff_arith.C * @brief NO DOC */ #include #include #include #include #include using namespace Givaro; template void TestField(const Field& F) { std::cerr << "Within " ; F.write(std::cerr ); std::cerr << " : " << std::flush; typename Field::Element a, b, c, d; F.init(a, 7U); F.init(b, -29.3); F.init(c); // empty constructor F.init(d); // empty constructor F.add(c, a, b); // c = a+b // Separate output writing F.write( std::cout, a) << " + " << std::flush; F.write( std::cout, b) << " = " << std::flush; F.write( std::cerr, c) << std::endl; F.mul(c, a, b); // c = a*b F.axpy(d, a, b, c); // d = a*b + c; // Writing all outputs in a single command line F.write( std::cerr << "Within " ) << " : " << std::flush; F.write( F.write( F.write( F.write( std::cout, c) << " + ", a) << " * ", b) << " = ", d) << std::endl; { typename Field::Element e; F.init(e); F.assign(e,d); F.maxpy(e, a, b, d); // e = d-a*b // Writing all outputs in a single command line F.write( std::cerr << "Within " ) << " : " << std::flush; F.write( F.write( F.write( F.write( std::cout, d) << " - ", a) << " * ", b) << " = ", e) << std::endl; } { typename Field::Element e; F.init(e); F.assign(e,d); F.maxpyin(e, a, b); // e = d - a*b; // Writing all outputs in a single command line F.write( std::cerr << "Within " ) << " : " << std::flush; F.write( F.write( F.write( F.write( std::cout, d) << " - ", a) << " * ", b) << " = ", e) << std::endl; } { typename Field::Element e; F.init(e); F.assign(e,d); F.axmy(e, a, b, d); // e = a*b -d; // Writing all outputs in a single command line F.write( std::cerr << "Within " ) << " : " << std::flush; F.write( F.write( F.write( F.write( std::cout, a) << " * ", b) << " - ", d) << " = ", e) << std::endl; } { typename Field::Element e; F.init(e); F.assign(e,d); F.maxpyin(e, a, b); // e = d - a*b; // Writing all outputs in a single command line F.write( std::cerr << "Within " ) << " : " << std::flush; F.write( F.write( F.write( F.write( std::cout, d) << " - ", a) << " * ", b) << " = ", e) << std::endl; } // Four operations F.write( F.write( std::cout, a) << " += ", b) << " is " ; F.write( std::cout, F.addin(a, b) ) << " ; "; F.write( F.write( std::cout, a) << " -= ", b) << " is "; F.write( std::cout, F.subin(a, b) ) << " ; "; F.write( F.write( std::cout, a) << " *= ", b) << " is " ; F.write( std::cout, F.mulin(a, b) ) << " ; "; F.write( F.write( std::cout, a) << " /= ", b) << " is "; F.write( std::cout, F.divin(a, b) ) << std::endl; F.init(a,22996); F.inv(b,a); F.write( F.write( std::cout << "1/", a) << " is ", b) << std::endl; F.mul(c,b,a); F.write( std::cout << "1 is ", c) << std::endl; F.init(a,22996); F.init(b,22996); F.write( std::cout << "1/", a) << " is "; F.invin(a); F.write( std::cout, a) << std::endl; F.mulin(a,b); F.write( std::cout << "1 is ", a) << std::endl; F.init(a,37403); F.inv(b,a); F.write( F.write( std::cout << "1/", a) << " is ", b) << std::endl; F.mul(c,b,a); F.write( std::cout << "1 is ", c) << std::endl; F.init(a,37403); F.init(b,37403); F.write( std::cout << "1/", a) << " is "; F.invin(a); F.write( std::cout, a) << std::endl; F.mulin(a,b); F.write( std::cout << "1 is ", a) << std::endl; } extern "C" { # include # include } int main(int argc, char ** argv) { // modulo 13 over 16 bits Modular C13(13); TestField( C13 ); // modulo 13 over 32 bits Modular Z13(13); TestField( Z13 ); // modulo 13 over unsigned 32 bits Modular U13(13); TestField( U13 ); #ifdef __USE_Givaro_SIXTYFOUR__ // modulo 13 over 64 bits Modular LL13(13U); TestField( LL13 ); #endif // modulo 13 fully tabulated Modular L13(13); TestField( L13 ); // modulo 13 over 32 bits with Montgomery reduction Montgomery M13(13); TestField( M13 ); Montgomery M3(39989); TestField( M3 ); // modulo 13 with primitive root representation GFqDom GF13( 13 ); TestField( GF13 ); // modulo 13 over arbitrary size Modular IntZ13(13); TestField( IntZ13 ); // Zech log finite field with 5^4 elements GFqDom GF625( 5, 4 ); TestField( GF625 ); // Zech log finite field with 256 elements // and prescribed irreducible polynomial std::vector< GFqDom::Residu_t > Irred(9); Irred[0] = 1; Irred[1] = 1; Irred[2] = 0; Irred[3] = 1; Irred[4] = 1; Irred[5] = 0; Irred[6] = 0; Irred[7] = 0; Irred[8] = 1; GFqDom F256(2,8, Irred); TestField( F256 ); // Zech log finite field with 3^4 elements // Using the Q-adic Transform GFqExt GF81( 3, 4 ); TestField( GF81 ); // Zech log finite field with 2Mb tables struct rusage tmp1 ; getrusage (RUSAGE_SELF, &tmp1) ; // user time double tim = (double) tmp1.ru_utime.tv_sec + ((double) tmp1.ru_utime.tv_usec)/ ( 1000000.0 ) ; ; getrusage (RUSAGE_SELF, &tmp1) ; tim = (double) tmp1.ru_utime.tv_sec + ((double) tmp1.ru_utime.tv_usec)/ (1000000.0) - tim; std::cerr << "Initialization took " << tim << " cpu seconds and : " << std::endl; std::cerr << tmp1.ru_maxrss << " maximum resident set size"<< std::endl << tmp1.ru_ixrss << " integral shared memory size"<< std::endl << tmp1.ru_idrss << " integral unshared data size"<< std::endl << tmp1.ru_isrss << " integral unshared stack size"<< std::endl << tmp1.ru_minflt << " page reclaims"<< std::endl << tmp1.ru_majflt << " page faults"<< std::endl << tmp1.ru_nswap << " swaps"<< std::endl << tmp1.ru_inblock << " block input operations"<< std::endl << tmp1.ru_oublock << " block output operations"<< std::endl; return 0; } givaro-4.0.2/examples/FiniteField/gfq_atomic.C000066400000000000000000000131601274707324300212330ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/FiniteField/gfq_atomic.C * @ingroup examples * @ingroup finitefields * @example examples/FiniteField/gfq_atomic.C * @brief NO DOC */ #include #include #include #include #include using namespace Givaro; #ifndef GIVMIN #define GIVMIN(a,b) (((a)<(b))?(a):(b)) #endif typedef GFqDom Domain; typedef GFqDom::Element Modulo; // NB: number of iterations, TAILLE: vector size #ifndef NB #define NB 1000000 #endif #ifndef TAILLE #define TAILLE 256 #endif int main(int argc, char ** argv) { GivRandom generator; int64_t P (65521); // argv[1] : characteristic int64_t expo(1); // argv[2] : exponent int offset = 0; if (argc > ++offset) P = atoi( argv[ offset ] ); if (argc > ++offset) expo = atoi( argv[ offset ] ); Timer inver; inver.clear(); inver.start(); Domain GFq((uint64_t)P, (uint64_t)expo); // Buiding of finite field with P^expo Elements Modulo * z1 = new Modulo[TAILLE], * z2 = new Modulo[TAILLE], * z23 = new Modulo[TAILLE], * z3 = new Modulo[TAILLE]; // int64_t seuil = GIVMIN(P*2,TAILLE); std::cout << "."<< std::flush; for(int i=0; is,f0,{0,g0,(0,\:0,t0,+0,=s givaro-4.0.2/examples/FiniteField/kronecker.C000066400000000000000000000073711274707324300211140ustar00rootroot00000000000000// ========================================================================== // Copyright(c)'1994-2010 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // file: gfqkronecker.h // Time-stamp: <12 Apr 10 16:46:17 Jean-Guillaume.Dumas@imag.fr> // ========================================================================== // /*! @file examples/FiniteField/kronecker.C * @ingroup examples * @ingroup finitefields * @example examples/FiniteField/kronecker.C * @brief NO DOC */ #include #include #include #include using namespace Givaro; int main(int argc, char ** argv) { unsigned long charac = (argc>1?atoi(argv[1]):3); unsigned long expo = (argc>2?atoi(argv[2]):8); GFqKronecker GF(charac, expo); GFqKronecker::Element a, b; GF.write(std::cerr << "After field init of ") << std::endl; GF.init(a, 7U); GF.write( std::cerr << "7 --> ", a ) << std::endl; GivRandom generator; GF.random(generator,b); GF.write( std::cerr << "b: ", b ) << std::endl; Modular Zp(charac); Poly1PadicDom > PAD(Zp ,"Y"); Poly1PadicDom >::Element pol; PAD.radixdirect(pol, GF.convert(b), expo); PAD.write(std::cerr<< "b(Y): ", pol) << std::endl; Integer r; unsigned long shift = ceil(log( (double)charac)/log(2.)); for(size_t i=0; i<5; ++i, ++shift) { GF.setShift( shift ); GF.convert(r, b); std::cerr << "b kron(" << shift << "): " << r << std::endl; Modular Zm( 1< > PmAD(Zm ,"Z"); Poly1PadicDom >::Element pol; PmAD.radixdirect(pol, r, expo); PmAD.write(std::cerr<< "b(" << (1< Zm( 1< > PmAD(Zm ,"B"); Poly1PadicDom >::Element Ipol; GFqKronecker::Element c,d,e,f; GF.random(generator,c); GF.random(generator,d); PAD.radixdirect(pol, GF.convert(c), expo); PmAD.radixdirect(Ipol, GF.convert(r,c), expo); PmAD.write(std::cerr<< "c:=", Ipol) << ';' << std::endl; PmAD.radixdirect(Ipol, GF.convert(r,d), expo); PmAD.write(std::cerr<< "d:=", Ipol) << ';' << std::endl; GF.random(generator,e); GF.random(generator,f); PmAD.radixdirect(Ipol, GF.convert(r,e), expo); PmAD.write(std::cerr<< "e:=", Ipol) << ';' << std::endl; PmAD.radixdirect(Ipol, GF.convert(r,f), expo); PmAD.write(std::cerr<< "f:=", Ipol) << ';' << std::endl; GFqKronecker::Element dot; GF.mul(dot,c,d); GF.axpyin(dot,e,f); GF.write( std::cerr << "dot: ", dot ) << std::endl; PmAD.radixdirect(Ipol, GF.convert(r,dot), expo); PmAD.write(std::cerr<< "dot:=", Ipol) << ';' << std::endl; Integer Ic,Id,Ie,If; GF.convert(Ic, c); GF.convert(Id, d); GF.convert(Ie, e); GF.convert(If, f); Integer Idot = Ic*Id+Ie*If; PmAD.radixdirect(Ipol, Idot, 2*(expo)); PmAD.write(std::cerr<< "Idot:=", Ipol) << ';' << std::endl; std::cerr << "Idot: " << Idot << std::endl; GFqKronecker::Element res; GF.init(res, Idot); GF.write( std::cerr << "res: ", res ) << std::endl; if (! GF.areEqual(res, dot)) { std::cerr << "ERROR: incoherency" << std::endl; } else std::cerr << "passed." << std::endl; return 0; } givaro-4.0.2/examples/FiniteField/zpz_atomic.C000066400000000000000000000133521274707324300213040ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/FiniteField/zpz_atomic.C * @ingroup examples * @ingroup finitefields * @example examples/FiniteField/zpz_atomic.C * @brief NO DOC */ #include #include #include #include #include using namespace Givaro; #ifndef GIVMIN #define GIVMIN(a,b) (((a)<(b))?(a):(b)) #endif typedef Modular Domain; typedef Domain::Element Modulo; #ifndef NB #define NB 1000000 #endif #ifndef TAILLE #define TAILLE 256 #endif int main(int argc, char ** argv) { GivRandom generator; long P (32749); // argv[1] : Modulus // int TAILLE (256); // argv[2] : Vector size // long NB (500000); // argv[3] : Number of iterations int offset = 0; if (argc > ++offset) P = atoi( argv[ offset ] ); // if (argc > ++offset) TAILLE = atoi( argv[ offset ] ); // if (argc > ++offset) NB = atoi( argv[ offset ] ); Timer inver; inver.clear(); inver.start(); Domain GFq((Domain::Residu_t)P); std::cout << "."<< std::flush; Modulo * z1 = new Modulo[TAILLE], * z2 = new Modulo[TAILLE], * z23 = new Modulo[TAILLE], * z3 = new Modulo[TAILLE]; // long seuil = GIVMIN(P*2,TAILLE); std::cout << "."<< std::flush; for(int i=0; is,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen:foldmethod=syntax /* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ givaro-4.0.2/examples/Integer/000077500000000000000000000000001274707324300162305ustar00rootroot00000000000000givaro-4.0.2/examples/Integer/Makefile.am000077500000000000000000000056251274707324300202770ustar00rootroot00000000000000# Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. examples: $(EXTRA_PROGRAMS) AM_CPPFLAGS=-I$(top_srcdir) #OPTFLAGS = -O7 -funroll-all-loops -felide-constructors -fstrict-aliasing #OPTFLAGS+= -frerun-loop-opt -fexpensive-optimizations #OPTFLAGS+= -fomit-frame-pointer #OPTFLAGS+= -fprefetch-loop-arrays -floop-optimize #OPTFLAGS+= -malign-double #OPTFLAGS+= -falign-loops -falign-jumps -falign-functions -falign-labels #OPTFLAGS+= -fschedule-insns2 #OPTFLAGS+= -fforce-addr -fforce-mem -fstrength-reduce #OPTFLAGS+= -ffast-math # for icc ... #OPTFLAGS = -fast -Ob2 -ipo_obj -unroll #OPTFLAGS+= -parallel -par_report1 # icc for itanium2 #OPTFLAGS+= -tpp2 -mcpu=itanium2 AM_CXXFLAGS = @DEFAULT_CFLAGS@ AM_CPPFLAGS += $(OPTFLAGS) $(GMP_CFLAGS) AM_CPPFLAGS += -I$(top_srcdir)/src/kernel/system -I$(top_srcdir)/src/kernel/memory -I$(top_srcdir)/src/kernel/integer -I$(top_srcdir)/src/kernel -I$(top_srcdir)/src/kernel/field -I$(top_srcdir)/src/kernel/ring -I$(top_srcdir)/src/kernel/bstruct -I$(top_srcdir)/src/library/poly1 -I$(top_srcdir)/src/library/tools LDADD = -L${top_srcdir}/src -L${top_srcdir}/src/.libs -lgivaro $(GMP_LIBS) $(LDFLAGS) AM_LDFLAGS=-static EXTRA_PROGRAMS=ifactor ifactor_lenstra igcd igcdext ilcm isproot nb_primes isprime nextprime order prevprime RSA_breaking RSA_keys_generator primitiveroot primitiveelement phi lambda lambda_inv iexponentiation RSA_decipher RSA_encipher ispower probable_primroot ProbLucas ModularSquareRoot CLEANFILES=$(EXTRA_PROGRAMS) ModularSquareRoot_SOURCES = ModularSquareRoot.C ProbLucas_SOURCES = ProbLucas.C probable_primroot_SOURCES = probable_primroot.C ispower_SOURCES = ispower.C ifactor_SOURCES = ifactor.C ifactor_lenstra_SOURCES = ifactor_lenstra.C igcd_SOURCES = igcd.C lambda_SOURCES = lambda.C lambda_inv_SOURCES = lambda_inv.C phi_SOURCES = phi.C igcdext_SOURCES = igcdext.C ilcm_SOURCES = ilcm.C isproot_SOURCES = isproot.C primitiveroot_SOURCES = primitiveroot.C primitiveelement_SOURCES = primitiveelement.C nb_primes_SOURCES = nb_primes.C isprime_SOURCES = isprime.C nextprime_SOURCES = nextprime.C order_SOURCES = order.C prevprime_SOURCES = prevprime.C RSA_breaking_SOURCES = RSA_breaking.C RSA_keys_generator_SOURCES = RSA_keys_generator.C RSA_encipher_SOURCES = RSA_encipher.C RSA_decipher_SOURCES = RSA_decipher.C iexponentiation_SOURCES = iexponentiation.C # for compilation of new examples GIVARO_BIN=@bindir@ %:%.C $(CXX) $(OPTFLAGS) $(AM_CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $*.C -o $* `$(GIVARO_BIN)/givaro-config --cflags` $(LDADD) `$(GIVARO_BIN)/givaro-config --libs` $(LOADLIBES) givaro-4.0.2/examples/Integer/ModularSquareRoot.C000066400000000000000000000047411274707324300217720ustar00rootroot00000000000000// =================================================================== // // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Time-stamp: <21 Feb 12 17:02:32 Jean-Guillaume.Dumas@imag.fr> // Givaro : Modular square roots // =================================================================== // /*! @file examples/Integer/ModularSquareRoot.C * @ingroup examples * @ingroup integers * @example examples/Integer/ModularSquareRoot.C * @brief NO DOC */ #include #include #include #include #include #include using namespace Givaro; // Algorithm 3.34 (Square Root Mod p) of // Handbook of Applied Cryptography // by Menezes, van Oorschot, Vanstone int main(int argc, char** argv) { Integer a(argv[1]), n(argv[2]); IntSqrtModDom<> ISM; { std::cerr << "a: " << a << std::endl; std::cerr << "n: " << n << std::endl; Integer::seeding ( (unsigned long)BaseTimer::seed ()); Integer r; Timer chrono; chrono.start(); ISM.sqrootmod(r,a,n); chrono.stop(); std::cout << r << std::endl; std::cerr << chrono << std::endl; std::cerr << "Check, (" << r << ")^2 mod " << n << " = " << ( (r*r)%n) << std::endl; } if (ISM.isprime(n)) { std::cout << "Using polynomial factorization : " << std::endl; typedef Modular Field; typedef Poly1FactorDom Polys; typedef Polys::Element Polynomial; Field F(n); Polys Pol(F, "X"); Polynomial quad, root; Pol.init(quad, Degree(2)); F.init(quad[0],a); F.negin(quad[0]); Timer chrono; chrono.start(); if (Pol.is_irreducible(quad)) { std::cerr << a << " is not a quadratic residue mod " << n << std::endl; chrono.stop(); std::cerr << chrono << std::endl; return 0; } Pol.SplitFactor(root, quad, Degree(1)); chrono.stop(); Pol.divin(root, root[1]); Pol.write(std::cout, root) << std::endl; std::cerr << chrono << std::endl; std::cerr << "Check, (" << root[0] << ")^2 mod " << n << " = " << ( (root[0]*root[0])%n) << std::endl; } return 0; } givaro-4.0.2/examples/Integer/ProbLucas.C000066400000000000000000000165271274707324300202410ustar00rootroot00000000000000// =================================================================== // // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Contributor: Jack Dubrois < Jacques.Dubrois@imag.fr> // Time-stamp: <12 Jun 15 18:24:19 Jean-Guillaume.Dumas@imag.fr> // // Primality check using Probabilistic Lucas ///////////////////////// // i.e. Primitive Root with choosen probability ///////////////////////// // =================================================================== // /*! @file examples/Integer/ProbLucas.C * @ingroup examples * @ingroup integers * @example examples/Integer/ProbLucas.C * @brief NO DOC */ #include #include #include #include using namespace std; #include #include #include #include #include #include #include #include #include #include using namespace Givaro; IntFactorDom<> IP; #define GIVABSDIV(a,b) ((a)<(b)?((a)/(b)):((b)/(a))) #ifndef GIVMIN #define GIVMIN(a,b) ((a)<(b)?(a):(b)) #endif #define ProbLucas_factor_first_primes(tmp,n) (tmp = IP.isZero(IP.mod(tmp,n,23))?23:( IP.isZero(IP.mod(tmp,n,19))?19:( IP.isZero(IP.mod(tmp,n,17))?17: (IP.isZero(IP.mod(tmp,n,2))?2:( IP.isZero(IP.mod(tmp,n,3))?3:( IP.isZero(IP.mod(tmp,n,5))?5:( IP.isZero(IP.mod(tmp,n,7))?7: ( IP.isZero(IP.mod(tmp,n,11))?11:13 )))))))) #define ProbLucas_factor_second_primes(tmp,n) (tmp = IP.isZero(IP.mod(tmp,n,31))?31:( IP.isZero(IP.mod(tmp,n,29))?29: ( IP.isZero(IP.mod(tmp,n,37))?37: ( IP.isZero(IP.mod(tmp,n,41))?41:( IP.isZero(IP.mod(tmp,n,43))?43: ( IP.isZero(IP.mod(tmp,n,71))?71:( IP.isZero(IP.mod(tmp,n,67))?67:( IP.isZero(IP.mod(tmp,n,61))?61:( IP.isZero(IP.mod(tmp,n,59))?59: ( IP.isZero(IP.mod(tmp,n,53))?53:( IP.isZero(IP.mod(tmp,n,47))?47: ( IP.isZero(IP.mod(tmp,n,97))?97: ( IP.isZero(IP.mod(tmp,n,89))?89:( IP.isZero(IP.mod(tmp,n,83))?83:( IP.isZero(IP.mod(tmp,n,79))?79:73))))))))))))))) Integer& MyPollard(GivRandom& gen, Integer& g, const Integer& n, const unsigned long threshold) { g=1; Integer m(0U), x, y, t; static Integer PROD_first_primes(223092870); static Integer PROD_second_primes("10334565887047481278774629361"); if (isOne(gcd(y,n,PROD_first_primes))) { if (isOne(gcd(y,n,PROD_second_primes))) { IP.random(gen, y, n); unsigned long p(1); for(unsigned long c = 0; isOne(g) && (++c < threshold); ) { if( p == c ) { x=y; p <<= 1; } // Pollard fctin IP.mulin(y,y); IP.addin(y,1U); IP.modin(y,n); gcd(g,IP.sub(t,y,x),n); } return g; } else { return ProbLucas_factor_second_primes(g,n); } } else { return ProbLucas_factor_first_primes(g,n); } } unsigned long Revert(const Integer p, const double epsilon, double firstguess) { // unsigned long L; double t1, t4, t8, t34(firstguess), dL; t1 = (double)p-1.0; t4 = 2.0/t1+1.0; t8 = logtwo(p)*log(2.0)-log(2.0); // log( p/2 ) do { double t3, t5, t7, t9, t11, t12, t18, t22, t23 ; // std::cerr << "dL: " << t34 << std::endl; dL = t34; t3 = 1.0/dL; t5 = t3*t3; t7 = 1.0-t5; t9 = 2.0*log(dL); t11 = t8/t9; t12 = ::pow(t7,t11); t18 = t9*t9; t22 = log(t7); t23 = (-t8/t18*t3*t22+t11*t5*t3/t7); t34 = dL-( 1.0 - (1.0-epsilon)/(t4*t12))/(2.0*t23); } while( (GIVABSDIV(t34,dL) < 0.95) && (dL<1048576.0) ); return /* L =*/ (unsigned long)GIVMIN(dL,1048576.0); } unsigned long Revert(const Integer p, const double epsilon) { return Revert(p, epsilon, ::sqrt(1.2/epsilon)); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////// Recherche de la racine primitive /////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool ProbLucas(const Integer n, const double orig_epsilon) { #ifdef __GMP_PLUSPLUS__ Integer::seeding( (unsigned long)BaseTimer::seed() ); #endif GivRandom generator; Integer Q=n-1,a,q,tmp(1); Integer nmu=Q; double P = 1.0; double epsilon = orig_epsilon; // Miller-Rabin unsigned long s=0; for( ; !( (int)Q & 0x1) ; Q>>=1, ++s) { } for(unsigned int i=0; ; ) { IP.random(generator,a,n); IP.powmod(tmp,a,Q,n); if (tmp!=1) { if (tmp != nmu) { for(i=(unsigned int) s; --i>0;) { tmp *= tmp; tmp %= n; if ((tmp == 1) || (tmp == nmu)) break; } if (tmp != nmu) return 0; if (i == 0) break; } else { if (s == 1) break; } } epsilon *= 4.0; P /= 2.0; } unsigned long L = Revert(Q,epsilon); Integer trn, r, b, expo; root( trn, n, 3); trn *= trn; q = 2; expo = nmu; MyPollard(generator, q, Q, L); if (q == 1) { q = Q; expo = nmu; expo /= q; IP.random(generator, a, n); IP.powmod(tmp,a,expo,n); if (tmp == 1) { P /= (double)(q); if (P < epsilon) { std::cerr << "Composite with probability > 1-" << P << std::endl; return 0; } } Q = 1; } else { expo = nmu; expo /= q; r=0; Integer::divexact(b, Q, q); while( isZero(r) ) { Q.copy(b); Integer::divmod( b, r, Q, q ); } L = Revert(Q,epsilon, (double)L); } while ( Q > trn ) { IP.random(generator, a, n); IP.powmod(tmp,a,expo,n); if (tmp == 1) { P /= (double)(q); if (P < epsilon) { std::cerr << "Composite with probability > 1-" << P << std::endl; return 0; } } else { if (IP.gcd(q,(tmp-1U),n) != 1) { std::cerr << "Factor found : " << q << std::endl; return 0; } MyPollard(generator, q, Q, L); if (q == 1) { q = Q; expo = nmu; expo /= q; IP.random(generator, a, n); IP.powmod(tmp,a,expo,n); if (tmp == 1) { P /= (double)(q); if (P < epsilon) { std::cerr << "Composite with probability > 1-" << P << std::endl; return 0; } } break; } else { expo = nmu; expo /= q; r=0; Integer::divexact(b, Q, q); while( isZero(r) ) { Q.copy(b); Integer::divmod( b, r, Q, q ); } L = Revert(Q,epsilon, (double)L); } } } if (! IP.isprime(q)) std::cerr << "Prime with probability > 1-" << orig_epsilon << std::endl; return 1; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int main (int argc, char * * argv) { Integer P; if (argc > 1) P = Integer(argv[1]); else std::cin >> P; double epsilon = argc > 2 ? atof(argv[2]) : 0.000001; unsigned int NB = argc > 3 ? (unsigned int)atoi(argv[3]) : 1U; // std::cerr << "P: " << P << " ; proba: " << epsilon << std::endl; bool a1(true); Timer tim; tim.clear(); for(unsigned int i = 0; i < NB; ++i) { Timer tt; tt.clear(); tt.start(); a1 = ProbLucas(P, epsilon); tt.stop(); // std::cout << a1 << std::endl; // std::cerr << tt << std::endl; tim += tt; } std::cout << (a1?"prime":"composite") << endl; std::cerr << tim << std::endl; return 0; } // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s givaro-4.0.2/examples/Integer/RSA_breaking.C000066400000000000000000000024331274707324300206250ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/RSA_breaking.C * @ingroup examples * @ingroup integers * @example examples/Integer/RSA_breaking.C * @brief NO DOC */ #include using namespace std; #define GIVARO_LENSTRA #include "givaro/givintrsa.h" #include "givaro/givtimer.h" using namespace Givaro; int main(int argc, char** argv) { Timer tim; tim.clear(); IntRSADom<>::Element m,k,u; if (argc > 1) m = IntRSADom<>::Element( argv[1] ); else cin >> m; if (argc > 2) k = IntRSADom<>::Element( argv[2] ); else cin >> k; IntRSADom<> IR(m,k); tim.start(); IR.point_break(u); tim.stop(); /* For a factored output : IR.write( cerr << "m=pq: ", IR.getm()) ; IR.write( cerr << ", cipher k: " , IR.getk()) << " ----> decipering key: " ; IR.write( cout, u ) << endl; */ // Unfactored output cerr << "n=pq: " << IR.getn() << ", cipher key: " << IR.gete() << " ----> decipering key: "; cout << u << endl; cerr << tim << endl; return 0; } givaro-4.0.2/examples/Integer/RSA_decipher.C000066400000000000000000000025641274707324300206330ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/RSA_decipher.C * @ingroup examples * @ingroup integers * @example examples/Integer/RSA_decipher.C * @brief NO DOC */ #include #include #include "givaro/givintrsa.h" #include "givaro/givrandom.h" #include "givaro/givtimer.h" // RSA, in CBC mode, deciphering of files using namespace Givaro; int main(int argc, char** argv) { Timer tim; tim.clear(); IntRSADom::Rep n,e,d; if (argc > 3) n = Integer( argv[3] ); else std::cin >> e; if (argc > 4) e = Integer( argv[4] ); else std::cin >> e; if (argc > 5) d = Integer( argv[5] ); else std::cin >> d; IntRSADom IR(n,e,d); std::ifstream TXT(argv[1]); if (!TXT) { std::cerr << "Error opening input file: " << argv[1] << std::endl; return -1; } std::ofstream OUT(argv[2]); if (!OUT) { std::cerr << "Error opening output file: " << argv[2] << std::endl; return -1; } tim.start(); IR.decipher( OUT, TXT ); OUT.close(); TXT.close(); tim.stop(); std::cerr << tim << std::endl; return 0; } givaro-4.0.2/examples/Integer/RSA_encipher.C000066400000000000000000000024321274707324300206370ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/RSA_encipher.C * @ingroup examples * @ingroup integers * @example examples/Integer/RSA_encipher.C * @brief NO DOC */ #include #include #include "givaro/givintrsa.h" #include "givaro/givrandom.h" #include "givaro/givtimer.h" // RSA, in CBC mode, enciphering of files using namespace Givaro; int main(int argc, char** argv) { Timer tim; tim.clear(); IntRSADom::Rep n,e; if (argc > 3) n = Integer( argv[3] ); else std::cin >> n; if (argc > 4) e = Integer( argv[4] ); else std::cin >> e; IntRSADom IR(n,e); std::ifstream TXT(argv[1]); if (!TXT) { std::cerr << "Error opening input file: " << argv[1] << std::endl; return -1; } std::ofstream OUT(argv[2]); if (!OUT) { std::cerr << "Error opening output file: " << argv[2] << std::endl; return -1; } tim.start(); IR.encipher( OUT, TXT ); OUT.close(); TXT.close(); tim.stop(); std::cerr << tim << std::endl; return 0; } givaro-4.0.2/examples/Integer/RSA_keys_generator.C000066400000000000000000000021161274707324300220620ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/RSA_keys_generator.C * @ingroup examples * @ingroup integers * @example examples/Integer/RSA_keys_generator.C * @brief NO DOC */ #include #include "givaro/givintrsa.h" #include "givaro/givrandom.h" #include "givaro/givtimer.h" using namespace Givaro; int main(int argc, char** argv) { Timer tim; tim.clear(); // m will be p times q // Sizes are in number of int to compose the big integer long keysize; if (argc > 1) keysize = atoi( argv[1] ); else std::cin >> keysize; GivRandom generator; Integer::seeding(generator.seed()); tim.start(); IntRSADom IR(keysize,true,generator); tim.stop(); std::cout << IR.getn() << " " << IR.gete() << " " << IR.getd() << std::endl; std::cerr << tim << std::endl; return 0; } givaro-4.0.2/examples/Integer/givaro-ssh-keygen.C000066400000000000000000000153761274707324300217120ustar00rootroot00000000000000// ==================================================================== // // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Time-stamp: <25 Aug 15 14:15:31 Jean-Guillaume.Dumas@imag.fr> // // ==================================================================== // // Givaro replacement for ssh-keygen: generated keys use strong primes // // Random generator is seeded by // // - true randomness in file, e.g. // // dd if=/dev/random of=.rand bs=1k count=16 // // - otherwise gettimeofday is used, see givrandom.h // // File formats are then managed by openssl and openssh, thus this file // // requires to be compiled with -lssl -lssh -lopenbsd-compat // // Warning: Sometimes putting -lssh twice is required // // You also need the openssl and openssh development headers below: // // openssh/buffer.h openssh/key.h openssh/uuencode.h openssh/xmalloc.h // // The latter libraries/headers are avaible from openssl and openssh // // openssl >= 0.9.8 and openssh >= 5.2p1 are expected // // For openssh >= 6.3p1, use "-lopenbsd-compat -lssh -lssl -lcrypto -ldl"// // For openssh >= commit 9690b78, use: // -lssh -lopenbsd-compat -lcrypto -ldl -lutil -lz -lnsl -lcrypt -lresolv// // Stack protection might also be required: // -fstack-protector-strong -lssh -lopenbsd-compat -lcrypto -lz // // ==================================================================== // /*! @file examples/Integer/givaro-ssh-keygen.C * @ingroup examples * @ingroup integers * @example examples/Integer/givaro-ssh-keygen.C * @brief NO DOC */ #include #include #include #include #include extern "C" { #include "openssh/digest.h" #include "openssh/key.h" } #include #include using namespace Givaro; /* Strong pseudo-prime generation using Gordon's algorithm */ template struct Givaro_keygen { void operator()(Integer& n, Integer& e, Integer& d, Integer& p, Integer& q, Integer& dmp1, Integer& dmq1, Integer& iqmp, long size, unsigned long seed) { typename IntRSADom::random_generator gen(seed); Integer::seeding(gen.seed()); IntRSADom IRD(false,gen); IRD.keys_gen(gen, (size>>1)+1, (size>>1)-1, n, e, d, p, q); Integer phim,p1,q1; IRD.mul(phim, IRD.sub(p1,p,IRD.one), IRD.sub(q1,q,IRD.one)); Integer v, g; IRD.mod(e, 65537, phim); IRD.gcd(g,d,v,e,phim); IRD.modin(d,phim); if ( IRD.islt(d,IRD.zero) ) IRD.addin(d,phim); IRD.mod(dmp1,d,p1); IRD.mod(dmq1,d,q1); IRD.gcd(g,iqmp,v,q,p); if ( IRD.islt(iqmp,IRD.zero) ) IRD.addin(iqmp,p); } }; /* Converts a givaro integer to an openssl BIGNUM */ BIGNUM* Integer2BN(BIGNUM * n, const Integer& a) { std::string str(a); BN_dec2bn(&n,str.c_str()); return n; } int mymain(FILE* fileout, FILE* filepub, long s, unsigned long seed) { RSA *rsa= new RSA(); Integer in, ie, id, ip, iq, idmp1, idmq1, iiqmp; Timer tim;tim.clear();tim.start(); Givaro_keygen<>()(in,ie,id,ip,iq,idmp1,idmq1,iiqmp, s, seed); tim.stop(); /* std::cerr << "n: " << in << std::endl; std::cerr << "e: " << ie << std::endl; std::cerr << "d: " << id << std::endl; std::cerr << "p: " << ip << std::endl; std::cerr << "q: " << iq << std::endl; std::cerr << "dmp1: " << idmp1 << std::endl; std::cerr << "dmq1: " << idmq1 << std::endl; std::cerr << "iqmp: " << iiqmp << std::endl; */ std::cerr << tim << std::endl; rsa->n = BN_new(); Integer2BN(rsa->n, in); rsa->e = BN_new(); Integer2BN(rsa->e, ie); rsa->d = BN_new(); Integer2BN(rsa->d, id); rsa->p = BN_new(); Integer2BN(rsa->p, ip); rsa->q = BN_new(); Integer2BN(rsa->q, iq); rsa->dmp1 = BN_new(); Integer2BN(rsa->dmp1, idmp1); rsa->dmq1 = BN_new(); Integer2BN(rsa->dmq1, idmq1); rsa->iqmp = BN_new(); Integer2BN(rsa->iqmp, iiqmp); Key rsakey; rsakey.type=KEY_RSA; rsakey.rsa = rsa; /* std::cerr << "print: " << std::endl; RSA_print_fp(stdout, rsa, 0); std::cerr << "PEM Write: " << std::endl; PEM_write_RSAPublicKey(stdout,rsa); */ std::cerr << "key's randomart: \n" << sshkey_fingerprint(&rsakey, SSH_FP_HASH_DEFAULT, SSH_FP_RANDOMART) << std::endl; // Write Private Key in ssl PEM format PEM_write_RSAPrivateKey(fileout,rsa,NULL,NULL,0,NULL,NULL); // Write Public key in ssh b64 format key_write(&rsakey, filepub); fprintf(filepub," givaro\n"); return 0; } unsigned long seedfromfile(char * filename) { std::ifstream filrand(filename); unsigned long seed=0; for(unsigned int i=0; i> t; seed <<= 8; seed |= t; } std::cerr << "Generated seed: " << seed << ", using " << filename << std::endl; return seed; } void usage() { std::cerr << "Usage: givaro-ssh-keygen [-b bits] [-f private-key-file] [-p public-key-file] [-r randomness-file]" << std::endl; } int main(int argc, char** argv) { if (argc > 10) { usage(); return 0; } long s = 4096; unsigned long seed = 0; long files = 0; std::string filprivname, filpubname; for (long i = 1; i < argc; i++) { if (argv[i][0] == '-') { switch(argv[i][1]) { case 'h':; case 'H': { usage(); return 0; } case 'b':; case 'B': { s = atoi(argv[++i]); break; } case 'f':; case 'F': { filprivname = std::string(argv[++i]); ++files; break; } case 'p':; case 'P': { filpubname = std::string(argv[++i]); ++files; break; } case 'r':; case 'R': { seed = seedfromfile(argv[++i]); break; } } } } if (files > 1) { FILE * filpriv; filpriv = fopen(filprivname.c_str(),"w"); if (argc>3) { FILE * filpub ; filpub = fopen(filpubname.c_str(),"w"); mymain(filpriv,filpub,s,seed); fclose(filpub); } else mymain(filpriv,stdout,s,seed); fclose(filpriv); chmod(filprivname.c_str(),(S_IRUSR|S_IWUSR)); } else mymain(stdout,stdout,s,seed); return 0; } givaro-4.0.2/examples/Integer/iexponentiation.C000066400000000000000000000022251274707324300215520ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/iexponentiation.C * @ingroup examples * @ingroup integers * @example examples/Integer/iexponentiation.C * @brief NO DOC */ #include #include #include #include using namespace Givaro; // Modular exponentiation // argv[1] : a // argv[2] : e // argv[3] : p // res ---> a^e % p int main(int argc, char ** argv) { { Integer p(argv[3]); Modular Zp( p ); Modular::Element a, b; unsigned long e = (unsigned long)atoi(argv[2]) ; Zp.init(a, Integer(argv[1])); Zp.init(b); Timer tim;tim.clear();tim.start(); dom_power(b, a, (long)e, Zp); tim.stop(); Zp.write( std::cout << '(', a) << '^' << e << ") % " << p << '=' << std::flush; Zp.write( std::cerr, b) << std::endl; std::cerr << tim << std::endl; } return 0; } givaro-4.0.2/examples/Integer/ifactor.C000066400000000000000000000017261274707324300177710ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/ifactor.C * @ingroup examples * @ingroup integers * @example examples/Integer/ifactor.C * @brief NO DOC */ #include #include #include #include using namespace std; using namespace Givaro; int main(int argc, char** argv) { IntFactorDom<> IP; Integer m; if (argc > 1) m = Integer(argv[1]); else cin >> m; if (IP.islt(m,0) ) { cerr << "-"; IP.negin(m); } if (IP.islt(m,4)) IP.write(cerr,m) << endl; else { Timer tim; tim.clear(); tim.start(); IP.write(cerr,m) << endl; tim.stop(); cerr << tim << endl; } return 0; } givaro-4.0.2/examples/Integer/ifactor_lenstra.C000066400000000000000000000021471274707324300215170ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/ifactor_lenstra.C * @ingroup examples * @ingroup integers * @example examples/Integer/ifactor_lenstra.C * @brief NO DOC */ #define GIVARO_LENSTRA #include using namespace std; #include #include #include using namespace Givaro; int main(int argc, char** argv) { IntFactorDom<> IP; #ifndef __GIVARO_GMP_NO_CXX IP.seeding(); // std::cerr << "Seeding..." << std::endl; #endif Integer m; if (argc > 1) m = Integer(argv[1]); else cin >> m; if (IP.islt(m,0) ) { cerr << "-"; IP.negin(m); } if (IP.islt(m,4)) IP.write(cerr,m) << endl; else { Timer tim; tim.clear(); tim.start(); IP.write(cerr,m) << endl; tim.stop(); cerr << tim << endl; } return 0; } givaro-4.0.2/examples/Integer/igcd.C000066400000000000000000000021571274707324300172470ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/igcd.C * @ingroup examples * @ingroup integers * @example examples/Integer/igcd.C * @brief NO DOC */ #include using namespace std; #include #include #include #include // Givaro initialization using namespace Givaro; int main(int argc, char** argv) { // Givaro::Init(&argc, &argv); IntegerDom IP; IntegerDom::Element GG, g,a,b; int offset = 0; if (argc > ++offset) a = Integer(argv[offset]); else cin >> a; if (argc > ++offset) b = Integer(argv[offset]); else cin >> b; Timer tim; tim.clear(); tim.start(); IP.gcd(GG,a,b); for ( ; argc > ++offset; ) { a = Integer(argv[offset]); IP.gcd(g, GG, a); GG = g; } tim.stop(); cout << GG << endl; cerr << tim << endl; // Givaro::End(); return 0; } givaro-4.0.2/examples/Integer/igcdext.C000066400000000000000000000020511274707324300177610ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/igcdext.C * @ingroup examples * @ingroup integers * @example examples/Integer/igcdext.C * @brief NO DOC */ #include using namespace std; #include #include #include #include // Givaro initialization using namespace Givaro; int main(int argc, char** argv) { // Givaro::Init(&argc, &argv); IntegerDom IP; IntegerDom::Element g,a,b,u,v; if (argc > 1) a = Integer(argv[1]); else cin >> a; if (argc > 2) b = Integer(argv[2]); else cin >> b; Timer tim; tim.clear(); tim.start(); IP.gcd(g,u,v,a,b); tim.stop(); cout << g << " = " << u << " * " << a << " + " << v << " * " << b << endl; cerr << tim << endl; // Givaro::End(); return 0; } givaro-4.0.2/examples/Integer/ilcm.C000066400000000000000000000030621274707324300172610ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/ilcm.C * @ingroup examples * @ingroup integers * @example examples/Integer/ilcm.C * @brief NO DOC */ #include using namespace std; #include #include #include #include // Givaro initialization using namespace Givaro; int main(int argc, char** argv) { // Givaro::Init(&argc, &argv); IntegerDom IP; IntegerDom::Element CM, g,a,b, c; int offset = 0; if (argc > ++offset) a = Integer(argv[offset]); else cin >> a; if (argc > ++offset) b = Integer(argv[offset]); else cin >> b; Timer tim; tim.clear(); tim.start(); IP.gcd(g,a,b); IP.mul(CM, a, b); IP.divin(CM, g); for ( ; argc > ++offset; ) { c = Integer(argv[offset]); IP.gcd(g, CM, c); IP.divin(CM, g); IP.mulin(CM, c); } tim.stop(); cout << CM << endl; cerr << "gcd+mul: " << tim << endl; tim.clear(); tim.start(); IP.lcm(CM,a,b); // cerr << "lcm(" << a << "," << b << ") = " << CM << endl; for ( offset = 2; argc > ++offset; ) { c = Integer(argv[offset]); // cerr << "lcm(" << c << "," << CM << ") = " ; IP.lcmin(CM, c); // cerr << CM << endl; } tim.stop(); cout << CM << endl; cerr << "lcm: " << tim << endl; // Givaro::End(); return 0; } givaro-4.0.2/examples/Integer/ispower.C000066400000000000000000000022011274707324300200170ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/ispower.C * @ingroup examples * @ingroup integers * @example examples/Integer/ispower.C * @brief NO DOC */ #include #include #include #include #include using namespace Givaro; int main(int argc, char** argv) { Integer m, p; if (argc > 1) m = Integer(argv[1]); IntPrimeDom IP; { Timer tim; tim.clear(); tim.start(); int a = isperfectpower(m); tim.stop(); std::cout << a << std::endl; std::cerr << tim << std::endl; } { Timer tim; tim.clear(); tim.start(); int a = (int)IP.isprimepower(p, m); tim.stop(); if (a) std::cout << "is " << p << "^" << a << std::endl; else std::cout << "not a prime power" << std::endl; std::cerr << tim << std::endl; } return 0; } givaro-4.0.2/examples/Integer/isprime.C000066400000000000000000000020031274707324300177770ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/ispower.C * @ingroup examples * @ingroup integers * @example examples/Integer/isprime.C * @brief NO DOC */ #include using namespace std; #include #include #include #include // Givaro initialization using namespace Givaro; int main(int argc, char** argv) { // Givaro::Init(&argc, &argv); IntPrimeDom IP; IntPrimeDom::Element m; if (argc > 1) m = Integer(argv[1]); unsigned int r = argc > 2 ? (unsigned int)atoi(argv[2]) : 5; Timer tim; tim.clear(); tim.start(); bool a = IP.isprime(m,(int)r); tim.stop(); cout << (a?"true":"false") << endl; cerr << tim << endl; // Givaro::End(); return 0; } givaro-4.0.2/examples/Integer/isproot.C000066400000000000000000000021121274707324300200270ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/isproot.C * @ingroup examples * @ingroup integers * @example examples/Integer/isproot.C * @brief NO DOC */ #include #include #include using namespace Givaro; //---------------------------------------------------------- // Deterministic, non-polynomial (factor b-1 for the order), // test for primitive roots. //---------------------------------------------------------- int main(int argc, char** argv) { IntNumTheoDom<> IP; IntNumTheoDom<>::Element a,b; if (argc > 1) a = Integer(argv[1]); else std::cin >> a; if (argc > 2) b = Integer(argv[2]); else std::cin >> b; Timer tim; tim.clear(); tim.start(); bool f = IP.is_prim_root(a,b); tim.stop(); std::cout << f << std::endl; std::cerr << tim << std::endl; return 0; } givaro-4.0.2/examples/Integer/lambda.C000066400000000000000000000016651274707324300175640ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/lambda.C * @ingroup examples * @ingroup integers * @example examples/Integer/lambda.C * @brief NO DOC */ #include #include #include using namespace Givaro; // Lambda function : order of a primitive Element // (Element of maximal orbit size) // int main(int argc, char** argv) { IntNumTheoDom<> IP; IntNumTheoDom<>::Element a,pr; if (argc > 1) a = IntNumTheoDom<>::Element(argv[1]); else std::cin >> a; Timer tim; tim.clear(); tim.start(); IP.lambda(pr, a); tim.stop(); IntegerDom().write( std::cout, pr ) << std::endl; std::cerr << tim << std::endl; return 0; } givaro-4.0.2/examples/Integer/lambda_inv.C000066400000000000000000000017171274707324300204360ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/lambda_inv.C * @ingroup examples * @ingroup integers * @example examples/Integer/lambda_inv.C * @brief NO DOC */ #include #include #include using namespace Givaro; // Lambda function : order of a primitive invertible // (invertible Element of maximal orbit size) // int main(int argc, char** argv) { IntNumTheoDom<> IP; IntNumTheoDom<>::Element a,pr; if (argc > 1) a = IntNumTheoDom<>::Element(argv[1]); else std::cin >> a; Timer tim; tim.clear(); tim.start(); IP.lambda_inv(pr, a); tim.stop(); IntegerDom().write( std::cout, pr ) << std::endl; std::cerr << tim << std::endl; return 0; } givaro-4.0.2/examples/Integer/nb_primes.C000066400000000000000000000024601274707324300203140ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/nb_primes.C * @ingroup examples * @ingroup integers * @example examples/Integer/nb_primes.C * @brief NO DOC */ #include #include "givaro/givintprime.h" #include "givaro/givtimer.h" using namespace Givaro; inline Integer GIVMAX(const Integer& a, const Integer& b) { return (a 1) np = Integer(argv[1]); else std::cin >> np; if (argc > 2) m = GIVMAX(1,Integer(argv[2])); else m = 2; Integer nf = m; unsigned long long nb = (IPD.isprime(m)?1:0); Timer tim; tim.clear(); tim.start(); for (;m < np; tp *= 2) { std::cout << nb << " primes between " << nf << " and " << m << "\t\t == nextprime(" << (ttp+nf-1) << ")" << std::endl; ttp = tp; for (;(m < np) && (m < (nf+tp)); ++nb) IPD.nextprimein(m); } tim.stop(); std::cout << (m>np?nb-1:nb) << " primes between " << nf << " and " << np << std::endl << tim << std::endl; return 0; } givaro-4.0.2/examples/Integer/nextprime.C000066400000000000000000000017071274707324300203540ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/nextprime.C * @ingroup examples * @ingroup integers * @example examples/Integer/nextprime.C * @brief NO DOC */ #include using namespace std; #include #include #include #include // Givaro initialization using namespace Givaro; int main(int argc, char** argv) { // Givaro::Init(&argc, &argv); IntPrimeDom IP; IntPrimeDom::Element m, ff; if (argc > 1) m = Integer(argv[1]); else std::cin >> m; Timer tim; tim.clear(); tim.start(); IP.nextprimein(m,1); tim.stop(); cout << m << endl; cerr << tim << endl; // Givaro::End(); return 0; } givaro-4.0.2/examples/Integer/order.C000066400000000000000000000021261274707324300174500ustar00rootroot00000000000000// ========================================================== // // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Time-stamp: <04 Sep 02 18:10:22 Jean-Guillaume.Dumas@imag.fr> // ========================================================== // /*! @file examples/Integer/order.C * @ingroup examples * @ingroup integers * @example examples/Integer/order.C * @brief NO DOC */ #include using namespace std; #include #include #include using namespace Givaro; int main(int argc, char ** argv) { IntNumTheoDom<> IP; IntNumTheoDom<>::Element a,q,o; if (argc > 1) a = Integer(argv[1]); else cin >> a; if (argc > 2) q = Integer(argv[2]); else cin >> q; Timer tim; tim.clear(); tim.start(); // Ordre de a dans GF(q) IP.order(o, a, q); tim.stop(); cout << o << endl; cerr << tim << endl; return 0; } givaro-4.0.2/examples/Integer/phi.C000066400000000000000000000015511274707324300171160ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/phi.C * @ingroup examples * @ingroup integers * @example examples/Integer/phi.C * @brief NO DOC */ #include #include #include // Euler's phi function (totient) // using namespace Givaro; int main(int argc, char** argv) { IntNumTheoDom<> IP; IntNumTheoDom<>::Element a,pr; if (argc > 1) a = IntNumTheoDom<>::Element(argv[1]); else std::cin >> a; Timer tim; tim.clear(); tim.start(); IP.phi(pr, a); tim.stop(); IntegerDom().write( std::cout, pr ) << std::endl; std::cerr << tim << std::endl; return 0; } givaro-4.0.2/examples/Integer/prevprime.C000066400000000000000000000017041274707324300203470ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/prevprime.C * @ingroup examples * @ingroup integers * @example examples/Integer/prevprime.C * @brief NO DOC */ #include using namespace std; #include #include #include #include // Givaro initialization using namespace Givaro; int main(int argc, char** argv) { // Givaro::Init(&argc, &argv); IntPrimeDom IP; IntPrimeDom::Element m, ff; if (argc > 1) m = Integer(argv[1]); else std::cin >> m; Timer tim; tim.clear(); tim.start(); IP.prevprimein(m); tim.stop(); cout << m << endl; cerr << tim << endl; // Givaro::End(); return 0; } givaro-4.0.2/examples/Integer/primitiveelement.C000066400000000000000000000015451274707324300217230ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/primitiveelement.C * @ingroup examples * @ingroup integers * @example examples/Integer/primitiveelement.C * @brief NO DOC */ #include #include #include using namespace Givaro; int main(int argc, char** argv) { IntNumTheoDom<> IP; IntNumTheoDom<>::Element a,pr; if (argc > 1) a = IntNumTheoDom<>::Element(argv[1]); else std::cin >> a; Timer tim; tim.clear(); tim.start(); IP.prim_elem(pr, a); tim.stop(); IntegerDom().write( std::cout, pr ) << std::endl; std::cerr << tim << std::endl; return 0; } givaro-4.0.2/examples/Integer/primitiveroot.C000066400000000000000000000031711274707324300212520ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/primitiveroot.C * @ingroup examples * @ingroup integers * @example examples/Integer/primitiveroot.C * @brief NO DOC */ #include #define GIVARO_LENSTRA #include #include #ifndef TIMING #define TIMING 1 #endif using namespace Givaro; int main(int argc, char** argv) { IntNumTheoDom<> IP; #ifndef __GIVARO_GMP_NO_CXX IP.seeding(); #endif IntNumTheoDom<>::Element a,pr; if (argc > 1) a = IntNumTheoDom<>::Element(argv[1]); else std::cin >> a; uint64_t runs; Timer tim; tim.clear(); if (IP.isprime(a)) { Integer phin; IP.sub(phin,a,IP.one); std::vector Lf; IP.write(std::cout << "Totient : ", Lf,phin) << std::endl; tim.start(); for(uint64_t i = 0; i < TIMING; ++i) IP.prim_root_of_prime(pr, a); tim.stop(); IP.write( std::cout << "Deterministic : ", pr ) << std::endl; std::cerr << tim << std::endl; } tim.start(); for(uint64_t i = 0; i < TIMING; ++i) IP.prim_root(pr, runs, a); tim.stop(); IP.write( std::cout << "Random : ", pr ) << std::endl; std::cerr << tim << " (" << runs << " runs)" << std::endl; tim.start(); for(uint64_t i = 0; i < TIMING; ++i) IP.lowest_prim_root(pr, a); tim.stop(); IP.write( std::cout << "Lowest : ", pr ) << std::endl; std::cerr << tim << std::endl; return 0; } givaro-4.0.2/examples/Integer/probable_primroot.C000066400000000000000000000067001274707324300220600ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Integer/probable_primroot.C * @ingroup examples * @ingroup integers * @example examples/Integer/probable_primroot.C * @brief NO DOC */ #include #include #include #include using namespace Givaro; // Polynomial-time generation of primitive roots // L is number of loops of Pollard partial factorization of n-1 // 10,000,000 gives at least 1-2^{-40} probability of success // [Dubrois & Dumas, Industrial-strength primitive roots] // Returns the probable primitive root and the probability of error. int main(int argc, char** argv) { IntNumTheoDom<> IP; #ifdef __GMP_PLUSPLUS__ IP.seeding( (unsigned long)BaseTimer::seed() ); #endif double error; IntNumTheoDom<>::Element a,pr,g; if (argc > 1) a = IntNumTheoDom<>::Element(argv[1]); else std::cin >> a; bool comp ; if ( (comp=(! IP.isprime(a))) ) std::cerr << a << " is not prime, primitive root will have no sense and may loop forever ..." << std::endl; double epsilon = argc > 2 ? atof(argv[2]) : 0.0000001; Timer tim; tim.clear(); tim.start(); //====================================================================== // Default is partial factorization up to factors of at least 12 digits. // with probability of error much less than 2^{-40} // IP.probable_prim_root(pr, error, a ); //====================================================================== // Choosing L to be O(log^2(p)) // gives the best probability with O(log^4(p)) complexity // Probability of error is approximately O(1/log^4(p)) // IP.probable_prim_root(pr, error, a, (unsigned long)power(logtwo(a),2)); //====================================================================== // Choosing L to be O( \sqrt(epsilon) ) // gives probability of error at most epsilon // Newton-Raphson iteration is used for // 1-epsilon = (1+2/(p-1))*(1-1/B)^(ln( (p-1)/2 )/ln(B)) // So that no factor less than B can be avoided // With Pollard's rho factorization, L is chosen to be sqrt(B) // Might not be polynomial if epsilon is too big #define GIVARO_POLLARD IP.probable_prim_root(pr, error, a, epsilon ); tim.stop(); if (comp) std::cerr << IP.gcd(g,a,pr) << " is a factor of " << a << std::endl; IntegerDom().write( std::cout << "Prim root : ", pr ); if (error > 0) { std::cout << ", correct with probability at least : 1-" << error << std::endl; std::cerr << tim << std::endl; std::cerr << "Now checking primitivity, this may take some time (complete factorization of n-1) ..."; #define GIVARO_LENSTRA Timer verif; verif.clear(); verif.start(); if ( IP.isorder(a-1, pr, a) ) { verif.stop(); std::cerr << "... Pimitivity checked" << std::endl; std::cerr << verif << std::endl; } else { verif.stop(); std::cerr << "... WARNING : FAILURE" << std::endl; std::cerr << verif << std::endl; } } else { std::cout << ", deterministically correct" << std::endl; std::cerr << tim << std::endl; } return 0; } givaro-4.0.2/examples/Makefile.am000066400000000000000000000006551274707324300166750ustar00rootroot00000000000000# Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. # all all-local: $(none) SUBDIRS=Rational Integer FiniteField Polynomial RecInt .PHONY:$(SUBDIRS) examples: $(SUBDIRS) $(SUBDIRS): $(MAKE) -C $@ examples CLEANFILES: $(SUBDIRS) givaro-4.0.2/examples/Polynomial/000077500000000000000000000000001274707324300167565ustar00rootroot00000000000000givaro-4.0.2/examples/Polynomial/Makefile.am000077500000000000000000000042031274707324300210140ustar00rootroot00000000000000# Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. examples: $(EXTRA_PROGRAMS) AM_CPPFLAGS=-I$(top_srcdir) #OPTFLAGS = -O7 -funroll-all-loops -felide-constructors -fstrict-aliasing #OPTFLAGS+= -frerun-loop-opt -fexpensive-optimizations #OPTFLAGS+= -fomit-frame-pointer #OPTFLAGS+= -fprefetch-loop-arrays -floop-optimize #OPTFLAGS+= -malign-double #OPTFLAGS+= -falign-loops -falign-jumps -falign-functions -falign-labels #OPTFLAGS+= -fschedule-insns2 #OPTFLAGS+= -fforce-addr -fforce-mem -fstrength-reduce #OPTFLAGS+= -ffast-math # for icc ... #OPTFLAGS = -fast -Ob2 -ipo_obj -unroll #OPTFLAGS+= -parallel -par_report1 # icc for itanium2 #OPTFLAGS+= -tpp2 -mcpu=itanium2 AM_CXXFLAGS = @DEFAULT_CFLAGS@ AM_CPPFLAGS += $(OPTFLAGS) $(GMP_CFLAGS) -I$(top_srcdir)/src/kernel/system -I$(top_srcdir)/src/kernel/memory -I$(top_srcdir)/src/kernel/integer -I$(top_srcdir)/src/kernel -I$(top_srcdir)/src/library/poly1 -I$(top_srcdir)/src/kernel/field -I$(top_srcdir)/src/kernel/ring -I$(top_srcdir)/src/kernel/bstruct -I$(top_srcdir)/src/kernel/rational -I$(top_srcdir)/src/library/tools LDADD = -L${top_srcdir}/src -L${top_srcdir}/src/.libs -lgivaro $(GMP_LIBS) $(LDFLAGS) AM_LDFLAGS=-static EXTRA_PROGRAMS=isirred isprimitive trunc_arith pol_arith pol_eval pol_factor interpolate PolynomialCRT highorder bivariate isgenerator CLEANFILES=$(EXTRA_PROGRAMS) interpolate_SOURCES = interpolate.C isirred_SOURCES = isirred.C isgenerator_SOURCES = isgenerator.C isprimitive_SOURCES = isprimitive.C pol_arith_SOURCES = pol_arith.C trunc_arith_SOURCES = trunc_arith.C pol_eval_SOURCES = pol_eval.C pol_factor_SOURCES = pol_factor.C PolynomialCRT_SOURCES = PolynomialCRT.C highorder_SOURCES = highorder.C bivariate_SOURCES = bivariate.C # for compilation of new examples GIVARO_BIN=@bindir@ %:%.C $(CXX) $(OPTFLAGS) $(AM_CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $*.C -o $* `$(GIVARO_BIN)/givaro-config --cflags` $(LDADD) `$(GIVARO_BIN)/givaro-config --libs` givaro-4.0.2/examples/Polynomial/PolynomialCRT.C000066400000000000000000000174241274707324300215660ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Polynomial/PolynomialCRT.C * @ingroup examples * @ingroup polynomials * @example examples/Polynomial/PolynomialCRT.C * @brief NO DOC */ #include #include #include #include #include #include #include #include #include #include // Chinese Remainder of two elements #include // Chinese Remainder of an array of elements #include #include using namespace Givaro; typedef GFqDom Field1; typedef Modular Field2; typedef Modular Field3; typedef Modular Field4; typedef Modular Field5; typedef Modular Field6; typedef Montgomery Field7; typedef QField Field8; typedef Modular Field9; typedef Extension<> Field10; template bool tmain(int argc, char ** argv, GivRandom& generator) { bool pass = true; typedef Poly1CRT< Field > CRTSystem; typedef typename CRTSystem::Element Poly; // typedef typename CRTSystem::Type_t Scal; // typedef typename CRTSystem::array_E VPoly; typedef typename CRTSystem::array_T VScal; IntPrimeDom ID; Integer a( generator() >>(argc>2?atoi(argv[2]):17) ); Field F(ID.nextprimein( a )); VScal Primes( argc>1 ? (size_t)atoi(argv[1]):15); VScal Moduli( Primes.size() ); typename VScal::iterator i = Primes.begin(); typename VScal::iterator e = Moduli.begin(); for(; i != Primes.end(); ++i, ++e) { do { F.init(*i, generator()); } while ( (std::find(Primes.begin(), i, *i) != i) || (F.isZero(*i))) ; F.init(*e, generator()); } // for(typename VScal::const_iterator it=Primes.begin(); it!=Primes.end();++it) // F.write(std::cout, *it) << std::endl; // for(typename VScal::const_iterator it=Moduli.begin(); it!=Moduli.end();++it) // F.write(std::cout, *it) << std::endl; CRTSystem CRT( F, Primes, "X" ); Poly res; Timer tim; tim.clear(); tim.start(); CRT.RnsToRing( res, Moduli ); tim.stop(); F.write( std::cerr << tim << " using ") << std::endl; if (Primes.size() < 14) { i = Primes.begin(); e = Moduli.begin(); for( ; i != Primes.end(); ++i, ++e) if (F.characteristic()>0) F.write(CRT.getpolydom().write(F.write(std::cout << "subs(X=", *i) << ",", res) << ") mod " << F.characteristic() << " = ", *e) << ';' << std::endl; else F.write(CRT.getpolydom().write(F.write(std::cout << "subs(X=", *i) << ",", res) << ") = ", *e) << ';' << std::endl; } VScal Verifs( Primes.size() ); CRT.RingToRns( Verifs, res ); typename VScal::const_iterator v = Verifs.begin(); e = Moduli.begin(); for( ; e != Moduli.end(); ++e, ++v) if (! F.areEqual(*e, *v) ) { F.write(std::cerr << "incoherency within ") << std::endl; F.write(std::cerr << "e: ", *e ) << std::endl; F.write(std::cerr << "v: ", *v ) << std::endl; pass = false; break; } CRT.getpolydom().random(generator, res, Degree((int64_t)Primes.size()-1)); CRT.RingToRns( Verifs, res ); Poly nres; tim.clear(); tim.start(); CRT.RnsToRing( nres, Verifs ); tim.stop(); if (! CRT.getpolydom().areEqual(res,nres) ) { CRT.getpolydom().write(std::cerr << "incoherency within ") << std::endl; CRT.getpolydom().write(std::cerr << "r: ", res ) << std::endl; CRT.getpolydom().write(std::cerr << "n: ", nres ) << std::endl; pass = false; } F.write( std::cerr << tim << " using ") << std::endl; return pass; } template bool tmainext(int argc, char ** argv, GivRandom& generator) { bool pass = true; typedef Poly1CRT< Field > CRTSystem; typedef typename CRTSystem::Element Poly; // typedef typename CRTSystem::Type_t Scal; // typedef typename CRTSystem::array_E VPoly; typedef typename CRTSystem::array_T VScal; IntPrimeDom ID; Integer a( generator() >>(argc>2?atoi(argv[2]):17) ); Field F(ID.nextprimein( a ),2); VScal Primes( argc>1 ? (size_t)atoi(argv[1]):15); VScal Moduli( Primes.size() ); typename VScal::iterator i = Primes.begin(); typename VScal::iterator e = Moduli.begin(); for(; i != Primes.end(); ++i, ++e) { F.init(*i); F.init(*e); do { F.random(generator,*i); } while ( (std::find(Primes.begin(), i, *i) != i) || (F.isZero(*i))) ; F.random(generator,*e); } for(typename VScal::const_iterator it=Primes.begin(); it!=Primes.end();++it) F.write(std::cout, *it) << std::endl; for(typename VScal::const_iterator it=Moduli.begin(); it!=Moduli.end();++it) F.write(std::cout, *it) << std::endl; CRTSystem CRT( F, Primes, "X" ); Poly res; Timer tim; tim.clear(); tim.start(); CRT.RnsToRing( res, Moduli ); tim.stop(); F.write( std::cerr << tim << " using ") << std::endl; if (Primes.size() < 14) { i = Primes.begin(); e = Moduli.begin(); for( ; i != Primes.end(); ++i, ++e) if (F.characteristic()>0) F.write(CRT.getpolydom().write(F.write(std::cout << "subs(X=", *i) << ",", res) << ") mod " << F.characteristic() << " = ", *e) << ';' << std::endl; else F.write(CRT.getpolydom().write(F.write(std::cout << "subs(X=", *i) << ",", res) << ") = ", *e) << ';' << std::endl; } VScal Verifs( Primes.size() ); CRT.RingToRns( Verifs, res ); typename VScal::const_iterator v = Verifs.begin(); e = Moduli.begin(); for( ; e != Moduli.end(); ++e, ++v) if (! F.areEqual(*e, *v) ) { F.write(std::cerr << "incoherency within ") << std::endl; F.write(std::cerr << "e: ", *e ) << std::endl; F.write(std::cerr << "v: ", *v ) << std::endl; pass = false; break; } CRT.getpolydom().random(generator, res, Degree((int64_t)Primes.size()-1)); CRT.RingToRns( Verifs, res ); Poly nres; tim.clear(); tim.start(); CRT.RnsToRing( nres, Verifs ); tim.stop(); if (! CRT.getpolydom().areEqual(res,nres) ) { CRT.getpolydom().write(std::cerr << "incoherency within ") << std::endl; CRT.getpolydom().write(std::cerr << "r: ", res ) << std::endl; CRT.getpolydom().write(std::cerr << "n: ", nres ) << std::endl; pass = false; } F.write( std::cerr << tim << " using ") << std::endl; return pass; } int main(int argc, char ** argv) { // argv[1] : number of primes // argv[2] : 2^{32-j} is size of primes // argv[3] : seed for generator GivRandom seedor( argc>3 ? (uint64_t)atoi(argv[3]): (uint64_t)BaseTimer::seed() ); uint64_t seed = seedor.seed(); std::cerr << "seed: " << seed << std::endl; Integer::seeding(seed); return tmain(argc, argv, *( new GivRandom(seed))) && tmain(argc, argv, *( new GivRandom(seed))) && tmain(argc, argv, *( new GivRandom(seed))) && tmain(argc, argv, *( new GivRandom(seed))) && tmain(argc, argv, *( new GivRandom(seed))) && tmain(argc, argv, *( new GivRandom(seed))) && tmain(argc, argv, *( new GivRandom(seed))) && tmain(argc, argv, *( new GivRandom(seed))) && tmain(argc, argv, *( new GivRandom(seed))) && tmainext(argc, argv, *( new GivRandom(seed))) ; } givaro-4.0.2/examples/Polynomial/bivariate.C000066400000000000000000000042071274707324300210330ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Polynomial/pol_arith.C * @ingroup examples * @ingroup polynomials * @example examples/Polynomial/pol_arith.C * @brief NO DOC */ #include #include #include #include #include #include #include using namespace Givaro; int main(int argc, char ** argv) { Modular Zp( "1234567891234567919" ); // integers modulo 1234567891234567919 typedef Modular Field; typedef Poly1Dom< Field, Dense> Polynomials; typedef Poly1Dom< Polynomials, Dense> Bivariates; // Polynomials over Z13, with X as indeterminate Polynomials PZp( Zp, Indeter("X") ); Bivariates PPZp( PZp, Indeter("Y") ); Field::Element tmp; Polynomials::Element P, R, S; PZp.init(P, Degree(1), 5 ); // 5X, PZp.init will call Zp.init on 5 PZp.addin(P, Zp.init(tmp,7) ); // 5X+7 std::istringstream stream(std::string("3 1 2 3 4")); PZp.read( stream, S ); PZp.write(std::cout << "S: ", S ) << std::endl; PZp.assign(R, Degree(3), Zp.init(tmp,11) ); // 11X^3, PZp.assign will call Zp.assign on tmp PZp.addin(R, Zp.init(tmp,13) ); // 11X^3+13 Bivariates::Element Q; PPZp.init(Q, Degree(2)); PZp.assign(Q[0], R); PZp.assign(Q[2], P);// (5X+7)Y^2 + 11X^3+13 PPZp.write(std::cout << "Q: ", Q) << std::endl; typedef QuotientDom BivMods; BivMods QD(PPZp, Q); QD.write(std::cout << "Quotient: ") << std::endl; BivMods::Element Res, G; QD.init(Res); QD.init(G); PZp.assign(P, Degree(1), 1 ); // X PPZp.init(G, Degree(1), 1); // Y PPZp.addin(G, P); // Y+X QD.write(std::cout << "Y+X: ", G) << std::endl; long l = 5; dom_power(Res, G, l, QD); // G^l mod Q QD.write(std::cout << "(Y+X)^" << l << ": ", Res) << std::endl; return 0; } givaro-4.0.2/examples/Polynomial/highorder.C000066400000000000000000000170711274707324300210430ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Polynomial/highorder.C * @ingroup examples * @ingroup polynomials * @example examples/Polynomial/highorder.C * @brief NO DOC */ #include #define GIVARO_DEBUG 1 #include #include #include #include #include #include using namespace Givaro; typedef GFqDom Field; typedef Poly1Dom< Field, Dense> Polys; typedef HighOrder< Field > HighOrders; long long TFDcount = 0; long long FiDcount = 0; Timer Ttaylor, Thighorder, Tfiduccia; bool TestFracDevel(const HighOrders& HO101, const Polys::Element P, const Polys::Element oQ, Degree a, Degree b) { bool success = false, successF=false; try { ++TFDcount; // std::cerr << "------------------------------------------------------------" << TFDcount <1?atoi(argv[1]):200); std::cerr << "numb: " << numb << std::endl; long tttn = (argc>2?atoi(argv[2]):100); std::cerr << "tttn: " << tttn << std::endl; long seed = (argc>3?atoi(argv[3]):BaseTimer::seed()); std::cerr << "seed: " << seed << std::endl; Field Z101( 101, 1 ); // integers modulo 101 // Polynomials over Z101, with X as indeterminate Polys DP101( Z101, Indeter("X") ); Polys::Element P, Q, R, monomial; GivRandom generator((unsigned long)seed); long deg1 = (long) generator() % 6; long deg2 = (long) generator() % 6; long deg3 = (long) generator() % 155; // long v1 = generator() % 195; // long v2 = v1 + (generator() % 5); DP101.random(generator, P, Degree(deg1) ); DP101.random(generator, Q, Degree(deg2) ); DP101.random(generator, R, Degree(deg3) ); Degree dP; DP101.degree(dP,P); Degree dQ; DP101.degree(dQ,Q); Degree dR; DP101.degree(dR,R); DP101.write(std::cout << "P:=", P) << ';' << std::endl; HighOrders HO101( Z101, Indeter("X") ); HighOrders::Element F; F._num = DP101.one; F._den = P; Polys::Element Tay; HO101.taylor(Tay, F, 128); DP101.write(std::cout << "Tay:=", Tay) << ';' << std::endl; Polys::Element S; Degree dS; size_t e = 0 ; // initialisé à quoi ? dans GammaId, k0 est const... HighOrders::Truncated G0; HO101.GammaId(G0, S, dS, (long)e, P, dP); std::cout << "e:=" << e << ';' << std::endl; HO101.write(std::cout << "G0:=", G0) << ';' << std::endl; DP101.write(std::cout << "S:=", S) << ';' << std::endl; std::vector Gam, T; std::vector D; Polys::Element nTay; Degree dT; HO101.highorder(Gam, T, D, nTay, dT, Degree(970), Degree(1000), P, dP); HO101.write(std::cout << "Gam:=", Gam.back()) << ';' << std::endl; HighOrders::Truncated TP; HO101.gettruncdom().assign(TP, P); HighOrders::Truncated I; HO101.Inverse(I, 113, 127, TP, dP, nTay, dT, Gam, T, D); HO101.write(std::cout << "I]_155^175:=", I) << ';' << std::endl; Ttaylor.clear(); Thighorder.clear(); bool success=true; success &= TestFracDevel(HO101, P, Q, tttn-(17*tttn)/100,tttn); success &= TestFracDevel(HO101, P, Q, tttn-(27*tttn)/100,tttn); success &= TestFracDevel(HO101, P, Q, tttn-(87*tttn)/100,tttn); success &= TestFracDevel(HO101, P, Q, 0,tttn); success &= TestFracDevel(HO101, P, Q, 1,tttn); success &= TestFracDevel(HO101, P, Q, 2,tttn); success &= TestFracDevel(HO101, P, Q, tttn,tttn); success &= TestFracDevel(HO101, P, Q, tttn-1,tttn); success &= TestFracDevel(HO101, P, Q, tttn-2,tttn); for(long i=0; i #include #include #include #include #include #include using namespace std; using namespace Givaro; int main(int argc, char** argv) { typedef Modular::Residu_t UT ; UT MOD; if (argc > 2) MOD = (UT) atoi(argv[2]); else std::cin >> MOD; Modular F(MOD); Interpolation< Modular > FD(F,Indeter("X")); Interpolation< Modular >::Element nouv, prec; int EarlyTerm = 0, Bound = 5; Modular::Element x, f; std::ifstream input (argv[1]); F.read(input, x); F.read(input, f); FD(x,f); prec = FD.interpolator(); Timer tim; tim.clear(); tim.start(); while(! F.read(input, x).eof() ) { F.read(input, f); FD(x,f); nouv = FD.interpolator(); if (FD.areEqual(nouv, prec)) { if (++EarlyTerm > Bound) { std::cerr << "EarlyTerminated" << std::endl ; break; } } else EarlyTerm = 0; prec = nouv; } tim.stop(); FD.write( std::cout, FD.interpolator() ) << std::endl; std::cerr << tim << std::endl; return 0; } givaro-4.0.2/examples/Polynomial/isgenerator.C000077500000000000000000000025611274707324300214130ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Polynomial/isprimitive.C * @ingroup examples * @ingroup polynomials * @example examples/Polynomial/isprimitive.C * @brief NO DOC */ #include #include #include #include #include // using namespace std; using namespace Givaro; int main(int argc, char** argv) { typedef GFqDom::Residu_t UT; UT MOD; if (argc > 1) MOD = (UT)atoi(argv[1]); else std::cin >> MOD; uint64_t expo = 1; if (argc > 2) expo = (uint64_t)atoi(argv[2]); GFqDom F(MOD, expo); Poly1FactorDom, Dense> FD(F,Indeter("X")); Poly1FactorDom, Dense>::Element P, G; FD.read( std::cin, P ); FD.read( std::cin, G ); Timer tim; tim.clear(); tim.start(); bool f = FD.is_prim_root(G, P ); tim.stop(); FD.write(F.write( FD.write( std::cout, G ) << " is " << (f?"":"not ") << " a generator in " ) << " defined with ", P) << std::endl; // std::cout << f << std::endl; std::cerr << tim << std::endl; return 0; } givaro-4.0.2/examples/Polynomial/isirred.C000066400000000000000000000023471274707324300205310ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Polynomial/isirred.C * @ingroup examples * @ingroup polynomials * @example examples/Polynomial/isirred.C * @brief NO DOC */ #include #include #include #include #include using namespace std; using namespace Givaro; int main(int argc, char** argv) { typedef GFqDom::Residu_t UT ; UT MOD; if (argc > 1) MOD =(UT) (atoi(argv[1])); else std::cin >> MOD; uint64_t expo = 1; if (argc > 2) expo = (uint64_t)atoi(argv[2]); GFqDom F(MOD, expo); Poly1FactorDom, Dense> FD(F,Indeter("X")); Poly1FactorDom, Dense>::Element P; FD.read( cin, P ); Timer tim; tim.clear(); tim.start(); bool f = FD.is_irreducible( P ); tim.stop(); F.write( FD.write( cout, P ) << " is " << (f?"":"not ") << "irreducible in " ) << endl; // std::cout << f << std::endl; std::cerr << tim << std::endl; return 0; } givaro-4.0.2/examples/Polynomial/isprimitive.C000066400000000000000000000024411274707324300214270ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Polynomial/isprimitive.C * @ingroup examples * @ingroup polynomials * @example examples/Polynomial/isprimitive.C * @brief NO DOC */ #include #include #include #include #include // using namespace std; using namespace Givaro; int main(int argc, char** argv) { typedef GFqDom::Residu_t UT; UT MOD; if (argc > 1) MOD = (UT)atoi(argv[1]); else std::cin >> MOD; uint64_t expo = 1; if (argc > 2) expo = (uint64_t)atoi(argv[2]); GFqDom F(MOD, expo); Poly1FactorDom, Dense> FD(F,Indeter("X")); Poly1FactorDom, Dense>::Element P, IXE; FD.init(IXE,Degree(1),F.one); FD.read( std::cin, P ); Timer tim; tim.clear(); tim.start(); bool f = FD.is_prim_root(IXE, P ); tim.stop(); F.write( FD.write( std::cout, P ) << " is " << (f?"":"not ") << "primitive in " ) << std::endl; // std::cout << f << std::endl; std::cerr << tim << std::endl; return 0; } givaro-4.0.2/examples/Polynomial/pol_arith.C000066400000000000000000000054271274707324300210530ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Polynomial/pol_arith.C * @ingroup examples * @ingroup polynomials * @example examples/Polynomial/pol_arith.C * @brief NO DOC */ #include #include #include using namespace Givaro; int main(int argc, char ** argv) { { GFqDom Z13( 13, 1 ); // integers modulo 13 // Polynomials over Z13, with X as indeterminate Poly1Dom< GFqDom, Dense > DP13( Z13, Indeter("X") ); Poly1Dom< GFqDom, Dense>::Element P, Q, R, monomial; GFqDom::Element tmp; DP13.assign( P, Z13.init(tmp,5) ); // P is degree 0 polynomial : 5 modulo 13 DP13.write( std::cout << "P: " , P )<< std::endl; DP13.init( monomial, Degree(1), 33U) ; // -33 X DP13.write( std::cout << "m: " , monomial )<< std::endl; DP13.addin( P, monomial ); // P += monomial DP13.write( std::cout << "P: " , P )<< std::endl; DP13.init( monomial, Degree(2), 12U) ; // 12 X^2 DP13.write( std::cout << "m: " , monomial )<< std::endl; DP13.addin( P, monomial ); // P is now 5-33*X+12*X^2 DP13.write( std::cout << "P: " , P )<< std::endl; // DP13.read( std::cin, P); // would read P as a succession of integers : // deg leadcoeff (lead-1)coeff ... unitcoeff DP13.init( Q, Degree(0), 6U ); DP13.write( std::cout << "Q: " , Q )<< std::endl; DP13.init( monomial, Degree(4), 3U); DP13.write( std::cout << "m: " , monomial )<< std::endl; DP13.addin( Q, monomial) ; DP13.write( std::cout << "Q: " , Q )<< std::endl; DP13.init( monomial, Degree(1), 75U); DP13.write( std::cout << "m: " , monomial )<< std::endl; DP13.addin( Q, monomial) ; DP13.write( std::cout << "Q: " , Q )<< std::endl; DP13.init( monomial, Degree(3), 45U); DP13.write( std::cout << "m: " , monomial )<< std::endl; DP13.subin( Q, monomial) ; DP13.write( std::cout << "Q: " , Q )<< std::endl; // Q is now 3*X^4+75*X-45*X^3+6 DP13.mul ( R, P, Q); // R = P*Q; DP13.write( DP13.write( std::cout << "(" , P ) << ") * (", Q) << ")"; DP13.write(std::cout << " = " , R) << std::endl; DP13.gcd ( R, P, Q); // DP13.write( DP13.write( DP13.write( std::cout << "gcd(", P ) << ",", Q) << ") = ", R) << std::endl; DP13.lcm ( R, P, Q); // DP13.write( DP13.write( DP13.write( std::cout << "lcm(", P ) << ",", Q) << ") = ", R) << std::endl; DP13.lcm ( R, Q, P); // DP13.write( DP13.write( DP13.write( std::cout << "lcm(", Q ) << ",", P) << ") = ", R) << std::endl; } return 0; } givaro-4.0.2/examples/Polynomial/pol_eval.C000066400000000000000000000023601274707324300206640ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Polynomial/pol_eval.C * @ingroup examples * @ingroup polynomials * @example examples/Polynomial/pol_eval.C * @brief NO DOC */ #include #include #include #include #include using namespace Givaro; using namespace std; int main(int argc, char** argv) { GFqDom::Residu_t MOD; if (argc > 1) MOD = (GFqDom::Residu_t) atoi(argv[1]); else std::cin >> MOD; uint64_t expo = 1; if (argc > 2) expo = (uint64_t)atoi(argv[2]); GFqDom F(MOD, expo); Poly1FactorDom, Dense> FD(F,Indeter("X")); Poly1FactorDom, Dense>::Element P; FD.read( cin, P ); GFqDom::Element res, val; F.read( cin, val ); Timer tim; tim.clear(); tim.start(); FD.eval(res, P, val ); tim.stop(); F.write( F.write( FD.write( cout, P ) << " is ", res ) << " at ", val) << endl; std::cerr << tim << std::endl; return 0; } givaro-4.0.2/examples/Polynomial/pol_factor.C000066400000000000000000000027211274707324300212140ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Polynomial/pol_factor.C * @ingroup examples * @ingroup polynomials * @example examples/Polynomial/pol_factor.C * @brief NO DOC */ #include #include #include #include #include using namespace std; using namespace Givaro; int main(int argc, char** argv) { GFqDom::Residu_t MOD; if (argc > 1) MOD = (GFqDom::Residu_t) atoi(argv[1]); else std::cin >> MOD; uint64_t expo = 1; if (argc > 2) expo = (uint64_t)atoi(argv[2]); GFqDom F(MOD, expo); Poly1FactorDom, Dense> FD(F,Indeter("X")); typedef Poly1FactorDom, Dense>::Element Polys ; Polys P; FD.read( cin, P ); std::vector Lf; std::vector Le; Timer tim; tim.clear(); tim.start(); FD.CZfactor(Lf, Le, P); tim.stop(); FD.write( cout, P ) << " is 1"; std::vector::const_iterator e = Le.begin(); for(std::vector::const_iterator i = Lf.begin(); i != Lf.end(); ++i, ++e) { FD.write(cout << " * (", *i) << ")"; if (*e > 1) cout << "^" << *e; } std::cout << std::endl; std::cerr << tim << std::endl; return 0; } givaro-4.0.2/examples/Polynomial/trunc_arith.C000066400000000000000000000315421274707324300214110ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Polynomial/trunc_arith.C * @ingroup examples * @ingroup polynomials * @example examples/Polynomial/trunc_arith.C * @brief NO DOC */ #include #include #include #include #include #include using namespace Givaro; long long TTcount = 0; bool TestAdd(const TruncDom< GFqDom >& DP, const TruncDom< GFqDom >::Element& P, const TruncDom< GFqDom >::Element& Q, size_t d1, size_t d2) { ++TTcount; TruncDom< GFqDom >::Element R, T, V; DP.add ( R, P, Q, (int64_t)d1, (int64_t)d2); // R = P*Q; // DP.write( DP.write( // std::cout << "[(" , P ) << ") + (", Q) << ")]_" << d1 << '^' << d2 ; // DP.write(std::cout << " = " , R) << std::endl; DP.add (T, P, Q); V=T; DP.truncin(V,(int64_t)d1,(int64_t)d2); if( DP.areNEqual( V, R) ) { std::cerr << "ERROR ADD:" << TTcount << std::endl; DP.write(std::cout << " R: " , R) << std::endl; DP.write(std::cout << " T: " , T) << std::endl; DP.write(std::cout << " V: " , V) << std::endl; Degree dP; DP.degree(dP,P); Degree dQ; DP.degree(dQ,Q); Degree vP; DP.val(vP,P); Degree vQ; DP.val(vQ,Q); std::cerr << "vR: " << vP << ", dR: " << dP << ", vP: " << vQ << ", dP: " << dQ << ", v: " << d1 << ", d: " << d2 << std::endl; return false; } return true; } bool TestSub(const TruncDom< GFqDom >& DP, const TruncDom< GFqDom >::Element& P, const TruncDom< GFqDom >::Element& Q, size_t d1, size_t d2) { ++TTcount; TruncDom< GFqDom >::Element R, T, V; DP.sub ( R, P, Q, (int64_t)d1, (int64_t)d2); // R = P*Q; // DP.write( DP.write( // std::cout << "[(" , P ) << ") + (", Q) << ")]_" << d1 << '^' << d2 ; // DP.write(std::cout << " = " , R) << std::endl; DP.sub (T, P, Q); V=T; DP.truncin(V,(int64_t)d1,(int64_t)d2); if( DP.areNEqual( V, R) ) { std::cerr << "ERROR SUB:" << TTcount << std::endl; DP.write(std::cout << " R: " , R) << std::endl; DP.write(std::cout << " T: " , T) << std::endl; DP.write(std::cout << " V: " , V) << std::endl; Degree dP; DP.degree(dP,P); Degree dQ; DP.degree(dQ,Q); Degree vP; DP.val(vP,P); Degree vQ; DP.val(vQ,Q); std::cerr << "vR: " << vP << ", dR: " << dP << ", vP: " << vQ << ", dP: " << dQ << ", v: " << d1 << ", d: " << d2 << std::endl; return false; } return true; } bool TestMul(const TruncDom< GFqDom >& DP, const TruncDom< GFqDom >::Element& P, const TruncDom< GFqDom >::Element& Q, size_t d1, size_t d2) { ++TTcount; TruncDom< GFqDom >::Element R, T, V; DP.mul ( R, P, Q, (int64_t)d1, (int64_t)d2); // R = P*Q; // DP.write( DP.write( // std::cout << "[(" , P ) << ") + (", Q) << ")]_" << d1 << '^' << d2 ; // DP.write(std::cout << " = " , R) << std::endl; DP.mul (T, P, Q); V=T; DP.truncin(V,(int64_t)d1,(int64_t)d2); if( DP.areNEqual( V, R) ) { std::cerr << "ERROR MUL:" << TTcount << std::endl; DP.write(std::cout << " R: " , R) << std::endl; DP.write(std::cout << " T: " , T) << std::endl; DP.write(std::cout << " V: " , V) << std::endl; Degree dP; DP.degree(dP,P); Degree dQ; DP.degree(dQ,Q); Degree vP; DP.val(vP,P); Degree vQ; DP.val(vQ,Q); std::cerr << "vR: " << vP << ", dR: " << dP << ", vP: " << vQ << ", dP: " << dQ << ", v: " << d1 << ", d: " << d2 << std::endl; return false; } return true; } bool TestAxpy(const TruncDom< GFqDom >& DP, const TruncDom< GFqDom >::Element& P, const TruncDom< GFqDom >::Element& Q, const TruncDom< GFqDom >::Element& G, size_t d1, size_t d2) { ++TTcount; TruncDom< GFqDom >::Element R, T, V; DP.axpy ( R, P, Q, G, (int64_t)d1, (int64_t)d2); // R = P*Q; // DP.write( DP.write( // std::cout << "[(" , P ) << ") + (", Q) << ")]_" << d1 << '^' << d2 ; // DP.write(std::cout << " = " , R) << std::endl; DP.axpy (T, P, Q, G); V=T; DP.truncin(V,(int64_t)d1,(int64_t)d2); if( DP.areNEqual( V, R) ) { std::cerr << "ERROR Axpy:" << std::endl; DP.write(std::cout << " P: " , P) << std::endl; DP.write(std::cout << " Q: " , Q) << std::endl; DP.write(std::cout << " G: " , G) << std::endl; DP.write(std::cout << " R: " , R) << std::endl; DP.write(std::cout << " T: " , T) << std::endl; DP.write(std::cout << " V: " , V) << std::endl; Degree dP; DP.degree(dP,P); Degree dQ; DP.degree(dQ,Q); Degree dG; DP.degree(dG,G); Degree vP; DP.val(vP,P); Degree vQ; DP.val(vQ,Q); Degree vG; DP.val(vG,G); std::cerr << "vP: " << vP << ", dP: " << dP << ", vQ: " << vQ << ", dQ: " << dQ << ", vG: " << vG << ", dG: " << dG << ", v: " << d1 << ", d: " << d2 << std::endl; return false; } return true; } bool TestAxmy(const TruncDom< GFqDom >& DP, const TruncDom< GFqDom >::Element& P, const TruncDom< GFqDom >::Element& Q, const TruncDom< GFqDom >::Element& G, size_t d1, size_t d2) { ++TTcount; TruncDom< GFqDom >::Element R, T, V; DP.axmy ( R, P, Q, G, (int64_t)d1, (int64_t)d2); // R = P*Q; // DP.write( DP.write( // std::cout << "[(" , P ) << ") + (", Q) << ")]_" << d1 << '^' << d2 ; // DP.write(std::cout << " = " , R) << std::endl; DP.axmy (T, P, Q, G); V=T; DP.truncin(V,(int64_t)d1,(int64_t)d2); if( DP.areNEqual( V, R) ) { std::cerr << "ERROR Axmy:" << std::endl; DP.write(std::cout << " R: " , R) << std::endl; DP.write(std::cout << " T: " , T) << std::endl; DP.write(std::cout << " V: " , V) << std::endl; Degree dP; DP.degree(dP,P); Degree dQ; DP.degree(dQ,Q); Degree vP; DP.val(vP,P); Degree vQ; DP.val(vQ,Q); std::cerr << "vR: " << vP << ", dR: " << dP << ", vP: " << vQ << ", dP: " << dQ << ", v: " << d1 << ", d: " << d2 << std::endl; return false; } return true; } bool TestMaxpy(const TruncDom< GFqDom >& DP, const TruncDom< GFqDom >::Element& P, const TruncDom< GFqDom >::Element& Q, const TruncDom< GFqDom >::Element& G, size_t d1, size_t d2) { ++TTcount; TruncDom< GFqDom >::Element R, T, V; DP.maxpy ( R, P, Q, G, (int64_t)d1, (int64_t)d2); // R = P*Q; // DP.write( DP.write( // std::cout << "[(" , P ) << ") + (", Q) << ")]_" << d1 << '^' << d2 ; // DP.write(std::cout << " = " , R) << std::endl; DP.maxpy (T, P, Q, G); V=T; DP.truncin(V,(int64_t)d1,(int64_t)d2); if( DP.areNEqual( V, R) ) { std::cerr << "ERROR Maxpy:" << std::endl; DP.write(std::cout << " R: " , R) << std::endl; DP.write(std::cout << " T: " , T) << std::endl; DP.write(std::cout << " V: " , V) << std::endl; Degree dP; DP.degree(dP,P); Degree dQ; DP.degree(dQ,Q); Degree vP; DP.val(vP,P); Degree vQ; DP.val(vQ,Q); std::cerr << "vR: " << vP << ", dR: " << dP << ", vP: " << vQ << ", dP: " << dQ << ", v: " << d1 << ", d: " << d2 << std::endl; return false; } return true; } int main(int argc, char ** argv) { { int64_t seed = (argc>1?atoi(argv[1]):BaseTimer::seed()); std::cerr << "seed: " << seed << std::endl; GFqDom Z101( 101, 1 ); // integers modulo 101 // Polynomials over Z101, with X as indeterminate TruncDom< GFqDom > DP101( Z101, Indeter("X") ); TruncDom< GFqDom >::Element P, Q, R, monomial; GFqDom::Element tmp; DP101.assign( P, Z101.init(tmp,5) ); // P is degree 0 polynomial : 5 modulo 101 DP101.write( std::cout << "P: " , P )<< std::endl; DP101.init( monomial, Degree(1), 33U) ; // -33 X DP101.write( std::cout << "m: " , monomial )<< std::endl; Degree deg,val; DP101.degree(deg,monomial); DP101.val(val,monomial); DP101.write( std::cout << "[m]_" << val << '^' << deg << ": " , monomial )<< std::endl; DP101.addin( P, monomial ); // P += monomial DP101.write( std::cout << "P: " , P )<< std::endl; DP101.init( monomial, Degree(2), 12U) ; // 12 X^2 DP101.write( std::cout << "m: " , monomial )<< std::endl; DP101.addin( P, monomial ); // P is now 5-33*X+12*X^2 DP101.write( std::cout << "P: " , P )<< std::endl; // // DP101.read( std::cin, P); // would read P as a succession of integers : // // deg leadcoeff (lead-1)coeff ... unitcoeff Q = P; DP101.write( std::cout << "P: " , P )<< std::endl; DP101.write( std::cout << "Q: " , Q )<< std::endl; DP101.init( Q, Degree(0), 6U ); DP101.write( std::cout << "Q: " , Q )<< std::endl; DP101.init( monomial, Degree(4), 3U); DP101.write( std::cout << "m: " , monomial )<< std::endl; DP101.addin( Q, monomial) ; DP101.write( std::cout << "Q: " , Q )<< std::endl; DP101.init( monomial, Degree(1), 75U); DP101.write( std::cout << "m: " , monomial )<< std::endl; DP101.addin( Q, monomial) ; DP101.write( std::cout << "Q: " , Q )<< std::endl; DP101.init( monomial, Degree(3), 45U); DP101.write( std::cout << "m: " , monomial )<< std::endl; DP101.subin( Q, monomial) ; DP101.write( std::cout << "Q: " , Q )<< std::endl; // Q is now 3*X^4+75*X-45*X^3+6 DP101.mulin( Q, Degree(15) ) ; DP101.write( std::cout << "Q: " , Q )<< std::endl; DP101.mulin( monomial, Degree(32)); DP101.write( std::cout << "m: " , monomial )<< std::endl; DP101.addin( Q, monomial) ; DP101.write( std::cout << "Q: " , Q )<< std::endl; DP101.subin( Q, monomial) ; DP101.write( std::cout << "Q: " , Q )<< std::endl; DP101.divin( Q, Degree(5) ) ; DP101.write( std::cout << "Q: " , Q )<< std::endl; DP101.divin( monomial, Degree(12)); DP101.write( std::cout << "m: " , monomial )<< std::endl; DP101.addin( Q, monomial) ; DP101.write( std::cout << "Q: " , Q )<< std::endl; DP101.subin( Q, monomial) ; DP101.write( std::cout << "Q: " , Q )<< std::endl; DP101.divin( monomial, Degree(10)); DP101.write( std::cout << "m: " , monomial )<< std::endl; DP101.addin( Q, monomial) ; DP101.write( std::cout << "Q: " , Q )<< std::endl; DP101.subin( Q, monomial) ; DP101.write( std::cout << "Q: " , Q )<< std::endl; DP101.divin( monomial, Degree(10)); DP101.write( std::cout << "m: " , monomial )<< std::endl; DP101.addin( Q, monomial) ; DP101.write( std::cout << "Q: " , Q )<< std::endl; DP101.subin( Q, monomial) ; DP101.write( std::cout << "Q: " , Q )<< std::endl; DP101.setval(Q); DP101.write( std::cout << "Q: " , Q )<< std::endl; DP101.mulin( P, Degree(15) ) ; DP101.mul ( R, P, Q); // R = P*Q; DP101.write( DP101.write( std::cout << "(" , P ) << ") * (", Q) << ")"; DP101.write(std::cout << " = " , R) << std::endl; DP101.mul ( R, P, Q, Degree(28), Degree(30)); // R = P*Q; DP101.write( DP101.write( std::cout << "[(" , P ) << ") * (", Q) << ")]_28^30"; DP101.write(std::cout << " = " , R) << std::endl; DP101.mul ( R, P, Q, Degree(0), Degree(30)); // R = P*Q; DP101.write( DP101.write( std::cout << "[(" , P ) << ") * (", Q) << ")]_0^30"; DP101.write(std::cout << " = " , R) << std::endl; DP101.mul ( R, P, Q, Degree(28), Degree(100)); // R = P*Q; DP101.write( DP101.write( std::cout << "[(" , P ) << ") * (", Q) << ")]_28^100"; DP101.write(std::cout << " = " , R) << std::endl; DP101.mul ( R, P, Q, Degree(4), Degree(10)); // R = P*Q; DP101.write( DP101.write( std::cout << "[(" , P ) << ") * (", Q) << ")]_4^10"; DP101.write(std::cout << " = " , R) << std::endl; DP101.mul ( R, P, Q, Degree(75), Degree(100)); // R = P*Q; DP101.write( DP101.write( std::cout << "[(" , P ) << ") * (", Q) << ")]_75^100"; DP101.write(std::cout << " = " , R) << std::endl; DP101.setval(R); DP101.write( std::cout << "R: " , R )<< std::endl; DP101.mulin( Q, Degree(3) ) ; DP101.add ( R, P, Q); // R = P*Q; DP101.write( DP101.write( std::cout << "(" , P ) << ") + (", Q) << ")"; DP101.write(std::cout << " = " , R) << std::endl; /* DP101.gcd ( R, P, Q); // DP101.write( DP101.write( DP101.write( std::cout << "gcd(", P ) << ",", Q) << ") = ", R) << std::endl; DP101.lcm ( R, P, Q); // DP101.write( DP101.write( DP101.write( std::cout << "lcm(", P ) << ",", Q) << ") = ", R) << std::endl; DP101.lcm ( R, Q, P); // DP101.write( DP101.write( DP101.write( std::cout << "lcm(", Q ) << ",", P) << ") = ", R) << std::endl; */ } return 0; } givaro-4.0.2/examples/Rational/000077500000000000000000000000001274707324300164045ustar00rootroot00000000000000givaro-4.0.2/examples/Rational/Makefile.am000077500000000000000000000033461274707324300204510ustar00rootroot00000000000000# Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. examples: $(EXTRA_PROGRAMS) AM_CPPFLAGS=-I$(top_srcdir) #OPTFLAGS = -O7 -funroll-all-loops -felide-constructors -fstrict-aliasing #OPTFLAGS+= -frerun-loop-opt -fexpensive-optimizations #OPTFLAGS+= -fomit-frame-pointer #OPTFLAGS+= -fprefetch-loop-arrays -floop-optimize #OPTFLAGS+= -malign-double #OPTFLAGS+= -falign-loops -falign-jumps -falign-functions -falign-labels #OPTFLAGS+= -fschedule-insns2 #OPTFLAGS+= -fforce-addr -fforce-mem -fstrength-reduce #OPTFLAGS+= -ffast-math # for icc ... #OPTFLAGS = -fast -Ob2 -ipo_obj -unroll #OPTFLAGS+= -parallel -par_report1 # icc for itanium2 #OPTFLAGS+= -tpp2 -mcpu=itanium2 AM_CXXFLAGS = @DEFAULT_CFLAGS@ AM_CPPFLAGS += $(OPTFLAGS) $(GMP_CFLAGS) AM_CPPFLAGS += -I$(top_srcdir)/src/kernel/system -I$(top_srcdir)/src/kernel/ring -I$(top_srcdir)/src/kernel/memory -I$(top_srcdir)/src/kernel/integer -I$(top_srcdir)/src/kernel -I$(top_srcdir)/src/kernel/bstruct -I$(top_srcdir)/src/kernel/rational -I$(top_srcdir)/src/library/tools -I$(top_srcdir)/src/library/poly1 LDADD = -L${top_srcdir}/src -L${top_srcdir}/src/.libs -lgivaro $(GMP_LIBS) $(LDFLAGS) AM_LDFLAGS=-static EXTRA_PROGRAMS=iratrecon polydouble CLEANFILES=$(EXTRA_PROGRAMS) iratrecon_SOURCES = iratrecon.C polydouble_SOURCES = polydouble.C # for compilation of new examples GIVARO_BIN=@bindir@ new_examp_comp = $(CXX) $(OPTFLAGS) $(AM_CPPFLAGS) $(AM_CXXFLAGS) $< -o $@ `$(GIVARO_BIN)/givaro-config --cflags` $(LDADD) `$(GIVARO_BIN)/givaro-config --libs` %:%.C $(new_examp_comp) %:%.cpp $(new_examp_comp)givaro-4.0.2/examples/Rational/iratrecon.C000066400000000000000000000021251274707324300204760ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Rational/iratrecon.C * @ingroup examples * @ingroup rationals * @example examples/Rational/iratrecon.C * @brief NO DOC */ #include #include #include #include #include // Givaro initialization using namespace Givaro; int main(int argc, char** argv) { Integer f,m,k; if (argc > 1) f = Integer(argv[1]); else std::cin >> f; if (argc > 2) m = Integer(argv[2]); else std::cin >> m; QField RD; Rational rec; Timer tim; tim.clear(); tim.start(); if (argc > 3) RD.ratrecon(rec,f,m, Integer(argv[3]) ); else RD.ratrecon(rec,f,m); tim.stop(); std::cout << rec.nume() << "/" << rec.deno() << " = " << f << " mod " << m << std::endl; std::cerr << tim << std::endl; return 0; } givaro-4.0.2/examples/Rational/polydouble.C000066400000000000000000000044221274707324300206700ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file examples/Rational/polydouble.C * @ingroup examples * @ingroup rationals * @example examples/Rational/polydouble.C * @brief NO DOC */ #include #include #include #include #include #include // Givaro initialization using namespace Givaro; typedef Poly1Dom< QField, Dense>::Element RatPoly; typedef std::vector DoublePoly; std::ostream& operator<< (std::ostream& o, const DoublePoly& v) { o << '['; for(size_t i=0; i Q; Poly1Dom< QField, Dense> PolQ(Q); DoublePoly D; RatPoly R; size_t n = (argc>1?(size_t)atoi(argv[1]):10); for(size_t i=0;i This software is a computer program whose purpose is to provide a fixed precision arithmetic library. This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL-B license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL-B license and that you accept its terms. */ #include #include #include int main(void) { RecInt::ruint64 a(1234567890); RecInt::ruint128 b("12345678901234567890123456789012345678901234567890123456789012345678901234567890"); RecInt::ruint256 c("12345678901234567890123456789012345678901234567890123456789012345678901234567890"); RecInt::ruint512 d("12345678901234567890123456789012345678901234567890123456789012345678901234567890"); RecInt::rint64 r(1234567890); RecInt::rint128 s("12345678901234567890123456789012345678901234567890123456789012345678901234567890"); RecInt::rint256 t("12345678901234567890123456789012345678901234567890123456789012345678901234567890"); RecInt::rint512 u("12345678901234567890123456789012345678901234567890123456789012345678901234567890"); std::cerr << " 64 bits; " << sizeof(a) << " octets: " << a << std::endl; std::cerr << "128 bits;" << sizeof(b) << " octets: " << b << std::endl; std::cerr << "256 bits;" << sizeof(c) << " octets: " << c << std::endl; std::cerr << "512 bits;" << sizeof(d) << " octets: " << d << std::endl; std::cerr << " 64 bits; " << sizeof(r) << " octets: " << r << std::endl; std::cerr << "128 bits;" << sizeof(s) << " octets: " << s << std::endl; std::cerr << "256 bits;" << sizeof(t) << " octets: " << t << std::endl; std::cerr << "512 bits;" << sizeof(u) << " octets: " << u << std::endl; return 0; } givaro-4.0.2/examples/RecInt/recint-iterator.C000066400000000000000000000044431274707324300212430ustar00rootroot00000000000000/* Copyright Université Grenoble Alpes Contributors : Jean-Guillaume DUMAS (Jean-Guillaume.Dumas@imag.fr) Time-stamp: <27 Jul 16 12:06:56 Jean-Guillaume.Dumas@imag.fr> This software is a computer program whose purpose is to provide a fixed precision arithmetic library. This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL-B license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL-B license and that you accept its terms. */ #include #include #include #if not defined(STD_RECINT_SIZE) #define STD_RECINT_SIZE 9 #endif using namespace RecInt; int main(void) { ruint n; ruint::cr_iterator itr; RecInt::srand(time(NULL)); rand(n); std::cout << "Our " << NBBITS::value << "-bit-wide number is: " << std::endl << std::hex << n << std::endl; const ruint n2(n); std::cout << std::endl << "Reverse:" << std::endl; for (itr = n2.rbegin(); itr != n2.rend(); itr++) std::cout << std::hex << *itr << std::endl; return 0; } givaro-4.0.2/examples/RecInt/rsa.C000066400000000000000000000024651274707324300167170ustar00rootroot00000000000000#include #include #include #include using namespace RecInt; int main(void) { ruint<7> p, q; ruint<8> d, e, n, g, phin; rmint<8> m, c, f; // p and q are two primes fill_with_1(p); p -= 796; fill_with_1(q); q -= 712; // n = p*q; lmul(n, p, q); m.init_module(n); std::cout << "p = " << p << std::endl; std::cout << "q = " << q << std::endl; std::cout << "Module n = p*q = " << n << std::endl; // phin = (p-1)*(q-1); lmul(phin, p-1, q-1); RecInt::srand(time(NULL)); // Looking for relatively prime e with phin so that inv(e) exists do { rand(e); gcd(g, e, phin); } while (g != 1); // d = inv(e) mod phin inv_mod(d, e, phin); std::cout << std::endl << "Encryption key e = " << e << std::endl; std::cout << "Decryption key d = " << d << std::endl; rand(m); std::cout << std::endl << "Message m = " << m << std::endl; exp(c, m, e); std::cout << "Encryption: c = m^e mod n --> " << c << std::endl; exp(f, c, d); std::cout << "Decryption: m = c^d mod n --> " << f << std::endl; if (m == f) std::cout << std::endl << "Decryption OK" << std::endl; else std::cout << std::endl << "Decryption failed" << std::endl; return 0; } givaro-4.0.2/givaro-config.in000066400000000000000000000030151274707324300160760ustar00rootroot00000000000000#! /bin/sh # Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. prefix=@prefix@ exec_prefix=@exec_prefix@ includedir=@includedir@ libdir=@libdir@ major=`echo @VERSION@ | cut -d'.' -f1` minor=`echo @VERSION@ | cut -d'.' -f2` micro=`echo @VERSION@ | cut -d'.' -f3` decvr=$((((($major*100)+$minor)*100)+$micro)) cflags=false libs=false usage() { cat < $macro.$minor.$pmicro) ? press '0' " echo "Increment minor revision number ($vern -> $macro.$pminor.0) ? press '1' " echo -n "Increment macro revision number ($vern -> $pmacro.0.0) ? press '2' " set increm = $< switch ($increm) case 0: set newv = "[$macro.$minor.$pmicro]" breaksw case 1: set newv = "[$macro.$pminor.0]" breaksw case 2: set newv = "[$pmacro.0.0]" breaksw default: set newv = "$verb" echo "'$increm' was read. Not incrementing anything." breaksw endsw # replacing [ ] and . with escaped version for sed would understand them as 'operators'. # This line is important when the used left spaces or removed []. echo "$line s/$verb/$newv/" | sed 's/\./\\\./g;s/\[/\\\[/g;s/\]/\\\]/g' > $sedfile sed -f $sedfile $conf > $tmpfile # clean up \rm -f $sedfile # diff for changes diff -u0 $conf $tmpfile # if something was changed, confirm incrementation : # if not confirm, we restore and abort. if ("$newv" != "$verb") then echo -n "Confirmation of incrementation ? (yes/no)" set answ = $< set backupconf = $conf.back$$ if ("$answ" == "yes") then \cp -p $conf $backupconf echo "Back-up of $conf made in $backupconf. Now overwriting $conf." \mv -f $tmpfile $conf else echo "'$answ' was read. Not incrementing anything." \rm -f $tmpfile exit 0 endif ##################################### ## INCREMENT THE GIVCONFIG VERSION ## ##################################### echo -n "Incrementing givconfig revision accordingly." set backupver = $ver.back$$ set tmpfile = `mktemp` set sedfile = `mktemp` switch ($increm) case 0: echo "s/GIVARO_REVISION_VERSION.*/GIVARO_REVISION_VERSION $pmicro/" > $sedfile set decimalversion = `expr \( $macro \* 100 + $minor \) \* 100 + $pmicro` breaksw case 1: echo "s/GIVARO_MINOR_VERSION.*/GIVARO_MINOR_VERSION $pminor/" > $sedfile echo "s/GIVARO_REVISION_VERSION.*/GIVARO_REVISION_VERSION 0/" >> $sedfile set decimalversion = `expr \( $macro \* 100 + $pminor \) \* 100` breaksw case 2: echo "s/GIVARO_MAJOR_VERSION.*/GIVARO_MAJOR_VERSION $pmacro/" > $sedfile echo "s/GIVARO_REVISION_VERSION.*/GIVARO_REVISION_VERSION 0/" >> $sedfile echo "s/GIVARO_MINOR_VERSION.*/GIVARO_MINOR_VERSION 0/" >> $sedfile set decimalversion = `expr $pmacro \* 10000` breaksw default: echo "Something abnormal happened" exit 1 breaksw endsw echo "s/GIVARO_VERSION.*/GIVARO_VERSION $decimalversion/" >> $sedfile sed -f $sedfile $ver > $tmpfile \rm -f $sedfile diff -u0 $ver $tmpfile echo -n "Confirmation of incrementation ? (yes/no) " set answ = $< if ("$answ" == "yes") then \cp -p $ver $backupver \mv -f $tmpfile $ver else echo "'$answ' was read. Not incrementing anything." echo " your old $conf is restored..." \rm -f $tmpfile \mv -f $backupconf $conf exit 0 endif ##################################### ## INCREMENT THE MAKEFILE VERSION ## ##################################### echo "Incrementing Makefile.am version." set tmpfile = `mktemp` #tempfile set sedfile = `mktemp` #tempfile switch ($increm) case 0: echo -n "s/VERSION.*/VERSION=$macro.$minor.$pmicro/" >> $sedfile breaksw case 1: echo "s/VERSION.*/VERSION=$macro.$pminor.0/" > $sedfile breaksw case 2: echo "s/VERSION.*/VERSION=$pmacro.0.0/" > $sedfile breaksw default: echo "Something abnormal happened" exit 1 breaksw endsw sed -f $sedfile $mkf > $tmpfile \rm -f $sedfile diff -u0 $mkf $tmpfile echo -n "Confirmation of incrementation ? (yes/no) " set backupmkf = $mkf.back$$ set answ = $< if ("$answ" == "yes") then \cp -p $mkf $backupmkf \mv -f $tmpfile $mkf else echo "'$answ' read. Not incrementing anything." echo " your old $conf and $ver are restored..." \rm -f $tmpfile \mv -f $backupconf $conf \mv -f $backupver $ver exit 0 endif ################################## ## INCREMENT THE SONAME VERSION ## ################################## echo "Incrementing soname version now." set backupmake = $mak.back$$ set infostring = `grep "libgivaro_la_LDFLAGS.*version-info" $mak | awk '{print $NF}'` set cur = `echo $infostring | cut -d':' -f1` set rev = `echo $infostring | cut -d':' -f2` set age = `echo $infostring | cut -d':' -f3` set pcur = `echo $cur` @ pcur ++ set prev = `echo $rev` @ prev ++ set page = `echo $age` @ page ++ set tmpfile = `mktemp` set sedfile = `mktemp` switch ($increm) case 0: echo "s/${infostring}/${cur}:${prev}:${age}/" > $sedfile breaksw case 1: echo "s/${infostring}/${pcur}:0:${page}/" > $sedfile breaksw case 2: echo "s/${infostring}/${pcur}:0:0/" > $sedfile breaksw default: echo "Something enourmously abnormal happened" exit 1 breaksw endsw sed -f $sedfile $mak > $tmpfile \rm -f $sedfile diff -u0 $mak $tmpfile echo -n "Confirmation of incrementation ? (yes/no) " set answ = $< if ("$answ" == "yes") then \cp -p $mak $backupmake \mv -f $tmpfile $mak echo -n "Removing back-up for $conf, $mkf, $mak and $ver ? (y/n)" set remo = $< if ("$remo" == "y") then \rm -f $backupconf \rm -f $backupver \rm -f $backupmake \rm -f $backupmkf else echo "You can find them in $backupconf, $backupmkf, $backupver and $backupmake." endif else echo "'$answ' was read. Not incrementing anything." echo " your old $conf and $ver are restored..." \rm -f $tmpfile \mv -f $backupconf $conf \mv -f $backupver $ver \mv -f $backupmkf $mkf exit 0 endif endif else echo "'$answ' was read. Not incrementing anything." exit 0 endif exit 0 # how to unset set variables ? givaro-4.0.2/macros/000077500000000000000000000000001274707324300143015ustar00rootroot00000000000000givaro-4.0.2/macros/CodeChunk/000077500000000000000000000000001274707324300161445ustar00rootroot00000000000000givaro-4.0.2/macros/CodeChunk/Makefile.am000066400000000000000000000010351274707324300201770ustar00rootroot00000000000000# Copyright (c) 2013 # written by Brice Boyer (briceboyer) # copied from fflas-ffpack by Clement Pernet # adapted from LinBox configuration # # ========LICENCE======== # Copyright(c)'1994-2016 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. # ========LICENCE======== #/ EXTRA_DIST= \ sse.C \ avx.C \ givaro-4.0.2/macros/CodeChunk/avx.C000066400000000000000000000002671274707324300170530ustar00rootroot00000000000000#include int main() { __m256d P ; double p = 0; P = _mm256_set1_pd(p); P = _mm256_add_pd(P,P); #ifdef __try_avx2 P = _mm256_fnmadd_pd(P,P,P); #endif return 0; } givaro-4.0.2/macros/CodeChunk/sse.C000066400000000000000000000002471274707324300170450ustar00rootroot00000000000000#include int main() { // SSE 2 __m128d P ; double p = 0; P = _mm_set1_pd(p); P = _mm_add_pd(P,P); // SSE 4.1 P = _mm_floor_pd(P); return 0; } givaro-4.0.2/macros/Makefile.am000066400000000000000000000006131274707324300163350ustar00rootroot00000000000000# Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. EXTRA_DIST= \ aclocal-include.m4 \ gmp-check.m4 \ config-header.m4 \ givaro-doc.m4 \ ax_cxx_compile_stdcxx_11.m4 \ debug.m4 givaro-4.0.2/macros/aclocal-include.m4000066400000000000000000000011501274707324300175570ustar00rootroot00000000000000# aclocal-include.m4 # Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. # # This macro adds the name macrodir to the set of directories # that `aclocal' searches for macros. # serial 1 dnl AM_ACLOCAL_INCLUDE(macrodir) AC_DEFUN([AM_ACLOCAL_INCLUDE], [ AM_CONDITIONAL(INSIDE_GNOME_COMMON, test x = y) test -n "$ACLOCAL_FLAGS" && ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS" for k in $1 ; do ACLOCAL="$ACLOCAL -I $k" ; done ]) givaro-4.0.2/macros/autogen.sh000077500000000000000000000145421274707324300163100ustar00rootroot00000000000000#!/bin/sh # Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. # # Run this to generate all the initial makefiles, etc. DIE=0 if [ -n "$GNOME2_PATH" ]; then ACLOCAL_FLAGS="-I $GNOME2_PATH/share/aclocal $ACLOCAL_FLAGS" PATH="$GNOME2_PATH/bin:$PATH" export PATH fi (autoconf --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`autoconf' installed to compile Gnome." echo "Download the appropriate package for your distribution," echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" DIE=1 } (grep "^AM_PROG_XML_I18N_TOOLS" $srcdir/configure.in >/dev/null) && { (xml-i18n-toolize --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`xml-i18n-toolize' installed to compile Gnome." echo "Get ftp://ftp.gnome.org/pub/GNOME/stable/sources/xml-i18n-tools/xml-i18n-tools-0.6.tar.gz" echo "(or a newer version if it is available)" DIE=1 } } (grep "^AM_PROG_LIBTOOL" $srcdir/configure.in >/dev/null) && { (libtool --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`libtool' installed to compile Gnome." echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.2d.tar.gz" echo "(or a newer version if it is available)" DIE=1 } } #grep "^AM_GNU_GETTEXT" $srcdir/configure.in >/dev/null && { # grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \ # (gettext --version) < /dev/null > /dev/null 2>&1 || { # echo # echo "**Error**: You must have \`gettext' installed to compile Gnome." # echo "Get ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz" # echo "(or a newer version if it is available)" # DIE=1 # } #} #grep "^AM_GNOME_GETTEXT" $srcdir/configure.in >/dev/null && { # grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \ # (gettext --version) < /dev/null > /dev/null 2>&1 || { # echo # echo "**Error**: You must have \`gettext' installed to compile Gnome." # echo "Get ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz" # echo "(or a newer version if it is available)" # DIE=1 # } #} (automake --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`automake' installed to compile Gnome." echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz" echo "(or a newer version if it is available)" DIE=1 NO_AUTOMAKE=yes } # if no automake, don't bother testing for aclocal test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: Missing \`aclocal'. The version of \`automake'" echo "installed doesn't appear recent enough." echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz" echo "(or a newer version if it is available)" DIE=1 } if test "$DIE" -eq 1; then exit 1 fi if test -z "$*"; then echo "**Warning**: I am going to run \`configure' with no arguments." echo "If you wish to pass any to it, please specify them on the" echo \`$0\'" command line." echo fi case $CC in xlc ) am_opt=--include-deps;; esac for coin in `find $srcdir -name configure.in -print` do dr=`dirname $coin` if test -f $dr/NO-AUTO-GEN; then echo skipping $dr -- flagged as no auto-gen else echo processing $dr macrodirs=`sed -n -e 's,AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < $coin` ( cd $dr macrosdir=`find . -name macros -print` for i in $macrodirs; do if test -f $i/gnome-gettext.m4; then DELETEFILES="$DELETEFILES $i/gnome-gettext.m4" fi done echo "deletefiles is $DELETEFILES" aclocalinclude="$ACLOCAL_FLAGS" for k in $aclocalinclude; do if test -d $k; then if [ -f $k/gnome.m4 -a "$GNOME_INTERFACE_VERSION" = "1" ]; then rm -f $DELETEFILES fi fi done for k in $macrodirs; do if test -d $k; then aclocalinclude="$aclocalinclude -I $k" if [ -f $k/gnome.m4 -a "$GNOME_INTERFACE_VERSION" = "1" ]; then rm -f $DELETEFILES fi fi done if grep "^AM_GNU_GETTEXT" configure.in >/dev/null; then if grep "sed.*POTFILES" configure.in >/dev/null; then : do nothing -- we still have an old unmodified configure.in else echo "Creating $dr/aclocal.m4 ..." test -r $dr/aclocal.m4 || touch $dr/aclocal.m4 echo "Running gettextize... Ignore non-fatal messages." echo "no" | gettextize --force --copy echo "Making $dr/aclocal.m4 writable ..." test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4 fi fi if grep "^AM_GNOME_GETTEXT" configure.in >/dev/null; then echo "Creating $dr/aclocal.m4 ..." test -r $dr/aclocal.m4 || touch $dr/aclocal.m4 echo "Running gettextize... Ignore non-fatal messages." echo "no" | gettextize --force --copy echo "Making $dr/aclocal.m4 writable ..." test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4 fi if grep "^AM_PROG_XML_I18N_TOOLS" configure.in >/dev/null; then echo "Running xml-i18n-toolize... Ignore non-fatal messages." xml-i18n-toolize --copy --force --automake fi if grep "^AM_PROG_LIBTOOL" configure.in >/dev/null; then if test -z "$NO_LIBTOOLIZE" ; then echo "Running libtoolize..." libtoolize --force --copy fi fi echo "Running aclocal $aclocalinclude ..." aclocal $aclocalinclude || { echo echo "**Error**: aclocal failed. This may mean that you have not" echo "installed all of the packages you need, or you may need to" echo "set ACLOCAL_FLAGS to include \"-I \$prefix/share/aclocal\"" echo "for the prefix where you installed the packages whose" echo "macros were not found" exit 1 } if grep "^AM_CONFIG_HEADER" configure.in >/dev/null; then echo "Running autoheader..." autoheader || { echo "**Error**: autoheader failed."; exit 1; } fi echo "Running automake --gnu $am_opt ..." automake --add-missing --gnu $am_opt || { echo "**Error**: automake failed."; exit 1; } echo "Running autoconf ..." autoconf || { echo "**Error**: autoconf failed."; exit 1; } ) || exit 1 fi done conf_flags="--enable-maintainer-mode --enable-compile-warnings" #--enable-iso-c if test x$NOCONFIGURE = x; then echo Running $srcdir/configure $conf_flags "$@" ... $srcdir/configure $conf_flags "$@" \ && echo Now type \`make\' to compile $PKG_NAME || exit 1 else echo Skipping configure process. fi givaro-4.0.2/macros/ax_check_x86_features.m4000066400000000000000000000066561274707324300207300ustar00rootroot00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_check_x86_features.html # =========================================================================== # # SYNOPSIS # # AX_CHECK_X86_FEATURES([ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) # # DESCRIPTION # # Checks if the host cpu supports various x86 instruction set, the # instructions that will get tested are "mmx, popcnt, sse, sse2, sse3, # sse4.1, sse4.2, sse4a, avx, avx2, avx512f, fma, fma4, bmi, bmi2". If the # instruction set is supported by the host cpu, the C preprocessor macro # HAVE_XXX_INSTRUCTIONS is set to 1. The XXX is up-cased instruction case # with dot replaced by underscore. For example, the test for "sse4.2" # would export HAVE_SSE4_2_INSTRUCTIONS=1. Also the compiler flag # "-msse4.2" would be added to X86_FEATURE_CFLAGS variable, that can be # obtained in Makefile.am using @X86_FEATURE_CFLAGS@. # # If any of the test for the instruction set were succeeded, the configure # script would run ACTION-IF-FOUND if it is specified, or append # X86_FEATURE_CFLAGS to CFLAGS. If none of the instruction were found, # ACTION-IF-NOT-FOUND hook is triggered. # # This macro requires gcc extended builtin function "__builtin_cpu_init" # and "__builtin_cpu_supports" to detect the cpu features. It will error # out if the compiler doesn't has these builtins. # # See also AX_GCC_X86_CPU_SUPPORTS, which is the actual macro that perform # the checks for the instruction sets. # # LICENSE # # Copyright (c) 2016 Felix Chern # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 1 AC_DEFUN([AX_CHECK_X86_FEATURES], [m4_foreach_w( [ax_x86_feature], [mmx popcnt sse sse2 sse3 sse4.1 sse4.2 sse4a avx avx2 avx512f fma fma4 bmi bmi2], [AX_GCC_X86_CPU_SUPPORTS(ax_x86_feature, [X86_FEATURE_CFLAGS="$X86_FEATURE_CFLAGS -m[]ax_x86_feature"], []) ]) AC_SUBST([X86_FEATURE_CFLAGS]) m4_ifval([$1],[$1], [CXXFLAGS="$CXXFLAGS $X86_FEATURE_CFLAGS"]) $2 ]) givaro-4.0.2/macros/ax_cxx_compile_stdcxx_11.m4000066400000000000000000000107631274707324300214520ustar00rootroot00000000000000# ============================================================================ # http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html # ============================================================================ # # SYNOPSIS # # AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional]) # # DESCRIPTION # # Check for baseline language coverage in the compiler for the C++11 # standard; if necessary, add switches to CXXFLAGS to enable support. # # The first argument, if specified, indicates whether you insist on an # extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. # -std=c++11). If neither is specified, you get whatever works, with # preference for an extended mode. # # The second argument, if specified 'mandatory' or if left unspecified, # indicates that baseline C++11 support is required and that the macro # should error out if no mode with that support is found. If specified # 'optional', then configuration proceeds regardless, after defining # HAVE_CXX11 if and only if a supporting mode is found. # # LICENSE # # Copyright (c) 2008 Benjamin Kosnik # Copyright (c) 2012 Zack Weinberg # Copyright (c) 2013 Roy Stogner # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 3 m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [ template struct check { static_assert(sizeof(int) <= sizeof(T), "not big enough"); }; typedef check> right_angle_brackets; int a; decltype(a) b; typedef check check_type; check_type c; check_type&& cr = static_cast(c); auto d = a; ]) AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl m4_if([$1], [], [], [$1], [ext], [], [$1], [noext], [], [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl m4_if([$2], [], [ax_cxx_compile_cxx11_required=true], [$2], [mandatory], [ax_cxx_compile_cxx11_required=true], [$2], [optional], [ax_cxx_compile_cxx11_required=false], [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])dnl AC_LANG_PUSH([C++])dnl ac_success=no AC_CACHE_CHECK(whether $CXX supports C++11 features by default, ax_cv_cxx_compile_cxx11, [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], [ax_cv_cxx_compile_cxx11=yes], [ax_cv_cxx_compile_cxx11=no])]) if test x$ax_cv_cxx_compile_cxx11 = xyes; then ac_success=yes fi m4_if([$1], [noext], [], [dnl if test x$ac_success = xno; then for switch in -std=gnu++11 -std=gnu++0x; do cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, $cachevar, [ac_save_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS $switch" AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], [eval $cachevar=yes], [eval $cachevar=no]) CXXFLAGS="$ac_save_CXXFLAGS"]) if eval test x\$$cachevar = xyes; then CXXFLAGS="$CXXFLAGS $switch" ac_success=yes break fi done fi]) m4_if([$1], [ext], [], [dnl if test x$ac_success = xno; then for switch in -std=c++11 -std=c++0x; do cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, $cachevar, [ac_save_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS $switch" AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], [eval $cachevar=yes], [eval $cachevar=no]) CXXFLAGS="$ac_save_CXXFLAGS"]) if eval test x\$$cachevar = xyes; then CXXFLAGS="$CXXFLAGS $switch" ac_success=yes break fi done fi]) AC_LANG_POP([C++]) if test x$ax_cxx_compile_cxx11_required = xtrue; then if test x$ac_success = xno; then AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.]) fi else if test x$ac_success = xno; then HAVE_CXX11=0 AC_MSG_NOTICE([No compiler with C++11 support was found]) else HAVE_CXX11=1 AC_DEFINE(HAVE_CXX11,1, [define if the compiler supports basic C++11 syntax]) fi AC_SUBST(HAVE_CXX11) fi ]) givaro-4.0.2/macros/ax_gcc_x86_cpu_supports.m4000066400000000000000000000101231274707324300213170ustar00rootroot00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpu_supports.html # =========================================================================== # # SYNOPSIS # # AX_GCC_X86_CPU_SUPPORTS(X86-INSTRUCTION-SET, # [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) # # DESCRIPTION # # Checks if the host cpu supports X86-INSTRUCTION-SET. The instruction set # that can be tested are "mmx, popcnt, sse, sse2, sse3, sse4.1, sse4.2, # sse4a, avx, avx2, avx512f, fma, fma4, bmi, bmi2". If the instruction set # is supported by the host cpu, the C preprocessor macro # HAVE_XXX_INSTRUCTIONS is set to 1. The XXX is up-cased instruction case # with dot replaced by underscore. For example, the test for "sse4.2" # would export HAVE_SSE4_2_INSTRUCTIONS=1. This macro requires gcc # extended builtin function "__builtin_cpu_init" and # "__builtin_cpu_supports" to detect the cpu features. It will error out # if the compiler doesn't has these builtins. # # If the test for the instruction set succeeded, the hook ACTION-IF-FOUND # would run. Otherwise the hook ACTION-IF-NOT-FOUND would run if # specified. # # See also AX_CHECK_X86_FEATURES, which checks all the possible # instruction set and export the corresponding CFLAGS. # # LICENSE # # Copyright (c) 2016 Felix Chern # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 1 AC_DEFUN_ONCE([_AX_GCC_X86_CPU_INIT], [AC_LANG_PUSH([C]) AC_CACHE_CHECK([for gcc __builtin_cpu_init function], [ax_cv_gcc_check_x86_cpu_init], [AC_RUN_IFELSE( [AC_LANG_PROGRAM([#include ], [__builtin_cpu_init ();]) ], [ax_cv_gcc_check_x86_cpu_init=yes], [ax_cv_gcc_check_x86_cpu_init=no])]) AS_IF([test "X$ax_cv_gcc_check_x86_cpu_init" = "Xno"], [AC_MSG_ERROR([Need GCC to support X86 CPU features tests])]) ]) AC_DEFUN([AX_GCC_X86_CPU_SUPPORTS], [AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([_AX_GCC_X86_CPU_INIT]) AC_LANG_PUSH([C]) AS_VAR_PUSHDEF([gcc_x86_feature], [AS_TR_SH([ax_cv_gcc_x86_cpu_supports_$1])]) AC_CACHE_CHECK([for x86 $1 instruction support], [gcc_x86_feature], [AC_RUN_IFELSE( [AC_LANG_PROGRAM( [#include ], [ __builtin_cpu_init (); if (__builtin_cpu_supports("$1")) return 0; return 1; ])], [gcc_x86_feature=yes], [gcc_x86_feature=no] )] ) AC_LANG_POP([C]) AS_VAR_IF([gcc_x86_feature],[yes], [AC_DEFINE( AS_TR_CPP([HAVE_$1_INSTRUCTIONS]), [1], [Define if $1 instructions are supported]) $2], [$3] ) AS_VAR_POPDEF([gcc_x86_feature]) ]) givaro-4.0.2/macros/config-header.m4000066400000000000000000000065651274707324300172520ustar00rootroot00000000000000# Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. AC_DEFUN([AX_PREFIX_CONFIG_H],[AC_REQUIRE([AC_CONFIG_HEADERS]) AC_CONFIG_COMMANDS([ifelse($1,,$PACKAGE-config.h,$1)],[dnl AS_VAR_PUSHDEF([_OUT],[ac_prefix_conf_OUT])dnl AS_VAR_PUSHDEF([_DEF],[ac_prefix_conf_DEF])dnl AS_VAR_PUSHDEF([_PKG],[ac_prefix_conf_PKG])dnl AS_VAR_PUSHDEF([_LOW],[ac_prefix_conf_LOW])dnl AS_VAR_PUSHDEF([_UPP],[ac_prefix_conf_UPP])dnl AS_VAR_PUSHDEF([_INP],[ac_prefix_conf_INP])dnl m4_pushdef([_script],[conftest.prefix])dnl m4_pushdef([_symbol],[m4_cr_Letters[]m4_cr_digits[]_])dnl _OUT=`echo ifelse($1, , $PACKAGE-config.h, $1)` _DEF=`echo _$_OUT | sed -e "y:m4_cr_letters:m4_cr_LETTERS[]:" -e "s/@<:@^m4_cr_Letters@:>@/_/g"` _PKG=`echo ifelse($2, , $PACKAGE, $2)` _LOW=`echo _$_PKG | sed -e "y:m4_cr_LETTERS-:m4_cr_letters[]_:"` _UPP=`echo $_PKG | sed -e "y:m4_cr_letters-:m4_cr_LETTERS[]_:" -e "/^@<:@m4_cr_digits@:>@/s/^/_/"` _INP=`echo "ifelse($3,,,$3)" | sed -e 's/ *//'` if test ".$_INP" = "."; then for ac_file in : $CONFIG_HEADERS; do test "_$ac_file" = _: && continue case "$ac_file" in *.h) _INP=$ac_file ;; *) esac test ".$_INP" != "." && break done fi if test ".$_INP" = "."; then case "$_OUT" in */*) _INP=`basename "$_OUT"` ;; *-*) _INP=`echo "$_OUT" | sed -e "s/@<:@_symbol@:>@*-//"` ;; *) _INP=config.h ;; esac fi if test -z "$_PKG" ; then AC_MSG_ERROR([no prefix for _PREFIX_PKG_CONFIG_H]) else if test ! -f "$_INP" ; then if test -f "$srcdir/$_INP" ; then _INP="$srcdir/$_INP" fi fi AC_MSG_NOTICE(creating $_OUT - prefix $_UPP for $_INP defines) if test -f $_INP ; then echo "s/@%:@undef *\\(@<:@m4_cr_LETTERS[]_@:>@\\)/@%:@undef $_UPP""_\\1/" > _script echo "s/@%:@undef *\\(@<:@m4_cr_letters@:>@\\)/@%:@undef $_LOW""_\\1/" >> _script echo "s/@%:@def[]ine *\\(@<:@m4_cr_LETTERS[]_@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_UPP""_\\1 \\" >> _script echo "@%:@def[]ine $_UPP""_\\1 \\2 \\" >> _script echo "@%:@endif/" >>_script echo "s/@%:@def[]ine *\\(@<:@m4_cr_letters@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_LOW""_\\1 \\" >> _script echo "@%:@define $_LOW""_\\1 \\2 \\" >> _script echo "@%:@endif/" >> _script # now executing _script on _DEF input to create _OUT output file echo "@%:@ifndef $_DEF" >$tmp/pconfig.h echo "@%:@def[]ine $_DEF 1" >>$tmp/pconfig.h echo ' ' >>$tmp/pconfig.h echo /'*' $_OUT. Generated automatically at end of configure. '*'/ >>$tmp/pconfig.h sed -f _script $_INP >>$tmp/pconfig.h echo ' ' >>$tmp/pconfig.h echo '/* once:' $_DEF '*/' >>$tmp/pconfig.h echo "@%:@endif" >>$tmp/pconfig.h if cmp -s $_OUT $tmp/pconfig.h 2>/dev/null; then AC_MSG_NOTICE([$_OUT is unchanged]) else ac_dir=`AS_DIRNAME(["$_OUT"])` AS_MKDIR_P(["$ac_dir"]) rm -f "$_OUT" mv $tmp/pconfig.h "$_OUT" fi else AC_MSG_ERROR([input file $_INP does not exist - skip generating $_OUT]) fi rm -f conftest.* fi m4_popdef([_symbol])dnl m4_popdef([_script])dnl AS_VAR_POPDEF([_INP])dnl AS_VAR_POPDEF([_UPP])dnl AS_VAR_POPDEF([_LOW])dnl AS_VAR_POPDEF([_PKG])dnl AS_VAR_POPDEF([_DEF])dnl AS_VAR_POPDEF([_OUT])dnl ],[PACKAGE="$PACKAGE"])]) givaro-4.0.2/macros/debug.m4000066400000000000000000000104331274707324300156320ustar00rootroot00000000000000# Copyright(c)'2011 by The Givaro group # Written by Brice Boyer (briceboyer) # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. dnl enable basic debug mode. AC_DEFUN([AC_DEBUG], [AC_MSG_CHECKING([whether to enable debugging options in the library]) AC_ARG_ENABLE(debug, [AC_HELP_STRING([--enable-debug=yes|no], [enable debugging options in library])], USE_DEBUG=$enableval, USE_DEBUG=no) AC_MSG_RESULT([$USE_DEBUG]) AM_CONDITIONAL(DEBUG, [test x$USE_DEBUG = xyes]) DBG=$USE_DEBUG AC_SUBST(DBG)dnl ] ) AC_DEFUN([AC_PROFILE], [AC_MSG_CHECKING([whether to enable profiling everything in the library]) AC_ARG_ENABLE(profile, [AC_HELP_STRING([--enable-profile=yes|no], [enable profiling options in library])], USE_PROFILE=$enableval, USE_PROFILE=no) AC_MSG_RESULT([$USE_PROFILE]) AM_CONDITIONAL(PROFILE, [test $USE_PROFILE = yes]) PROF=$USE_PROFILE AC_SUBST(PROF)dnl ] ) dnl Enable warnings from compiler. AC_DEFUN([AC_WARNINGS], [AC_MSG_CHECKING([whether to enable warnings when compiling the library]) AC_ARG_ENABLE(warnings, [AC_HELP_STRING([--enable-warnings=yes|full|no], [enable warnings when compiling the library. If nothing or yes is given, more aggressive compiler warnings are passed to the compiler. If full is given, we become paranoïd about warnings and treat them as errors.])], USE_WARNINGS=$enableval, USE_WARNINGS=no) AC_MSG_RESULT([$USE_WARNINGS]) dnl AM_CONDITIONAL(WARNINGS, [test $USE_WARNINGS = yes]) WARN=$USE_WARNINGS AC_SUBST(WARN)dnl ]dnl )dnl CCNAM="" AC_DEFUN([AC_COMPILER_NAME], [ AC_MSG_CHECKING(for family name of compiler) dnl CHECKING for various compilers dnl ICC ? AC_TRY_RUN( [ #ifdef __INTEL_COMPILER int main() { return 0 ; } #else pas intel #endif], [ AC_MSG_RESULT(icc) CCNAM=icc AC_SUBST(CCNAM) ]) dnl PATHSCALE > 4 ? AS_IF([ test -z "${CCNAM}"], [ AC_TRY_RUN( [ #ifdef __PATHSCALE__ int main() { return !(__PATHCC__ >= 4) ; } #else pas ekopath non plus. #endif], [ AC_MSG_RESULT(eko) CCNAM=eko AC_SUBST(CCNAM) ]) ]) dnl CLANG > 3.1 ? AS_IF([ test -z "${CCNAM}"], [ AC_TRY_RUN( [ #ifdef __clang__ int main() { return !(__clang_major__ >=3 && __clang_minor__ >=1) ; } #else pas clang non plus. #endif], [ AC_MSG_RESULT(clang31) CCNAM=clang31 AC_SUBST(CCNAM) ]) ]) dnl CLANG > 3 ? AS_IF([ test -z "${CCNAM}"], [ AC_TRY_RUN( [ #ifdef __clang__ int main() { return !(__clang_major__ >=3) ; } #else pas clang non plus. #endif], [ AC_MSG_RESULT(clang31) CCNAM=clang AC_SUBST(CCNAM) ]) ]) dnl GCC >= 4.8 ? AS_IF([ test -z "${CCNAM}"], [ AC_TRY_RUN( [ #ifdef __GNUC__ int main() { return !(__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ > 7 )) ; } #else pas gcc non plus ??? #endif], [ CCNOM=gcc AS_IF([ test -n "${CC}" ], [CCNOM="`$CC --version 2>&1| awk 'NR<2{print $1}'`"]) CCNAM=gcc48 AC_SUBST(CCNAM) AC_MSG_RESULT($CCNOM) ]) ]) dnl GCC > 4.2 ? AS_IF([ test -z "${CCNAM}"], [ AC_TRY_RUN( [ #ifdef __GNUC__ int main() { return !(__GNUC__ >= 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)) ; } #else pas gcc non plus ??? #endif], [ CCNOM=gcc AS_IF([ test -n "${CC}" ], [CCNOM="`$CC --version 2>&1| awk 'NR<2{print $1}'`"]) CCNAM=gcc AC_SUBST(CCNAM) AC_MSG_RESULT($CCNOM) ]) ]) dnl autre ? AS_IF([ test -z "${CCNAM}"], [ AC_MSG_RESULT(unknown) CCNAM=unknown AC_SUBST(CCNAM) echo echo " *** unknow compiler. please file a bug " echo ]) ]) dnl compile library or make it mostly inlined headers ? AC_DEFUN([AC_INLINE], [AC_MSG_CHECKING([whether to inline or not most of the code ?]) AC_ARG_ENABLE(inline, [AC_HELP_STRING([--enable-inline], [enable inlining most of the code])], USE_INLINE=$enableval AC_DEFINE(INLINE_ALL,1,[Define if you want most code inlined]) , USE_INLINE=no) AC_MSG_RESULT([$USE_INLINE]) AM_CONDITIONAL(GIVARO_INLINE_ALL, [test $USE_INLINE = yes]) AC_SUBST(GIVARO_INLINE_ALL) echo $GIVARO_INLINE_ALL dnl DBG=$USE_DEBUG dnl AC_SUBST(DBG)dnl ] ) givaro-4.0.2/macros/givaro-doc.m4000066400000000000000000000040371274707324300166010ustar00rootroot00000000000000# Copyright(c)'2011 by The Givaro group # Written by Brice Boyer (briceboyer) # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. AC_DEFUN([GIV_DOC], [ AC_MSG_CHECKING(whether to build documentation) AC_ARG_WITH(docdir, [AC_HELP_STRING([--with-docdir=], [Where the Givaro documentation should be installed])], [ GIVARO_DOC_PATH="$withval" ], [ eval GIVARO_DOC_PATH="${prefix}/docs" ]) AC_SUBST(GIVARO_DOC_PATH) AC_ARG_WITH(doxygen, [AC_HELP_STRING([--with-doxygen=], [Give the path to Doxygen. Note: --enable-doc needed])], [ DOXYGEN_PATH="$PATH $withval" ], [ DOXYGEN_PATH="$PATH" ]) AC_ARG_ENABLE(doc,[AC_HELP_STRING([--enable-doc], [Enable building documentation])], [ AC_MSG_RESULT(yes) AC_MSG_CHECKING(whether doxygen works) export PATH=$DOXYGEN_PATH (doxygen --version) < /dev/null > /dev/null 2>&1 || { AC_MSG_RESULT(no) echo echo "You must have doxygen installed to create documentation for" echo "Givaro. This error only happens if you use --enable-doc." echo "Download the appropriate package for your distribution, or get" echo "the source tarball from http://www.stack.nl/~dimitri/doxygen/" exit -1 } AM_CONDITIONAL(GIVARO_DOXYGEN_FOUND, true) AC_MSG_RESULT(yes) AM_CONDITIONAL(GIVARO_BUILD_DOC, true) ], [ AS_IF([(doxygen --version) < /dev/null > /dev/null 2>&1], [AM_CONDITIONAL(GIVARO_DOXYGEN_FOUND, true)], [AM_CONDITIONAL(GIVARO_DOXYGEN_FOUND, false)] ) AC_MSG_RESULT(no) AM_CONDITIONAL(GIVARO_BUILD_DOC, false) ]) AC_MSG_CHECKING(whether dot works) res=yes; (dot -V) < /dev/null > /dev/null 2>&1 || res=no AC_MSG_RESULT([$res]) AS_IF([test $res = yes], [ sed 's/^HAVE_DOT.*/HAVE_DOT = YES/' docs/Doxyfile.mod > docs/Doxyfile sed 's/^HAVE_DOT.*/HAVE_DOT = YES/' docs/DoxyfileDev.mod > docs/DoxyfileDev ], [ cp docs/Doxyfile.mod docs/Doxyfile ; cp docs/DoxyfileDev.mod docs/DoxyfileDev ]) ]) givaro-4.0.2/macros/gmp-check.m4000066400000000000000000000066711274707324300164130ustar00rootroot00000000000000# Check for GMP # Copyright(c)'1994-2009,2003,2013 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. # # Modified by Pascal Giorgi, 2003-12-03 # Modified by BB, 2013-5-22 dnl LB_CHECK_GMP ([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) dnl dnl Test for the GNU Multiprecision library and define GMP_CFLAGS and GMP_LIBS AC_DEFUN([GIV_CHECK_GMP], [ AC_ARG_WITH(gmp, [AC_HELP_STRING([--with-gmp=|yes|no],[ Use GMP library. If argument is no, you do not have the library installed on your machine. If argument is yes or that means the library is reachable with the standard search path "/usr" or "/usr/local" (set as default). Otherwise you give the to the directory which contain the library. ])], [if test "$withval" = yes || test "x$withval" = "x"; then GMP_HOME_PATH="/usr" elif test "$withval" != no ; then GMP_HOME_PATH="$withval" fi], [GMP_HOME_PATH="/usr"]) min_gmp_version=ifelse([$1], ,4.0.0,$1) dnl Check for existence BACKUP_CXXFLAGS=${CXXFLAGS} BACKUP_LIBS=${LIBS} AC_MSG_CHECKING(for GMP >= $min_gmp_version with cxx enabled) GMP_PATH= for GMP_HOME in ${GMP_HOME_PATH} do if test "x$GMP_HOME" != "x/usr" -a "x$GMP_HOME" != "x/usr/local"; then if test -r "$GMP_HOME/include/gmp.h" ; then GMP_CFLAGS="-I${GMP_HOME}/include" GMP_PATH="-L${GMP_HOME}/lib" GMP_LIBS="-L${GMP_HOME}/lib -lgmpxx -lgmp" elif test -r "$GMP_HOME/gmp.h" ; then GMP_CFLAGS="-I${GMP_HOME}" GMP_PATH="-L${GMP_HOME}" GMP_LIBS="-L${GMP_HOME} -lgmpxx -lgmp" else echo "($GMP_HOME) seems an invalid GMP prefix" echo "Searching GMP in PATH" GMP_CFLAGS="" GMP_LIBS="-lgmpxx -lgmp" fi else GMP_CFLAGS="" GMP_LIBS="-lgmpxx -lgmp" fi CXXFLAGS="${CXXFLAGS} ${GMP_CFLAGS}" LIBS="${LIBS} ${GMP_LIBS}" AC_TRY_LINK( [ // Check was there, added version control - A. Breust 2015-01-21 #ifdef __PATHCC__ #if __PATHCC__ < 5 #include #include #endif #endif #include "stddef.h" #include ], [mpz_t a; mpz_init (a);], [ dnl # See if we are running GMP 4.0 with --enable-cxx dnl There seems to be incompatiblity between g++-4.9 and gmp-5.1.2 AC_TRY_RUN( [#include int main () { if (__GNU_MP_VERSION < 4) return -1; mpz_class a(2),b(3),c(5); if ( a+b == c ) return 0; else return -1; } ], [ AC_MSG_RESULT(found) AC_DEFINE(HAVE_GMP,1,[Define if GMP is installed]) dnl GMP_VERSION="" dnl I could find it but why is it here ? GMP_LIBS="${GMP_PATH} -lgmpxx -lgmp" dnl AC_SUBST(GMP_VERSION) AC_SUBST(GMP_LIBS) AC_SUBST(GMP_CFLAGS) break; ],[ AC_MSG_RESULT(no : gmp is too old or not compiled with cpp support) dnl AC_DEFINE(GMP_NO_CXX,1,[Define if GMP has no ]) dnl GMP_VERSION="-DGMP_NO_CXX" dnl AC_SUBST(GMP_VERSION) ],[ dnl This should never happen AC_MSG_RESULT(no) ]) ],[ AC_MSG_RESULT(unknown) echo "WARNING: You appear to be cross compiling, so there is no way to determine" echo "whether your GMP version is new enough. I am assuming it is." AC_SUBST(GMP_CFLAGS) AC_SUBST(GMP_LIBS) AC_DEFINE(HAVE_GMP,1,[Define if GMP is installed]) ]) unset GMP_CFLAGS unset GMP_LIBS done CXXFLAGS=${BACKUP_CXXFLAGS} LIBS=${BACKUP_LIBS} #unset LD_LIBRARY_PATH ]) givaro-4.0.2/macros/simd-check.m4000066400000000000000000000066221274707324300165600ustar00rootroot00000000000000dnl Check for SIMD dnl Created by BB, 2014-03-25 dnl modified by CP, 2016-07-11 dnl copied from fflas-ffpack by CP dnl ========LICENCE======== dnl Copyright(c)'1994-2016 by The Givaro group dnl This file is part of Givaro. dnl Givaro is governed by the CeCILL-B license under French law dnl and abiding by the rules of distribution of free software. dnl see the COPYRIGHT file for more details. dnl ========LICENCE======== dnl dnl FF_CHECK_SIMD dnl dnl turn on SSE4.1 AVX, AVX2 extensions if available AC_DEFUN([FF_CHECK_SIMD], [ AC_ARG_ENABLE(simd,[AC_HELP_STRING([--disable-simd], [ Disable vectorized instructions: SSE4.1, AVX, AVX2])]) AS_IF([ test "x$enable_simd" != "xno" ], [ AS_ECHO("SIMD enabled") arch=`echo $target | cut -d"-" -f1` # if we are on a x86 (32 or 64 bits) with gcc>=4.8 then run the AX_CHECK_X86_FEATURES macro AS_IF([test "x$arch" = "xx86_64" -o "x$arch" = "xi686"], [archx86="yes"], [archx86="no"] ) AS_IF([ test "x$CCNAM" != "xgcc48" -o "x$archx86" = "xno" ], [ CUSTOM_SIMD="yes" echo "Compiling with $CCNAM for a $arch target: running custom checks for SSE4.1 and AVX1,2" AC_MSG_CHECKING(for SSE 4.1) BACKUP_CXXFLAGS=${CXXFLAGS} SSEFLAGS="-msse4.1" CXXFLAGS="${BACKUP_CXXFLAGS} ${SSEFLAGS}" CODE_SSE=`cat macros/CodeChunk/sse.C` AC_TRY_RUN([ ${CODE_SSE} ], [ sse_found="yes" ], [ sse_found="no" ], [ echo "cross compiling...disabling" sse_found="no" ]) AS_IF([ test "x$sse_found" = "xyes" ], [ AC_DEFINE(HAVE_SSE4_1_INSTRUCTIONS,1,[Define if SSE is available]) AC_MSG_RESULT(yes) ], [ SSEFLAGS="" AC_MSG_RESULT(no) ]) CXXFLAGS=${BACKUP_CXXFLAGS} dnl Check for AVX AC_MSG_CHECKING(for AVX) CODE_AVX=`cat macros/CodeChunk/avx.C` dnl Intel compilers usually do not require option to enable avx dnl Thus, we test with no option on for switch_avxflags in "" "-mavx"; do CXXFLAGS="${BACKUP_CXXFLAGS} -O0 ${switch_avxflags}" AC_TRY_RUN([ ${CODE_AVX} ], [ avx_found="yes" AVXFLAGS=${switch_avxflags} break ], [ avx_found="no" ], [ echo "cross compiling...disabling" avx_found="no" break ]) done dnl Is AVX found? AS_IF([ test "x$avx_found" = "xyes" ], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_AVX_INSTRUCTIONS,1,[Define if AVX is available]) dnl Check for AVX2 AC_MSG_CHECKING(for AVX2) for switch_avx2flags in "" "-mfma -mavx2"; do CXXFLAGS="${BACKUP_CXXFLAGS} -O0 ${switch_avx2flags}" AC_TRY_RUN( [ #define __try_avx2 ${CODE_AVX} ], [ avx2_found="yes" AVX2FLAGS="${switch_avx2flags}" break ], [ avx2_found="no" ], [ echo "cross compiling...disabling" avx2_found = "no" break ]) done dnl Is AVX2 found? AS_IF([ test "x$avx2_found" = "xyes" ], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_AVX2_INSTRUCTIONS,1,[Define if AVX2 is available]) AVXFLAGS=${AVX2FLAGS} ], [ AC_MSG_RESULT(no) ] ) ], [ dnl No AVX AC_MSG_RESULT(no) ]) CXXFLAGS=${BACKUP_CXXFLAGS} ], [ ]) ],[ AS_ECHO("SIMD disabled") CUSTOM_SIMD="yes" ]) ]) givaro-4.0.2/src/000077500000000000000000000000001274707324300136045ustar00rootroot00000000000000givaro-4.0.2/src/Makefile.am000066400000000000000000000015131274707324300156400ustar00rootroot00000000000000# Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. AM_CPPFLAGS=-I$(top_srcdir) AM_CXXFLAGS = @DEFAULT_CFLAGS@ AM_LDFLAGS=$(LDFLAGS) SUBDIRS=kernel library lib_LTLIBRARIES= libgivaro.la libgivaro_la_SOURCES = dummy.C libgivaro_la_LIBADD= \ kernel/gmp++/libgmppp.la kernel/bstruct/libgivbstruct.la kernel/integer/libgivinteger.la kernel/memory/libgivmemory.la kernel/rational/libgivrational.la kernel/system/libgivsystem.la kernel/field/libgivfield.la library/tools/libgivtools.la library/poly1/libgivpoly1.la # soname of libgivaro libgivaro_la_LDFLAGS = -version-info 9:0:0 libgivaro_la_LDFLAGS+= -no-undefined libgivaro_la_LDFLAGS+=$(LDFLAGS) givaro-4.0.2/src/dummy.C000066400000000000000000000004461274707324300150470ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. #include "givaro-config.h" static int dummy; givaro-4.0.2/src/kernel/000077500000000000000000000000001274707324300150645ustar00rootroot00000000000000givaro-4.0.2/src/kernel/Makefile.am000066400000000000000000000005701274707324300171220ustar00rootroot00000000000000# Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. AM_CPPFLAGS=-I$(top_srcdir) AM_CXXFLAGS = @DEFAULT_CFLAGS@ SUBDIRS=system memory gmp++ integer bstruct rational recint field ring givaro-4.0.2/src/kernel/bstruct/000077500000000000000000000000001274707324300165525ustar00rootroot00000000000000givaro-4.0.2/src/kernel/bstruct/Makefile.am000066400000000000000000000013651274707324300206130ustar00rootroot00000000000000# Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. AM_CPPFLAGS=-I$(top_srcdir) AM_CXXFLAGS = @DEFAULT_CFLAGS@ AM_CPPFLAGS+= -I$(top_srcdir)/src/kernel/system -I$(top_srcdir)/src/kernel/memory pkginclude_HEADERS= \ givarray0.h \ givarrayallocator.h \ givarrayfixed.h \ givbits.h \ givelem.h \ givhashtable.h \ givlist0.h \ givstack.h \ givarray0.inl \ givbits.inl \ givhashtable.inl \ givlist0.inl \ givstack.inl EXTRA_DIST = bstruct.doxy noinst_LTLIBRARIES=libgivbstruct.la libgivbstruct_la_SOURCES=givbits.C givaro-4.0.2/src/kernel/bstruct/bstruct.doxy000066400000000000000000000001501274707324300211410ustar00rootroot00000000000000/** @defgroup bstruct bstruct * @ingroup givaro * @brief NO DOC. * NO DOC */ // vim:syntax=doxygen givaro-4.0.2/src/kernel/bstruct/givarray0.h000066400000000000000000000102471274707324300206330ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/bstruct/givarray0.h,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Author: T. Gautier // $Id: givarray0.h,v 1.7 2011-02-02 16:23:55 briceboyer Exp $ // ========================================================================== // /*! @file givarray0.h * @brief Array of type T with reference mecanism. */ #ifndef __GIVARO_array0_H #define __GIVARO_array0_H #include // size_t #include "givaro/givaromm.h" #include "givaro/givperf.h" #include "givaro/giverror.h" namespace Givaro { #ifndef DOXYGEN_SHOULD_SKIP_THIS GIVARO_PERF_DEFCLASS(Array0,T) #else //! defined by marco GIVARO_PERF_DEFCLASS. ref counting and stuff. template struct _perfArray0 {}; #endif /** @class Array0 * NODOC */ template class Array0 #ifndef DOXYGEN_SHOULD_SKIP_THIS GIVARO_PERF_INEHERIT(Array0,T) #else : public _perfArray0 #endif { /** @internal * build...? */ void build( size_t s, const T& t) ; public : typedef int Indice_t; typedef T Type_t; typedef Array0 Self_t; typedef Type_t *Iterator_t; typedef const Type_t *constIterator_t; //! STL compliance //@{ typedef Type_t value_type; typedef Type_t *iterator; typedef const Type_t *const_iterator; //@} //! Default cstor : ctsor of s size array //@{ Array0 (size_t s = 0); Array0 (size_t s, const T& t); //@} //! Recopy cstor : logical copy Array0 (const Self_t& p, givNoCopy); //! Recopy cstor : physical copy Array0 (const Self_t& p, givWithCopy); //! Destructor ~Array0 (); //! Destroy of the array void destroy (); /** Allocation of an array of s Elements. * if refcount>1 * then it is always a creation of new array */ void allocate (size_t s); /** Reallocation of an array of s Elements. * if refcount>1 * then it is always a creation of new array + recopy */ void reallocate (size_t s); //! resize void resize (size_t s) { this->reallocate(s); } //! reserve void reserve (size_t s) { this->reallocate(s); this->reallocate(0); } /** Physical copy operator. *reallocate dest of the same size * as src (if necessary) and apply GivaroCopyItem,T> on each Element. * This class can be specialized. Return dest (i.e, *this). */ Self_t& copy(const Self_t& src); //! Logical recopy operator: make an alias to src. Return dest. Self_t& logcopy(const Self_t& src); //! assignement operator is physical copy Self_t& operator= (const Self_t& p); //! Return the occuped size of the array size_t size() const { return _size; } //! Return the physical size of the array (capacity) size_t phsize() const; //! Return the base ptr to the array //@{ Type_t* baseptr(); const Type_t* baseptr() const; //@} //! Access to the ith Element: //@{ const T& operator[] (Indice_t i) const; // { return _d[i]; } T& operator[] (Indice_t i); // { return _d[i]; } ; //@} //! back/front //@{ const T& front () const; // { return _d[0]; } T& front (); // { return _d[0]; } ; const T& back () const; // *(--end()) T& back (); // *(--end()) //@} //! add one element at the end void push_back( const T& a ); //!write void write(Indice_t i, const Type_t& val); //! read void read (Indice_t i, Type_t& val) const; //! Iterators //@{ Iterator_t begin(); Iterator_t end(); constIterator_t begin() const; constIterator_t end() const; //@} //! @internal //! get Counter int getCounter() const { return *_cnt ; } protected : //--------------------- protected Internal representation int* _cnt; //!< reference counter on _d size_t _size; //!< actual size of the array. If ==0 then _psz=_d=_cnt=0 size_t _psz; //!< physical size of the array T* _d; //!< ptr to the memory }; } // namespace Givaro #include "givaro/givarray0.inl" #endif // __GIVARO_array0_H /* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/bstruct/givarray0.inl000066400000000000000000000167041274707324300211720ustar00rootroot00000000000000// ========================================================================== // // $Source: /var/lib/cvs/Givaro/src/kernel/bstruct/givarray0.inl,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Author: T. Gautier // $Id: givarray0.inl,v 1.7 2011-02-02 16:23:55 briceboyer Exp $ // ======================================================================= // /** @internal * @file bstruct/givarray0.inl * implementation of operators of Array0 */ #ifndef __GIVARO__array0_INL #define __GIVARO__array0_INL namespace Givaro { // Default cstor : ctsor of s size array template inline void Array0::build( size_t s, const T& t) { // JGD 24.02.2011 : size_t is unsigned // GIVARO_ASSERT( s>=0, "[Array::cstor(size_t)] must takes a >=0 parameter"); _psz = _size = s; if (s !=0) { _d = GivaroMM::allocate(s); GivaroMM::initialize(_d, s, t); _cnt = GivaroMM::allocate(1); *_cnt = 1; } else { _d =0; _cnt =0; } } template inline Array0::Array0 ( size_t s ) { build(s, T()); } template inline Array0::Array0 ( size_t s, const T& t) { build(s, t); } // Recopy cstor : logical copy template inline Array0::Array0 (const Self_t& p, givNoCopy) { _psz = p._psz; _size = p._size; if (_size !=0) { // increment ref. counting _d = p._d; _cnt = p._cnt; (*_cnt) ++; } else { _d = 0; _cnt = 0; } } // Recopy cstor : physical copy template inline Array0::Array0 (const Self_t& p, givWithCopy) { _psz = _size = p._size; if (_size !=0) { _d = GivaroMM::allocate(_size); _cnt = GivaroMM::allocate(1); *_cnt = 1; for (size_t i=0; i<_size; i++) GivaroMM::initone(&_d[i], p._d[i]); } else { _d =0; _cnt =0; } } // Destroy of the array template inline void Array0::destroy( ) { if (_psz !=0) { if (--(*_cnt) ==0) { GivaroMM::destroy(_d, _psz); GivaroMM::desallocate(_d); GivaroMM::desallocate(_cnt); } } _size = _psz = 0; _cnt = 0; _d = 0; } // Allocation of an array of s Elements template inline void Array0::allocate( size_t s ) { // JGD 24.02.2011 : size_t is unsigned // GIVARO_ASSERT( s>=0, "[Array::allocate]: must takes a >=0 parameter"); if (_cnt !=0) { if (((*_cnt) ==1) && (_psz >= s)) { _size = s; return; } this->destroy(); } if (s >0) { _d = GivaroMM::allocate(s); GivaroMM::initialize(_d, s); _cnt = GivaroMM::allocate(1); *_cnt = 1; } else _cnt =0; _psz = _size = s; } // Reallocation of an array of s Elements // and recopy the min(_size,s) first Elements template inline void Array0::reallocate( size_t s ) { // JGD 24.02.2011 : size_t is unsigned // GIVARO_ASSERT( s>=0, "[Array::reallocate]: must takes a >=0 parameter"); if (_cnt !=0) { if (*_cnt ==1) { if (_psz >=s) { _size = s; return; } } else (*_cnt) --; } if (s >0) { T* tmp = GivaroMM::allocate(s); GivaroMM::initialize(tmp+_size, s-_size); if (_cnt !=0) { for (size_t i=0; i<_size; i++) GivaroMM::initone(&(tmp[i]), _d[i]); this->destroy(); } _cnt = GivaroMM::allocate(1); *_cnt = 1; _d = tmp; } else _cnt =0; _psz = _size = s; } template inline void Array0::push_back( const T& a ) { this->reallocate(_size+1); this->back() = a; } // Logical destructor: identical to free template inline Array0::~Array0 () { this->destroy(); } // Physical copy : recopy and assignement on each Element template inline Array0& Array0::copy (const Array0& src) { if (src._d == _d) return *this; reallocate(src._size); // - try... // -- here we have a large enough array with refcount==1 const T* baseP = src._d; T* baseThis = _d; for (size_t i=0; i<_size; i++) baseThis[i] = baseP[i]; return *this; } // Logical copy template inline Array0& Array0::logcopy (const Array0& src) { destroy(); _psz = src._psz; _size = src._size; if (_psz !=0) { _d = src._d; _cnt = src._cnt; (*_cnt) ++; } else { _d = 0; _cnt = 0; } return *this; } // Physical copy template Array0& Array0::operator= (const Array0& p) { //throw GivError("[Array0::operator=] cannot be used" " File:" ##__FILE__ ", line:" ##__LINE__ ); // throw GivError("[Array0::operator=] cannot be used"); return this->copy(p); } template inline size_t Array0::phsize() const { return _psz; } template inline T* Array0::baseptr() { return _d; } template inline const T* Array0::baseptr() const { return _d; } // This following functions directly access to protected template inline const T& Array0::front () const { GIVARO_ASSERT(_size >0, "[Array::[]]: try to access to an Element of null size Array0."); return _d[0]; } // Access operator : Write access template inline T& Array0::front () { GIVARO_ASSERT(_size >0, "[Array::[]]: try to access to an Element of null size Array0."); return _d[0]; } // This following functions directly access to protected template inline const T& Array0::back () const { GIVARO_ASSERT(_size >0, "[Array::[]]: try to access to an Element of null size Array0."); return _d[_size-1]; } // Access operator : Write access template inline T& Array0::back () { GIVARO_ASSERT(_size >0, "[Array::[]]: try to access to an Element of null size Array0."); return _d[_size-1]; } template inline const T& Array0::operator[] (Indice_t i) const { GIVARO_ASSERT(_size >0, "[Array::[]]: try to access to an Element of null size Array0."); GIVARO_ASSERT((i >=0)&&(i<(Indice_t)_size), "[Array::[]]: index out of bounds."); return _d[i]; } // Access operator : Write access template inline T& Array0::operator[] (Indice_t i) { GIVARO_ASSERT(_size >0, "[Array::[]]: try to access to an Element of null size Array0."); GIVARO_ASSERT((i >=0)&&(i<(Indice_t)_size), "[Array]: index out of bounds."); return _d[i]; } template inline void Array0::write( Indice_t i, const T& val) { GIVARO_ASSERT(_size >0, "[Array::write]: try to access to an Element of null size Array0."); GIVARO_ASSERT((i >=0)&&(i<(Indice_t)_size), "[Array::write]: index out of bounds."); _d[i] = val; } template inline void Array0::read ( Indice_t i, T& val ) const { GIVARO_ASSERT(_size >0, "[Array::read]: try to access to an Element of null size Array0"); GIVARO_ASSERT((i >=0)&&(i<(Indice_t)_size), "[Array::read]: index out of bounds."); val = _d[i]; } template inline typename Array0::Iterator_t Array0::begin() { return _d; } template inline typename Array0::Iterator_t Array0::end() { return _d + _size; } template inline typename Array0::constIterator_t Array0::begin() const { return _d; } template inline typename Array0::constIterator_t Array0::end() const { return _d + _size; } } // namespace Givaro #endif // __GIVARO__array0_INL /* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/bstruct/givarrayallocator.h000066400000000000000000000021641274707324300224530ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/bstruct/givarrayallocator.h,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Author: T. Gautier // $Id: givarrayallocator.h,v 1.3 2011-02-02 16:23:55 briceboyer Exp $ // ========================================================================== /** @file givarrayallocator.h * @ingroup bstruct * @brief NO DOC */ #ifndef __GIVARO_array_allocator_H #define __GIVARO_array_allocator_H namespace Givaro { /*! @brief ArrayAllocator: class for allocation of arrays. * Should have * - allocate(size_n) * - reallocate(size_n) * - destroy * . */ template class ArrayAllocatort { }; //! Array0Tag class Array0Tag {}; //! Specialization: for Array0Tag template class ArrayAllocatort : public Array0 {}; } // namespace Givaro #endif // __GIVARO_array_allocator_H givaro-4.0.2/src/kernel/bstruct/givarrayfixed.h000066400000000000000000000103001274707324300215610ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/bstruct/givarrayfixed.h,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Author: T. Gautier // $Id: givarrayfixed.h,v 1.5 2011-02-02 16:23:55 briceboyer Exp $ // ========================================================================== /*! @file givarrayfixed.h * @ingroup bstruct * @brief ArrayFixed of type T with fixed dimension. */ #ifndef __GIVARO_array_fixed_H #define __GIVARO_array_fixed_H #include // size_t #include "givaro/givaromm.h" #include "givaro/giverror.h" #include "givaro/givperf.h" namespace Givaro { //! ArrayFixed template class ArrayFixed #ifndef DOXYGEN_SHOULD_SKIP_THIS GIVARO_PERF_INEHERIT(ArrayFixed,T) #else : public _perfArrayFixed #endif { T _data[SIZE]; // _data public : typedef int Indice_t; typedef T Type_t; typedef ArrayFixed Self_t; typedef Type_t *Iterator_t; typedef const Type_t *constIterator_t; //-- Default cstor: ArrayFixed () {}; //-- Recopy cstor : implicit //-- Destructor: implicit //-- Physical copy operator: reallocate dest of the same SIZE // as src (if necessary) and apply GivaroCopyItem,T> on each Element. // This class can be specialized. Return dest (i.e, *this). Self_t& copy(const Self_t& src); //-- Return the occuped SIZE of the array size_t size() const { return SIZE; } //-- Return the physical size of the array (capacity) size_t phsize() const { return SIZE; } //-- Return the base ptr to the array Type_t* baseptr() { return _data; } Type_t* const baseptr() const { return _data; } //-- Access to the ith Element: const T& operator[] (Indice_t i) const { GIVARO_ASSERT((i >=0)&&(i::[]]: index out of bounds."); return _data[i]; } T& operator[] (Indice_t i) { GIVARO_ASSERT((i >=0)&&(i::[]]: index out of bounds."); return _data[i]; } // -- Iterator Iterator_t begin() { return _data; } Iterator_t end() { return _data + SIZE; } constIterator_t begin() const { return _data; } constIterator_t end() const { return _data + SIZE; } template void map( UNARYOP& opcode ); template void map( UNARYOP& opcode ) const; protected : //--------------------- protected Internal representation private: //-- assignement operator cannot be herited. Self_t& operator= (const Self_t& p) {}; }; //! Map opcode on all Elements less or requal that ith. //! Terminal recursion, specialization template struct __giv_map_less_ith; template struct __giv_map_less_ith { inline void operator()( T* data, UNARYOP& opcode ) { opcode(data[0]); } }; template struct __giv_map_less_ith { inline void operator()( T* data, UNARYOP& opcode ) { opcode(data[ith]); __giv_map_less_ith()(data, opcode); } }; template struct __giv_map_less_ith_const; template struct __giv_map_less_ith_const { inline operator()( const T* data, UNARYOP& opcode ) { opcode(data[0]); } }; template struct __giv_map_less_ith_const { inline void operator() ( const T* data, UNARYOP& opcode ) { opcode(data[ith]); __giv_map_less_ith(data, opcode); } }; //! Specialization template template void ArrayFixed::map( UNARYOP& opcode ) { __giv_map_less_ith()(_data, opcode); } //! Specialization template template void ArrayFixed::map( UNARYOP& opcode ) const { __giv_map_less_ith_const()(_data, opcode); } } // namespace Givaro #endif // __GIVARO_array_fixed_H // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/bstruct/givbits.C000066400000000000000000000167451274707324300203420ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/bstruct/givbits.C,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Author: T. Gautier // $Id: givbits.C,v 1.2 2009-09-17 14:28:22 jgdumas Exp $ // ========================================================================== // Description: // - field of n bits, for any n. // The bits field is and array of long: a_(k-1),...,a_0. // each entry has sizeof(long) bits. Give an number i, to i-th // bit in the representation is the r-th bit carried by entry a_q, // where q = i quo sizeof(long) and r = i rem sizeof(long) (counting from 0). #include #include #include "givaro/givbits.h" #include "givaro/givmodule.h" #define GIV_SIZE_LONG 32 #if (GIV_SIZE_LONG == 32) # define SIZE_IN_BYTE 4 // size of the base # define SIZE_IN_BIT 32 // size of the base # define QUO(x) ( (x >>5) ) // quotient by 32 # define REM(x) ( (x & 0x1f) ) // remainder by 32 # define MAX_WORD(x) ( QUO(x) + (0!=REM(x) ? 1 : 0) ) // ceil( QUO(x) ) #else # define SIZE_IN_BYTE sizeof(Bits::base) # define SIZE_IN_BIT (sizeof(Bits::base)*8) # define QUO(x) (x / SIZE_IN_BIT) # define REM(x) (x % SIZE_IN_BIT) # define MAX_WORD(x) (QUO(x) + (0!=REM(x) ? 1 : 0)) #endif namespace Givaro { // -- Table of 2^i = Table2pow[i], for i =0..sizeof(base) static Bits::base* Table2pow; Bits::Bits () : rep(0) { } Bits::Bits (const size_t n) { size_t len = MAX_WORD(n) ; rep.allocate( len ); } Bits::Bits( const Bits& B ) : rep(B.rep, givWithCopy()) {} Bits::Bits( const Bits::Rep& B ) : rep(B, givWithCopy()) {} Bits::~Bits() { rep.destroy(); } // And const Bits Bits::operator& (const Bits& A) const { GIVARO_ASSERT( rep.size() == A.rep.size(), "[Bits]: invalide size in 'and'"); size_t len = rep.size(); Rep res( len ); for (int i=0; i< int(len); ++i) res[i] = rep[i] & A.rep[i]; return Bits(res); } Bits& Bits::andin( const Bits& A, const Bits B) { GIVARO_ASSERT( B.rep.size() == A.rep.size(), "[Bits]: invalide size in andin"); GIVARO_ASSERT( rep.size() == A.rep.size(), "[Bits]: invalide size in andin"); size_t len = rep.size(); for (int i=0; i> rem) !=0) num++; } return num; } // -- Returns the index of non zero bits void Bits::indexofone( Array0& index) const { size_t l = rep.size(); index.allocate( (size_t) numone() ); long num =0; for (int i=0; i> rem) !=0) index[int(num++)] = (base)i; } } // -- Returns the length (in byte) of this : size_t Bits::length() const { return rep.size(); } // return the i-th bit of *this int Bits::operator[] (const int i) const { GIVARO_ASSERT( i>=0, "invalide index in Bits::operator[]"); GIVARO_ASSERT( i<(int)length()*SIZE_IN_BIT, "invalide index in Bits::operator[]"); int quo = QUO(i); int rem = REM(i); return int((rep[quo] & Table2pow[rem]) >> rem); } int Bits::operator[] (const size_t i) const { // GIVARO_ASSERT( i>=0, "invalide index in Bits::operator[]"); GIVARO_ASSERT( i> rem); } int Bits::get (const int i) const { GIVARO_ASSERT( i>=0, "invalide index in Bits::get"); GIVARO_ASSERT( i<(int)length()*SIZE_IN_BIT, "invalide index in Bits::get"); int quo = QUO(i); int rem = REM(i); return int((rep[quo] & Table2pow[rem]) >> rem); } // Set all bits void Bits::set() { int len = (int) rep.size(); for (int i=0; i< len; ++i) rep[i] = (base) ~0L; } // Set the i-th bit of *this void Bits::set(const int i) { GIVARO_ASSERT( i>=0, "invalide index in Bits::set"); GIVARO_ASSERT( i<(int)length()*SIZE_IN_BIT, "invalide index in Bits::set"); int quo = QUO(i); int rem = REM(i); rep[quo] |= Table2pow[rem]; } void Bits::clear() { size_t len = rep.size(); for (int i=0; i=0, "invalide index in Bits::clear"); GIVARO_ASSERT( i<(int)length()*SIZE_IN_BIT, "invalide index in Bits::clear"); int quo = QUO(i); int rem = REM(i); rep[quo] ^= !(Table2pow[rem]); // is the true not ? } std::ostream& Bits::print( std::ostream& o ) const { //- o << ""; size_t len = rep.size(); for (int i= int(len-1); i>=0; i--) { for (int j=SIZE_IN_BIT-1; j>=0; j--) if ((rep[i] & Table2pow[j]) !=0) o << '1'; else o << '0'; } return o; } // -- Module definition void Bits::Init(int*, char***) { Table2pow = new Bits::base[SIZE_IN_BIT]; int i; Table2pow[0] = 1; for (i=1; i #include "givaro/givaromm.h" #include "givaro/givarray0.h" namespace Givaro { //! Bits. class Bits { public: typedef size_t base ; Bits () ; Bits (const size_t n) ; // -- n is the number of bits reclaimed Bits( const Bits& B ) ; // -- logical recopy ~Bits() ; // -- All binary operand must have same type: // in are for inplace operator (this receives the result) const Bits operator&( const Bits& A ) const ; Bits& andin( const Bits& A, const Bits B) ; Bits& operator&= (const Bits& A) ; //inline const Bits operator& (const Bits& A) const { return operator&(A) ; } // -- Or const Bits operator|( const Bits& A ) const ; Bits& orin( const Bits& A, const Bits B) ; Bits& operator|=( const Bits& A ) ; //inline const Bits operator| (const Bits& A) const { return operator|(A) ; } // -- Or const Bits operator^( const Bits& A ) const ; Bits& xorin( const Bits& A, const Bits B) ; Bits& operator^=( const Bits& A ) ; //inline const Bits operator^ (const Bits& A) const { return operator^(A) ; } // -- Not const Bits operator~( ) const ; Bits& notin( const Bits& A ) ; //inline const Bits operator~ () const { return operator~() ; } // -- Assignement: physical recopy Bits& copy( const Bits& src ) ; Bits& operator= (const Bits& B); // -- Logical recopy Bits& logcopy( const Bits& src ) ; // -- Returns the number of non zero bits : long numone() const ; // -- Returns the index of non zero bits void indexofone( Array0& ) const ; // -- Returns the length (in bit) of this : size_t length() const ; // -- set to 0 all bits: void clear() ; // -- set to 0 the i-th bit void clear(const int i) ; // -- set to 1 all bits void set() ; // -- set to 1 the i-th bit void set(const int i) ; // -- returns the i-th bit int get(const int i) const ; int operator[] (const int i) const ; int operator[] (const size_t i) const ; // -- IO/methods std::ostream& print( std::ostream& o ) const ; protected: typedef Array0 Rep ; Bits( const Rep& r ) ; Rep rep ; private: static GivModule Module; friend class GivModule; static void Init(int*, char***); static void End(); } ; } // namespace Givaro #include "givaro/givbits.inl" #endif // __GIVARO_bits_H givaro-4.0.2/src/kernel/bstruct/givbits.inl000066400000000000000000000021061274707324300207240ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/bstruct/givbits.inl,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Author: T. Gautier // $Id: givbits.inl,v 1.3 2011-02-02 16:23:55 briceboyer Exp $ // ========================================================================== #ifndef __GIVARO_bits_INL #define __GIVARO_bits_INL namespace Givaro { // -- Copy operators inline Bits& Bits::copy( const Bits& src ) { rep.copy( src.rep ); return *this; } inline Bits& Bits::logcopy( const Bits& src ) { rep.copy( src.rep ); return *this; } inline Bits& Bits::operator= (const Bits& B) { return copy(B); } //-------------------------------------------------inline << operators inline std::ostream& operator<< (std::ostream& o, const Bits& a) { return a.print(o); } } // namespace Givaro #endif // __GIVARO_bits_INL givaro-4.0.2/src/kernel/bstruct/givelem.h000066400000000000000000000043751274707324300203640ustar00rootroot00000000000000// ========================================================================== // $Source // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: T. Gautier // $Id // ========================================================================== /** @file givelem.h * @ingroup bstuct * @brief definition of a reference to an object. */ // #ifndef __GIVARO_Elem_H #define __GIVARO_Elem_H namespace Givaro { //! Elem Ref template struct ElemRef { typedef T Type_t; T& _ref; ElemRef( Type_t& ref ) : _ref(ref) {} operator Type_t& () { return _ref; } operator const Type_t& () const { return _ref; } ElemRef operator= (const Type_t& v) { _ref = v; return *this; } }; //! Elem const Ref template struct ElemConstRef { typedef T Type_t; const T& _ref; ElemConstRef( const Type_t& ref ) : _ref(ref) {} operator const Type_t& () const { return _ref; } }; //! Pair template struct Pair { T1 _val1; T2 _val2; Pair() {} Pair( const T1& v1, const T2& v2) : _val1(v1), _val2(v2) {} T1& first() { return _val1; } const T1& first() const { return _val1; } T2& second() { return _val2; } const T2& second() const { return _val2; } }; //! IO template std::ostream& operator<< (std::ostream& o, const Pair& p ) { return o << '(' << p._val1 << ',' << p._val2 << ')'; } //! IO template std::istream& operator>> (std::istream& fin, Pair& p ) { char ch; // Skip the first blanks: fin >> std::ws; fin.get(ch); if (ch != '(') GivError::throw_error( GivBadFormat("operator>> >: syntax error no '('")); // - read a T1 + ',' fin >> std::ws >> p._val1; fin >> std::ws; fin.get(ch); if (ch != ',') GivError::throw_error( GivBadFormat("operator>> >: syntax error no ','")); // - read a T1 + ')' fin >> p._val2; fin >> std::ws; fin.get(ch); if (ch != ')') GivError::throw_error( GivBadFormat("operator>> >: syntax error no ')'")); return fin; } } // namespace Givaro #endif // __GIVARO_Elem_H givaro-4.0.2/src/kernel/bstruct/givhashtable.h000066400000000000000000000101211274707324300213570ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/bstruct/givhashtable.h,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Author: T. Gautier // $Id: givhashtable.h,v 1.3 2011-02-02 16:23:55 briceboyer Exp $ // ========================================================================== /*! @file givhashtable.h * @ingroup bstruct * @brief hash table */ #ifndef __GIVARO_hashtable_H #define __GIVARO_hashtable_H namespace Givaro { /*! @brief The class Key. * must have : * - default cstor * - operator== : (const Key&, const Key&) -> int * - godel : void -> int * . */ // Generic Key for class T which can be cast to and int template class Key { public: inline Key() {} ; inline Key(const T& aa) : a(aa) {} ; inline operator T& () { return a ; } inline operator const T& () const { return a ; } inline int godel() const { return (int)a ; } inline int operator== (const Key& K) const { return a == K.a ; } private: T a ; } ; //! Hash table template class HashTable { public: // Size of the table : HashTable ( int n = 0 ) ; void allocate( int n ) ; ~HashTable ( ) ; void freeing() ; // Insert and remove functions void insert ( const T& item, const Key& k) ; void insertLast ( const T& item, const Key& k) ; void insertFront( const T& item, const Key& k) ; // remove all entry with key k void remove ( const Key& k) ; void removeall ( ) ; // Get and "Get and Remove" functions, return 0 if no found // select the first item that they found int get ( T& item, const Key& k ) const ; int getrmv ( T& item, const Key& k ) ; // Returns the number of items of the same key : int num_item( const Key& k ) const ; public: // ----- internal data structure // must be private but is access by Iterator class int num ; struct _E { _E( const T& item, const Key& k) : oneitem(item), key(k) {} ; public: T oneitem ; Key key ; _E* next ; _E* pred ; } ; _E** tabH ; // Head of list _E** tabE ; // End of list public: // Iterator of all item of a HashTable : class Iterator { public: Iterator ( HashTable& r) : ref(r) { // search the first non-void pointer in ref.tabH : for (e_curr =0; e_curr < ref.num ; e_curr++) if ((curr =ref.tabH[e_curr]) !=0) break ; } ; operator int() const { return !isend() ; } ; int isend() const { if (e_curr >= ref.num) return 1 ; if (e_curr == ref.num-1) if (curr ==0) return 1 ; return 0 ; } void next() { _E* tmp = curr->next ; if (tmp ==0) { int i ; for (i=e_curr+1 ; i= ref.num) { curr =0 ; e_curr = i ; } else { curr = tmp ; e_curr = i ; } } else curr = tmp ; } ; T curr_item() { return curr->oneitem ; } ; Key curr_key() { return curr->key ; } ; private: HashTable& ref ; int e_curr ; _E* curr ; } ; // Iterator of all item for a same Key : class IteratorKey { public: IteratorKey ( HashTable& r, const Key& k ) : ref(r), key(k) { e_curr = key.godel() % r.num ; curr = ref.tabH[e_curr] ; } ; operator int() const { return !isend() ; } ; int isend() const { return curr == 0 ; } void next() { curr = curr->next ; while ( curr != 0 ) { if (curr->key == key) break ; curr = curr->next ; } } ; T curr_item() { return curr->oneitem ; } ; Key curr_key() { return curr->key ; } ; private: HashTable& ref ; Key key ; int e_curr ; _E* curr ; } ; } ; } // namespace Givaro #include "givaro/givhashtable.inl" #endif // __GIVARO_hashtable_H givaro-4.0.2/src/kernel/bstruct/givhashtable.inl000066400000000000000000000111261274707324300217200ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/bstruct/givhashtable.inl,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Author: T. Gautier // $Id: givhashtable.inl,v 1.3 2011-02-02 16:23:55 briceboyer Exp $ // ========================================================================== // Description: // - hash table implementation #ifndef __GIVARO_hashtable_INL #define __GIVARO_hashtable_INL namespace Givaro { // Size of the table : template HashTable::HashTable ( int n ) { allocate(n) ; } template void HashTable::allocate( int n ) { num = n ; if (n ==0) { tabH = tabE = 0 ; return ; } tabH = new _E*[n] ; tabE = new _E*[n] ; for (int i=0 ; i HashTable::~HashTable() { freeing() ; } template void HashTable::freeing() { if (tabH ==0) return ; for (int i=0 ; inext ; delete curr ; curr = tmp ; } } delete [] tabH ; delete [] tabE ; tabH = 0 ; tabE = 0 ; } template void HashTable::removeall ( ) { if (tabH ==0) return ; int i ; for (i=0 ; inext ; delete curr ; curr = tmp ; } } for (i=0 ; i void HashTable::insert( const T& item, const Key& k ) { if ((tabE ==0) || (tabH ==0)) return ; insertLast( item, k ) ; } template void HashTable::insertLast( const T& item, const Key& k ) { if ((tabE ==0) || (tabH ==0)) return ; unsigned int e = ((unsigned long)k.godel()) % ((unsigned long)num) ; _E* cur = new _E ( item, k) ; if (tabE[e] == 0) { tabH[e] = tabE[e] = cur ; cur->next = cur->pred = 0 ; return ; } tabE[e]->next = cur ; cur->pred = tabE[e] ; cur->next = 0 ; tabE[e] = cur ; } template void HashTable::insertFront( const T& item, const Key& k ) { if ((tabE ==0) || (tabH ==0)) return ; unsigned int e = ((unsigned long)k.godel()) % ((unsigned long)num) ; _E* cur = new _E ( item, k) ; if (tabH[e] == 0) { tabH[e] = tabE[e] = cur ; cur->next = cur->pred = 0 ; return ; } tabH[e]->pred = cur ; cur->next = tabE[e] ; cur->pred = 0 ; tabH[e] = cur ; } // Remove entry with key k template void HashTable::remove ( const Key& k) { if ((tabE ==0) || (tabH ==0)) return ; unsigned int e = ((unsigned long)k.godel()) % ((unsigned long)num) ; _E* cur = tabH[e] ; while (cur !=0) { if (k == cur->key) { if (cur->pred ==0) tabH[e] = cur->next ; else cur->pred->next = cur->next ; if (cur->next ==0) tabE[e] = cur->pred ; else cur->next->pred = cur->pred ; delete cur ; } cur = cur->next ; } } template int HashTable::get ( T& item, const Key& k ) const { if ((tabE ==0) || (tabH ==0)) return 0 ; unsigned int e = ((unsigned long)k.godel()) % ((unsigned long)num) ; _E* cur = tabH[e] ; while (cur !=0) { if (k == cur->key) { item = cur->oneitem ; return 1 ; } cur = cur->next ; } return 0 ; } template int HashTable::getrmv ( T& item, const Key& k ) { if ((tabE ==0) || (tabH ==0)) return 0 ; unsigned int e = ((unsigned long)k.godel()) % ((unsigned long)num) ; _E* cur = tabH[e] ; while (cur !=0) { if (k == cur->key) { item = cur->oneitem ; if (cur->pred ==0) tabH[e] = cur->next ; else cur->pred->next = cur->next ; if (cur->next ==0) tabE[e] = cur->pred ; else cur->next->pred = cur->pred ; delete cur ; return 1 ; } cur = cur->next ; } return 0 ; } // Returns the number of items of the same key : template int HashTable::num_item( const Key& k ) const { if ((tabE ==0) || (tabH ==0)) return 0 ; int count = 0 ; unsigned int e = ((unsigned long)k.godel()) % ((unsigned long)num) ; _E* cur = tabH[e] ; while (cur !=0) { if (k == cur->key) count++ ; cur = cur->next ; } return count ; } } // namespace Givaro #endif // __GIVARO_hashtable_INL givaro-4.0.2/src/kernel/bstruct/givlist0.h000066400000000000000000000057311274707324300204720ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/bstruct/givlist0.h,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Author: T. Gautier // $Id: givlist0.h,v 1.3 2011-02-02 16:23:55 briceboyer Exp $ // ========================================================================== /*! @file givlist0.h * @ingroup bstruct * @brief List of type T with double link and various insert/get/rmv method. * Used reference counting on each node of the list. */ #ifndef __GIVARO_list0_H #define __GIVARO_list0_H #include "givaro/givbasictype.h" #include "givaro/giverror.h" namespace Givaro { //! ListO template class List0 { public : // -- Default cstor : ctsor of s size array List0 (); // -- Recopy cstor : logical copy List0 ( const List0& p ) ; // -- Destructor ~List0 (); // -- Destroy of the list void destroy( ); // -- Physical copy operator List0& copy(const List0& p); // -- Logical recopy operator List0& logcopy(const List0& p); // -- Logical recopy List0& operator= (const List0& p); // -- Return 1 if the list is empty or 0 int is_empty() const; // -- Return the occuped size of the list size_t size() const; // -- insertlast: add at the end of the list void insertlast( const T& ); // -- insertfirst: add at the end of the list void insertfirst( const T& ); // -- The four next methods return 1 is val is set (list not empty) // -- getlast: get the last item of the list, don't remove the item int getlast(T& item) const; // -- getfirst: get the first item of the list, don't remove the item int getfirst(T& item) const; // -- getrmvlast: get and remove the last item of the list int getrmvlast(T& item); // -- getrmvfirst: get and remove the first item of the list int getrmvfirst(T& item); public: struct node { ~node() { GivaroMM::destroy(item,1); GivaroMM::desallocate(item,1); GivaroMM::desallocate(cnt,1); } node* next; node* prev; T* item; int* cnt; // reference counter on item }; friend class Iterator; class Iterator { public: Iterator( List0& lst ) : currnode(lst._head) { } int is_empty() const { return currnode =0; }; void prev() { currnode = currnode->prev;}; void next() { currnode = currnode->next;}; T& get_item() { return *currnode->item;}; const T& get_item() const { return *currnode->item; }; private: List0::node* currnode; }; protected : // --------------------- Public Internal representation size_t _size; // actual size of the list node* _head; // head of the list node* _queue; // queue of the list }; } // namespace Givaro #include "givaro/givlist0.inl" #endif // __GIVARO_list0_H givaro-4.0.2/src/kernel/bstruct/givlist0.inl000066400000000000000000000074511274707324300210260ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/bstruct/givlist0.inl,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Author: T. Gautier // $Id: givlist0.inl,v 1.3 2011-02-02 16:23:55 briceboyer Exp $ // ========================================================================== // inline implementation of the List0 methods #ifndef __GIVARO_list0_INL #define __GIVARO_list0_INL namespace Givaro { template inline List0::List0() : _head(0), _queue(0), _size(0) {} template inline List0::List0( const List0& l) : _head(l._head), _queue(l._queue), _size(l._size) { node* curr = _head; while (curr !=0) { curr->cnt++ ; curr = curr->next ; } } template inline void List0::destroy() { node* curr = _head; while (curr !=0) { node* tmp = curr->next ; if (--*(curr->cnt) ==0) { GivaroMM::destroy(curr,1); GivaroMM::desallocate(curr,1); } curr = tmp ; } _head = _queue = 0 ; _size = 0 ; } template inline List0::~List0() { destroy() ; } template inline List0& List0::copy(const List0& l) { destroy(); node* curr = l._head ; while (curr !=0) { this->insertlast( *(curr->item) ); curr = curr->next ; } return *this; } template inline List0& List0::logcopy(const List0& l) { destroy(); _head = l._head; _queue = l._queue; _size = l._size ; node* curr = _head; while (curr !=0) { curr->cnt++ ; curr = curr->next ; } return *this; } template inline List0& List0::operator=(const List0& l) { return logcpy(l); } template inline size_t List0::size() const { return _size ; } template inline int List0::is_empty() const { return _size ==0; } template void List0::insertlast( const T& val) { node* curr = GivaroMM::allocate(1); curr->cnt = GivaroMM::allocate(1); *(curr->cnt) = 1 ; curr->item = GivaroMM::allocate(1); GivaroMM::initone(curr->item, val); curr->prev = _queue ; curr->next = 0; if (_queue !=0) _queue->next = curr ; _queue = curr ; if (_head ==0) _head = curr ; _size++ ; } template void List0::insertfirst( const T& val) { node* curr = GivaroMM::allocate(1); curr->cnt = GivaroMM::allocate(1); *(curr->cnt) = 1 ; curr->item = GivaroMM::allocate(1); GivaroMM::initone(curr->item, val); curr->prev = 0; curr->next = _head; if (_head !=0) _head->prev = curr ; _head = curr ; if (_queue ==0) _queue = curr ; _size++ ; } template int List0::getlast(T& val) const { if (_queue ==0) return 0; val = *(_queue->item); return 1; } template int List0::getfirst(T& val) const { if (_head ==0) return 0; val = *(_head->item); return 1; } template int List0::getrmvlast(T& val) { if (_queue ==0) return 0; node* curr = _queue; val = *(curr->item); _queue = curr->prev; if (_queue !=0) _queue->next = 0; else _head = 0 ; // one item in the list ! if (--*(curr->cnt) ==0) { GivaroMM::destroy(curr,1); GivaroMM::desallocate(curr,1); } --_size; return 1; } template int List0::getrmvfirst(T& val) { if (_head ==0) return 0; node* curr = _head; val = *(curr->item); _head = curr->next; if (_head !=0) _head->prev = 0; else _queue = 0 ; // one item in the list ! if (--*(curr->cnt) ==0) { GivaroMM::destroy(curr,1); GivaroMM::desallocate(curr,1); } --_size; return 1; } } // namespace Givaro #endif // __GIVARO_list0_INL givaro-4.0.2/src/kernel/bstruct/givstack.h000066400000000000000000000021141274707324300205340ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/bstruct/givstack.h,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Author: T. Gautier // $Id: givstack.h,v 1.3 2011-02-02 16:23:55 briceboyer Exp $ // ========================================================================== /** @file givstack.h * @ingroup bstruct * @brief no doc. */ #ifndef __GIVARO_stack_H #define __GIVARO_stack_H namespace Givaro { //! Stack template class Stack { public : inline Stack() ; inline ~Stack() ; inline void push(const THING&) ; inline void pop() ; inline int isEmpty() const { return (ThePointer == NULL) ; } inline THING top() const ; private : struct inner_stack { THING thething ; inner_stack * next ; } *ThePointer ; } ; } // Givaro #include "givaro/givstack.inl" #endif // __GIVARO_stack_H givaro-4.0.2/src/kernel/bstruct/givstack.inl000066400000000000000000000025031274707324300210710ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/bstruct/givstack.inl,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Author: T. Gautier // $Id: givstack.inl,v 1.3 2011-02-02 16:23:55 briceboyer Exp $ // ========================================================================== #ifndef __GIVARO_stack_INL #define __GIVARO_stack_INL namespace Givaro { template Stack::~Stack() { } template Stack::Stack() { ThePointer = NULL ; } template void Stack::push(const THING& T) { struct inner_stack * Newpt ; Newpt = new struct inner_stack ; Newpt->thething = T ; Newpt->next = ThePointer ; ThePointer = Newpt ; } template void Stack::pop() { if (ThePointer == NULL) { cerr << "*** Error: Empty Stack" << endl ; } else { inner_stack* tmp = ThePointer ; ThePointer = ThePointer->next ; delete tmp ; } } template THING Stack::top() const { return ThePointer->thething ; } } // namespace Givaro #endif // __GIVARO_stack_INL givaro-4.0.2/src/kernel/field/000077500000000000000000000000001274707324300161475ustar00rootroot00000000000000givaro-4.0.2/src/kernel/field/Makefile.am000066400000000000000000000016631274707324300202110ustar00rootroot00000000000000# Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. AM_CPPFLAGS=-I$(top_srcdir) ${GMP_VERSION} AM_CXXFLAGS = @DEFAULT_CFLAGS@ AM_CPPFLAGS+= -I$(top_srcdir)/src/kernel/integer -I$(top_srcdir)/src/kernel -I$(top_srcdir)/src/kernel/system -I$(top_srcdir)/src/kernel/memory -I$(top_srcdir)/src/kernel/bstruct pkginclude_HEADERS= \ StaticElement.h \ gf2.h \ gfq.h \ gfqext.h \ gfqkronecker.h \ extension.h \ givprimes16.h \ givrns.h \ givrnsfixed.h \ chineseremainder.h \ givtablelimits.h \ givrnsfixed.inl \ givrnscstor.inl \ givrnsconvert.inl \ gf2.inl \ gfq.inl noinst_LTLIBRARIES=libgivfield.la libgivfield_la_SOURCES= \ givprimes16.C \ givtablelimits.C EXTRA_DIST=field.doxy givaro-4.0.2/src/kernel/field/StaticElement.h000066400000000000000000000136641274707324300210730ustar00rootroot00000000000000//================================================================== // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // ----------------------------------------------------------------- // Time-stamp: <12 Jun 15 18:43:52 Jean-Guillaume.Dumas@imag.fr> // ----------------------------------------------------------------- // author: Jean-Guillaume.Dumas // date: 2004 //================================================================== /*! @file StaticElement.h * @ingroup zpz * @brief NO DOC */ #ifndef __GIVARO_static_element_H #define __GIVARO_static_element_H #include #include namespace Givaro { //! Static Element template struct StaticElement { typedef DomainStyle Domain; protected: static Domain _domain; typedef typename Domain::Element Rep; Rep _elem; public: static void setDomain(const Domain& D) { StaticElement::_domain = D; } static const Domain & getDomain() { return StaticElement::_domain; } StaticElement() { _domain.init(_elem); } StaticElement(const Integer& i) { _domain.init( (_elem), i); } StaticElement(const double& i) { _domain.init( (_elem), i); } StaticElement(const int32_t& i) { _domain.init( (_elem), (int64_t)i); } StaticElement(const uint32_t& i) { _domain.init( (_elem), (uint64_t)i); } StaticElement(const int64_t& i) { _domain.init( (_elem), i); } StaticElement(const uint64_t& i) { _domain.init( (_elem), i); } operator short() const { int64_t tmp; return (short)_domain.convert(tmp,_elem); } operator unsigned short() const { uint64_t tmp; return (unsigned short)_domain.convert(tmp,_elem); } operator unsigned char() const { uint64_t tmp; return (unsigned char)_domain.convert(tmp,_elem); } operator uint32_t() const { uint64_t tmp; return (uint32_t)_domain.convert(tmp,_elem); } operator int() const { int64_t tmp; return (int)_domain.convert(tmp,_elem); } operator float() const { double tmp; return (float)_domain.convert(tmp,_elem); } operator uint64_t() const { uint64_t tmp; return _domain.convert(tmp,_elem); } operator int64_t() const { int64_t tmp; return _domain.convert(tmp,_elem); } operator double() const { double tmp; return (double)_domain.convert(tmp,_elem); } operator Integer() const { Integer tmp; return _domain.convert(tmp,_elem); } template operator INITCST() const { INITCST tmp; return _domain.convert(tmp,_elem); } template StaticElement(const INITCST& i) { _domain.init( (_elem), i); } template StaticElement(const INITCST& i, const Domain& D) { setDomain(D); _domain.init((_elem), i); } StaticElement& operator=( const StaticElement& e) { _domain.assign((_elem), e._elem); return *this; } bool operator==(const StaticElement& e) { return _domain.areEqual((_elem), e._elem); } bool operator!=(const StaticElement& e) { return !_domain.areEqual((_elem), e._elem); } bool isZero() const { return StaticElement::_domain.isZero(this->_elem); } static bool isZero(const StaticElement& e) { return e.isZero(); } bool isOne() const { return StaticElement::_domain.isOne(this->_elem); } static bool isOne(const StaticElement& e) { return e.isOne(); } bool isMOne() const { return StaticElement::_domain.isMOne(this->_elem); } static bool isMOne(const StaticElement& e) { return e.isMOne(); } inline const StaticElement operator* (const StaticElement& e) const { StaticElement tmp; StaticElement(_domain.mul(tmp._elem,(_elem), e._elem)); return tmp; } inline const StaticElement operator/ (const StaticElement& e) const { StaticElement tmp; StaticElement(_domain.div(tmp._elem,(_elem), e._elem)); return tmp; } inline const StaticElement operator+ (const StaticElement& e) const { StaticElement tmp; StaticElement(_domain.add(tmp._elem,(_elem), e._elem)); return tmp; } inline const StaticElement operator- (const StaticElement& e) const { StaticElement tmp; StaticElement(_domain.sub(tmp._elem,(_elem), e._elem)); return tmp; } inline const StaticElement operator- () const { StaticElement tmp; StaticElement(_domain.neg(tmp._elem,(_elem))); return tmp; } inline StaticElement& operator*= (const StaticElement& e) { _domain.mulin((_elem), e._elem); return *this; } inline StaticElement& operator/= (const StaticElement& e) { _domain.divin((_elem), e._elem); return *this; } inline StaticElement& operator+= (const StaticElement& e) { _domain.addin((_elem), e._elem); return *this; } inline StaticElement& operator-= (const StaticElement& e) { _domain.subin((_elem), e._elem); return *this; } inline StaticElement& operator-- () { _domain.subin(this->_elem, _domain.one); return *this; } inline StaticElement& operator++ () { _domain.addin(this->_elem, _domain.one); return *this; } inline StaticElement operator-- (int) { StaticElement tmp(*this); _domain.subin(this->_elem, _domain.one); return tmp; } inline StaticElement operator++ (int) { StaticElement tmp(*this); _domain.addin(this->_elem, _domain.one); return tmp; } friend inline std::istream& operator>> (std::istream& i, StaticElement& a) { return _domain.read(i,(a._elem)); } friend inline std::ostream& operator<< (std::ostream& o, const StaticElement& a) { return _domain.write(o,(a._elem)); } }; } // namespace Givaro #endif // __GIVARO_static_element_H givaro-4.0.2/src/kernel/field/chineseremainder.h000066400000000000000000000054441274707324300216340ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/zpz/chineseremainder.h,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: T. Gautier // $Id: chineseremainder.h,v 1.12 2011-02-02 16:23:56 briceboyer Exp $ // ========================================================================== /*!@file chineseremainder.h * @ingroup zpz * @brief Chinese Remainder Algorithm for 2 Elements. * @sa * For any number of moduli see zpz/givrns.h or zpz/givrnsfixed.h */ #ifndef __GIVARO_cra_H #define __GIVARO_cra_H #include "givaro/givconfig.h" #include "givaro/giverror.h" namespace Givaro { //! CRA template struct ChineseRemainder { typedef typename Ring::Element RingElement; typedef typename Domain::Element DomainElement; // Computes u = M^-1 in the domain // Then C_12 = (M^-1 mod D)M ChineseRemainder(const Ring& R, const RingElement& M, const Domain& D) : _domain(D) { DomainElement u; _domain.invin( _domain.init(u, M) ); _domain.convert(C_12, u); C_12 *= M; } // Computes res = A + ((e-A) mod D)*(M^-1 mod D)M // Then res mod M == A // And res mod D == e RingElement & operator()( RingElement& res, const RingElement& A, const DomainElement& e) const { DomainElement smallA, smallM; _domain.init(smallA, A); _domain.init(smallM); _domain.sub(smallM, e, smallA); _domain.convert(res, smallM); res *= C_12; return res += A; } private: Domain _domain; RingElement C_12; }; //! CRA2. //! JGD 05.12.2007: not required anymore ... template struct ChineseRemainder { typedef typename Ring::Element RingElement; typedef typename Domain::Element DomainElement; // Computes u = M^-1 in the domain // Then C_12 = (M^-1 mod D)M ChineseRemainder(const Ring& R, const RingElement& M, const Domain& D) : _domain(D) { DomainElement u; _domain.invin( _domain.init(u, M) ); _domain.convert(C_12, u); C_12 *= M; } // Computes res = A + (e-A)*(M^-1 mod D)M // Then res mod M == A // And res mod D == e RingElement & operator()( RingElement& res, const RingElement& A, const DomainElement& e) const { _domain.convert(res, e); res -= A; res *= C_12; return res += A; } private: Domain _domain; RingElement C_12; }; } // namespace Givaro #endif // __GIVARO_cra_H givaro-4.0.2/src/kernel/field/extension.h000077500000000000000000000443641274707324300203520ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @file extension.h * @ingroup zpz * @brief NO DOX */ #ifndef __GIVARO_extension_H #define __GIVARO_extension_H #include #include #include #include #include #include #include "givaro/givtablelimits.h" namespace Givaro { // ----- Forward declaration template class GIV_ExtensionrandIter; //! XXX template Rt FF_EXPONENT_MAX(const Rt p, const Rt maxe = _GIVARO_FF_MAXEXPONENT_) { Rt f = 0; for(Rt i = p; (i < (Rt)_GIVARO_FF_TABLE_MAX) && (f < maxe); ++f, i*=p) ; return f; } //! XXX template Rt FF_SUBEXPONENT_MAX(const Rt p, const Rt e) { Rt f = FF_EXPONENT_MAX(p,e); for( ; f > 1; --f) if ((e % f) == 0) break; return f; } #define NEED_POLYNOMIAL_REPRESENTATION(p,e) ((e) > FF_SUBEXPONENT_MAX((p),(e))) #define EXTENSION(q,expo) ( NEED_POLYNOMIAL_REPRESENTATION((q),(expo)) ? Extension<>((q), (expo)) : GFqDom((q), (expo)) ) //! XXX template int64_t Exponent_Trait(const Field& F) { return 1; } //! XXX template<> inline int64_t Exponent_Trait(const GFqDom& F) { return F.exponent(); } template class Extension; //! XXX template int64_t Exponent_Trait(const Extension& F) { return F.exponent(); } //! Extension template > class Extension { public: typedef Extension Self_t; typedef BFT BaseField_t; typedef typename BFT::Element BFElement; typedef typename Signed_Trait::unsigned_type Residu_t; typedef Poly1FactorDom< BFT, Dense > Pol_t; typedef typename Pol_t::Element PolElement; protected: BaseField_t _bF; Pol_t _pD; PolElement _irred; Residu_t _characteristic; Residu_t _extension_order; Residu_t _exponent; Integer _cardinality; public: bool extension_type () const { return true; } typedef PolElement Element; typedef Element* Element_ptr ; typedef const Element* ConstElement_ptr; Element zero; Element one; Element mOne; Extension() {} Extension ( const Residu_t p, const Residu_t e = 1, const Indeter Y="Y") : _bF(p, FF_SUBEXPONENT_MAX(p,e) ), _pD( _bF, Y ), _characteristic( p ) , _extension_order( e/FF_SUBEXPONENT_MAX(p,e) ), _exponent ( e ) , _cardinality( pow(Integer(p),e) ), zero (_pD.zero) , one (_pD.one), mOne(_pD.mOne) { /* cerr << "Pol Cstor" << endl; */ int64_t basedegree = FF_SUBEXPONENT_MAX(p,e) ; if (basedegree >= (int64_t)e) { std::cerr << "WARNING : Try a direct extension field GFDom instead of a polynomial extension" << std::endl; _bF = BaseField_t(p, 1); _pD = Pol_t(_bF, Y); _extension_order = _exponent; } _pD.creux_random_irreducible( _irred, (int64_t)_extension_order ); } Extension ( const BaseField_t& bF, const Residu_t ex = 1, const Indeter Y="Y") : _bF( bF ) , _pD( _bF, Y ) , _characteristic( (Residu_t) bF.characteristic() ) , _extension_order( (Residu_t)( ex ) ) , _exponent( (Residu_t)(ex + (Residu_t)Exponent_Trait(bF)) ) , _cardinality( (Integer) pow( Integer(bF.cardinality()) , (uint64_t)(ex) ) ) , zero( (Element)(_pD.zero)) , one ( (Element)(_pD.one)) , mOne ( (Element)(_pD.mOne)) { Degree eo ((int64_t)_extension_order); if (_cardinality < (1<<20) ) _pD.creux_random_irreducible( _irred, eo); else _pD.random_irreducible( _irred, eo); } Extension ( const Pol_t& polydomain, const PolElement& Irred) : _bF( polydomain.getdomain() ) , _pD( polydomain ) , _irred( Irred ) , _characteristic( (Residu_t) _bF.characteristic() ) , _extension_order( (Residu_t) _pD.degree(Irred).value() ) , _exponent( (Residu_t)( _extension_order + (Residu_t)Exponent_Trait(_bF)) ) , _cardinality( (Integer) pow( Integer(_bF.cardinality()) , (uint64_t)_extension_order ) ) , zero( (Element)(_pD.zero)) , one ( (Element)(_pD.one)) , mOne ( (Element)(_pD.mOne)) { if (polydomain.isOne(_irred)) { if (_cardinality < (1<<20) ) _pD.creux_random_irreducible( _irred, (int64_t) _extension_order); else _pD.random_irreducible( _irred, (int64_t) _extension_order); } } Extension ( const Self_t& eF) : _bF( eF._bF ), _pD( eF._pD ), _irred( eF._irred ) , _characteristic( eF._characteristic ) , _extension_order( eF._extension_order ) , _exponent( eF._exponent ), _cardinality( eF._cardinality ) , zero (_pD.zero), one (_pD.one), mOne (_pD.mOne) { } Self_t & operator=(const Self_t& eF) { if (this != &eF) { _bF = eF._bF; _pD = eF._pD; _irred = eF._irred; _characteristic = eF._characteristic; _exponent = eF._exponent; _extension_order = eF._extension_order; _cardinality = eF._cardinality; zero = eF.zero; one = eF.one; mOne = eF.mOne; } return *this; } PolElement& init( PolElement& e) const { return _pD.init(e) ; } template PolElement& init( PolElement& e, const XXX& i) const { return _pD.modin( _pD.init(e, i), _irred) ; } PolElement& assign( PolElement& e, const BFElement& a) const { return _pD.assign(e, a) ; } PolElement& assign( PolElement& e, const PolElement& a) const { return _pD.assign(e, a) ; } Integer& convert(Integer& i, const PolElement& e) const { return (Poly1PadicDom(_pD)).eval(i, e); } PolElement& init(PolElement& e, const Integer& i) const { return (Poly1PadicDom(_pD)).radix(e, i, _extension_order); } template XXX& convert( XXX& i, const PolElement& e) const { return _pD.convert( i, e) ; } PolElement& add (PolElement& r, const PolElement& a, const PolElement& b) const { return _pD.add( r, a, b); } PolElement& sub (PolElement& r, const PolElement& a, const PolElement& b) const { return _pD.sub( r, a, b); } PolElement& neg (PolElement& r, const PolElement& a) const { return _pD.neg( r, a ); } PolElement& mul (PolElement& r, const PolElement& a, const PolElement& b) const { return _pD.modin( _pD.mul( r, a, b), _irred ); } PolElement& inv (PolElement& r, const PolElement& a) const { // _pD.write(_pD.write(_pD.write( std::cerr << "(", _pD.invmod( r, a, _irred)) << ") * (", a) << ") == 1 + V * (", _irred) << std::endl; return _pD.invmod( r, a, _irred); } PolElement& div (PolElement& r, const PolElement& a, const PolElement& b) const { return _pD.modin( _pD.mulin( inv(r, b), a), _irred ); } PolElement& axpy (PolElement& r, const PolElement& a, const PolElement& b, const PolElement& c) const { // return _pD.modin( _pD.addin(_pD.mul( r, a, b), c), _irred ); // return _pD.modin( _pD.axpy(r, a, b, c), _irred ); return addin(mul(r,a,b),c); } // -- maxpy: r <- c - a * b mod p PolElement& maxpy (PolElement& r, const PolElement a, const PolElement b, const PolElement c) const { return _pD.modin( _pD.maxpy( r, a, b, c), _irred ); } // -- maxpyin: r <- r - a * b mod p PolElement& maxpyin(PolElement& r, const PolElement a, const PolElement b) const { return _pD.modin( _pD.maxpyin( r, a, b), _irred ); } // -- axmy: r <- a * x - y mod p PolElement& axmy (PolElement& r, const PolElement a, const PolElement b, const PolElement c) const { return subin(mul(r,a,b),c); } // -- axmyin: r <- a * x - r mod p PolElement& axmyin(PolElement& r, const PolElement a, const PolElement b) const { maxpyin(r,a,b); return negin(r); } PolElement& addin(PolElement& r, const PolElement& b) const { return _pD.addin( r, b); } PolElement& subin(PolElement& r, const PolElement& b) const { return _pD.subin( r, b); } PolElement& negin(PolElement& r) const { return _pD.negin( r ); } PolElement& mulin(PolElement& r, const PolElement& b) const { return _pD.modin( _pD.mulin( r, b), _irred ); } PolElement& invin(PolElement& r) const { PolElement a(r); return _pD.invmod( r, a, _irred); } PolElement& divin(PolElement& r, const PolElement& b) const { PolElement tmp; inv(tmp,b); return _pD.modin( _pD.mulin( r, tmp), _irred ); } PolElement& axpyin(PolElement& r, const PolElement& b, const PolElement& c) const { PolElement tmp; _pD.mul(tmp,b,c); return _pD.modin( _pD.addin( r, tmp), _irred ); } bool areEqual (const PolElement& b, const PolElement& c) const { return _pD.areEqual( b, c) ; } bool isZero (const PolElement& b) const { return _pD.isZero(b) ; } bool isOne (const PolElement& b) const { return _pD.isOne(b) ; } bool isMOne (const PolElement& b) const { return _pD.isMOne(b) ; } template Element& random(RandIter& g, Element& r) const { return _pD.random(g,r,Degree((int64_t)_exponent-1)); } template Element& random(RandIter& g, Element& r, int64_t s) const { return _pD.random(g,r,(s>=_exponent?_exponent-1:s)); } template Element& random(RandIter& g, Element& r, const Element& b) const { return _pD.random(g,r,b.size()); } template Element& nonzerorandom(RandIter& g, Element& r) const { return _pD.nonzerorandom(g,r,Degree((int64_t)_exponent-1)); } template Element& nonzerorandom(RandIter& g, Element& r, int64_t s) const { return _pD.nonzerorandom(g,r,(s>=_exponent?_exponent-1:s)); } template Element& nonzerorandom(RandIter& g, Element& r, const Element& b) const { return _pD.nonzerorandom(g,r,b.size()); } typedef GIV_ExtensionrandIter< Self_t, Integer > RandIter; Integer &cardinality (Integer &c) const { return c=_cardinality; } Residu_t cardinality() const { return _cardinality ; } Integer &characteristic (Integer &c) const { return c=_characteristic; } Residu_t characteristic() const { return _characteristic; } int64_t & characteristic(int64_t & c) const { return c = (int64_t) _characteristic; } Residu_t exponent() const { return _exponent; } Residu_t order() const { return _extension_order; } PolElement& irreducible(PolElement& P) const { return _pD.assign(P, _irred); } const PolElement& irreducible() const { return _irred; } const BaseField_t& base_field() const { return _bF; } const Pol_t& polynomial_domain() const { return _pD; } std::ostream& write( std::ostream& o ) const { return _pD.write( _pD.write(o) << "/(", _irred) << ")"; } std::istream& read ( std::istream& s, PolElement& a ) const { _pD.read( s, a); _pD.modin( a, _irred); return s; } std::ostream& write( std::ostream& o, const PolElement& R) const { return _pD.write( o, R ); } std::istream& read( std::istream& o ) const { std::cerr << "READ Extension, NOT YET IMPLEMENTED" << std::endl; return o; } }; //! Extension rand iters template class GIV_ExtensionrandIter { public: /** @name Common Object Interface. * These methods are required of all LinBox random field Element generators. */ //@{ /** Field Element type. * The field Element must contain a default constructor, * a copy constructor, a destructor, and an assignment operator. */ typedef typename ExtensionField::PolElement Element; /** Constructor from field, sampling size, and seed. * The random field Element iterator works in the field F, is seeded * by seed, and it returns any one Element with probability no more * than 1/min(size, F.cardinality()). * A sampling size of zero means to sample from the entire field. * A seed of zero means to use some arbitrary seed for the generator. * This implementation sets the sampling size to be no more than the * cardinality of the field. * @param F LinBox field archetype object in which to do arithmetic * @param size constant integer reference of sample size from which to * sample (default = 0) * @param seed constant integer reference from which to seed random number * generator (default = 0) */ GIV_ExtensionrandIter(const ExtensionField& F, const Type& size = 0, const Type& seed = 0) : _size(size), _givrand( GivRandom(seed) ), _field(F) { Type charact = Type( F.characteristic() ); if ((_size > charact) || (_size == 0) ) _size = charact; } /** Copy constructor. * Constructs ALP_randIter object by copying the random field * Element generator. * This is required to allow generator objects to be passed by value * into functions. * In this implementation, this means copying the random field Element * generator to which R._randIter_ptr points. * @param R ALP_randIter object. */ GIV_ExtensionrandIter(const GIV_ExtensionrandIter& R) : _size(R._size), _givrand(R._givrand) , _field(R._field) {} /** Destructor. * This destructs the random field Element generator object. * In this implementation, this destroys the generator by deleting * the random generator object to which _randIter_ptr points. */ ~GIV_ExtensionrandIter(void) {} // /** Assignment operator. // * Assigns ALP_randIter object R to generator. // * In this implementation, this means copying the generator to // * which R._randIter_ptr points. // * @param R ALP_randIter object. // */ // GIV_ExtensionrandIter& operator= ( const GIV_ExtensionrandIter< ExtensionField, Type >& R ) // { // if (this != &R) // guard against self-assignment // { // _size = R._size; // _givrand = R._givrand; // _field = R._field; // } // return *this; // } /** Random field Element creator with assignement. * This returns a random field Element from the information supplied * at the creation of the generator. * @return random field Element */ Element& random(Element& elt) const { // Create new random Elements elt.resize( (uint64_t)(_field.order())); for(typename Element::iterator it = elt.begin(); it != elt.end() ; ++ it) { int64_t tmp = static_cast((double (_givrand()) / double(_GIVRAN_MODULO_)) * double(_size)); (_field.base_field()).init(*it , tmp); //(_field.base_field()) . random (*it); } return elt; } // Element& random(Element& ) /** Random field Element creator with assignement. * This returns a random field Element from the information supplied * at the creation of the generator. * @return random field Element */ Element& operator()(Element& elt) const { return this->random(elt); } /** Random field Element creator. * This returns a random field Element from the information supplied * at the creation of the generator. * @return random field Element */ Element& operator() (void) { Element* x=new Element; return this->random(*x); } // Element& operator() (void) //@} Common Object Iterface const ExtensionField& ring() { return _field; } private: /// Sampling size Type _size; /// Random generator GivRandom _givrand; /// ExtensionField const ExtensionField& _field; }; // class GIV_ExtensionrandIter } // namespace Givaro #endif //__GIVARO_extension_H /* -*- mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ // vim:sts=4:sw=4:ts=4:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s givaro-4.0.2/src/kernel/field/field.doxy000066400000000000000000000001271274707324300201370ustar00rootroot00000000000000/** @degroup zpz Zpz * @ingroup givaro * @brief Z/pZ. * NO DOC */ // vim:syn=doxygen givaro-4.0.2/src/kernel/field/gf2.h000077500000000000000000000372631274707324300170140ustar00rootroot00000000000000// ========================================================================== // Copyright(c)'1994-2015 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Original authors (LinBox): B. Hovinen, JG Dumas, C. Pernet // Imported and adapted by: A. Breust // ========================================================================== #ifndef __Givaro_field_gf2_H #define __Givaro_field_gf2_H #include #include #include #include "givaro-config.h" #include "givaro/ring-interface.h" #include "givaro/udl.h" namespace Givaro { /** * \brief Integers modulo 2 * * This is a tuned implementation of the field of integers modulo * 2. In particular, when one constructs a VectorDomain object over * this field, highly optimized bit operations will be used to make * vector arithmetic very fast. \ingroup field */ class GF2 : public virtual FiniteFieldInterface { public: const bool zero = false; const bool one = true; const bool mOne = true; /** Element type */ using Self_t = GF2; using Residu_t = uint8_t; using Element = FiniteFieldInterface::Element; using BitVector = std::vector; using BitReference = BitVector::reference; /** Random */ using RandIter = GIV_randIter; Element& random(const GivRandom& g, Element& e) const { return e = static_cast(g() & 1u); } /** @name Object Management */ //@{ /** Default constructor. */ GF2 () {} GF2 (int p, int exp = 1) { assert(p == 2); assert(exp == 1); } /** Copy constructor. * Constructs Givaro::GF2 object by copying the field. * This is required to allow field objects to be passed by value * into functions. * @param F Givaro::GF2 object. */ GF2 (const GF2& F) {} /** Assignment operator. * Required by the archetype * * @param F constant reference to Givaro::Modular object * @return reference to Givaro::Modular object for self */ GF2& operator=(const GF2& F) { return *this; } /** Accessors */ inline Element minElement() const { return false; } inline Element maxElement() const { return true; } /** Access to the modulus */ inline Residu_t residu() const { return 2_ui8; } inline Residu_t size() const { return 2_ui8; } inline Residu_t characteristic() const { return 2_ui8; } inline Residu_t cardinality() const { return 2_ui8; } template inline T& characteristic(T& p) const { return p = 2u; } template inline T& cardinality(T& p) const { return p = 2u; } /** Initialization of field base element from an Integer. * Behaves like C++ allocator construct. * This function assumes the output field base element x has already been * constructed, but that it is not already initialized. * This is not a specialization of the template function because * such a specialization is not allowed inside the class declaration. * @return reference to field base element. * @param x field base element to contain output (reference returned). * @param y Integer. */ Element& init (Element& x, const int32_t &y ) const { return x = y & 1; } Element& init (Element& x, const uint32_t &y ) const { return x = y & 1; } Element& init (Element& x, const int64_t &y ) const { return x = y & 1; } Element& init (Element& x, const uint64_t &y ) const { return x = y & 1; } Element& init (Element& x, const float &y) const { return x = static_cast(y) & 1; } Element& init (Element& x, const double &y) const { return x = static_cast(y) & 1; } Element& init (Element& x, const Integer& y) const { return x = y & (uint32_t)1; } Element& init(Element& x) const { return x = false; } BitReference init(BitReference x, const Integer& y = 0) const { return x = y & (uint32_t)1; } /** Conversion of field base element to a template class T. * This function assumes the output field base element x has already been * constructed, but that it is not already initialized. * @return reference to template class T. * @param x template class T to contain output (reference returned). * @param y constant field base element. */ Integer& convert (Integer& x, const Element& y) const { return x = y; } BitReference convert (BitReference x, const Element& y) const { return x = y; } template T& convert (T& x, const Element& y) const { return x = Caster(y); } /** Assignment of one field base element to another. * This function assumes both field base elements have already been * constructed and initialized. * @return reference to x * @param x field base element (reference returned). * @param y field base element. */ Element& assign (Element& x, const Element& y) const { return x = y; } BitReference assign (BitReference x, const Element& y) const { return x = y; } /** Cardinality. * Return Integer representing cardinality of the domain. * Returns a non-negative Integer for all domains with finite * cardinality, and returns -1 to signify a domain of infinite * cardinality. * @return Integer representing cardinality of the domain */ Integer& cardinality (Integer& c) const { return c = 2; } /** Characteristic. * Return Integer representing characteristic of the domain. * Returns a positive Integer to all domains with finite characteristic, * and returns 0 to signify a domain of infinite characteristic. * @return Integer representing characteristic of the domain. */ Integer& characteristic (Integer& c) const { return c = 2; } //@} Object Management /** @name Arithmetic Operations * x <- y op z; x <- op y * These operations require all elements, including x, to be initialized * before the operation is called. Uninitialized field base elements will * give undefined results. */ //@{ /** Equality of two elements. * This function assumes both field base elements have already been * constructed and initialized. * @return boolean true if equal, false if not. * @param x field base element * @param y field base element */ bool areEqual (const Element& x, const Element& y) const { return x == y; } /** Zero equality. * Test if field base element is equal to zero. * This function assumes the field base element has already been * constructed and initialized. * @return boolean true if equals zero, false if not. * @param x field base element. */ bool isZero (const Element& x) const { return !x; } /** One equality. * Test if field base element is equal to one. * This function assumes the field base element has already been * constructed and initialized. * @return boolean true if equals one, false if not. * @param x field base element. */ bool isOne (const Element& x) const { return x; } /** MOne equality. * Test if field base element is equal to one. * This function assumes the field base element has already been * constructed and initialized. * @return boolean true if equals one, false if not. * @param x field base element. */ bool isMOne (const Element& x) const { return x; } //@} Arithmetic Operations /** @name Input/Output Operations */ //@{ /** Print field. * @return output stream to which field is written. * @param os output stream to which field is written. */ std::ostream& write (std::ostream& os) const; /** Read field. * @return input stream from which field is read. * @param is input stream from which field is read. */ std::istream& read (std::istream& is); /** Print field base element. * This function assumes the field base element has already been * constructed and initialized. * @return output stream to which field base element is written. * @param os output stream to which field base element is written. * @param x field base element. */ std::ostream& write (std::ostream& os, const Element& x) const; /** Read field base element. * @pre This function assumes the field base element has already been * constructed and initialized. * @return input stream from which field base element is read. * @param is input stream from which field base element is read. * @param x field base element. */ std::istream& read (std::istream& is, Element& x) const; std::istream &read (std::istream &is, BitReference x) const; //@} /** @name Arithmetic Operations * x <- y op z; x <- op y * These operations require all elements, including x, to be initialized * before the operation is called. Uninitialized field base elements will * give undefined results. */ //@{ /** Addition. * x = y + z * This function assumes all the field base elements have already been * constructed and initialized. * @return reference to x. * @param x field base element (reference returned). * @param y field base element. * @param z field base element. */ Element& add (Element& x, const Element& y, const Element& z) const; BitReference add (BitReference x, const Element& y, const Element& z) const; /** Subtraction. * x = y - z * This function assumes all the field base elements have already been * constructed and initialized. * @return reference to x. * @param x field base element (reference returned). * @param y field base element. * @param z field base element. */ Element& sub (Element& x, const Element& y, const Element& z) const; BitReference sub (BitReference x, const Element& y, const Element& z) const; /** Multiplication. * x = y * z * This function assumes all the field base elements have already been * constructed and initialized. * @return reference to x. * @param x field base element (reference returned). * @param y field base element. * @param z field base element. */ Element& mul (Element& x, const Element& y, const Element& z) const; BitReference mul (BitReference x, const Element& y, const Element& z) const; /** Division. * x = y / z * This function assumes all the field base elements have already been * constructed and initialized. * @return reference to x. * @param x field base element (reference returned). * @param y field base element. * @param z field base element. */ Element& div (Element& x, const Element& y, const Element& z ) const; BitReference div (BitReference x, const Element& y, const Element& z ) const; /** Additive Inverse (Negation). * x = - y * This function assumes both field base elements have already been * constructed and initialized. * @return reference to x. * @param x field base element (reference returned). * @param y field base element. */ Element& neg (Element& x, const Element& y) const; BitReference neg (BitReference x, const Element& y) const; /** Multiplicative Inverse. * x = 1 / y * This function assumes both field base elements have already been * constructed and initialized. * @return reference to x. * @param x field base element (reference returned). * @param y field base element. */ Element& inv (Element& x, const Element& y) const; BitReference inv (BitReference x, const Element& y) const; /** Natural AXPY. * @return reference to r. * @param r * @param a * @param x * @param y */ BitReference axpy (BitReference r, const Element& a, const Element& x, const Element& y) const; Element& axpy (Element& r, const Element& a, const Element& x, const Element& y) const; /** Natural AXMY. * @return reference to r. * @param r * @param a * @param x * @param y */ BitReference axmy (BitReference r, const Element& a, const Element& x, const Element& y) const; Element& axmy (Element& r, const Element& a, const Element& x, const Element& y) const; /** Natural MAXPY. * @return reference to r. * @param r * @param a * @param x * @param y */ BitReference maxpy (BitReference r, const Element& a, const Element& x, const Element& y) const; Element& maxpy (Element& r, const Element& a, const Element& x, const Element& y) const; //@} Arithmetic Operations /** @name Inplace Arithmetic Operations * x <- x op y; x <- op x */ //@{ /** Inplace Addition. * x += y * This function assumes both field base elements have already been * constructed and initialized. * @return reference to x. * @param x field base element (reference returned). * @param y field base element. */ Element& addin (Element& x, const Element& y) const; BitReference addin (BitReference x, const Element& y) const; /** Inplace Subtraction. * x -= y * This function assumes both field base elements have already been * constructed and initialized. * @return reference to x. * @param x field base element (reference returned). * @param y field base element. */ Element& subin (Element& x, const Element& y) const; BitReference subin (BitReference x, const Element& y) const; /** Inplace Multiplication. * x *= y * This function assumes both field base elements have already been * constructed and initialized. * @return reference to x. * @param x field base element (reference returned). * @param y field base element. */ Element& mulin (Element& x, const Element& y) const; BitReference mulin (BitReference x, const Element& y) const; /** Inplace Division. * x /= y * This function assumes both field base elements have already been * constructed and initialized. * @return reference to x. * @param x field base element (reference returned). * @param y field base element. */ Element& divin (Element& x, const Element& y) const; BitReference divin (BitReference x, const Element& y) const; /** Inplace Additive Inverse (Inplace Negation). * x = - x * This function assumes the field base element has already been * constructed and initialized. * @return reference to x. * @param x field base element (reference returned). */ Element& negin (Element& x) const; BitReference negin (BitReference x) const; /** Inplace Multiplicative Inverse. * x = 1 / x * This function assumes the field base elementhas already been * constructed and initialized. * @return reference to x. * @param x field base element (reference returned). */ Element& invin (Element& x) const; BitReference invin (BitReference x) const; /** Inplace AXPY. * @return reference to r. * @param r field element (reference returned). * @param a field element. * @param x field element. */ Element& axpyin (Element& r, const Element& a, const Element& x) const; BitReference axpyin (BitReference r, const Element& a, const Element& x) const; /** Inplace AXMY. * @return reference to r. * @param r field element (reference returned). * @param a field element. * @param x field element. */ Element& axmyin (Element& r, const Element& a, const Element& x) const; BitReference axmyin (BitReference r, const Element& a, const Element& x) const; /** Inplace MAXPY. * @return reference to r. * @param r field element (reference returned). * @param a field element. * @param x field element. */ Element& maxpyin (Element& r, const Element& a, const Element& x) const; BitReference maxpyin (BitReference r, const Element& a, const Element& x) const; //@} Inplace Arithmetic Operations static inline int maxCardinality() { return 2; } }; // class GF2 } #include "givaro/gf2.inl" #endif givaro-4.0.2/src/kernel/field/gf2.inl000077500000000000000000000131611274707324300173360ustar00rootroot00000000000000// ========================================================================== // Copyright(c)'1994-2015 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Original authors (LinBox): B. Hovinen, JG Dumas, C. Pernet // Imported and adapted by: A. Breust // ========================================================================== #ifndef __Givaro_field_gf2_INL #define __Givaro_field_gf2_INL namespace Givaro { inline std::ostream& GF2::write (std::ostream& os) const { return os << "GF2"; } inline std::istream& GF2::read (std::istream& is) { return is; } inline std::ostream& GF2::write (std::ostream &os, const Element& x) const { return os << x; } inline std::istream& GF2::read (std::istream& is, Element& x) const { is >> x; return is; } inline std::istream& GF2::read (std::istream& is, BitReference x) const { bool a; is >> a; x = a; return is; } inline GF2::Element& GF2::add (Element& x, const Element& y, const Element& z) const { return x = y ^ z; } inline GF2::BitReference GF2::add (BitReference x, const Element& y, const Element& z) const { return x = y ^ z; } inline GF2::Element& GF2::sub (Element& x, const Element& y, const Element& z) const { return x = y ^ z; } inline GF2::BitReference GF2::sub (BitReference x, const Element& y, const Element& z) const { return x = y ^ z; } inline GF2::Element& GF2::mul (Element& x, const Element& y, const Element& z) const { return x = y & z; } inline GF2::BitReference GF2::mul (BitReference x, const Element& y, const Element& z) const { return x = y & z; } inline GF2::Element& GF2::div (Element& x, const Element& y, const Element& z ) const { assert(z); return x = y; } inline GF2::BitReference GF2::div (BitReference x, const Element& y, const Element& z ) const { assert(z); return x = y; } inline GF2::Element& GF2::neg (Element& x, const Element& y) const { return x = y; } inline GF2::BitReference GF2::neg (BitReference x, const Element& y) const { return x = y; } inline GF2::Element& GF2::inv (Element& x, const Element& y) const { assert(y); return x = y; } inline GF2::BitReference GF2::inv (BitReference x, const Element& y) const { assert(y); return x = y; } inline GF2::BitReference GF2::axpy (BitReference r, const Element& a, const Element& x, const Element& y) const { return r = (a & x) ^ y; } inline GF2::Element& GF2::axpy (Element& r, const Element& a, const Element& x, const Element& y) const { return r = (a & x) ^ y; } inline GF2::BitReference GF2::axmy (BitReference r, const Element& a, const Element& x, const Element& y) const { return r = (a & x) ^ y; } inline GF2::Element& GF2::axmy (Element& r, const Element& a, const Element& x, const Element& y) const { return r = (a & x) ^ y; } inline GF2::BitReference GF2::maxpy (BitReference r, const Element& a, const Element& x, const Element& y) const { return r = (a & x) ^ y; } inline GF2::Element& GF2::maxpy (Element& r, const Element& a, const Element& x, const Element& y) const { return r = (a & x) ^ y; } inline GF2::Element& GF2::addin (Element& x, const Element& y) const { return x ^= y; } inline GF2::BitReference GF2::addin (BitReference x, const Element& y) const { return x = x ^ y; } inline GF2::Element& GF2::subin (Element& x, const Element& y) const { return x ^= y; } inline GF2::BitReference GF2::subin (BitReference x, const Element& y) const { return x = x ^ y; } inline GF2::Element& GF2::mulin (Element& x, const Element& y) const { return x &= y; } inline GF2::BitReference GF2::mulin (BitReference x, const Element& y) const { return x = (bool)x & y; } inline GF2::Element& GF2::divin (Element& x, const Element& y ) const { assert(y); return x; } inline GF2::BitReference GF2::divin (BitReference x, const Element& y ) const { assert(y); return x; } inline GF2::Element& GF2::negin (Element& x) const { return x; } inline GF2::BitReference GF2::negin (BitReference x) const { return x; } inline GF2::Element& GF2::invin (Element& x) const { assert(x); return x; } inline GF2::BitReference GF2::invin (BitReference x) const { assert(x); return x; } inline GF2::Element& GF2::axpyin (Element& r, const Element& a, const Element& x) const { return r ^= a & x; } inline GF2::BitReference GF2::axpyin (BitReference r, const Element& a, const Element& x) const { return r = r ^ (a & x); } inline GF2::Element& GF2::axmyin (Element& r, const Element& a, const Element& x) const { return r ^= a & x; } inline GF2::BitReference GF2::axmyin (BitReference r, const Element& a, const Element& x) const { return r = r ^ (a & x); } inline GF2::Element& GF2::maxpyin (Element& r, const Element& a, const Element& x) const { return r ^= a & x; } inline GF2::BitReference GF2::maxpyin (BitReference r, const Element& a, const Element& x) const { return r = r ^ (a & x); } } #endif givaro-4.0.2/src/kernel/field/gfq.h000077500000000000000000000300501274707324300170760ustar00rootroot00000000000000// ========================================================================== // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // file: gfq.h // Time-stamp: <17 Jul 16 16:12:52 Jean-Guillaume.Dumas@imag.fr> // date: 1999 // version: // author: Jean-Guillaume.Dumas /*! @file gfq.h * @ingroup zpz * @brief Arithmetic on GF(p^k), with p a prime number less than 2^16. */ #ifndef __GIVARO_gfq1_H #define __GIVARO_gfq1_H #include "givaro/givconfig.h" #include "givaro/givinteger.h" #include "givaro/givranditer.h" #include "givaro/givpoly1factor.h" #include #include #ifdef __GIVARO_COUNT__ #include #endif namespace Givaro { //! class GFqDom template class GFqDom { protected: typedef typename Signed_Trait::unsigned_type UTT; typedef TT Rep; typedef typename std::vector::size_type UT ; public: Rep zero; Rep one; Rep mOne; protected: UTT _characteristic; // Field Characteristic (p) UTT _exponent; // Extension degree (k) UTT _irred; // Irreducible polynomial in p-adic UTT _q; // p^k UTT _qm1; // p^k-1 // G is a generator of GF(q) // p is GF(q)'s characteristic // log2pol[ i ] = G^i(p) // pol2log[ j ] = i such that log2pol[i] = j // plus1[i] = k such that G^i + 1 = G^k std::vector _log2pol; std::vector _pol2log; std::vector _plus1; // Floating point representations double _dcharacteristic; public: UTT zech2padic(UTT x) const { return _log2pol[x]; }; UTT padic2zech(UTT x) const { return _pol2log[x]; }; public: typedef GFqDom Self_t; typedef Rep Element; typedef Element* Element_ptr ; typedef const Element* ConstElement_ptr; // class Element { // public: // mutable Rep _value; // Element() {} // }; typedef UTT Residu_t; // ----- Representation of vector of the Element typedef Rep* Array; typedef const Rep* constArray; GFqDom(): zero(0), one(1), mOne(-1), _log2pol(0), _pol2log(0),_plus1(0) {} // Automatic construction GFqDom( const UTT P, const UTT e = 1); // Construction with prescribed irreducible polynomial // coefficients of the vector should be integers-like // there will be a call to this->init to build the // representation of the irreducible polynomial template GFqDom(const UTT P, const UTT e, const Vector& modPoly); // Construction with prescribed irreducible polynomial // and with prescribed generator polynomial // coefficients of the vector should be integers-like // there will be a call to this->init to build the // representation of both polynomials template GFqDom( const UTT P, const UTT e, const Vector& modPoly, const Vector& genPoly); GFqDom( const GFqDom& F) : zero(F.zero), one(F.one), mOne(F.mOne), _characteristic(F._characteristic), _exponent(F._exponent), _irred(F._irred), _q(F._q), _qm1(F._qm1), _log2pol(F._log2pol), _pol2log(F._pol2log), _plus1(F._plus1), _dcharacteristic(F._dcharacteristic) {} // Allows to choose the randomization // and therefore the field generator // template // GFqDom(RandIter& g, const UTT P, const UTT e = 1); // Destructor // ~GFqDom() {}; GFqDom& operator=( const GFqDom& F) { this->zero = F.zero; this->one = F.one; this->mOne = F.mOne; this->_characteristic = F._characteristic; this->_dcharacteristic = F._dcharacteristic; this->_exponent = F._exponent; this->_irred = F._irred; this->_q = F._q; this->_qm1 = F._qm1; this->_log2pol = F._log2pol; this->_pol2log = F._pol2log; this->_plus1 = F._plus1; return *this; } // Access to the modulus, characteristic, size, exponent UTT residu() const; UTT characteristic() const; Integer& characteristic(Integer& p) const { return p=characteristic(); } uint64_t& characteristic(uint64_t& p) const { return p=(uint64_t)_characteristic; } static inline Residu_t maxCardinality() { return 65536u; } static inline Residu_t minCardinality() { return 2; } UTT cardinality() const; template T& cardinality(T& p) const { return p = T(_q); } UTT size() const; UTT exponent() const; // Internal representation of the used generator Rep& generator(Rep&) const; // p-adic representation of the used generator UTT generator() const; // p-adic representation of the used irreducible polynomial UTT irreducible() const; // the internal representation of the polynomial X // where the indeterminate is replaced by the characteristic // This has no meaning if exponent is 1 Rep sage_generator() const; Rep indeterminate() const; Rep& indeterminate(Rep&) const; // Initialization of Elements Rep& init(Rep& r) const { return r=zero;} Rep& init( Rep&, const int32_t) const ; Rep& init( Rep&, const uint32_t) const ; Rep& init( Rep&, const int64_t) const ; Rep& init( Rep&, const uint64_t) const ; Rep& init( Rep&, const Integer) const; Rep& init( Rep&, const float) const ; Rep& init( Rep&, const double) const ; Rep& init( Rep& a, std::istream& s ) const { return read(a,s); } // Reduction of Elements Rep& reduce(Rep& r) const; Rep& reduce(Rep& r, const Rep& e) const; // Initialization of a polynomial template class Vector,template class Alloc> Rep& init( Rep&, const Vector >&); // -- Misc: r <- a mod p Rep& assign (Rep&, const Integer) const; Rep& assign (Rep&, const Rep) const; void assign ( const size_t sz, Array r, constArray a ) const; // --- IO methods for the Domain std::istream& read ( std::istream& s ); std::ostream& write( std::ostream& s ) const; std::ostream& write( std::ostream& s , const std::string& ) const; // --- IO methods for the Elements std::istream& read ( std::istream& s, Rep& a ) const; std::ostream& write( std::ostream& s, const Rep a ) const; // Conversions of the elements std::ostream& convert(std::ostream& s, const Rep a ) const { return write(s,a); } TT convert(const Rep) const ; int64_t& convert(int64_t&, const Rep) const ; uint64_t& convert(uint64_t&, const Rep) const ; int32_t& convert(int32_t&, const Rep) const ; float& convert(float&, const Rep) const ; double& convert(double&, const Rep) const ; uint32_t& convert(uint32_t&, const Rep) const ; Integer& convert(Integer&, const Rep) const ; // Test operators inline int operator== (const GFqDom& a) const; inline int operator!= (const GFqDom& a) const; // Miscellaneous functions bool areEqual( const Rep&, const Rep& ) const; bool areNEqual ( const Rep , const Rep ) const; bool isZero( const Rep ) const; bool isnzero( const Rep ) const; bool isOne ( const Rep ) const; bool isMOne ( const Rep ) const; bool isunit ( const Rep ) const; // Element belongs to prime subfield size_t length ( const Rep ) const; // ----- Operations with reduction: r <- a op b mod p, r <- op a mod p Rep& mul (Rep& r, const Rep a, const Rep b) const; Rep& div (Rep& r, const Rep a, const Rep b) const; Rep& add (Rep& r, const Rep a, const Rep b) const; Rep& sub (Rep& r, const Rep a, const Rep b) const; Rep& neg (Rep& r, const Rep a) const; Rep& inv (Rep& r, const Rep a) const; Rep& mulin (Rep& r, const Rep a) const; Rep& divin (Rep& r, const Rep a) const; Rep& addin (Rep& r, const Rep a) const; Rep& subin (Rep& r, const Rep a) const; Rep& negin (Rep& r) const; Rep& invin (Rep& r) const; // ----- Operations with reduction: r <- a op b mod p, r <- op a mod p void mul (const size_t sz, Array r, constArray a, constArray b) const; void mul (const size_t sz, Array r, constArray a, Rep b) const; void div (const size_t sz, Array r, constArray a, constArray b) const; void div (const size_t sz, Array r, constArray a, Rep b) const; void add (const size_t sz, Array r, constArray a, constArray b) const; void add (const size_t sz, Array r, constArray a, Rep b) const; void sub (const size_t sz, Array r, constArray a, constArray b) const; void sub (const size_t sz, Array r, constArray a, Rep b) const; void neg (const size_t sz, Array r, constArray a) const; void inv (const size_t sz, Array r, constArray a) const; Rep& axpy (Rep& r, const Rep a, const Rep b, const Rep c) const; void axpy (const size_t sz, Array r, Rep a, constArray x, constArray y) const; void axpy (const size_t sz, Array r, Rep a, constArray x, Rep c) const; // -- axpyin: r <- r + a * x mod p Rep& axpyin (Rep& r, const Rep a, const Rep b) const; void axpyin (const size_t sz, Array r, Rep a, constArray x) const; // -- axmy: r <- a * b - c mod p Rep& axmy (Rep& r, const Rep a, const Rep b, const Rep c) const; void axmy (const size_t sz, Array r, Rep a, constArray x, constArray y) const; void axmy (const size_t sz, Array r, Rep a, constArray x, Rep c) const; // -- maxpy: r <- c - a * b mod p Rep& maxpy (Rep& r, const Rep a, const Rep b, const Rep c) const; // -- axmyin: r <- a * b - r mod p Rep& axmyin (Rep& r, const Rep a, const Rep b) const; // void axmyin (const size_t sz, Array r, Rep a, constArray x) const; // // -- sqpyin: r <- r + a * a mod p // Rep& sqpyin (Rep& r, const Rep a) const; // -- maxpyin: r <- r - a * b mod p Rep& maxpyin (Rep& r, const Rep a, const Rep b) const; void maxpyin (const size_t sz, Array r, Rep a, constArray x) const; // <- \sum_i a[i], return 1 if a.size() ==0, void reduceadd ( Rep& r, const size_t sz, constArray a ) const; // <- \prod_i a[i], return 1 if a.size() ==0, void reducemul ( Rep& r, const size_t sz, constArray a ) const; // <- \sum_i a[i] * b[i] Rep& dotprod ( Rep& r, const size_t sz, constArray a, constArray b ) const; // ----- random generators // ----- random generators template Rep& random(RandIter& g, Rep& r) const ; template Rep& random(RandIter& g, Rep& r, int64_t s) const ; template Rep& random(RandIter& g, Rep& r, const Rep& b) const ; template Rep& nonzerorandom(RandIter& g, Rep& r) const ; template Rep& nonzerorandom(RandIter& g, Rep& r, int64_t s) const ; template Rep& nonzerorandom(RandIter& g, Rep& r, const Rep& b) const ; typedef GIV_randIter< GFqDom, Rep> RandIter; #ifdef __GIVARO_COUNT__ void clear() { _add_count = 0; _mul_count = 0; _neg_count = 0; _div_count = 0; _sub_count = 0; _inv_count = 0; _add_call = 0; _mul_call = 0; _neg_call = 0; _div_call = 0; _sub_call = 0; _inv_call = 0; } void info() const { std::cerr << "Mul Call: " << _mul_call << ", real: " << _mul_count << std::endl; std::cerr << "Add Call: " << _add_call << ", real: " << _add_count << std::endl; std::cerr << "Div Call: " << _div_call << ", real: " << _div_count << std::endl; std::cerr << "Sub Call: " << _sub_call << ", real: " << _sub_count << std::endl; std::cerr << "Neg Call: " << _neg_call << ", real: " << _neg_count << std::endl; std::cerr << "Inv Call: " << _inv_call << ", real: " << _inv_count << std::endl; } #endif #ifdef __GIVARO_COUNT__ static int64_t _add_count; static int64_t _mul_count; static int64_t _neg_count; static int64_t _div_count; static int64_t _sub_count; static int64_t _inv_count; static int64_t _add_call; static int64_t _mul_call; static int64_t _neg_call; static int64_t _div_call; static int64_t _sub_call; static int64_t _inv_call; #endif static void Init(); static void End(); }; } // namespace Givaro #include "givaro/gfq.inl" #endif // __GIVARO_gfq1_H // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s givaro-4.0.2/src/kernel/field/gfq.inl000077500000000000000000001140261274707324300174370ustar00rootroot00000000000000// ========================================================================== // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // file: gfq.inl // Description: // Arithmetic on GF(q) // Bugs: // Authors : JG Dumas // Modified 20 Mar 03 by Clement Pernet // Time-stamp: <09 Jul 08 08:47:17 Jean-Guillaume.Dumas@imag.fr> // ========================================================================== #ifndef __GIVARO_gfq_INL #define __GIVARO_gfq_INL #include #include #include #include #include // Warning : valid iff b != c #ifndef __GIVARO_COUNT__ #define _GIVARO_GFQ_ADD(c, a, b, mun, plun) { if ((b)==0) (c)=(a); else if ((a)==0) (c)=(b); else { \ (c) = (a)-(b); \ (c) = ((c)>0)?(c):(c)+ (TT)(mun); \ (c) = (plun)[(UT)(c)]; \ if (c) { \ (c) = (c)+(b); \ (c) = ((c)>0)?(c):(c)+(TT)(mun); \ } } } #define _GIVARO_GFQ_NEG(res, a, mo, mun) { if ( (a)==0 ) (res)=0; else\ { (res) = (Rep) ( (a) - (Rep) (mo) ) ; (res) = (Rep) ( ((res)>0)?(res):(res)+(Rep)(mun) ) ; } } // Warning : valid iff a != c // if not use AUTOSUB ... #define _GIVARO_GFQ_SUB(c, a, b, mo, mun, plun) { if ((a)==0) {_GIVARO_GFQ_NEG(c,b,mo,mun);} else if ((b)==0) (c)=(a); else { \ (c) = (b)-(a)-(TT)(mo); \ (c) = ((c)>0)?(c):(c)+(TT)(mun); \ (c) = ((c)>0)?(c):(c)+ (TT)(mun); \ (c) = (plun)[(UT)(c)]; \ if (c) { \ (c) = (c)+(a); \ (c) = ((c)>0)?(c):(c)+(TT)(mun); \ } } } #define _GIVARO_GFQ_AUTOSUB(c, b, mo, mun, plun) { if ((c)==0) {_GIVARO_GFQ_NEG(c,b,mo,mun);} else if ((b)!=0) { \ (c) = (c)-(b)-(TT)(mo); \ (c) = ((c)>0)?(c):(c)+(TT)(mun); \ (c) = ((c)>0)?(c):(c)+ (TT)(mun); \ (c) = (plun)[(UT)(c)]; \ if (c) { \ (c) = (c)+(b); \ (c) = ((c)>0)?(c)-(TT)(mo):(c)+(TT)(mo); \ (c) = ((c)>0)?(c):(c)+(TT)(mun); \ } } } #define _GIVARO_GFQ_MUL(res, a, b, mun) { if ( ((a)==0) || ((b)==0) ) { (res) =0; } else { (res) = (((res) = (a)+(b) )>(TT)(mun))?(res)-(TT)(mun):(res); } } // JGD 02.04.1998 : if a==1, a /= a used to be --> 0 !!! #define _GIVARO_GFQ_INV(res, a, mun) { (res) = (Rep)( (Rep)(mun)-(a) ); (res)= (Rep) ( (res)?(res):(Rep)(mun) ); } #define _GIVARO_GFQ_DIV(res, a, b, mun) { \ if ( (a)==0 ) { (res)=0; } else { (res) = (((res)=(a)-(b))>0)?(res):(res)+(TT)(mun); } } #define _GIVARO_GFQ_SQ(res, a, mun) { if ( (a)==0) (res) = 0; else \ { (res) = ( (a) << 1) - (mun); \ (res) = ((res)>0)?(res):(res)+ (mun); } } // plun -> 1+^c - (q-1) !!! // Warning : valid iff b != c #define _GIVARO_GFQ_SQADD(c,a,b,mun,plun) { \ if ((a)==0) { (c)=(b); \ } else if ((b)==0) { \ (c) = (( (c)=((a) << 1) - (mun) )>0)?(c):(c) + (mun); \ } else { \ (c) = (( (c) = ((a) << 1)-(b)-(mun) )<0)?(c)+(mun):(c); \ if ( (c) = (plun)[(UT)(((c)>0)?(c):(c)+(mun))] ) { \ (c) = (( (c) = (c)+(b) )>0)?(c):(c)+(mun); } \ }\ } // Warning : valid iff b != c #define _GIVARO_GFQ_MULADD(c,a1,a2,b,mun,plun) { \ if (((a1)==0) || ((a2)==0)) { (c)=(b); \ } else if ((b)==0) { \ (c) = (( (c)=(a1)+(a2) - (TT)(mun) )>0)?(c):(c) + (TT)(mun); \ } else { \ (c) = (( (c) = (a1)+(a2)-(b)-(TT)(mun) )<0)?(c)+(TT)(mun):(c); \ if (( (c) = (plun)[(UT)( ((c)>0)?(c):(c)+(TT)(mun) )]) ) { \ (c) = (( (c) = (c)+(b) )>0)?(c):(c)+(TT)(mun); }\ }\ } // Warning : valid iff b != c #define _GIVARO_GFQ_MULSUB(c,a1,a2,b,mo,mun,plun) { \ if (((a1)==0) || ((a2)==0)) { (c)=(b); \ } else if ((b)==0) { \ (c) = (( (c)=(a1)+(a2) - (mo) -(mun) )>0)?(c):(c) + (mun); \ (c) = (c)>0?(c):(c) + (mun); \ } else { \ (c) = (( (c) = (a1)+(a2)-(b)-(mun) - (mo) )<0)?(c)+(mun):(c); \ (c) = (c)<0?(c)+(mun):(c); \ if ( (c) = (plun)[(UT)( ((c)>0)?(c):(c)+(mun) )] ) { \ (c) = (( (c) = (c)+(b) )>0)?(c):(c)+(mun); }\ }\ } #else // Warning : valid iff b != c #define _GIVARO_GFQ_ADD(c, a, b, mun, plun) { ++_add_call; if ((b)==0) (c)=(a); else if ((a)==0) (c)=(b); else { \ (c) = (a)-(b); \ (c) = ((c)>0)?(c):(c)+ (mun); \ (c) = (plun)[(UT)(c)]; \ if (c) { \ (c) = (c)+(b); \ (c) = ((c)>0)?(c):(c)+(mun); \ } ++_add_count; } } #define _GIVARO_GFQ_NEG(res, a, mo, mun) { ++_neg_call; if ( (a)==0 ) (res)=0; else\ { (res) = (Rep) ((a) - (mo)) ; (res) = (Rep) ( ((res)>0)?(res):(res)+(mun) ); ++_neg_count; } } // Warning : valid iff a != c // if not use AUTOSUB ... #define _GIVARO_GFQ_SUB(c, a, b, mo, mun, plun) { ++_sub_call; if ((a)==0) {_GIVARO_GFQ_NEG(c,b,mo,mun);} else if ((b)==0) (c)=(a); else { \ (c) = (b)-(a)-(mo); \ (c) = ((c)>0)?(c):(c)+(mun); \ (c) = ((c)>0)?(c):(c)+ (mun); \ (c) = (plun)[(UT)(c)]; \ if (c) { \ (c) = (c)+(a); \ (c) = ((c)>0)?(c):(c)+(mun); \ } ++_sub_count; } } #define _GIVARO_GFQ_AUTOSUB(c, b, mo, mun, plun) { ++_sub_call; if ((c)==0) {_GIVARO_GFQ_NEG(c,b,mo,mun);} else if ((b)!=0) { \ (c) = (c)-(b)-(mo); \ (c) = ((c)>0)?(c):(c)+(mun); \ (c) = ((c)>0)?(c):(c)+ (mun); \ (c) = (plun)[(UT)(c)]; \ if (c) { \ (c) = (c)+(b); \ (c) = ((c)>0)?(c)-(mo):(c)+(mo); \ (c) = ((c)>0)?(c):(c)+(mun); \ } ++_sub_count; } } #define _GIVARO_GFQ_MUL(res, a, b, mun) { ++_mul_call; if ( ((a)==0) || ((b)==0) ) { (res) =0; } else { (res) = (((res) = (a)+(b)-(mun) )>0)?(res):(res)+ (mun); ++_mul_count; } } // JGD 02.04.1998 : if a==1, a /= a used to be --> 0 !!! #define _GIVARO_GFQ_INV(res, a, mun) { ++_inv_call; (res) = (mun)-(a); (res)=(res)?(res):(mun); ++_inv_count; } #define _GIVARO_GFQ_DIV(res, a, b, mun) { ++_div_call; \ if ( (a)==0 ) { (res)=0; } else { (res) = (((res)=(a)-(b))>0)?(res):(res)+(mun); ++_div_count; } } #define _GIVARO_GFQ_SQ(res, a, mun) { ++_mul_call; if ( (a)==0) (res) = 0; else \ { (res) = ( (a) << 1) - (mun); \ (res) = ((res)>0)?(res):(res)+ (mun); ++_mul_count; } } // plun -> 1+^c - (q-1) !!! // Warning : valid iff b != c #define _GIVARO_GFQ_SQADD(c,a,b,mun,plun) { ++_mul_call; ++_add_call; \ if ((a)==0) { (c)=(b); \ } else if ((b)==0) { \ (c) = (( (c)=((a) << 1) - (mun) )>0)?(c):(c) + (mun); \ ++_mul_count; } else { \ (c) = (( (c) = ((a) << 1)-(b)-(mun) )<0)?(c)+(mun):(c); \ if ( (c) = (plun)[(UT)(((c)>0)?(c):(c)+(mun))] ) { \ (c) = (( (c) = (c)+(b) )>0)?(c):(c)+(mun); } \ ++_mul_count; ++_add_count; }\ } // Warning : valid iff b != c #define _GIVARO_GFQ_MULADD(c,a1,a2,b,mun,plun) { ++_mul_call; ++_add_call; \ if (((a1)==0) || ((a2)==0)) { (c)=(b); \ } else if ((b)==0) { \ (c) = (( (c)=(a1)+(a2) - (mun) )>0)?(c):(c) + (mun); \ ++_mul_count; } else { \ (c) = (( (c) = (a1)+(a2)-(b)-(mun) )<0)?(c)+(mun):(c); \ if ( (c) = (plun)[(UT)( ((c)>0)?(c):(c)+(mun) )] ) { \ (c) = (( (c) = (c)+(b) )>0)?(c):(c)+(mun); }\ ++_mul_count; ++_add_count; }\ } // Warning : valid iff b != c #define _GIVARO_GFQ_MULSUB(c,a1,a2,b,mo,mun,plun) { ++_mul_call; ++_sub_call; \ if (((a1)==0) || ((a2)==0)) { (c)=(b); \ } else if ((b)==0) { \ (c) = (( (c)=(a1)+(a2) - (mo) -(mun) )>0)?(c):(c) + (mun); \ (c) = (c)>0?(c):(c) + (mun); \ ++_mul_count; ++_neg_count; } else { \ (c) = (( (c) = (a1)+(a2)-(b)-(mun) - (mo) )<0)?(c)+(mun):(c); \ (c) = (c)<0?(c)+(mun):(c); \ if ( (c) = (plun)[(UT)( ((c)>0)?(c):(c)+(mun) )] ) { \ (c) = (( (c) = (c)+(b) )>0)?(c):(c)+(mun); }\ ++_mul_count; ++_sub_count; }\ } #endif namespace Givaro { template inline typename GFqDom::Residu_t GFqDom::residu() const { return _q; } template inline typename GFqDom::Residu_t GFqDom::cardinality() const { return _q; } template inline typename GFqDom::Residu_t GFqDom::characteristic() const { return _characteristic; } template inline typename GFqDom::Residu_t GFqDom::generator() const { return _log2pol[1]; } template inline typename GFqDom::Rep& GFqDom::generator(Rep& g) const { return g=1; } template inline typename GFqDom::Rep& GFqDom::indeterminate(Rep& X) const { if (exponent()>1) { return X=(Rep)_pol2log[(size_t)_characteristic]; } else { return X=one; } } template inline typename GFqDom::Rep GFqDom::indeterminate() const { Rep X; return indeterminate(X); } template inline typename GFqDom::Rep GFqDom::sage_generator() const { return indeterminate(); } template inline typename GFqDom::Residu_t GFqDom::irreducible() const { return _irred; } template inline typename GFqDom::Residu_t GFqDom::exponent() const { return _exponent; } template inline typename GFqDom::Residu_t GFqDom::size() const { return _q; } // ------------------------- Miscellaneous functions template inline bool GFqDom::areEqual(const Rep& a, const Rep& b) const { return a == b ; } template inline bool GFqDom::areNEqual(const Rep a, const Rep b) const { return a != b ; } template inline bool GFqDom::isZero(const Rep a) const { return a == GFqDom::zero ; } template inline bool GFqDom::isnzero(const Rep a) const { return a != GFqDom::zero ; } template inline bool GFqDom::isOne(const Rep a) const { return a == GFqDom::one ; } template inline bool GFqDom::isMOne(const Rep a) const { return a == GFqDom::mOne ; } template inline bool GFqDom::isunit(const Rep a) const { // Fermat : x^(p-1) = 1 whenever x is a unit return ( ( a * (_characteristic-1) ) % _qm1 ) == 0; } template inline size_t GFqDom::length(const Rep ) const { return sizeof(TT) ;} // ----------- Usefull method : template inline typename GFqDom::Rep& GFqDom::mul (Rep& r, const Rep a, const Rep b) const { _GIVARO_GFQ_MUL(r,a,b, GFqDom::_qm1) ; return r; } template inline typename GFqDom::Rep& GFqDom::mulin (Rep& r, const Rep a) const { _GIVARO_GFQ_MUL(r,r,a, GFqDom::_qm1) ; return r; } template inline typename GFqDom::Rep& GFqDom::div (Rep& r, const Rep a, const Rep b) const { _GIVARO_GFQ_DIV(r, a, b, GFqDom::_qm1) ; return r; } template inline typename GFqDom::Rep& GFqDom::divin (Rep& r, const Rep a) const { _GIVARO_GFQ_DIV(r, r, a, GFqDom::_qm1) ; return r; } template inline typename GFqDom::Rep& GFqDom::add (Rep& r, const Rep a, const Rep b) const { _GIVARO_GFQ_ADD(r, a, b, GFqDom::_qm1, GFqDom::_plus1) ; return r; } template inline typename GFqDom::Rep& GFqDom::addin (Rep& r, const Rep a) const { _GIVARO_GFQ_ADD(r, r, a, GFqDom::_qm1, GFqDom::_plus1) ; return r; } template inline typename GFqDom::Rep& GFqDom::sub (Rep& r, const Rep a, const Rep b) const { _GIVARO_GFQ_SUB(r, a, b, GFqDom::mOne, GFqDom::_qm1, GFqDom::_plus1) ; return r; } template inline typename GFqDom::Rep& GFqDom::subin (Rep& r, const Rep a) const { _GIVARO_GFQ_AUTOSUB(r, a, GFqDom::mOne, GFqDom::_qm1, GFqDom::_plus1) ; return r; } template inline typename GFqDom::Rep& GFqDom::neg (Rep& r, const Rep a) const { _GIVARO_GFQ_NEG(r, a, GFqDom::mOne, GFqDom::_qm1) ; return r; } template inline typename GFqDom::Rep& GFqDom::negin (Rep& r) const { _GIVARO_GFQ_NEG(r, r, GFqDom::mOne, GFqDom::_qm1) ; return r; } template inline typename GFqDom::Rep& GFqDom::inv (Rep& r, const Rep a) const { _GIVARO_GFQ_INV(r, a, GFqDom::_qm1) ; return r; } template inline typename GFqDom::Rep& GFqDom::invin (Rep& r) const { _GIVARO_GFQ_INV(r, r, GFqDom::_qm1) ; return r; } template inline typename GFqDom::Rep& GFqDom::axpy (Rep& r, const Rep a, const Rep b, const Rep c) const { _GIVARO_GFQ_MULADD(r,a,b,c, GFqDom::_qm1, GFqDom::_plus1) ; return r; } template inline typename GFqDom::Rep& GFqDom::axpyin (Rep& r, const Rep a, const Rep b) const { Rep tmp = r; _GIVARO_GFQ_MULADD((r),a,b,tmp, (GFqDom::_qm1), (GFqDom::_plus1)) ; return r; } // r <- r-a*b template inline typename GFqDom::Rep& GFqDom::maxpyin (Rep& r, const Rep a, const Rep b) const { // Rep tmp = r; // _GIVARO_GFQ_MULSUB(r,a,b,tmp, mOne, _qm1, _plus1) ; Rep tmp; _GIVARO_GFQ_MUL(tmp,a,b, _qm1) ; _GIVARO_GFQ_AUTOSUB(r,tmp, mOne, _qm1, _plus1) ; return r; } template inline typename GFqDom::Rep& GFqDom::axmyin (Rep& r, const Rep a, const Rep b) const { this->maxpyin(r,a,b); return this->negin(r); } // r <- a*b-c template inline typename GFqDom::Rep& GFqDom::axmy (Rep& r, const Rep a, const Rep b, const Rep c) const { _GIVARO_GFQ_MUL(r,a,b, GFqDom::_qm1) ; _GIVARO_GFQ_AUTOSUB(r,c, GFqDom::mOne, GFqDom::_qm1, GFqDom::_plus1) ; return r; } template inline typename GFqDom::Rep& GFqDom::maxpy (Rep& r, const Rep a, const Rep b, const Rep c) const { _GIVARO_GFQ_MUL(r,a,b, GFqDom::_qm1) ; _GIVARO_GFQ_SUB(r,c,r, GFqDom::mOne, GFqDom::_qm1, GFqDom::_plus1) ; return r; } // -- inline array operations between Reps template inline void GFqDom::mul (const size_t sz, Array r, constArray a, constArray b) const { for ( size_t i=sz ; --i ; ) { _GIVARO_GFQ_MUL(r[i],a[i],b[i], GFqDom::_qm1) ; } } template inline void GFqDom::mul (const size_t sz, Array r, constArray a, Rep b) const { for ( size_t i=sz ; --i ; ) { _GIVARO_GFQ_MUL(r[i],a[i],b, GFqDom::_qm1) ; } } template inline void GFqDom::div (const size_t sz, Array r, constArray a, constArray b) const { for ( size_t i=sz ; --i ; ) { _GIVARO_GFQ_DIV(r[i],a[i],b[i], GFqDom::_qm1) ; } } template inline void GFqDom::div (const size_t sz, Array r, constArray a, Rep b) const { for ( size_t i=sz ; --i ; ) { _GIVARO_GFQ_DIV(r[i],a[i],b, GFqDom::_qm1) ; } } template inline void GFqDom::add (const size_t sz, Array r, constArray a, constArray b) const { for ( size_t i=sz ; --i ; ) { _GIVARO_GFQ_ADD(r[i], a[i], b[i], GFqDom::_qm1, GFqDom::_plus1) ; } } template inline void GFqDom::add (const size_t sz, Array r, constArray a, Rep b) const { for ( size_t i=sz ; --i ; ) { _GIVARO_GFQ_ADD(r[i], a[i], b, GFqDom::_qm1, GFqDom::_plus1) ; } } template inline void GFqDom::sub (const size_t sz, Array r, constArray a, constArray b) const { for ( size_t i=sz ; --i ; ) { _GIVARO_GFQ_SUB(r[i], a[i], b[i], GFqDom::mOne, GFqDom::_qm1, GFqDom::_plus1) ; } } template inline void GFqDom::sub (const size_t sz, Array r, constArray a, Rep b) const { for ( size_t i=sz ; --i ; ) { _GIVARO_GFQ_SUB(r[i], a[i], b, GFqDom::mOne, GFqDom::_qm1, GFqDom::_plus1) ; } } template inline void GFqDom::neg (const size_t sz, Array r, constArray a) const { for ( size_t i=sz ; --i ; ) { _GIVARO_GFQ_NEG(r[i], a[i], GFqDom::mOne, GFqDom::_qm1) ; } } template inline void GFqDom::inv (const size_t sz, Array r, constArray a) const { for ( size_t i=sz ; --i ; ) { _GIVARO_GFQ_INV(r[i], a[i], GFqDom::_qm1) ; } } template inline void GFqDom::axpy (const size_t sz, Array r, Rep a, constArray x, constArray y) const { for ( size_t i=sz ; --i ; ) { _GIVARO_GFQ_MULADD(r[i], a, x[i], y[i], GFqDom::_qm1, GFqDom::_plus1) ; } } template inline void GFqDom::axpyin (const size_t sz, Array r, Rep a, constArray x) const { Rep tmp; for ( size_t i=sz ; --i ; ) { tmp = r[i]; _GIVARO_GFQ_MULADD(r[i], a, x[i], tmp, GFqDom::_qm1, GFqDom::_plus1) ; } } template inline void GFqDom::axpy (const size_t sz, Array r, Rep a, constArray x, Rep y) const { for ( size_t i=sz ; --i ; ) { _GIVARO_GFQ_MULADD(r[i], a, x[i], y, GFqDom::_qm1, GFqDom::_plus1) ; } } template inline void GFqDom::axmy (const size_t sz, Array r, Rep a, constArray x, constArray y) const { for ( size_t i=sz ; --i ; ) { _GIVARO_GFQ_MUL(r[i], a, x[i], GFqDom::_qm1) ; _GIVARO_GFQ_AUTOSUB(r[i], y[i], GFqDom::mOne, GFqDom::_qm1, GFqDom::_plus1) ; } } template inline void GFqDom::axmy (const size_t sz, Array r, Rep a, constArray x, Rep y) const { for ( size_t i=sz ; --i ; ) { _GIVARO_GFQ_MUL(r[i], a, x[i], GFqDom::_qm1) ; _GIVARO_GFQ_AUTOSUB(r[i], y, GFqDom::mOne, GFqDom::_qm1, GFqDom::_plus1) ; } } template inline void GFqDom::maxpyin (const size_t sz, Array r, Rep a, constArray x) const { Rep tmp; for ( size_t i=sz ; --i ; ) { _GIVARO_GFQ_MUL(tmp, a, x[i], GFqDom::_qm1) ; _GIVARO_GFQ_AUTOSUB(r[i], tmp, GFqDom::mOne, GFqDom::_qm1, GFqDom::_plus1) ; } } // ------------------------------------ // Input - Output of the Domain // template inline std::istream& GFqDom::read (std::istream& s) { char ch; s >> std::ws >> ch; if (ch != '(') std::cerr << "GFqDom::read: syntax error: no '('" << std::endl; UTT p; s >> p; s >> std::ws >> ch; if (ch == ')') *this = GFqDom(p,UTT(1)); else { if (ch != '^') std::cerr << "GFqDom::read: syntax error: no '^'" << std::endl; UTT k; s >> std::ws >> k; if (ch != ')') std::cerr << "GFqDom::read: syntax error: no ')'" << std::endl; *this = GFqDom(p,k); // Seems like a useless copy... better have a reinit function. } return s; } template inline std::ostream& GFqDom::write (std::ostream& o) const { return o << "GFqDom<> (" << _characteristic << '^' << _exponent << ")"; } template inline std::ostream& GFqDom::write (std::ostream& o, const std::string& s) const { return this->write(o) << s; } // ------------------------------------ // Input - Output of the Elements // template inline std::istream& GFqDom::read (std::istream& i, Rep& a) const { TT t; i >> t; init(a,t); return i; } template inline typename GFqDom::Rep& GFqDom::reduce( Rep& r, const Rep& e) const { return r = e; } template inline typename GFqDom::Rep& GFqDom::reduce( Rep& r ) const { return r; } // template // template // inline typename GFqDom::Element& GFqDom::init(Element& r, const XXX& value) const { // return r = (Rep)_pol2log[ (UT)(value) ]; // } template inline typename GFqDom::Rep& GFqDom::init( Rep& r, const double Residu ) const { double tr = Residu ; if (tr <0) { // -a = b [p] <==> a = p-b [p] tr = -tr; if (tr > Signed_Trait::max() ) tr = fmod(tr,(double)_q); //tr -= (double)floor(tr * _inversecharacteristic)*_dcharacteristic; else{ if (tr >= (TT)_q ) tr = double((UTT)tr % _q) ; } if ((bool)tr) return r = (Rep)_pol2log[ UT(_q - (UTT)tr) ]; else return r = zero; } else { if (tr > Signed_Trait::max() ) tr = fmod(tr, (double)_q); //tr -= (double)floor(tr * _inversecharacteristic)*_dcharacteristic; else{ if (tr >= (TT)_q ) tr = double((UTT)tr % _q) ; } return r = (Rep)_pol2log[ (UT)tr ]; } } template inline typename GFqDom::Rep& GFqDom::init( Rep& r, const float Residu ) const { return init(r, static_cast(Residu)); } template inline typename GFqDom::Rep& GFqDom::init( Rep& r, const int32_t Residu ) const { int32_t tr = Residu ; if (tr <0) { // -a = b [p] // a = p-b [p] tr = -tr; if (tr >= (int32_t)_q ) tr =(int32_t)( (UT)tr % _q ) ; if (tr) return r = (Rep) _pol2log[(UT) _q - (UT)tr ]; else return r = zero; } else { if (tr >= (int32_t)_q ) tr = int32_t((uint32_t)tr % _q ) ; return r = (Rep)_pol2log[ (UT)tr ]; } } template inline typename GFqDom::Rep& GFqDom::init( Rep& r, const int64_t Residu ) const { int64_t tr = Residu ; if (tr <0) { // -a = b [p] // a = p-b [p] tr = -tr; if (tr >= (int64_t)_q ) tr = tr % (int64_t)_q ; if (tr) return r = (typename GFqDom::Rep) _pol2log[ (size_t)_q - (size_t)tr ]; else return r = zero; } else { if (tr >= (int64_t)_q ) tr = tr % (int64_t)_q ; return r = (Rep)_pol2log[ (size_t)tr ]; } } template inline typename GFqDom::Rep& GFqDom::init( Rep& r, const Integer Residu ) const { UTT tr; if (Residu <0) { // -a = b [p] // a = p-b [p] if ( Residu <= (Integer)(-_q) ) tr = (UTT) ( (-Residu) % (UTT)_q ); else tr = UTT(-Residu); if (tr) return r = (Rep)_pol2log[ _q - (UTT)tr ]; else return r = zero; } else { /* Residu >=0 */ if (Residu >= (Integer)_q ) tr = (UTT)(Residu % (UTT)_q ); else tr = UTT(Residu); return r = (Rep)_pol2log[ (size_t)tr ]; } } template inline typename GFqDom::Rep& GFqDom::init( Rep& r, const uint64_t Residu ) const { uint64_t tr = Residu ; if (tr >= _q ) tr =tr % (uint64_t) _q ; return r = (Rep)_pol2log[ (size_t)tr ]; } template inline typename GFqDom::Rep& GFqDom::init( Rep& r, const uint32_t Residu ) const { uint64_t tr = static_cast(Residu) ; if (tr >= _q ) tr = tr % (uint64_t) _q ; return r = (Rep)_pol2log[ (size_t)tr ]; } template inline double& GFqDom::convert (double& r, const Rep a) const { return r = (double)_log2pol[ (UT)a] ; } template inline float& GFqDom::convert (float& r, const Rep a) const { return r = (float)_log2pol[ (UT)a] ; } template inline std::ostream& GFqDom::write (std::ostream& o, const Rep a) const { return o << _log2pol[ (UT)a] ; } template inline int64_t& GFqDom::convert (int64_t& r, const Rep a) const { return r = (int64_t)_log2pol[ (uint64_t)a] ; } template inline uint64_t& GFqDom::convert (uint64_t& r, const Rep a) const { return r = (uint64_t)_log2pol[ (uint64_t)a] ; } template inline int32_t& GFqDom::convert (int32_t& r, const Rep a) const { return r = (int32_t)_log2pol[ (UT)a] ; } template inline uint32_t& GFqDom::convert (uint32_t& r, const Rep a) const { return r = (uint32_t)_log2pol[ (UT)a] ; } template inline TT GFqDom::convert (const Rep a) const { return (TT)_log2pol[ (UT)a] ; } template inline Integer& GFqDom::convert (Integer& r, const Rep a) const { return r = (Integer)_log2pol[ (UT)a] ; } // --------- // -- Initialization operations // --------- template template class Vector, template class Alloc> inline typename GFqDom::Rep& GFqDom::init( Rep& r, const Vector >& P) { static Self_t PrimeField(this->_characteristic); typedef Poly1Dom< Self_t, Dense > PolDom; static PolDom Pdom( PrimeField ); typedef Poly1PadicDom< GFqDom, Dense > PadicDom; static PadicDom PAD(Pdom); Degree d; Pdom.degree(d, P); if (d >= (int64_t)this->_exponent) { static typename PadicDom::Element tmp; static typename PadicDom::Element Irreducible = PAD.radix(tmp, this->_irred); // All this was to get the irreducible polynomial // Now we can mod it out typename PolDom::Element modP; Pdom.mod(modP, P, Irreducible); TT tr; PAD.eval(tr, modP); return r = (Rep) this->_pol2log[(size_t) tr ]; } else { TT tr; PAD.eval(tr, P); return r = (Rep) this->_pol2log[ (size_t)tr ]; } } template inline typename GFqDom::Rep& GFqDom::assign( Rep& r, const Integer a) const { return init (r, a); } template inline typename GFqDom::Rep& GFqDom::assign( Rep& r, const Rep a) const { return r = a; } template inline void GFqDom::assign( const size_t sz, Array r, constArray a ) const { TT tr; // for ( size_t i=sz ; --i ; ) for ( size_t i=sz; i--;) { tr = a[i] ; if (tr <0) { // -a = b [p] // a = p-b [p] tr = -tr; if (tr >=_characteristic ) tr = tr % _characteristic ; if (tr) r[i] = _pol2log[ _characteristic - tr ]; else r[i] = 0; } else { if (tr >=_characteristic ) tr = tr % _characteristic ; r[i] = _pol2log[ tr ]; } } } template inline typename GFqDom::Rep& GFqDom::dotprod ( Rep& r, const size_t sz, constArray a, constArray b ) const { if (sz) { _GIVARO_GFQ_MUL(r,a[0],b[0],_qm1); Rep tmp; for( int i= (int)sz; --i; ) { _GIVARO_GFQ_MUL(tmp,a[i],b[i],_qm1); _GIVARO_GFQ_ADD(r,r,tmp,_qm1,_plus1); } return r; } else return r = zero; } // ----- random generators template template inline typename GFqDom::Rep& GFqDom::nonzerorandom(randIter& g, Rep& a) const { a = Rep( ((UTT)(g()) % (_q-1)) + 1); return a = (a<0?a+(Rep)_q:a); } template template inline typename GFqDom::Rep& GFqDom::random(randIter& g, Rep& a) const { a = Rep( (UTT)(g()) % _q); return a = (a<0?a+(Rep)_q:a); } template template inline typename GFqDom::Rep& GFqDom::random(randIter& g, Rep& r, int64_t s) const { return random(g,r); } template template inline typename GFqDom::Rep& GFqDom::random(randIter& g, Rep& r, const Rep& b) const { return random(g,r); } template template inline typename GFqDom::Rep& GFqDom::nonzerorandom(randIter& g, Rep& r, int64_t s) const { return nonzerorandom(g,r); } template template inline typename GFqDom::Rep& GFqDom::nonzerorandom(randIter& g, Rep& r, const Rep& b) const { return nonzerorandom(g,r); } template inline GFqDom::GFqDom(const UTT P, const UTT e) // Precondition P prime : zero(0) , one ( (TT)power(P,e) - 1 ) , mOne( (P==2)? (one) : (one >> 1) ) // 1 == -1 in GF(2^k) , _characteristic(P) , _exponent(e) , _q( (UTT) one + 1 ) , _qm1 ( (UTT) one ) , _log2pol((UT) _q ) , _pol2log( (UT)_q ) , _plus1( (UT)_q ) , _dcharacteristic( (double)P ) { // 1 is represented by q-1, zero by 0 _log2pol[0] = (UTT) zero; if (e <= 1) { IntNumTheoDom<> NTD; IntNumTheoDom<>::Rep IP(P), pr; // UTT seed = (UTT) ( NTD.Integer2long( NTD.lowest_prim_root(pr, IP) ) ); UTT seed; NTD.convert(seed, NTD.lowest_prim_root(pr, IP) ); UTT accu = 1; for(UTT i=1; i Zp(P,1); // typedef CyclotomicTable< GFqDom, Dense > PolDom; // PolDom Pdom( Zp, e ); typedef Poly1FactorDom< Self_t, Dense > PolDom; PolDom Pdom( Zp ); typename PolDom::Element F, G, H; // F is irreducible of degree e over Zp // G is a primitive polynomial for F // Pdom.random_prim_root(F,G, Degree(e)); // F is an irreducible factor of the // (p^e-1) th cyclotomic polynomial // G is a primitive polynomial for F : X // Pdom.getcyclo(F); // Pdom.init(G, Degree(1), Zp.one); // F is irreducible of degree e over Zp // with X as a primitive polynomial #ifndef GIVARO_RANDOM_IRREDUCTIBLE_PRIMITIVE_ROOT Pdom.ixe_irreducible(F, Degree((long)e)); // Pdom.init(G, Degree(1), Zp.one); // Pdom.assign(G, Degree(1), Zp.one); Pdom.init(G, Degree(1)); #else Pdom.random_irreducible(F, Degree((int64_t)e)); Pdom.give_random_prim_root(G,F); #endif Pdom.assign(H, G); typedef Poly1PadicDom< GFqDom, Dense > PadicDom; PadicDom PAD(Pdom); PAD.eval(_log2pol[1], H); PAD.eval(_irred, F); for (UTT i = 2; i < _qm1; ++i) { Pdom.mulin(H, G); Pdom.modin(H, F); PAD.eval(_log2pol[(UT)i], H); } _log2pol[(UT)_qm1] = 1; } _log2pol[0] = 0; // pol2log[ j ] = i such that log2pol[i] = j for (UTT i = 0; i < _q; ++i) _pol2log[ (UT)_log2pol[(UT)i] ] = i; // plus1[i] = k such that G^i + 1 = G^k // WARNING : in the plus1 table, we now pre-substract (_q - 1) _plus1[0] = 0; UTT a,b,r; for (UTT i = 1; i < _q; ++i) { a = _log2pol[(UT)i]; r = a % P; if (r == (P - 1)) b = a - r; else b = a + 1; // WARNING : in the plus1 table we pre-substract (_q - 1) _plus1[(UT)i] = (TT)(_pol2log[(UT)b] - _qm1); } // -1 + 1 == 0 _plus1[(UT)mOne] = 0; } // Dan Roche 6-15-04, adapted my/ported back to Givaro // by Martin Albrecht 10-06-06 // This constructor takes a vector of ints that represent the polynomial // to use (for modular arithmetic on the extension field). template template inline GFqDom::GFqDom(const UTT P, const UTT e, const Vector& modPoly): zero(0) , one ((TT) power(P,e) - 1 ) , mOne( (P==2)? (one) : ( one >> 1) ) // 1 == -1 in GF(2^k) , _characteristic(P) , _exponent(e) , _q( (UTT) one + 1 ) , _qm1 ( (UTT)one ) , _log2pol( (UT)_q ) , _pol2log( (UT)_q ) , _plus1( (UT)_q ) , _dcharacteristic( (double)P ) { // 1 is represented by q-1, zero by 0 _log2pol[0] = (UTT)zero; GFqDom Zp(P,1); typedef Poly1FactorDom< GFqDom, Dense > PolDom; PolDom Pdom( Zp ); typename PolDom::Element Ft, F(e+1), G, H; for( size_t i = 0; i < F.size(); ++i ) Zp.init( F[i], modPoly[i]); Pdom.give_prim_root(G,F); Pdom.assign(H,G); typedef Poly1PadicDom< GFqDom, Dense > PadicDom; PadicDom PAD(Pdom); PAD.eval(_log2pol[1],H); PAD.eval(_irred, F); for (UTT i = 2; i < _qm1; ++i) { Pdom.mulin(H, G); Pdom.modin(H, F); PAD.eval(_log2pol[i], H); } _log2pol[_qm1] = 1; _log2pol[0] = 0; for (UTT i = 0; i < _q; ++i) _pol2log[ _log2pol[i] ] = i; _plus1[0] = 0; UTT a,b,r; for (UTT i = 1; i < _q; ++i) { a = _log2pol[i]; r = a % P; if (r == (P - 1)) b = a - r; else b = a + 1; _plus1[i] = (TT)_pol2log[b] - (TT)_qm1; } _plus1[size_t(mOne)] = 0; } // Construction with prescribed irreducible polynomial // and with prescribed generator polynomial // coefficients of the vector should be integers-like // there will be a call to this->init to build the // representation of both polynomials template template inline GFqDom::GFqDom(const UTT P, const UTT e, const Vector& modPoly, const Vector& genPoly): zero(0) , one ((TT) power(P,e) - 1 ) , mOne( (P==2)? (one) : ( one >> 1) ) // 1 == -1 in GF(2^k) , _characteristic(P) , _exponent(e) , _q( (UTT) one + 1 ) , _qm1 ( (UTT)one ) , _log2pol( (UT)_q ) , _pol2log( (UT)_q ) , _plus1( (UT)_q ) , _dcharacteristic( (double)P ) { // 1 is represented by q-1, zero by 0 _log2pol[0] = (UTT)zero; GFqDom Zp(P,1); typedef Poly1FactorDom< GFqDom, Dense > PolDom; PolDom Pdom( Zp ); typename PolDom::Element Ft, F(e+1), G(genPoly.size()), H; for( size_t i = 0; i < F.size(); ++i ) Zp.init( F[i], modPoly[i]); for( size_t i = 0; i < G.size(); ++i ) Zp.init( G[i], genPoly[i]); Pdom.assign(H,G); typedef Poly1PadicDom< GFqDom, Dense > PadicDom; PadicDom PAD(Pdom); PAD.eval(_log2pol[1],H); PAD.eval(_irred, F); for (UTT i = 2; i < _qm1; ++i) { Pdom.mulin(H, G); Pdom.modin(H, F); PAD.eval(_log2pol[i], H); } _log2pol[_qm1] = 1; _log2pol[0] = 0; for (UTT i = 0; i < _q; ++i) _pol2log[ _log2pol[i] ] = i; _plus1[0] = 0; UTT a,b,r; for (UTT i = 1; i < _q; ++i) { a = _log2pol[i]; r = a % P; if (r == (P - 1)) b = a - r; else b = a + 1; _plus1[i] = (TT)_pol2log[b] - (TT)_qm1; } _plus1[size_t(mOne)] = 0; } template inline void GFqDom::Init() {} template inline void GFqDom::End() {} #ifdef __GIVARO_COUNT__ template int64_t GFqDom::_mul_count = 0; template int64_t GFqDom::_add_count = 0; template int64_t GFqDom::_div_count = 0; template int64_t GFqDom::_sub_count = 0; template int64_t GFqDom::_neg_count = 0; template int64_t GFqDom::_inv_count = 0; template int64_t GFqDom::_mul_call = 0; template int64_t GFqDom::_add_call = 0; template int64_t GFqDom::_div_call = 0; template int64_t GFqDom::_sub_call = 0; template int64_t GFqDom::_neg_call = 0; template int64_t GFqDom::_inv_call = 0; #endif } // namespace Givaro #endif // __GIVARO_gfq_INL // vim:sts=4:sw=4:ts=4:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s givaro-4.0.2/src/kernel/field/gfqext.h000066400000000000000000000217261274707324300176260ustar00rootroot00000000000000// ========================================================================== // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // file: gfqext.h // Time-stamp: <12 Jun 15 16:28:43 Jean-Guillaume.Dumas@imag.fr> // date: 2007 // version: // author: Jean-Guillaume.Dumas /*! @file gfqext.h * @ingroup zpz * @brief Arithmetic on GF(p^k), with p a prime number less than 2^15. * Specialized for fast conversions to floating point numbers. * Main difference in interface is init/convert. * @bib * - JG Dumas, Q-adic Transform Revisited, ISSAC 2008 * @warning k strictly greater than 1 */ #ifndef __GIVARO_gfq_extension_H #define __GIVARO_gfq_extension_H #include "givaro/gfq.h" #include "givaro/givpower.h" #include #include namespace Givaro { // init with preconditions, bad entry could segfault template class GFqExtFast; // init defensive, bad entry are transformed, to the cost of slowdown template class GFqExt; //! GFq Ext template class GFqExtFast : public GFqDom { protected: typedef typename Signed_Trait::unsigned_type UTT; typedef TT Rep; typedef GFqDom Father_t; UTT _BITS; // the q-adic transform will be with q=2^_BITS UTT _BASE; // this is 2^_BITS UTT _MASK; // 2^_BITS - 1 UTT _maxn; // Worst case Maximal number of multiplications // without reduction UTT _degree;// exponent-1 UTT _pceil; // smallest such that characteristic<2^_pceil, // used for fast for table indexing UTT _MODOUT;// Largest accepted double for init // Conversion tables from exponent to double z-adic representation std::vector _log2dbl; // Exponent to double std::vector _high2log; // Half double to exponent std::vector _low2log; // Other half in Time-Memory Trade-Off public: typedef GFqExtFast Self_t; typedef Rep Element; typedef Element* Element_ptr ; typedef const Element* ConstElement_ptr; typedef UTT Residu_t; typedef Rep* Array; typedef const Rep* constArray; GFqExtFast(): Father_t() // , balanced(false) { } // Extension MUST be a parameter of the constructor GFqExtFast( const UTT P, const UTT e) : Father_t(P,e), _BITS( std::numeric_limits< double >::digits/( (e<<1)-1) ), _BASE(1 << _BITS), _MASK( _BASE - 1), _maxn( _BASE/(P-1)/(P-1)/e), _degree( e-1 ) // , balanced(false) { GIVARO_ASSERT(_maxn>0 , "[GFqExtFast]: field too large"); builddoubletables(); } // Extension MUST be a parameter of the constructor template GFqExtFast( const UTT P, const UTT e, const Vector& modPoly) : Father_t(P,e, modPoly), _BITS( std::numeric_limits< double >::digits/( (e<<1)-1) ), _BASE(1 << _BITS), _MASK( _BASE - 1), _maxn( _BASE/(P-1)/(P-1)/e), _degree( e-1 ) // , balanced(false) { GIVARO_ASSERT(_maxn>0 , "[GFqExtFast]: field too large"); builddoubletables(); } virtual ~GFqExtFast() {}; Self_t operator=( const Self_t& F) { this->zero = F.zero; this->one = F.one; this->mOne = F.mOne; this->_characteristic = F._characteristic; this->_dcharacteristic = F._dcharacteristic; this->_exponent = F._exponent; this->_q = F._q; this->_qm1 = F._qm1; this->_log2pol = F._log2pol; this->_pol2log = F._pol2log; this->_plus1 = F._plus1; this->_BITS = F._BITS; this->_BASE = F._BASE; this->_MASK = F._MASK; this->_maxn = F._maxn; this->_degree = F._degree; this->_log2dbl = F._log2dbl; this->_low2log = F._low2log; this->_high2log = F._high2log; return *this; } GFqExtFast( const GFqDom& F) : Father_t(F), _BITS( F._BITS ), _BASE( F._BASE ),_MASK( F._MASK ), _maxn( F._maxn ),_degree( F._degree ), _log2dbl ( F._log2dbl ), _low2log( F._low2log ), _high2log (F._high2log ) // , balanced(false) { } // Accesses UTT bits() const { return _BITS;} UTT base() const { return _BASE;} UTT mask() const { return _MASK;} UTT maxdot() const { return _maxn; } UTT& characteristic(UTT& a) const { return a=this->_characteristic; } UTT characteristic() const { return this->_characteristic; } // const bool balanced; // Init/Convert using Father_t::init; Rep& init( Rep& r, const unsigned long l) const { return Father_t::init(r,l); } virtual Rep& init(Rep& pad, const double d) const { GIVARO_ASSERT(d>=0.0 , "[GFqExtFast]: init from a negative number"); GIVARO_ASSERT(d<_MODOUT, "[GFqExtFast]: init from a too large number"); // WARNING WARNING WARNING WARNING // Precondition : 0 <= d < _MODOUT // Can segfault if d is too large // WARNING WARNING WARNING WARNING uint64_t rll( static_cast(d) ); uint64_t tll( static_cast(d/this->_dcharacteristic) ); UTT prec(0); UTT padl = (UTT)(rll - tll*this->_characteristic); if (padl == this->_characteristic) { padl -= this->_characteristic; tll += 1; } for(size_t j = 0;j<_degree;++j) { rll >>= _BITS; tll >>= _BITS; prec = (UTT)(rll-tll*this->_characteristic); padl <<= _pceil; padl ^= prec; } pad = (Rep)prec; for(size_t j = 0;j<_degree;++j) { rll >>= _BITS; tll >>= _BITS; prec = (UTT)(rll-tll*this->_characteristic); pad <<= _pceil; pad ^= prec; } padl = this->_low2log[(size_t)padl]; pad = (Rep)this->_high2log[(size_t)pad]; return this->addin(pad,(Rep)padl); } virtual Rep& init(Rep& pad, const float d) const { return init(pad, (double)d); } using Father_t::convert; virtual double& convert(double& d, const Rep a) const { return d=_log2dbl[(size_t)a]; } virtual float& convert(float& d, const Rep a) const { return d=(float)_log2dbl[(size_t)a]; } template Rep& random(RandIter& g, Rep& r) const { return init(r, static_cast( (UTT)g() % _MODOUT)); } protected: void builddoubletables() { _log2dbl.resize(this->_log2pol.size()); _pceil = 1; for(unsigned long ppow = 2; ppow < this->_characteristic; ppow <<= 1,++_pceil) {} unsigned long powersize = 1<<(_pceil * this->_exponent); _MODOUT = UTT(powersize - 1); _high2log.resize(powersize); _low2log.resize(powersize); typedef typename Father_t::Element ZElem; Father_t Zp(this->_characteristic,1); ZElem q,mq; Zp.init(q,2); dom_power(q,q,_BITS,Zp); Zp.neg(mq,q); Element xkmu; // This is X xkmu = (Element)this->_pol2log[(size_t)this->_characteristic]; // This is X^{e-1} dom_power(xkmu,xkmu,this->_exponent-1,*this); typedef Poly1FactorDom< Father_t, Dense > PolDom; PolDom Pdom( Zp ); typedef Poly1PadicDom< Father_t, Dense > PadicDom; PadicDom PAD(Pdom); Father_t Z2B(2,_BITS); PolDom P2dom( Z2B ); PadicDom P2AD( P2dom ); std::vector::iterator dblit = _log2dbl.begin(); typename std::vector::const_iterator polit = this->_log2pol.begin(); for( ; polit != this->_log2pol.end(); ++polit, ++dblit) { std::vector vect; std::deque low_ui; P2AD.evaldirect( *dblit, PAD.radixdirect( vect, (double)(*polit), this->_exponent) ); unsigned long binpolit = static_cast(vect[0]); for(size_t i =1; i_exponent; ++i) { binpolit <<= _pceil; binpolit += static_cast(vect[i]); } ZElem tmp, prec, cour; Zp.init(cour); Zp.init(prec, vect[0]); for(size_t i = 1; i_exponent; ++i) { Zp.init(cour, vect[i]); Zp.axpy(tmp, mq, cour, prec); low_ui.push_back(tmp); prec = cour; } PAD.eval(tmp , low_ui ); _low2log[binpolit] = this->_pol2log[(size_t)tmp]; low_ui.push_back(cour); PAD.eval( tmp, low_ui); Father_t::mul((Element&)_high2log[(size_t)binpolit],(Element)this->_pol2log[(size_t)tmp], xkmu); } } }; //! GFq Ext (other) template class GFqExt : public GFqExtFast { protected: typedef typename Signed_Trait::unsigned_type UTT; typedef TT Rep; typedef GFqDom Father_t; typedef GFqExtFast DirectFather_t; double _fMODOUT; public: typedef GFqExt Self_t; typedef Rep Element; typedef UTT Residu_t; typedef Rep* Array; typedef const Rep* constArray; GFqExt(): DirectFather_t(), _fMODOUT(static_cast(this->_MODOUT)) {} GFqExt( const UTT P, const UTT e) : DirectFather_t(P,e), _fMODOUT(static_cast(this->_MODOUT)) {} GFqExt( const GFqDom& F) : DirectFather_t(F), _fMODOUT(static_cast(this->_MODOUT)) {} ~GFqExt() {} using Father_t::init; virtual Rep& init(Rep& pad, const double d) const { // Defensive init const double tmp(fmod(d,this->_fMODOUT)); return DirectFather_t::init(pad, (tmp>0.0)?tmp:(tmp+_fMODOUT) ); } }; } // namespace Givaro #endif // __GIVARO_gfq_extension_H // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s givaro-4.0.2/src/kernel/field/gfqkronecker.h000066400000000000000000000136571274707324300210150ustar00rootroot00000000000000// ========================================================================== // Copyright(c)'1994-2010 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // file: gfqkronecker.h // Time-stamp: <12 Apr 10 16:45:02 Jean-Guillaume.Dumas@imag.fr> // date: 2007 // version: // author: Jean-Guillaume.Dumas /*! @file gfqkronecker.h * @ingroup zpz * @brief Arithmetic on GF(p^k), with dynamic Kronecker substitution. * @pre k(p-1)^2 < word size */ #ifndef __GIVARO_gfq_kronecker_H #define __GIVARO_gfq_kronecker_H #include "givaro/givzpz.h" #include "givaro/givzpzInt.h" #include "givaro/gfq.h" #include "givaro/givpower.h" #include #include #include namespace Givaro { //! GFqKronecker template struct GFqKronecker : public GFqDom { protected: typedef typename Signed_Trait::unsigned_type UTT; typedef TT Rep; typedef GFqDom Father_t; public: typedef GFqKronecker Self_t; typedef Rep Element; typedef Element* Element_ptr ; typedef const Element* ConstElement_ptr; typedef UTT Residu_t; typedef Rep* Array; typedef const Rep* constArray; typedef ModularRandIter< Father_t , Rep> RandIter; GFqKronecker(): Father_t() {} // Extension MUST be a parameter of the constructor GFqKronecker( const UTT P, const UTT e) : Father_t(P,e), _degree(e-1),_epmunsq(e*(P-1)*(P-1)) { buildsmalltables(); setShift(std::numeric_limits::digits/( (e<<1)-1) ); } Ints getMaxn() const { return _sMAXN; } UTT getShift() const { return _SHIFTS; } UTT getBase() const { return _sBASE; } // Set shifts, returns maxn Ints setShift(const Ints& i) { _SHIFTS=i; _sBASE = Ints(1); _sBASE <<=_SHIFTS; _sMASK = _sBASE - 1; return _sMAXN = _sBASE / _epmunsq; } // Set maxn, returns shifts UTT setMaxn(const Ints& n) { _sMAXN = n; Ints m = _sMAXN * _epmunsq; _SHIFTS = 0; for(_sBASE = 1; _sBASE < m; ++_SHIFTS, _sBASE<<=1); _sMASK = _sBASE - 1; return _SHIFTS; } virtual ~GFqKronecker() {}; using Father_t::init; using Father_t::convert; virtual Ints& convert(Ints& r, const Rep a) const { // First Step // from element to polynomial coefficient binary shifted UTT binpol=_log2bin[a]; // Second step // from a0|a1|...|ad // to 0-0ad | ... | 0-0a1 | 0-0a0 r = binpol & _pMASK; // a0 for(size_t i=1; i_exponent; ++i) { r <<= _SHIFTS; binpol >>= _pceil; r |= ( binpol & _pMASK); } return r; } virtual Rep& init(Rep& a, const Ints r) const { // WARNING: This could be speeded up with a REDQ transform // First Step lower part // from rd | ... | r1 | r0 // to a0|a1|...|ad // where ai = ri mod p Ints rs=r; UTT binpolLOW = (UTT)( (rs & _sMASK) % this->_characteristic); for(size_t i=1; i_exponent; ++i) { binpolLOW <<= _pceil; rs >>= _SHIFTS; binpolLOW |= (UTT)( (rs & _sMASK) % this->_characteristic); } // First Step upper part rs >>= _SHIFTS; UTT binpolHIGH = (UTT)( (rs & _sMASK) % this->_characteristic); for(size_t i=1; i_degree; ++i) { binpolHIGH <<= _pceil; rs >>= _SHIFTS; binpolHIGH |= (UTT)( (rs & _sMASK) % this->_characteristic); } binpolHIGH <<= _pceil; // Second step // transform to element H*X^k+L return this->axpy(a, _bin2log[binpolHIGH], _Xk, _bin2log[binpolLOW]); } protected: std::ostream& polywrite(std::ostream& out, const Element& a, const Indeter In= "B") const { static Modular Zp(this->_characteristic); static Poly1PadicDom > PAD(Zp ,In); static Poly1PadicDom >::Element pol; Integer r; PAD.radixdirect(pol, this->convert(r, a), this->_exponent); return PAD.write(out, pol); } void buildsmalltables() { _log2bin.resize(this->_log2pol.size()); _pceil = 1; for(unsigned long ppow = 2; ppow < this->_characteristic; ppow <<= 1,++_pceil) {} _pMASK = (1<<_pceil) - 1; Father_t Zp(this->_characteristic,1); typedef Poly1FactorDom< Father_t, Dense > PolDom; PolDom Pdom( Zp ); typedef Poly1PadicDom< Father_t, Dense > PadicDom; PadicDom PAD(Pdom); typename std::vector::iterator binit = _log2bin.begin(); typename std::vector::const_iterator polit = this->_log2pol.begin(); for( ; polit != this->_log2pol.end(); ++polit, ++binit) { std::vector vect; PAD.radixdirect( vect, (unsigned long)(*polit), this->_exponent); *binit = vect[0]; for(size_t i =1; i_exponent; ++i) { *binit <<= _pceil; *binit += vect[i]; } } _bin2log.resize( 1<<(_pceil*this->_exponent) ); for(size_t i=0; i<_log2bin.size(); ++i) _bin2log[ _log2bin[ i ] ] = i; // This is X _Xk = this->_pol2log[this->_characteristic]; // polywrite(std::cerr << "Xk: " << _Xk << " rep ", _Xk) << std::endl; // This is X^{e} dom_power(_Xk,_Xk,this->_exponent,*this); // polywrite(std::cerr << "Xk: ", _Xk) << std::endl; } UTT _SHIFTS; Ints _sBASE,_sMASK,_sMAXN; UTT _pceil,_pMASK,_degree; Ints _epmunsq; std::vector _log2bin; std::vector _bin2log; Element _Xk; }; } // namespace Givaro #endif // __GIVARO_gfq_kronecker_H givaro-4.0.2/src/kernel/field/givprimes16.C000066400000000000000000001301051274707324300204270ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/zpz/givprimes16.C,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: T. Gautier // Time-stamp: <11 Jun 07 13:22:50 Jean-Guillaume.Dumas@imag.fr> // ========================================================================== // Description: #include "givaro/givprimes16.h" namespace Givaro { // Number of primes <= 2^16-1 const size_t Primes16::_size = 6542 ; const size_t Primes16::_primes[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001, 16007, 16033, 16057, 16061, 16063, 16067, 16069, 16073, 16087, 16091, 16097, 16103, 16111, 16127, 16139, 16141, 16183, 16187, 16189, 16193, 16217, 16223, 16229, 16231, 16249, 16253, 16267, 16273, 16301, 16319, 16333, 16339, 16349, 16361, 16363, 16369, 16381, 16411, 16417, 16421, 16427, 16433, 16447, 16451, 16453, 16477, 16481, 16487, 16493, 16519, 16529, 16547, 16553, 16561, 16567, 16573, 16603, 16607, 16619, 16631, 16633, 16649, 16651, 16657, 16661, 16673, 16691, 16693, 16699, 16703, 16729, 16741, 16747, 16759, 16763, 16787, 16811, 16823, 16829, 16831, 16843, 16871, 16879, 16883, 16889, 16901, 16903, 16921, 16927, 16931, 16937, 16943, 16963, 16979, 16981, 16987, 16993, 17011, 17021, 17027, 17029, 17033, 17041, 17047, 17053, 17077, 17093, 17099, 17107, 17117, 17123, 17137, 17159, 17167, 17183, 17189, 17191, 17203, 17207, 17209, 17231, 17239, 17257, 17291, 17293, 17299, 17317, 17321, 17327, 17333, 17341, 17351, 17359, 17377, 17383, 17387, 17389, 17393, 17401, 17417, 17419, 17431, 17443, 17449, 17467, 17471, 17477, 17483, 17489, 17491, 17497, 17509, 17519, 17539, 17551, 17569, 17573, 17579, 17581, 17597, 17599, 17609, 17623, 17627, 17657, 17659, 17669, 17681, 17683, 17707, 17713, 17729, 17737, 17747, 17749, 17761, 17783, 17789, 17791, 17807, 17827, 17837, 17839, 17851, 17863, 17881, 17891, 17903, 17909, 17911, 17921, 17923, 17929, 17939, 17957, 17959, 17971, 17977, 17981, 17987, 17989, 18013, 18041, 18043, 18047, 18049, 18059, 18061, 18077, 18089, 18097, 18119, 18121, 18127, 18131, 18133, 18143, 18149, 18169, 18181, 18191, 18199, 18211, 18217, 18223, 18229, 18233, 18251, 18253, 18257, 18269, 18287, 18289, 18301, 18307, 18311, 18313, 18329, 18341, 18353, 18367, 18371, 18379, 18397, 18401, 18413, 18427, 18433, 18439, 18443, 18451, 18457, 18461, 18481, 18493, 18503, 18517, 18521, 18523, 18539, 18541, 18553, 18583, 18587, 18593, 18617, 18637, 18661, 18671, 18679, 18691, 18701, 18713, 18719, 18731, 18743, 18749, 18757, 18773, 18787, 18793, 18797, 18803, 18839, 18859, 18869, 18899, 18911, 18913, 18917, 18919, 18947, 18959, 18973, 18979, 19001, 19009, 19013, 19031, 19037, 19051, 19069, 19073, 19079, 19081, 19087, 19121, 19139, 19141, 19157, 19163, 19181, 19183, 19207, 19211, 19213, 19219, 19231, 19237, 19249, 19259, 19267, 19273, 19289, 19301, 19309, 19319, 19333, 19373, 19379, 19381, 19387, 19391, 19403, 19417, 19421, 19423, 19427, 19429, 19433, 19441, 19447, 19457, 19463, 19469, 19471, 19477, 19483, 19489, 19501, 19507, 19531, 19541, 19543, 19553, 19559, 19571, 19577, 19583, 19597, 19603, 19609, 19661, 19681, 19687, 19697, 19699, 19709, 19717, 19727, 19739, 19751, 19753, 19759, 19763, 19777, 19793, 19801, 19813, 19819, 19841, 19843, 19853, 19861, 19867, 19889, 19891, 19913, 19919, 19927, 19937, 19949, 19961, 19963, 19973, 19979, 19991, 19993, 19997, 20011, 20021, 20023, 20029, 20047, 20051, 20063, 20071, 20089, 20101, 20107, 20113, 20117, 20123, 20129, 20143, 20147, 20149, 20161, 20173, 20177, 20183, 20201, 20219, 20231, 20233, 20249, 20261, 20269, 20287, 20297, 20323, 20327, 20333, 20341, 20347, 20353, 20357, 20359, 20369, 20389, 20393, 20399, 20407, 20411, 20431, 20441, 20443, 20477, 20479, 20483, 20507, 20509, 20521, 20533, 20543, 20549, 20551, 20563, 20593, 20599, 20611, 20627, 20639, 20641, 20663, 20681, 20693, 20707, 20717, 20719, 20731, 20743, 20747, 20749, 20753, 20759, 20771, 20773, 20789, 20807, 20809, 20849, 20857, 20873, 20879, 20887, 20897, 20899, 20903, 20921, 20929, 20939, 20947, 20959, 20963, 20981, 20983, 21001, 21011, 21013, 21017, 21019, 21023, 21031, 21059, 21061, 21067, 21089, 21101, 21107, 21121, 21139, 21143, 21149, 21157, 21163, 21169, 21179, 21187, 21191, 21193, 21211, 21221, 21227, 21247, 21269, 21277, 21283, 21313, 21317, 21319, 21323, 21341, 21347, 21377, 21379, 21383, 21391, 21397, 21401, 21407, 21419, 21433, 21467, 21481, 21487, 21491, 21493, 21499, 21503, 21517, 21521, 21523, 21529, 21557, 21559, 21563, 21569, 21577, 21587, 21589, 21599, 21601, 21611, 21613, 21617, 21647, 21649, 21661, 21673, 21683, 21701, 21713, 21727, 21737, 21739, 21751, 21757, 21767, 21773, 21787, 21799, 21803, 21817, 21821, 21839, 21841, 21851, 21859, 21863, 21871, 21881, 21893, 21911, 21929, 21937, 21943, 21961, 21977, 21991, 21997, 22003, 22013, 22027, 22031, 22037, 22039, 22051, 22063, 22067, 22073, 22079, 22091, 22093, 22109, 22111, 22123, 22129, 22133, 22147, 22153, 22157, 22159, 22171, 22189, 22193, 22229, 22247, 22259, 22271, 22273, 22277, 22279, 22283, 22291, 22303, 22307, 22343, 22349, 22367, 22369, 22381, 22391, 22397, 22409, 22433, 22441, 22447, 22453, 22469, 22481, 22483, 22501, 22511, 22531, 22541, 22543, 22549, 22567, 22571, 22573, 22613, 22619, 22621, 22637, 22639, 22643, 22651, 22669, 22679, 22691, 22697, 22699, 22709, 22717, 22721, 22727, 22739, 22741, 22751, 22769, 22777, 22783, 22787, 22807, 22811, 22817, 22853, 22859, 22861, 22871, 22877, 22901, 22907, 22921, 22937, 22943, 22961, 22963, 22973, 22993, 23003, 23011, 23017, 23021, 23027, 23029, 23039, 23041, 23053, 23057, 23059, 23063, 23071, 23081, 23087, 23099, 23117, 23131, 23143, 23159, 23167, 23173, 23189, 23197, 23201, 23203, 23209, 23227, 23251, 23269, 23279, 23291, 23293, 23297, 23311, 23321, 23327, 23333, 23339, 23357, 23369, 23371, 23399, 23417, 23431, 23447, 23459, 23473, 23497, 23509, 23531, 23537, 23539, 23549, 23557, 23561, 23563, 23567, 23581, 23593, 23599, 23603, 23609, 23623, 23627, 23629, 23633, 23663, 23669, 23671, 23677, 23687, 23689, 23719, 23741, 23743, 23747, 23753, 23761, 23767, 23773, 23789, 23801, 23813, 23819, 23827, 23831, 23833, 23857, 23869, 23873, 23879, 23887, 23893, 23899, 23909, 23911, 23917, 23929, 23957, 23971, 23977, 23981, 23993, 24001, 24007, 24019, 24023, 24029, 24043, 24049, 24061, 24071, 24077, 24083, 24091, 24097, 24103, 24107, 24109, 24113, 24121, 24133, 24137, 24151, 24169, 24179, 24181, 24197, 24203, 24223, 24229, 24239, 24247, 24251, 24281, 24317, 24329, 24337, 24359, 24371, 24373, 24379, 24391, 24407, 24413, 24419, 24421, 24439, 24443, 24469, 24473, 24481, 24499, 24509, 24517, 24527, 24533, 24547, 24551, 24571, 24593, 24611, 24623, 24631, 24659, 24671, 24677, 24683, 24691, 24697, 24709, 24733, 24749, 24763, 24767, 24781, 24793, 24799, 24809, 24821, 24841, 24847, 24851, 24859, 24877, 24889, 24907, 24917, 24919, 24923, 24943, 24953, 24967, 24971, 24977, 24979, 24989, 25013, 25031, 25033, 25037, 25057, 25073, 25087, 25097, 25111, 25117, 25121, 25127, 25147, 25153, 25163, 25169, 25171, 25183, 25189, 25219, 25229, 25237, 25243, 25247, 25253, 25261, 25301, 25303, 25307, 25309, 25321, 25339, 25343, 25349, 25357, 25367, 25373, 25391, 25409, 25411, 25423, 25439, 25447, 25453, 25457, 25463, 25469, 25471, 25523, 25537, 25541, 25561, 25577, 25579, 25583, 25589, 25601, 25603, 25609, 25621, 25633, 25639, 25643, 25657, 25667, 25673, 25679, 25693, 25703, 25717, 25733, 25741, 25747, 25759, 25763, 25771, 25793, 25799, 25801, 25819, 25841, 25847, 25849, 25867, 25873, 25889, 25903, 25913, 25919, 25931, 25933, 25939, 25943, 25951, 25969, 25981, 25997, 25999, 26003, 26017, 26021, 26029, 26041, 26053, 26083, 26099, 26107, 26111, 26113, 26119, 26141, 26153, 26161, 26171, 26177, 26183, 26189, 26203, 26209, 26227, 26237, 26249, 26251, 26261, 26263, 26267, 26293, 26297, 26309, 26317, 26321, 26339, 26347, 26357, 26371, 26387, 26393, 26399, 26407, 26417, 26423, 26431, 26437, 26449, 26459, 26479, 26489, 26497, 26501, 26513, 26539, 26557, 26561, 26573, 26591, 26597, 26627, 26633, 26641, 26647, 26669, 26681, 26683, 26687, 26693, 26699, 26701, 26711, 26713, 26717, 26723, 26729, 26731, 26737, 26759, 26777, 26783, 26801, 26813, 26821, 26833, 26839, 26849, 26861, 26863, 26879, 26881, 26891, 26893, 26903, 26921, 26927, 26947, 26951, 26953, 26959, 26981, 26987, 26993, 27011, 27017, 27031, 27043, 27059, 27061, 27067, 27073, 27077, 27091, 27103, 27107, 27109, 27127, 27143, 27179, 27191, 27197, 27211, 27239, 27241, 27253, 27259, 27271, 27277, 27281, 27283, 27299, 27329, 27337, 27361, 27367, 27397, 27407, 27409, 27427, 27431, 27437, 27449, 27457, 27479, 27481, 27487, 27509, 27527, 27529, 27539, 27541, 27551, 27581, 27583, 27611, 27617, 27631, 27647, 27653, 27673, 27689, 27691, 27697, 27701, 27733, 27737, 27739, 27743, 27749, 27751, 27763, 27767, 27773, 27779, 27791, 27793, 27799, 27803, 27809, 27817, 27823, 27827, 27847, 27851, 27883, 27893, 27901, 27917, 27919, 27941, 27943, 27947, 27953, 27961, 27967, 27983, 27997, 28001, 28019, 28027, 28031, 28051, 28057, 28069, 28081, 28087, 28097, 28099, 28109, 28111, 28123, 28151, 28163, 28181, 28183, 28201, 28211, 28219, 28229, 28277, 28279, 28283, 28289, 28297, 28307, 28309, 28319, 28349, 28351, 28387, 28393, 28403, 28409, 28411, 28429, 28433, 28439, 28447, 28463, 28477, 28493, 28499, 28513, 28517, 28537, 28541, 28547, 28549, 28559, 28571, 28573, 28579, 28591, 28597, 28603, 28607, 28619, 28621, 28627, 28631, 28643, 28649, 28657, 28661, 28663, 28669, 28687, 28697, 28703, 28711, 28723, 28729, 28751, 28753, 28759, 28771, 28789, 28793, 28807, 28813, 28817, 28837, 28843, 28859, 28867, 28871, 28879, 28901, 28909, 28921, 28927, 28933, 28949, 28961, 28979, 29009, 29017, 29021, 29023, 29027, 29033, 29059, 29063, 29077, 29101, 29123, 29129, 29131, 29137, 29147, 29153, 29167, 29173, 29179, 29191, 29201, 29207, 29209, 29221, 29231, 29243, 29251, 29269, 29287, 29297, 29303, 29311, 29327, 29333, 29339, 29347, 29363, 29383, 29387, 29389, 29399, 29401, 29411, 29423, 29429, 29437, 29443, 29453, 29473, 29483, 29501, 29527, 29531, 29537, 29567, 29569, 29573, 29581, 29587, 29599, 29611, 29629, 29633, 29641, 29663, 29669, 29671, 29683, 29717, 29723, 29741, 29753, 29759, 29761, 29789, 29803, 29819, 29833, 29837, 29851, 29863, 29867, 29873, 29879, 29881, 29917, 29921, 29927, 29947, 29959, 29983, 29989, 30011, 30013, 30029, 30047, 30059, 30071, 30089, 30091, 30097, 30103, 30109, 30113, 30119, 30133, 30137, 30139, 30161, 30169, 30181, 30187, 30197, 30203, 30211, 30223, 30241, 30253, 30259, 30269, 30271, 30293, 30307, 30313, 30319, 30323, 30341, 30347, 30367, 30389, 30391, 30403, 30427, 30431, 30449, 30467, 30469, 30491, 30493, 30497, 30509, 30517, 30529, 30539, 30553, 30557, 30559, 30577, 30593, 30631, 30637, 30643, 30649, 30661, 30671, 30677, 30689, 30697, 30703, 30707, 30713, 30727, 30757, 30763, 30773, 30781, 30803, 30809, 30817, 30829, 30839, 30841, 30851, 30853, 30859, 30869, 30871, 30881, 30893, 30911, 30931, 30937, 30941, 30949, 30971, 30977, 30983, 31013, 31019, 31033, 31039, 31051, 31063, 31069, 31079, 31081, 31091, 31121, 31123, 31139, 31147, 31151, 31153, 31159, 31177, 31181, 31183, 31189, 31193, 31219, 31223, 31231, 31237, 31247, 31249, 31253, 31259, 31267, 31271, 31277, 31307, 31319, 31321, 31327, 31333, 31337, 31357, 31379, 31387, 31391, 31393, 31397, 31469, 31477, 31481, 31489, 31511, 31513, 31517, 31531, 31541, 31543, 31547, 31567, 31573, 31583, 31601, 31607, 31627, 31643, 31649, 31657, 31663, 31667, 31687, 31699, 31721, 31723, 31727, 31729, 31741, 31751, 31769, 31771, 31793, 31799, 31817, 31847, 31849, 31859, 31873, 31883, 31891, 31907, 31957, 31963, 31973, 31981, 31991, 32003, 32009, 32027, 32029, 32051, 32057, 32059, 32063, 32069, 32077, 32083, 32089, 32099, 32117, 32119, 32141, 32143, 32159, 32173, 32183, 32189, 32191, 32203, 32213, 32233, 32237, 32251, 32257, 32261, 32297, 32299, 32303, 32309, 32321, 32323, 32327, 32341, 32353, 32359, 32363, 32369, 32371, 32377, 32381, 32401, 32411, 32413, 32423, 32429, 32441, 32443, 32467, 32479, 32491, 32497, 32503, 32507, 32531, 32533, 32537, 32561, 32563, 32569, 32573, 32579, 32587, 32603, 32609, 32611, 32621, 32633, 32647, 32653, 32687, 32693, 32707, 32713, 32717, 32719, 32749, 32771, 32779, 32783, 32789, 32797, 32801, 32803, 32831, 32833, 32839, 32843, 32869, 32887, 32909, 32911, 32917, 32933, 32939, 32941, 32957, 32969, 32971, 32983, 32987, 32993, 32999, 33013, 33023, 33029, 33037, 33049, 33053, 33071, 33073, 33083, 33091, 33107, 33113, 33119, 33149, 33151, 33161, 33179, 33181, 33191, 33199, 33203, 33211, 33223, 33247, 33287, 33289, 33301, 33311, 33317, 33329, 33331, 33343, 33347, 33349, 33353, 33359, 33377, 33391, 33403, 33409, 33413, 33427, 33457, 33461, 33469, 33479, 33487, 33493, 33503, 33521, 33529, 33533, 33547, 33563, 33569, 33577, 33581, 33587, 33589, 33599, 33601, 33613, 33617, 33619, 33623, 33629, 33637, 33641, 33647, 33679, 33703, 33713, 33721, 33739, 33749, 33751, 33757, 33767, 33769, 33773, 33791, 33797, 33809, 33811, 33827, 33829, 33851, 33857, 33863, 33871, 33889, 33893, 33911, 33923, 33931, 33937, 33941, 33961, 33967, 33997, 34019, 34031, 34033, 34039, 34057, 34061, 34123, 34127, 34129, 34141, 34147, 34157, 34159, 34171, 34183, 34211, 34213, 34217, 34231, 34253, 34259, 34261, 34267, 34273, 34283, 34297, 34301, 34303, 34313, 34319, 34327, 34337, 34351, 34361, 34367, 34369, 34381, 34403, 34421, 34429, 34439, 34457, 34469, 34471, 34483, 34487, 34499, 34501, 34511, 34513, 34519, 34537, 34543, 34549, 34583, 34589, 34591, 34603, 34607, 34613, 34631, 34649, 34651, 34667, 34673, 34679, 34687, 34693, 34703, 34721, 34729, 34739, 34747, 34757, 34759, 34763, 34781, 34807, 34819, 34841, 34843, 34847, 34849, 34871, 34877, 34883, 34897, 34913, 34919, 34939, 34949, 34961, 34963, 34981, 35023, 35027, 35051, 35053, 35059, 35069, 35081, 35083, 35089, 35099, 35107, 35111, 35117, 35129, 35141, 35149, 35153, 35159, 35171, 35201, 35221, 35227, 35251, 35257, 35267, 35279, 35281, 35291, 35311, 35317, 35323, 35327, 35339, 35353, 35363, 35381, 35393, 35401, 35407, 35419, 35423, 35437, 35447, 35449, 35461, 35491, 35507, 35509, 35521, 35527, 35531, 35533, 35537, 35543, 35569, 35573, 35591, 35593, 35597, 35603, 35617, 35671, 35677, 35729, 35731, 35747, 35753, 35759, 35771, 35797, 35801, 35803, 35809, 35831, 35837, 35839, 35851, 35863, 35869, 35879, 35897, 35899, 35911, 35923, 35933, 35951, 35963, 35969, 35977, 35983, 35993, 35999, 36007, 36011, 36013, 36017, 36037, 36061, 36067, 36073, 36083, 36097, 36107, 36109, 36131, 36137, 36151, 36161, 36187, 36191, 36209, 36217, 36229, 36241, 36251, 36263, 36269, 36277, 36293, 36299, 36307, 36313, 36319, 36341, 36343, 36353, 36373, 36383, 36389, 36433, 36451, 36457, 36467, 36469, 36473, 36479, 36493, 36497, 36523, 36527, 36529, 36541, 36551, 36559, 36563, 36571, 36583, 36587, 36599, 36607, 36629, 36637, 36643, 36653, 36671, 36677, 36683, 36691, 36697, 36709, 36713, 36721, 36739, 36749, 36761, 36767, 36779, 36781, 36787, 36791, 36793, 36809, 36821, 36833, 36847, 36857, 36871, 36877, 36887, 36899, 36901, 36913, 36919, 36923, 36929, 36931, 36943, 36947, 36973, 36979, 36997, 37003, 37013, 37019, 37021, 37039, 37049, 37057, 37061, 37087, 37097, 37117, 37123, 37139, 37159, 37171, 37181, 37189, 37199, 37201, 37217, 37223, 37243, 37253, 37273, 37277, 37307, 37309, 37313, 37321, 37337, 37339, 37357, 37361, 37363, 37369, 37379, 37397, 37409, 37423, 37441, 37447, 37463, 37483, 37489, 37493, 37501, 37507, 37511, 37517, 37529, 37537, 37547, 37549, 37561, 37567, 37571, 37573, 37579, 37589, 37591, 37607, 37619, 37633, 37643, 37649, 37657, 37663, 37691, 37693, 37699, 37717, 37747, 37781, 37783, 37799, 37811, 37813, 37831, 37847, 37853, 37861, 37871, 37879, 37889, 37897, 37907, 37951, 37957, 37963, 37967, 37987, 37991, 37993, 37997, 38011, 38039, 38047, 38053, 38069, 38083, 38113, 38119, 38149, 38153, 38167, 38177, 38183, 38189, 38197, 38201, 38219, 38231, 38237, 38239, 38261, 38273, 38281, 38287, 38299, 38303, 38317, 38321, 38327, 38329, 38333, 38351, 38371, 38377, 38393, 38431, 38447, 38449, 38453, 38459, 38461, 38501, 38543, 38557, 38561, 38567, 38569, 38593, 38603, 38609, 38611, 38629, 38639, 38651, 38653, 38669, 38671, 38677, 38693, 38699, 38707, 38711, 38713, 38723, 38729, 38737, 38747, 38749, 38767, 38783, 38791, 38803, 38821, 38833, 38839, 38851, 38861, 38867, 38873, 38891, 38903, 38917, 38921, 38923, 38933, 38953, 38959, 38971, 38977, 38993, 39019, 39023, 39041, 39043, 39047, 39079, 39089, 39097, 39103, 39107, 39113, 39119, 39133, 39139, 39157, 39161, 39163, 39181, 39191, 39199, 39209, 39217, 39227, 39229, 39233, 39239, 39241, 39251, 39293, 39301, 39313, 39317, 39323, 39341, 39343, 39359, 39367, 39371, 39373, 39383, 39397, 39409, 39419, 39439, 39443, 39451, 39461, 39499, 39503, 39509, 39511, 39521, 39541, 39551, 39563, 39569, 39581, 39607, 39619, 39623, 39631, 39659, 39667, 39671, 39679, 39703, 39709, 39719, 39727, 39733, 39749, 39761, 39769, 39779, 39791, 39799, 39821, 39827, 39829, 39839, 39841, 39847, 39857, 39863, 39869, 39877, 39883, 39887, 39901, 39929, 39937, 39953, 39971, 39979, 39983, 39989, 40009, 40013, 40031, 40037, 40039, 40063, 40087, 40093, 40099, 40111, 40123, 40127, 40129, 40151, 40153, 40163, 40169, 40177, 40189, 40193, 40213, 40231, 40237, 40241, 40253, 40277, 40283, 40289, 40343, 40351, 40357, 40361, 40387, 40423, 40427, 40429, 40433, 40459, 40471, 40483, 40487, 40493, 40499, 40507, 40519, 40529, 40531, 40543, 40559, 40577, 40583, 40591, 40597, 40609, 40627, 40637, 40639, 40693, 40697, 40699, 40709, 40739, 40751, 40759, 40763, 40771, 40787, 40801, 40813, 40819, 40823, 40829, 40841, 40847, 40849, 40853, 40867, 40879, 40883, 40897, 40903, 40927, 40933, 40939, 40949, 40961, 40973, 40993, 41011, 41017, 41023, 41039, 41047, 41051, 41057, 41077, 41081, 41113, 41117, 41131, 41141, 41143, 41149, 41161, 41177, 41179, 41183, 41189, 41201, 41203, 41213, 41221, 41227, 41231, 41233, 41243, 41257, 41263, 41269, 41281, 41299, 41333, 41341, 41351, 41357, 41381, 41387, 41389, 41399, 41411, 41413, 41443, 41453, 41467, 41479, 41491, 41507, 41513, 41519, 41521, 41539, 41543, 41549, 41579, 41593, 41597, 41603, 41609, 41611, 41617, 41621, 41627, 41641, 41647, 41651, 41659, 41669, 41681, 41687, 41719, 41729, 41737, 41759, 41761, 41771, 41777, 41801, 41809, 41813, 41843, 41849, 41851, 41863, 41879, 41887, 41893, 41897, 41903, 41911, 41927, 41941, 41947, 41953, 41957, 41959, 41969, 41981, 41983, 41999, 42013, 42017, 42019, 42023, 42043, 42061, 42071, 42073, 42083, 42089, 42101, 42131, 42139, 42157, 42169, 42179, 42181, 42187, 42193, 42197, 42209, 42221, 42223, 42227, 42239, 42257, 42281, 42283, 42293, 42299, 42307, 42323, 42331, 42337, 42349, 42359, 42373, 42379, 42391, 42397, 42403, 42407, 42409, 42433, 42437, 42443, 42451, 42457, 42461, 42463, 42467, 42473, 42487, 42491, 42499, 42509, 42533, 42557, 42569, 42571, 42577, 42589, 42611, 42641, 42643, 42649, 42667, 42677, 42683, 42689, 42697, 42701, 42703, 42709, 42719, 42727, 42737, 42743, 42751, 42767, 42773, 42787, 42793, 42797, 42821, 42829, 42839, 42841, 42853, 42859, 42863, 42899, 42901, 42923, 42929, 42937, 42943, 42953, 42961, 42967, 42979, 42989, 43003, 43013, 43019, 43037, 43049, 43051, 43063, 43067, 43093, 43103, 43117, 43133, 43151, 43159, 43177, 43189, 43201, 43207, 43223, 43237, 43261, 43271, 43283, 43291, 43313, 43319, 43321, 43331, 43391, 43397, 43399, 43403, 43411, 43427, 43441, 43451, 43457, 43481, 43487, 43499, 43517, 43541, 43543, 43573, 43577, 43579, 43591, 43597, 43607, 43609, 43613, 43627, 43633, 43649, 43651, 43661, 43669, 43691, 43711, 43717, 43721, 43753, 43759, 43777, 43781, 43783, 43787, 43789, 43793, 43801, 43853, 43867, 43889, 43891, 43913, 43933, 43943, 43951, 43961, 43963, 43969, 43973, 43987, 43991, 43997, 44017, 44021, 44027, 44029, 44041, 44053, 44059, 44071, 44087, 44089, 44101, 44111, 44119, 44123, 44129, 44131, 44159, 44171, 44179, 44189, 44201, 44203, 44207, 44221, 44249, 44257, 44263, 44267, 44269, 44273, 44279, 44281, 44293, 44351, 44357, 44371, 44381, 44383, 44389, 44417, 44449, 44453, 44483, 44491, 44497, 44501, 44507, 44519, 44531, 44533, 44537, 44543, 44549, 44563, 44579, 44587, 44617, 44621, 44623, 44633, 44641, 44647, 44651, 44657, 44683, 44687, 44699, 44701, 44711, 44729, 44741, 44753, 44771, 44773, 44777, 44789, 44797, 44809, 44819, 44839, 44843, 44851, 44867, 44879, 44887, 44893, 44909, 44917, 44927, 44939, 44953, 44959, 44963, 44971, 44983, 44987, 45007, 45013, 45053, 45061, 45077, 45083, 45119, 45121, 45127, 45131, 45137, 45139, 45161, 45179, 45181, 45191, 45197, 45233, 45247, 45259, 45263, 45281, 45289, 45293, 45307, 45317, 45319, 45329, 45337, 45341, 45343, 45361, 45377, 45389, 45403, 45413, 45427, 45433, 45439, 45481, 45491, 45497, 45503, 45523, 45533, 45541, 45553, 45557, 45569, 45587, 45589, 45599, 45613, 45631, 45641, 45659, 45667, 45673, 45677, 45691, 45697, 45707, 45737, 45751, 45757, 45763, 45767, 45779, 45817, 45821, 45823, 45827, 45833, 45841, 45853, 45863, 45869, 45887, 45893, 45943, 45949, 45953, 45959, 45971, 45979, 45989, 46021, 46027, 46049, 46051, 46061, 46073, 46091, 46093, 46099, 46103, 46133, 46141, 46147, 46153, 46171, 46181, 46183, 46187, 46199, 46219, 46229, 46237, 46261, 46271, 46273, 46279, 46301, 46307, 46309, 46327, 46337, 46349, 46351, 46381, 46399, 46411, 46439, 46441, 46447, 46451, 46457, 46471, 46477, 46489, 46499, 46507, 46511, 46523, 46549, 46559, 46567, 46573, 46589, 46591, 46601, 46619, 46633, 46639, 46643, 46649, 46663, 46679, 46681, 46687, 46691, 46703, 46723, 46727, 46747, 46751, 46757, 46769, 46771, 46807, 46811, 46817, 46819, 46829, 46831, 46853, 46861, 46867, 46877, 46889, 46901, 46919, 46933, 46957, 46993, 46997, 47017, 47041, 47051, 47057, 47059, 47087, 47093, 47111, 47119, 47123, 47129, 47137, 47143, 47147, 47149, 47161, 47189, 47207, 47221, 47237, 47251, 47269, 47279, 47287, 47293, 47297, 47303, 47309, 47317, 47339, 47351, 47353, 47363, 47381, 47387, 47389, 47407, 47417, 47419, 47431, 47441, 47459, 47491, 47497, 47501, 47507, 47513, 47521, 47527, 47533, 47543, 47563, 47569, 47581, 47591, 47599, 47609, 47623, 47629, 47639, 47653, 47657, 47659, 47681, 47699, 47701, 47711, 47713, 47717, 47737, 47741, 47743, 47777, 47779, 47791, 47797, 47807, 47809, 47819, 47837, 47843, 47857, 47869, 47881, 47903, 47911, 47917, 47933, 47939, 47947, 47951, 47963, 47969, 47977, 47981, 48017, 48023, 48029, 48049, 48073, 48079, 48091, 48109, 48119, 48121, 48131, 48157, 48163, 48179, 48187, 48193, 48197, 48221, 48239, 48247, 48259, 48271, 48281, 48299, 48311, 48313, 48337, 48341, 48353, 48371, 48383, 48397, 48407, 48409, 48413, 48437, 48449, 48463, 48473, 48479, 48481, 48487, 48491, 48497, 48523, 48527, 48533, 48539, 48541, 48563, 48571, 48589, 48593, 48611, 48619, 48623, 48647, 48649, 48661, 48673, 48677, 48679, 48731, 48733, 48751, 48757, 48761, 48767, 48779, 48781, 48787, 48799, 48809, 48817, 48821, 48823, 48847, 48857, 48859, 48869, 48871, 48883, 48889, 48907, 48947, 48953, 48973, 48989, 48991, 49003, 49009, 49019, 49031, 49033, 49037, 49043, 49057, 49069, 49081, 49103, 49109, 49117, 49121, 49123, 49139, 49157, 49169, 49171, 49177, 49193, 49199, 49201, 49207, 49211, 49223, 49253, 49261, 49277, 49279, 49297, 49307, 49331, 49333, 49339, 49363, 49367, 49369, 49391, 49393, 49409, 49411, 49417, 49429, 49433, 49451, 49459, 49463, 49477, 49481, 49499, 49523, 49529, 49531, 49537, 49547, 49549, 49559, 49597, 49603, 49613, 49627, 49633, 49639, 49663, 49667, 49669, 49681, 49697, 49711, 49727, 49739, 49741, 49747, 49757, 49783, 49787, 49789, 49801, 49807, 49811, 49823, 49831, 49843, 49853, 49871, 49877, 49891, 49919, 49921, 49927, 49937, 49939, 49943, 49957, 49991, 49993, 49999, 50021, 50023, 50033, 50047, 50051, 50053, 50069, 50077, 50087, 50093, 50101, 50111, 50119, 50123, 50129, 50131, 50147, 50153, 50159, 50177, 50207, 50221, 50227, 50231, 50261, 50263, 50273, 50287, 50291, 50311, 50321, 50329, 50333, 50341, 50359, 50363, 50377, 50383, 50387, 50411, 50417, 50423, 50441, 50459, 50461, 50497, 50503, 50513, 50527, 50539, 50543, 50549, 50551, 50581, 50587, 50591, 50593, 50599, 50627, 50647, 50651, 50671, 50683, 50707, 50723, 50741, 50753, 50767, 50773, 50777, 50789, 50821, 50833, 50839, 50849, 50857, 50867, 50873, 50891, 50893, 50909, 50923, 50929, 50951, 50957, 50969, 50971, 50989, 50993, 51001, 51031, 51043, 51047, 51059, 51061, 51071, 51109, 51131, 51133, 51137, 51151, 51157, 51169, 51193, 51197, 51199, 51203, 51217, 51229, 51239, 51241, 51257, 51263, 51283, 51287, 51307, 51329, 51341, 51343, 51347, 51349, 51361, 51383, 51407, 51413, 51419, 51421, 51427, 51431, 51437, 51439, 51449, 51461, 51473, 51479, 51481, 51487, 51503, 51511, 51517, 51521, 51539, 51551, 51563, 51577, 51581, 51593, 51599, 51607, 51613, 51631, 51637, 51647, 51659, 51673, 51679, 51683, 51691, 51713, 51719, 51721, 51749, 51767, 51769, 51787, 51797, 51803, 51817, 51827, 51829, 51839, 51853, 51859, 51869, 51871, 51893, 51899, 51907, 51913, 51929, 51941, 51949, 51971, 51973, 51977, 51991, 52009, 52021, 52027, 52051, 52057, 52067, 52069, 52081, 52103, 52121, 52127, 52147, 52153, 52163, 52177, 52181, 52183, 52189, 52201, 52223, 52237, 52249, 52253, 52259, 52267, 52289, 52291, 52301, 52313, 52321, 52361, 52363, 52369, 52379, 52387, 52391, 52433, 52453, 52457, 52489, 52501, 52511, 52517, 52529, 52541, 52543, 52553, 52561, 52567, 52571, 52579, 52583, 52609, 52627, 52631, 52639, 52667, 52673, 52691, 52697, 52709, 52711, 52721, 52727, 52733, 52747, 52757, 52769, 52783, 52807, 52813, 52817, 52837, 52859, 52861, 52879, 52883, 52889, 52901, 52903, 52919, 52937, 52951, 52957, 52963, 52967, 52973, 52981, 52999, 53003, 53017, 53047, 53051, 53069, 53077, 53087, 53089, 53093, 53101, 53113, 53117, 53129, 53147, 53149, 53161, 53171, 53173, 53189, 53197, 53201, 53231, 53233, 53239, 53267, 53269, 53279, 53281, 53299, 53309, 53323, 53327, 53353, 53359, 53377, 53381, 53401, 53407, 53411, 53419, 53437, 53441, 53453, 53479, 53503, 53507, 53527, 53549, 53551, 53569, 53591, 53593, 53597, 53609, 53611, 53617, 53623, 53629, 53633, 53639, 53653, 53657, 53681, 53693, 53699, 53717, 53719, 53731, 53759, 53773, 53777, 53783, 53791, 53813, 53819, 53831, 53849, 53857, 53861, 53881, 53887, 53891, 53897, 53899, 53917, 53923, 53927, 53939, 53951, 53959, 53987, 53993, 54001, 54011, 54013, 54037, 54049, 54059, 54083, 54091, 54101, 54121, 54133, 54139, 54151, 54163, 54167, 54181, 54193, 54217, 54251, 54269, 54277, 54287, 54293, 54311, 54319, 54323, 54331, 54347, 54361, 54367, 54371, 54377, 54401, 54403, 54409, 54413, 54419, 54421, 54437, 54443, 54449, 54469, 54493, 54497, 54499, 54503, 54517, 54521, 54539, 54541, 54547, 54559, 54563, 54577, 54581, 54583, 54601, 54617, 54623, 54629, 54631, 54647, 54667, 54673, 54679, 54709, 54713, 54721, 54727, 54751, 54767, 54773, 54779, 54787, 54799, 54829, 54833, 54851, 54869, 54877, 54881, 54907, 54917, 54919, 54941, 54949, 54959, 54973, 54979, 54983, 55001, 55009, 55021, 55049, 55051, 55057, 55061, 55073, 55079, 55103, 55109, 55117, 55127, 55147, 55163, 55171, 55201, 55207, 55213, 55217, 55219, 55229, 55243, 55249, 55259, 55291, 55313, 55331, 55333, 55337, 55339, 55343, 55351, 55373, 55381, 55399, 55411, 55439, 55441, 55457, 55469, 55487, 55501, 55511, 55529, 55541, 55547, 55579, 55589, 55603, 55609, 55619, 55621, 55631, 55633, 55639, 55661, 55663, 55667, 55673, 55681, 55691, 55697, 55711, 55717, 55721, 55733, 55763, 55787, 55793, 55799, 55807, 55813, 55817, 55819, 55823, 55829, 55837, 55843, 55849, 55871, 55889, 55897, 55901, 55903, 55921, 55927, 55931, 55933, 55949, 55967, 55987, 55997, 56003, 56009, 56039, 56041, 56053, 56081, 56087, 56093, 56099, 56101, 56113, 56123, 56131, 56149, 56167, 56171, 56179, 56197, 56207, 56209, 56237, 56239, 56249, 56263, 56267, 56269, 56299, 56311, 56333, 56359, 56369, 56377, 56383, 56393, 56401, 56417, 56431, 56437, 56443, 56453, 56467, 56473, 56477, 56479, 56489, 56501, 56503, 56509, 56519, 56527, 56531, 56533, 56543, 56569, 56591, 56597, 56599, 56611, 56629, 56633, 56659, 56663, 56671, 56681, 56687, 56701, 56711, 56713, 56731, 56737, 56747, 56767, 56773, 56779, 56783, 56807, 56809, 56813, 56821, 56827, 56843, 56857, 56873, 56891, 56893, 56897, 56909, 56911, 56921, 56923, 56929, 56941, 56951, 56957, 56963, 56983, 56989, 56993, 56999, 57037, 57041, 57047, 57059, 57073, 57077, 57089, 57097, 57107, 57119, 57131, 57139, 57143, 57149, 57163, 57173, 57179, 57191, 57193, 57203, 57221, 57223, 57241, 57251, 57259, 57269, 57271, 57283, 57287, 57301, 57329, 57331, 57347, 57349, 57367, 57373, 57383, 57389, 57397, 57413, 57427, 57457, 57467, 57487, 57493, 57503, 57527, 57529, 57557, 57559, 57571, 57587, 57593, 57601, 57637, 57641, 57649, 57653, 57667, 57679, 57689, 57697, 57709, 57713, 57719, 57727, 57731, 57737, 57751, 57773, 57781, 57787, 57791, 57793, 57803, 57809, 57829, 57839, 57847, 57853, 57859, 57881, 57899, 57901, 57917, 57923, 57943, 57947, 57973, 57977, 57991, 58013, 58027, 58031, 58043, 58049, 58057, 58061, 58067, 58073, 58099, 58109, 58111, 58129, 58147, 58151, 58153, 58169, 58171, 58189, 58193, 58199, 58207, 58211, 58217, 58229, 58231, 58237, 58243, 58271, 58309, 58313, 58321, 58337, 58363, 58367, 58369, 58379, 58391, 58393, 58403, 58411, 58417, 58427, 58439, 58441, 58451, 58453, 58477, 58481, 58511, 58537, 58543, 58549, 58567, 58573, 58579, 58601, 58603, 58613, 58631, 58657, 58661, 58679, 58687, 58693, 58699, 58711, 58727, 58733, 58741, 58757, 58763, 58771, 58787, 58789, 58831, 58889, 58897, 58901, 58907, 58909, 58913, 58921, 58937, 58943, 58963, 58967, 58979, 58991, 58997, 59009, 59011, 59021, 59023, 59029, 59051, 59053, 59063, 59069, 59077, 59083, 59093, 59107, 59113, 59119, 59123, 59141, 59149, 59159, 59167, 59183, 59197, 59207, 59209, 59219, 59221, 59233, 59239, 59243, 59263, 59273, 59281, 59333, 59341, 59351, 59357, 59359, 59369, 59377, 59387, 59393, 59399, 59407, 59417, 59419, 59441, 59443, 59447, 59453, 59467, 59471, 59473, 59497, 59509, 59513, 59539, 59557, 59561, 59567, 59581, 59611, 59617, 59621, 59627, 59629, 59651, 59659, 59663, 59669, 59671, 59693, 59699, 59707, 59723, 59729, 59743, 59747, 59753, 59771, 59779, 59791, 59797, 59809, 59833, 59863, 59879, 59887, 59921, 59929, 59951, 59957, 59971, 59981, 59999, 60013, 60017, 60029, 60037, 60041, 60077, 60083, 60089, 60091, 60101, 60103, 60107, 60127, 60133, 60139, 60149, 60161, 60167, 60169, 60209, 60217, 60223, 60251, 60257, 60259, 60271, 60289, 60293, 60317, 60331, 60337, 60343, 60353, 60373, 60383, 60397, 60413, 60427, 60443, 60449, 60457, 60493, 60497, 60509, 60521, 60527, 60539, 60589, 60601, 60607, 60611, 60617, 60623, 60631, 60637, 60647, 60649, 60659, 60661, 60679, 60689, 60703, 60719, 60727, 60733, 60737, 60757, 60761, 60763, 60773, 60779, 60793, 60811, 60821, 60859, 60869, 60887, 60889, 60899, 60901, 60913, 60917, 60919, 60923, 60937, 60943, 60953, 60961, 61001, 61007, 61027, 61031, 61043, 61051, 61057, 61091, 61099, 61121, 61129, 61141, 61151, 61153, 61169, 61211, 61223, 61231, 61253, 61261, 61283, 61291, 61297, 61331, 61333, 61339, 61343, 61357, 61363, 61379, 61381, 61403, 61409, 61417, 61441, 61463, 61469, 61471, 61483, 61487, 61493, 61507, 61511, 61519, 61543, 61547, 61553, 61559, 61561, 61583, 61603, 61609, 61613, 61627, 61631, 61637, 61643, 61651, 61657, 61667, 61673, 61681, 61687, 61703, 61717, 61723, 61729, 61751, 61757, 61781, 61813, 61819, 61837, 61843, 61861, 61871, 61879, 61909, 61927, 61933, 61949, 61961, 61967, 61979, 61981, 61987, 61991, 62003, 62011, 62017, 62039, 62047, 62053, 62057, 62071, 62081, 62099, 62119, 62129, 62131, 62137, 62141, 62143, 62171, 62189, 62191, 62201, 62207, 62213, 62219, 62233, 62273, 62297, 62299, 62303, 62311, 62323, 62327, 62347, 62351, 62383, 62401, 62417, 62423, 62459, 62467, 62473, 62477, 62483, 62497, 62501, 62507, 62533, 62539, 62549, 62563, 62581, 62591, 62597, 62603, 62617, 62627, 62633, 62639, 62653, 62659, 62683, 62687, 62701, 62723, 62731, 62743, 62753, 62761, 62773, 62791, 62801, 62819, 62827, 62851, 62861, 62869, 62873, 62897, 62903, 62921, 62927, 62929, 62939, 62969, 62971, 62981, 62983, 62987, 62989, 63029, 63031, 63059, 63067, 63073, 63079, 63097, 63103, 63113, 63127, 63131, 63149, 63179, 63197, 63199, 63211, 63241, 63247, 63277, 63281, 63299, 63311, 63313, 63317, 63331, 63337, 63347, 63353, 63361, 63367, 63377, 63389, 63391, 63397, 63409, 63419, 63421, 63439, 63443, 63463, 63467, 63473, 63487, 63493, 63499, 63521, 63527, 63533, 63541, 63559, 63577, 63587, 63589, 63599, 63601, 63607, 63611, 63617, 63629, 63647, 63649, 63659, 63667, 63671, 63689, 63691, 63697, 63703, 63709, 63719, 63727, 63737, 63743, 63761, 63773, 63781, 63793, 63799, 63803, 63809, 63823, 63839, 63841, 63853, 63857, 63863, 63901, 63907, 63913, 63929, 63949, 63977, 63997, 64007, 64013, 64019, 64033, 64037, 64063, 64067, 64081, 64091, 64109, 64123, 64151, 64153, 64157, 64171, 64187, 64189, 64217, 64223, 64231, 64237, 64271, 64279, 64283, 64301, 64303, 64319, 64327, 64333, 64373, 64381, 64399, 64403, 64433, 64439, 64451, 64453, 64483, 64489, 64499, 64513, 64553, 64567, 64577, 64579, 64591, 64601, 64609, 64613, 64621, 64627, 64633, 64661, 64663, 64667, 64679, 64693, 64709, 64717, 64747, 64763, 64781, 64783, 64793, 64811, 64817, 64849, 64853, 64871, 64877, 64879, 64891, 64901, 64919, 64921, 64927, 64937, 64951, 64969, 64997, 65003, 65011, 65027, 65029, 65033, 65053, 65063, 65071, 65089, 65099, 65101, 65111, 65119, 65123, 65129, 65141, 65147, 65167, 65171, 65173, 65179, 65183, 65203, 65213, 65239, 65257, 65267, 65269, 65287, 65293, 65309, 65323, 65327, 65353, 65357, 65371, 65381, 65393, 65407, 65413, 65419, 65423, 65437, 65447, 65449, 65479, 65497, 65519, 65521 } ; } // namespace Givaro givaro-4.0.2/src/kernel/field/givprimes16.h000066400000000000000000000022551274707324300205000ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/zpz/givprimes16.h,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: T. Gautier // Time-stamp: <02 Oct 07 16:43:17 Jean-Guillaume.Dumas@imag.fr> // ========================================================================== /*! @file givprimes16.h * @ingroup zpz * @brief set of primes less than 2^16 */ #ifndef __GIVARO_primes16_H #define __GIVARO_primes16_H #include namespace Givaro { //! class Primes16 class Primes16 { public: // -- Returns the number of primes of this ctxt static size_t count() { return _size; } static size_t ith(size_t i) { // JGD 02.10.2007 : dependent of system/givconfig.h // GIVARO_ASSERT( (i>=0)&&(i<(int)_size), "[Primes16::ith] index out of bounds"); return _primes[i]; } private: static const size_t _size; static const size_t _primes[]; }; } // namespace Givaro #endif // __GIVARO_primes16_H givaro-4.0.2/src/kernel/field/givrns.h000066400000000000000000000063351274707324300176370ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/zpz/givrns.h,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: T. Gautier // $Id: givrns.h,v 1.5 2011-02-02 16:23:56 briceboyer Exp $ // ========================================================================== /*! @file givrns.h * @ingroup zpz * @brief Modular arithmetic for GIVARO. * Here is defined arithmetic functions * on rns representation and interface between RNS and Integer, * all is done via the Chinese Remainder Algorithm. */ #ifndef __GIVARO_arithmodu_H #define __GIVARO_arithmodu_H #include "givaro/givconfig.h" #include "givaro/giverror.h" #include "givaro/givarray0.h" namespace Givaro { /*! @brief class RNSsystem. * Structure which manages list of domains in order to convert integer * to/from RNS number system using a mixed radix form. This class is * parameterized by the type of \c RING and of \c Domain. * The ring should have: * - Ring( Modulo ) and Domain.init(Ring) conversions * - operator *= (Ring&, const Modulo&) * - operator += (Ring&, const Modulo&) * . */ template class RNSsystem { typedef RNSsystem Self_t; public: typedef RING ring; typedef typename Domain::Element modulo; typedef Array0 array; typedef Array0 domains; // Default Cstor, Dstor/Cstor of recopy: RNSsystem() ; ~RNSsystem() ; RNSsystem(const Self_t& R); // -- Cstor with given primes RNSsystem( const domains& primes ); // -- Computation of a mixed-radix representation of the residus. void RnsToMixedRadix(array& mixrad, const array& residu) ; // -- Convert a mixed radix representation to an Integer RING& MixedRadixToRing( RING& res, const array& mixrad ) const; // -- Convert a Ring Element to a its RNS representation // with the "this" rns system. void RingToRns( array& rns, const RING& a ) const; // -- Convert a RNS representation to a RING Element RING& RnsToRing( RING& a, const array& rns ) ; // ------------- Access methods // -- Returns the number of primes of this ctxt size_t size() const { return _primes.size(); } // -- Returns a array to the begin of the array of primes const domains& Primes() const; // -- Returns the ith primes of the rns system const Domain ith(const size_t i) const; //! -- Returns an array of the reciprocal \f$ck = \left(\prod_{j=0..k-1}p_j\right)^{-1} \mod pk\f$ const array& Reciprocals() const; const modulo reciprocal(const size_t i) const; // -- Cstor with given primes void setPrimes( const domains& primes ); protected: // -------------- Compute some fields of the structure : void ComputeCk(); domains _primes; // - array of the primes array _ck; // - reciprocals, _ck[0] = 1, same size as _primes }; } // namespace Givaro #include "givaro/givrnscstor.inl" #include "givaro/givrnsconvert.inl" #endif // __GIVARO_arithmodu_H // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/field/givrnsconvert.inl000077500000000000000000000102531274707324300215700ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/zpz/givrnsconvert.inl,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: T. Gautier // $Id: givrnsconvert.inl,v 1.5 2011-02-02 16:23:56 briceboyer Exp $ // ========================================================================== // Description: #ifndef __GIVARO_rns_convert_INL #define __GIVARO_rns_convert_INL namespace Givaro { // -- Computation of a mixed-radix representation of the residu. template void RNSsystem::RnsToMixedRadix (RNSsystem::array& mixrad, const RNSsystem::array& residu) { int j; int i=0,Size = (int)_primes.size(); if ((int)mixrad.size() < Size) mixrad.reallocate( (size_t)Size ); // -- Computation of Ck if (_ck.size()==0) ((RNSsystem*)this)->ComputeCk(); // -- Size-1 steps modulo t2, t3, t4, tmp; _primes[0].assign(mixrad[0],residu[0]); // _primes[0].write(std::cerr << "mixrad0 = ", mixrad[0]) << std::endl; for (i=1; i < (int)Size; ++i) { // - computes pp_i = r_0 + r_1*p_0 + ... + r_{i-1} \prod_{j "; // _primes[i].write(std::cerr << t4 << " mod " << _primes[i].characteristic() << ":: ", tmp) << std::endl; for (j= i-2; j>=0; --j) { // _primes[j].write(_primes[i].write(std::cerr << "mod " << _primes[i].characteristic() << ":: ", tmp) << " * " << _primes[j].characteristic() << " + ", mixrad[j]) <<" ="; _primes[i].init(t3, _primes[j].convert(t4, mixrad[j])); _primes[i].init(t4, _primes[j].characteristic()); _primes[i].axpy(t2, tmp, t4, t3); _primes[i].assign(tmp, t2); // _primes[i].write(std::cerr << " ", tmp) << std::endl; } // _primes[i].write(std::cerr << "\nmod" << _primes[i].characteristic() << ", sumprod = ", tmp) << std::endl; // - m_i = (r_i - pp_i)*ck_i, ck is reciprocals _primes[i].sub(t2, residu[i], tmp); _primes[i].assign(tmp, t2); // _primes[i].write(std::cerr << "mod " << _primes[i].characteristic() << ", sum - sumprod = ", tmp) << std::endl; _primes[i].mul(mixrad[i], tmp, _ck[i]); // _primes[i].write(std::cerr << "mod " << _primes[i].characteristic() << ", mixrad = ", mixrad[i]) << std::endl; } } // -- Convert a mixed radix representation to an Integer template RING& RNSsystem::MixedRadixToRing( RING& res, const RNSsystem::array& mixrad ) const { size_t Size = _primes.size(); if (!Size) GivError("_primes is empty"); if (Size != mixrad.size()) throw GivError("[RNSsystem::MixedRadixToRing]: bad size of input array"); _primes[int(Size-1)].convert(res,mixrad[int(Size-1)]); RING tmp; if( Size == 1 ) return res; for (int i=int(Size-1); i--; ) { res *= _primes[i].characteristic(); res += _primes[i].convert(tmp, mixrad[i]); } return res; } // Convert an integer to a RNS representation (which is given by this) template void RNSsystem::RingToRns( RNSsystem::array& rns , const RING& a) const { int Size = (int) _primes.size(); if ((int)rns.size() != Size) rns.reallocate((size_t)Size); // -- may be faster using the recursive // tree algorithm a mod p_1...p_k/2, and a mod p_k/2+1...p_k for (int i=0; i RING& RNSsystem::RnsToRing( RING& I, const RNSsystem::array& rns) { // - Computation of a mixed radix representation of this typename RNSsystem::array mixrad(_primes.size()); RnsToMixedRadix( mixrad , rns ); // - Convert mixrad to an integer return MixedRadixToRing( I, mixrad ) ; } } // namespace Givaro #endif // __GIVARO_rns_convert_INL // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/field/givrnscstor.inl000066400000000000000000000057211274707324300212430ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/zpz/givrnscstor.inl,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: T. Gaut%ier // $Id: givrnscstor.inl,v 1.4 2011-02-02 16:23:56 briceboyer Exp $ // ========================================================================== // Description: #ifndef __GIVARO_rns_cstor_INL #define __GIVARO_rns_cstor_INL namespace Givaro { // -- free memory allocated in array ! template RNSsystem::~RNSsystem() { } template RNSsystem::RNSsystem () : _primes(0), _ck(0) {} template RNSsystem::RNSsystem (const Self_t & R) : _primes(R._primes, givWithCopy()), _ck(R._ck, givWithCopy()) {} template void RNSsystem::setPrimes (const domains& inprimes) { _primes.allocate(0); _primes.copy( inprimes ); _ck.reallocate(0); } // -- Array of primes are given template RNSsystem::RNSsystem( const domains& inprimes) : _primes(inprimes, givWithCopy()), _ck(0) { GIVARO_ASSERT( inprimes.size()>0, "[RNSsystem::RNSsystem] bad size of array"); } // -- Computes Ck , Ck = (\prod_{i=0}^{k-1} primes[i])^(-1) % primes[k], // for k=1..(_sz-1) template void RNSsystem::ComputeCk() { if (_ck.size() !=0) return; // -- already computed // - reallocation of a new array : int Size = (int) _primes.size(); _ck.reallocate((size_t)Size); // _ck[0] = Neutral::zero; // -- undefined and never used for (int k=1; k < Size; ++k) { modulo prod, tmp; _primes[k].init(prod, _primes[0].characteristic()); for (int i= 1; i < k; ++i) _primes[k].mulin(prod, _primes[k].init(tmp,_primes[i].characteristic())); _primes[k].inv(_ck[k], prod); } } template const typename RNSsystem::domains& RNSsystem::Primes() const { return _primes; } template const Domain RNSsystem::ith(const size_t i) const { return _primes[i]; } template const typename RNSsystem::array& RNSsystem::Reciprocals() const { if (_ck.size() ==0) ((RNSsystem*)this)->ComputeCk(); return _ck; } template const typename RNSsystem::modulo RNSsystem::reciprocal(const size_t i) const { if (_ck.size() ==0) ((RNSsystem*)this)->ComputeCk(); return _ck[i]; } } // namespace Givaro #endif // __GIVARO_rns_cstor_INL // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/field/givrnsfixed.h000066400000000000000000000041461274707324300206550ustar00rootroot00000000000000// Copyright(c)'1994-2011 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Time-stamp: <01 Apr 11 15:43:07 Jean-Guillaume.Dumas@imag.fr> // ========================================================================== /*! @file givrnsfixed.h * @ingroup zpz * @brief Chinese Remainder Algorithm. */ #ifndef __GIVARO_arithmodu_fixedprimes_H #define __GIVARO_arithmodu_fixedprimes_H #include "givaro/givrns.h" #include "givaro/givrandom.h" #include "givaro/givintprime.h" #include "givaro/modular-integer.h" #include namespace Givaro { /*! @brief NO DOC */ template class RNSsystemFixed { typedef RNSsystemFixed Self_t; typedef RNSsystem > RNS_t; public: typedef std::vector array; typedef std::vector tree; // Default Cstor, Dstor/Cstor of recopy: RNSsystemFixed() ; ~RNSsystemFixed(); RNSsystemFixed(const Self_t& R); // -- Cstor with given primes RNSsystemFixed( const array& primes ); // -- Convert a RNS representation to a Ints Element template Ints& RnsToRing( Ints& a, const smallIntVector& rns ) ; // ------------- Access methods // -- Returns the number of primes of this ctxt int size() const { return _primes.size(); } // -- Returns a array to the beginning of the array of primes const tree& Primes() const; // -- Returns the ith primes of the rns system const Ints ith(const size_t i) const; protected: template Ints& RnsToRingLeft( Ints& I, const smallIntVector& residues, const int level, const int col ) ; template Ints& RnsToRingRight( Ints& I, const smallIntVector& residues, const int level, const int col ) ; tree _primes; // - array of the primes and reciprocals RNS_t _RNS; // - unbalanced recovery }; } // namespace Givaro #include "givaro/givrnsfixed.inl" #endif givaro-4.0.2/src/kernel/field/givrnsfixed.inl000066400000000000000000000117731274707324300212140ustar00rootroot00000000000000// Copyright(c)'1994-2011 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Time-stamp: <08 Mar 11 16:23:50 Jean-Guillaume.Dumas@imag.fr> // ========================================================================== // Description: // Chinese Remainder Algorithm. #ifndef __GIVARO_arithmodu_fixedprimes_INL #define __GIVARO_arithmodu_fixedprimes_INL #include "givaro/givpower.h" namespace Givaro { template template Ints& RNSsystemFixed::RnsToRingLeft( Ints& I, const smallIntVector& residues, const int level, const int col ) { if (level) { int lowercol=col<<1, lowercolnext=lowercol+1; int lowerlevel=level-1; Ints u0; RnsToRingLeft(u0, residues, lowerlevel, lowercol); RnsToRingRight(I, residues, lowerlevel, lowercolnext); I -= u0; // u1-u0 I *= _primes[(size_t)lowerlevel][(size_t)lowercolnext]; // (u1-u0) * (p0(p0^{-1} mod p1)) I += u0; // (u1-u0)*M01+u0 return Integer::modin(I, _primes[(size_t)level][(size_t)col]);// (u1-u0)*M01 +u0 mod p0p1, between 0 and p0p1-1 } else { return I=residues[(size_t)col]; } } template template Ints& RNSsystemFixed::RnsToRingRight( Ints& I, const smallIntVector& residues, const int level, const int col ) { if (level) { int lowercol=col<<1, lowercolnext=lowercol+1; int lowerlevel=level-1; Ints u0; RnsToRingLeft(u0, residues, lowerlevel, lowercol); RnsToRingRight(I, residues, lowerlevel, lowercolnext); I -= u0; // u1-u0 I *= _primes[(size_t)lowerlevel][(size_t)lowercolnext]; // (u1-u0) * (p0(p0^{-1} mod p1)) return I += u0; // (u1-u0)*M01+u0 } else { return I=residues[(size_t)col]; } } // Convert to an Ints: template template Ints& RNSsystemFixed::RnsToRing( Ints& I, const smallIntVector& rns) { int ir = (int)_RNS.Primes().size(); typename RNS_t::array Reds( (size_t)ir ); for(int i = (int)_primes.size(); i-- ;) { int is = (int)_primes[(size_t)i].size(); if (is & 1) { RnsToRingLeft(Reds[--ir], rns, i, --is); } } return _RNS.RnsToRing( I, Reds); } // -- free memory allocated in array ! template RNSsystemFixed::~RNSsystemFixed() {} template RNSsystemFixed::RNSsystemFixed () : _primes(0) {} template RNSsystemFixed::RNSsystemFixed (const Self_t& R) : _primes(R._primes, givWithCopy()) {} // -- Array of primes are given template RNSsystemFixed::RNSsystemFixed( const array& inprimes) : _primes(0) { GIVARO_ASSERT( inprimes.size()>0, "[RNSsystemFixed::RNSsystemFixed] bad size of array"); _primes.reserve( GIVINTLOG(inprimes.size()) ); _primes.resize(1); for(typename array::const_iterator pit = inprimes.begin(); pit != inprimes.end(); ++pit) { _primes.front().push_back( *pit ); for(int i = 1; i< (int)_primes.size(); ++i) { int s = (int)_primes[(size_t)i-1].size(); if (s & 1) break; else { Ints& p0(_primes[(size_t)i-1][(size_t)s-2]), & p1(_primes[(size_t)i-1][(size_t)s-1]); Ints prod(p0*p1); inv(p1, p0, p1) *= p0; _primes[(size_t)i].push_back( prod ); } } int lastp = int(_primes.size()-1); if (! (_primes.back().size() & 1)) { // std::cout << '['; // for(int j=0; j<_primes.back().size(); ++j) // std::cout << ' ' << _primes.back()[j]; // std::cout << ']' << std::endl; array newlevel; int s = (int)_primes.back().size(); Ints& p0(_primes[(size_t)lastp][(size_t)s-2]), & p1(_primes[(size_t)lastp][(size_t)s-1]); newlevel.push_back( p0*p1 ); inv(p1, p0, p1) *= p0; _primes.push_back( newlevel ); } // std::cout << std::endl << "----------------" << std::endl; // std::cout << '['; // for(int i=0; i<_primes.size(); ++i) { // std::cout << '['; // for(int j=0; j<_primes[i].size(); ++j) // std::cout << ' ' << _primes[i][j]; // std::cout << ']' << std::endl; // } // std::cout << ']' << std::endl; // std::cout << "----------------" << std::endl; } int numodd=0; for(int i = (int)_primes.size(); i-- ; ) if (_primes[(size_t)i].size() & 1) ++numodd; typename RNS_t::domains Mods((size_t)numodd); for(int i = (int)_primes.size(); i-- ; ) { if (_primes[(size_t)i].size() & 1) Mods[--numodd] = _primes[(size_t)i].back(); } _RNS.setPrimes( Mods ); } template const typename RNSsystemFixed::tree& RNSsystemFixed::Primes() const { return _primes; } template const Ints RNSsystemFixed::ith(const size_t i) const { return _primes.front()[i]; } } // namespace Givaro #endif // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/field/givtablelimits.C000066400000000000000000000270501274707324300212760ustar00rootroot00000000000000// ========================================================================== // file: givadicqfq.C // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Time-stamp: <11 Jun 07 18:20:54 Jean-Guillaume.Dumas@imag.fr> // author: Jean-Guillaume.Dumas // Description: // t-adic max sizes for BLAS based linear algebra over extension fields // see: // [Dumas, Gautier, Pernet 2002] Finite field linear algebra subroutines. // ISSAC'02: Proceedings of the 2002 International Symposium on Symbolic // and Algebraic Computation, Lille, France pp 63--74. // ========================================================================== #include "givaro/givtablelimits.h" namespace Givaro { const size_t AdicSize::n_max_53[][_GIVARO_FF_MAXEXPONENT_] = { /* 2 */ { 104028, 517, 47, 11, 4, 2, 1}, /* 3 */ { 26007, 129, 11, 2, 1}, /* 5 */ { 6501, 32, 2}, /* 7 */ { 2889, 14, 1}, /* 11 */ { 1040, 5}, /* 13 */ { 722, 3}, /* 17 */ { 406, 2}, /* 19 */ { 321, 1}, /* 23 */ { 214, 1}, /* 29 */ { 132}, /* 31 */ { 115}, /* 37 */ { 80}, /* 41 */ { 65}, /* 43 */ { 58}, /* 47 */ { 49}, /* 53 */ { 38}, /* 59 */ { 30}, /* 61 */ { 28}, /* 67 */ { 23}, /* 71 */ { 21}, /* 73 */ { 20}, /* 79 */ { 17}, /* 83 */ { 15}, /* 89 */ { 13}, /* 97 */ { 11}, /* 101 */ { 10}, /* 103 */ { 9}, /* 107 */ { 9}, /* 109 */ { 8}, /* 113 */ { 8}, /* 127 */ { 6}, /* 131 */ { 6}, /* 137 */ { 5}, /* 139 */ { 5}, /* 149 */ { 4}, /* 151 */ { 4}, /* 157 */ { 4}, /* 163 */ { 3}, /* 167 */ { 3}, /* 173 */ { 3}, /* 179 */ { 3}, /* 181 */ { 3}, /* 191 */ { 2}, /* 193 */ { 2}, /* 197 */ { 2}, /* 199 */ { 2}, /* 211 */ { 2}, /* 223 */ { 2}, /* 227 */ { 2}, /* 229 */ { 2}, /* 233 */ { 1}, /* 239 */ { 1}, /* 241 */ { 1}, /* 251 */ { 1}, /* 257 */ { 1}, /* 263 */ { 1}, /* 269 */ { 1}, /* 271 */ { 1}, /* 277 */ { 1}, /* 281 */ { 1}, /* 283 */ { 1}, /* 293 */ { 1}, /* 307 */ { 1}, /* 311 */ { 1}, /* 313 */ { 1}, /* 317 */ { 1} }; const size_t AdicSize::qadic_53[][_GIVARO_FF_MAXEXPONENT_] = { /* 2 */ { 208057, 1553, 191, 59, 29, 17, 11}, /* 3 */ { 208057, 1549, 179, 41, 29}, /* 5 */ { 208037, 1543, 131}, /* 7 */ { 208009, 1523, 149}, /* 11 */ { 208001, 1511}, /* 13 */ { 207941, 1297}, /* 17 */ { 207877, 1543}, /* 19 */ { 208009, 977}, /* 23 */ { 207169, 1453}, /* 29 */ { 206993}, /* 31 */ { 207013}, /* 37 */ { 207367}, /* 41 */ { 208001}, /* 43 */ { 204641}, /* 47 */ { 207371}, /* 53 */ { 205507}, /* 59 */ { 201847}, /* 61 */ { 201611}, /* 67 */ { 200381}, /* 71 */ { 205817}, /* 73 */ { 207367}, /* 79 */ { 206879}, /* 83 */ { 201731}, /* 89 */ { 201359}, /* 97 */ { 202753}, /* 101 */ { 200003}, /* 103 */ { 187273}, /* 107 */ { 202277}, /* 109 */ { 186629}, /* 113 */ { 200713}, /* 127 */ { 190523}, /* 131 */ { 202817}, /* 137 */ { 184967}, /* 139 */ { 190471}, /* 149 */ { 175261}, /* 151 */ { 180001}, /* 157 */ { 194707}, /* 163 */ { 157477}, /* 167 */ { 165343}, /* 173 */ { 177511}, /* 179 */ { 190121}, /* 181 */ { 194413}, /* 191 */ { 144407}, /* 193 */ { 147457}, /* 197 */ { 153689}, /* 199 */ { 156817}, /* 211 */ { 176401}, /* 223 */ { 197137}, /* 227 */ { 204311}, /* 229 */ { 207941}, /* 233 */ { 107671}, /* 239 */ { 113327}, /* 241 */ { 115201}, /* 251 */ { 125003}, /* 257 */ { 131101}, /* 263 */ { 137303}, /* 269 */ { 143651}, /* 271 */ { 145807}, /* 277 */ { 152363}, /* 281 */ { 156817}, /* 283 */ { 159059}, /* 293 */ { 170537}, /* 307 */ { 187273}, /* 311 */ { 192229}, /* 313 */ { 194707}, /* 317 */ { 199721} }; const size_t AdicSize::n_max_64[][_GIVARO_FF_MAXEXPONENT_] = { /* 2 */ { 1321119, 2376, 140, 27, 8, 4, 2, 1, 1}, /* 3 */ { 330279, 594, 35, 6, 2, 1}, /* 5 */ { 82569, 148, 8, 1}, /* 7 */ { 36697, 66, 3}, /* 11 */ { 13211, 23, 1}, /* 13 */ { 9174, 16}, /* 17 */ { 5160, 9}, /* 19 */ { 4077, 7}, /* 23 */ { 2729, 4}, /* 29 */ { 1685, 3}, /* 31 */ { 1467, 2}, /* 37 */ { 1019, 1}, /* 41 */ { 825, 1}, /* 43 */ { 748, 1}, /* 47 */ { 624, 1}, /* 53 */ { 488}, /* 59 */ { 392}, /* 61 */ { 366}, /* 67 */ { 303}, /* 71 */ { 269}, /* 73 */ { 254}, /* 79 */ { 217}, /* 83 */ { 196}, /* 89 */ { 170}, /* 97 */ { 143}, /* 101 */ { 132}, /* 103 */ { 126}, /* 107 */ { 117}, /* 109 */ { 113}, /* 113 */ { 105}, /* 127 */ { 83}, /* 131 */ { 78}, /* 137 */ { 71}, /* 139 */ { 69}, /* 149 */ { 60}, /* 151 */ { 58}, /* 157 */ { 54}, /* 163 */ { 50}, /* 167 */ { 47}, /* 173 */ { 44}, /* 179 */ { 41}, /* 181 */ { 40}, /* 191 */ { 36}, /* 193 */ { 35}, /* 197 */ { 34}, /* 199 */ { 33}, /* 211 */ { 29}, /* 223 */ { 26}, /* 227 */ { 25}, /* 229 */ { 25}, /* 233 */ { 24}, /* 239 */ { 23}, /* 241 */ { 22}, /* 251 */ { 21}, /* 257 */ { 20}, /* 263 */ { 19}, /* 269 */ { 18}, /* 271 */ { 18}, /* 277 */ { 17}, /* 281 */ { 16}, /* 283 */ { 16}, /* 293 */ { 15}, /* 307 */ { 14}, /* 311 */ { 13}, /* 313 */ { 13}, /* 317 */ { 13}, /* 331 */ { 12}, /* 337 */ { 11}, /* 347 */ { 11}, /* 349 */ { 10}, /* 353 */ { 10}, /* 359 */ { 10}, /* 367 */ { 9}, /* 373 */ { 9}, /* 379 */ { 9}, /* 383 */ { 9}, /* 389 */ { 8}, /* 397 */ { 8}, /* 401 */ { 8}, /* 409 */ { 7}, /* 419 */ { 7}, /* 421 */ { 7}, /* 431 */ { 7}, /* 433 */ { 7}, /* 439 */ { 6}, /* 443 */ { 6}, /* 449 */ { 6}, /* 457 */ { 6}, /* 461 */ { 6}, /* 463 */ { 6}, /* 467 */ { 6}, /* 479 */ { 5}, /* 487 */ { 5}, /* 491 */ { 5}, /* 499 */ { 5}, /* 503 */ { 5}, /* 509 */ { 5}, /* 521 */ { 4}, /* 523 */ { 4}, /* 541 */ { 4}, /* 547 */ { 4}, /* 557 */ { 4}, /* 563 */ { 4}, /* 569 */ { 4}, /* 571 */ { 4}, /* 577 */ { 3}, /* 587 */ { 3}, /* 593 */ { 3}, /* 599 */ { 3}, /* 601 */ { 3}, /* 607 */ { 3}, /* 613 */ { 3}, /* 617 */ { 3}, /* 619 */ { 3}, /* 631 */ { 3}, /* 641 */ { 3}, /* 643 */ { 3}, /* 647 */ { 3}, /* 653 */ { 3}, /* 659 */ { 3}, /* 661 */ { 3}, /* 673 */ { 2}, /* 677 */ { 2}, /* 683 */ { 2}, /* 691 */ { 2}, /* 701 */ { 2}, /* 709 */ { 2}, /* 719 */ { 2}, /* 727 */ { 2}, /* 733 */ { 2}, /* 739 */ { 2}, /* 743 */ { 2}, /* 751 */ { 2}, /* 757 */ { 2}, /* 761 */ { 2}, /* 769 */ { 2}, /* 773 */ { 2}, /* 787 */ { 2}, /* 797 */ { 2}, /* 809 */ { 2}, /* 811 */ { 2}, /* 821 */ { 1}, /* 823 */ { 1}, /* 827 */ { 1}, /* 829 */ { 1}, /* 839 */ { 1}, /* 853 */ { 1}, /* 857 */ { 1}, /* 859 */ { 1}, /* 863 */ { 1}, /* 877 */ { 1}, /* 881 */ { 1}, /* 883 */ { 1}, /* 887 */ { 1}, /* 907 */ { 1}, /* 911 */ { 1}, /* 919 */ { 1}, /* 929 */ { 1}, /* 937 */ { 1}, /* 941 */ { 1}, /* 947 */ { 1}, /* 953 */ { 1}, /* 967 */ { 1}, /* 971 */ { 1}, /* 977 */ { 1}, /* 983 */ { 1}, /* 991 */ { 1}, /* 997 */ { 1}, /* 1009 */ { 1}, /* 1013 */ { 1}, /* 1019 */ { 1}, /* 1021 */ { 1}, /* 1031 */ { 1}, /* 1033 */ { 1}, /* 1039 */ { 1}, /* 1049 */ { 1}, /* 1051 */ { 1}, /* 1061 */ { 1}, /* 1063 */ { 1}, /* 1069 */ { 1}, /* 1087 */ { 1}, /* 1091 */ { 1}, /* 1093 */ { 1}, /* 1097 */ { 1}, /* 1103 */ { 1}, /* 1109 */ { 1}, /* 1117 */ { 1}, /* 1123 */ { 1}, /* 1129 */ { 1} }; const size_t AdicSize::qadic_64[][_GIVARO_FF_MAXEXPONENT_] = { /* 2 */ { 2642239, 7129, 563, 137, 53, 29, 17, 11, 11}, /* 3 */ { 2642239, 7129, 563, 127, 53, 29}, /* 5 */ { 2642231, 7109, 521, 83}, /* 7 */ { 2642201, 7129, 433}, /* 11 */ { 2642201, 6907, 401}, /* 13 */ { 2642117, 6917}, /* 17 */ { 2641921, 6917}, /* 19 */ { 2641901, 6823}, /* 23 */ { 2641687, 5813}, /* 29 */ { 2642111, 7057}, /* 31 */ { 2640643, 5407}, /* 37 */ { 2641277, 3889}, /* 41 */ { 2640013, 4801}, /* 43 */ { 2638949, 5297}, /* 47 */ { 2640779, 6353}, /* 53 */ { 2639107}, /* 59 */ { 2637379}, /* 61 */ { 2635229}, /* 67 */ { 2639759}, /* 71 */ { 2636203}, /* 73 */ { 2633473}, /* 79 */ { 2640497}, /* 83 */ { 2635819}, /* 89 */ { 2632967}, /* 97 */ { 2635783}, /* 101 */ { 2640013}, /* 103 */ { 2621819}, /* 107 */ { 2629243}, /* 109 */ { 2636077}, /* 113 */ { 2634241}, /* 127 */ { 2635429}, /* 131 */ { 2636401}, /* 137 */ { 2626433}, /* 139 */ { 2628077}, /* 149 */ { 2628481}, /* 151 */ { 2610059}, /* 157 */ { 2628331}, /* 163 */ { 2624411}, /* 167 */ { 2590271}, /* 173 */ { 2603401}, /* 179 */ { 2598091}, /* 181 */ { 2592043}, /* 191 */ { 2599217}, /* 193 */ { 2580493}, /* 197 */ { 2612297}, /* 199 */ { 2587499}, /* 211 */ { 2557813}, /* 223 */ { 2562803}, /* 227 */ { 2553823}, /* 229 */ { 2599217}, /* 233 */ { 2583557}, /* 239 */ { 2605627}, /* 241 */ { 2534401}, /* 251 */ { 2625001}, /* 257 */ { 2621447}, /* 263 */ { 2608483}, /* 269 */ { 2585707}, /* 271 */ { 2624411}, /* 277 */ { 2589991}, /* 281 */ { 2508823}, /* 283 */ { 2544769}, /* 293 */ { 2557931}, /* 307 */ { 2621819}, /* 311 */ { 2498603}, /* 313 */ { 2530961}, /* 317 */ { 2596277}, /* 331 */ { 2613601}, /* 337 */ { 2483713}, /* 347 */ { 2633783}, /* 349 */ { 2422087}, /* 353 */ { 2478083}, /* 359 */ { 2563291}, /* 367 */ { 2411209}, /* 373 */ { 2490931}, /* 379 */ { 2571937}, /* 383 */ { 2626633}, /* 389 */ { 2408723}, /* 397 */ { 2509061}, /* 401 */ { 2560021}, /* 409 */ { 2330501}, /* 419 */ { 2446139}, /* 421 */ { 2469629}, /* 431 */ { 2588611}, /* 433 */ { 2612749}, /* 439 */ { 2302151}, /* 443 */ { 2344379}, /* 449 */ { 2408501}, /* 457 */ { 2495239}, /* 461 */ { 2539213}, /* 463 */ { 2561341}, /* 467 */ { 2605909}, /* 479 */ { 2284859}, /* 487 */ { 2361977}, /* 491 */ { 2401013}, /* 499 */ { 2480053}, /* 503 */ { 2520073}, /* 509 */ { 2580647}, /* 521 */ { 2163221}, /* 523 */ { 2179897}, /* 541 */ { 2332817}, /* 547 */ { 2384951}, /* 557 */ { 2473099}, /* 563 */ { 2526763}, /* 569 */ { 2580997}, /* 571 */ { 2599217}, /* 577 */ { 1990657}, /* 587 */ { 2060389}, /* 593 */ { 2102791}, /* 599 */ { 2145629}, /* 601 */ { 2160001}, /* 607 */ { 2203427}, /* 613 */ { 2247277}, /* 617 */ { 2276737}, /* 619 */ { 2291557}, /* 631 */ { 2381413}, /* 641 */ { 2457607}, /* 643 */ { 2473019}, /* 647 */ { 2503909}, /* 653 */ { 2550641}, /* 659 */ { 2597809}, /* 661 */ { 2613601}, /* 673 */ { 1806341}, /* 677 */ { 1827929}, /* 683 */ { 1860503}, /* 691 */ { 1904407}, /* 701 */ { 1960009}, /* 709 */ { 2005057}, /* 719 */ { 2062129}, /* 727 */ { 2108317}, /* 733 */ { 2143313}, /* 739 */ { 2178581}, /* 743 */ { 2202269}, /* 751 */ { 2250013}, /* 757 */ { 2286149}, /* 761 */ { 2310421}, /* 769 */ { 2359303}, /* 773 */ { 2383943}, /* 787 */ { 2471201}, /* 797 */ { 2534471}, /* 809 */ { 2611457}, /* 811 */ { 2624411}, /* 821 */ { 1344821}, /* 823 */ { 1351373}, /* 827 */ { 1364569}, /* 829 */ { 1371179}, /* 839 */ { 1404497}, /* 853 */ { 1451831}, /* 857 */ { 1465481}, /* 859 */ { 1472333}, /* 863 */ { 1486091}, /* 877 */ { 1534783}, /* 881 */ { 1548847}, /* 883 */ { 1555861}, /* 887 */ { 1570007}, /* 907 */ { 1641709}, /* 911 */ { 1656203}, /* 919 */ { 1685449}, /* 929 */ { 1722373}, /* 937 */ { 1752193}, /* 941 */ { 1767203}, /* 947 */ { 1789849}, /* 953 */ { 1812611}, /* 967 */ { 1866331}, /* 971 */ { 1881811}, /* 977 */ { 1905157}, /* 983 */ { 1928653}, /* 991 */ { 1960201}, /* 997 */ { 1984039}, /* 1009 */ { 2032133}, /* 1013 */ { 2048327}, /* 1019 */ { 2072663}, /* 1021 */ { 2080801}, /* 1031 */ { 2121803}, /* 1033 */ { 2130061}, /* 1039 */ { 2154899}, /* 1049 */ { 2196611}, /* 1051 */ { 2205001}, /* 1061 */ { 2247209}, /* 1063 */ { 2255717}, /* 1069 */ { 2281249}, /* 1087 */ { 2358799}, /* 1091 */ { 2376203}, /* 1093 */ { 2384951}, /* 1097 */ { 2402441}, /* 1103 */ { 2428859}, /* 1109 */ { 2455337}, /* 1117 */ { 2490931}, /* 1123 */ { 2517797}, /* 1129 */ { 2544769} }; } // namespace Givaro givaro-4.0.2/src/kernel/field/givtablelimits.h000066400000000000000000000056461274707324300213520ustar00rootroot00000000000000// ========================================================================== // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // file: givadicqfq.h // Time-stamp: <30 Nov 11 11:12:05 Jean-Guillaume.Dumas@imag.fr> // date: 2007 // version: // author: Jean-Guillaume.Dumas /*! @file zpz/givtablelimits.h * @ingroup zpz * @brief Zech extension. * Zech extension fitting a small enough memory space * t-adic max sizes for BLAS based linear algebra over extension fields * @bib * - Dumas, Gautier, Pernet Finite field linear algebra subroutines. * ISSAC'02: Proceedings of the 2002 International Symposium on Symbolic * and Algebraic Computation, Lille, France pp 63--74. */ #ifndef __GIVARO_tablesize_MAX_H #define __GIVARO_tablesize_MAX_H #ifndef _GIVARO_FF_TABLE_MAX // 2^23 ---> 2^23*4*3 = 100K // #define FF_TABLE_MAX 8388608U // 2^20 ---> 2s on 735MHz //#define FF_TABLE_MAX 1048576U // Now 2^21+1 seems OK #define _GIVARO_FF_TABLE_MAX 2097153U #endif #ifndef _GIVARO_FF_MAXEXPONENT_ #define _GIVARO_FF_MAXEXPONENT_ 21 #endif #include #include #include "givaro/givprimes16.h" #include #include namespace Givaro { // --------------------------------------------- class class AdicSize { public: static size_t nmax53(const unsigned long P, const unsigned long e) { size_t i = 0; while (Primes16::ith(i) < P) ++i; return n_max_53[i][e-2]; } static size_t qmax53(const unsigned long P, const unsigned long e) { size_t i = 0; while (Primes16::ith(i) < P) ++i; return qadic_53[i][e-2]; } static size_t nmax64(const unsigned long P, const unsigned long e) { size_t i = 0; while (Primes16::ith(i) < P) ++i; return n_max_64[i][e-2]; } size_t qmax64(const unsigned long P, const unsigned long e) { size_t i = 0; while (Primes16::ith(i) < P) ++i; return qadic_64[i][e-2]; } static size_t twopmax53(const unsigned long P, const unsigned long e, const unsigned long nm) { double tmp = double(P-1); tmp *= double(P-1); tmp *= double(e); tmp *= double(nm); size_t k = (size_t)ilogb(tmp); return ( (53/(2*e-1))>k ? ++k : 0); } static size_t twopmax53(const unsigned long P, const unsigned long e) { size_t k = 53/(2*e-1); return ( std::pow((double)2.0,double(k))>double(e*(P-1)*(P-1)) ? k: 0); } private: static const size_t n_max_53[][_GIVARO_FF_MAXEXPONENT_]; static const size_t n_max_64[][_GIVARO_FF_MAXEXPONENT_]; static const size_t qadic_53[][_GIVARO_FF_MAXEXPONENT_]; static const size_t qadic_64[][_GIVARO_FF_MAXEXPONENT_]; }; } // namespace Givaro #endif // __GIVARO_tablesize_MAX_H givaro-4.0.2/src/kernel/gmp++/000077500000000000000000000000001274707324300157755ustar00rootroot00000000000000givaro-4.0.2/src/kernel/gmp++/Makefile.am000066400000000000000000000022651274707324300200360ustar00rootroot00000000000000# Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. AM_CPPFLAGS=-I$(top_srcdir) ${GMP_VERSION} pkgincludesubdir=$(includedir)/gmp++ AM_CXXFLAGS=@DEFAULT_CFLAGS@ AM_CPPFLAGS+= -I$(top_srcdir)/src/kernel/memory -I$(top_srcdir)/src/kernel/system -I$(top_srcdir)/src/kernel/recint noinst_LTLIBRARIES=libgmppp.la pkgincludesub_HEADERS=\ gmp++.h \ gmp++_int.h \ gmp++_int_rand.inl \ gmp++_rat.h \ gmp++_rat.inl libgmppp_la_SOURCES= gmp++_int_lib.C COMMONFILES= \ gmp++_int_div.C \ gmp++_int_mod.C \ gmp++_int_sub.C \ gmp++_int_compare.C \ gmp++_rat_compare.C \ gmp++_int_gcd.C \ gmp++_int_io.C \ gmp++_rat_io.C \ gmp++_int_mul.C \ gmp++_int_add.C \ gmp++_rat_add.C \ gmp++_int_cstor.C \ gmp++_rat_cstor.C \ gmp++_int_misc.C \ gmp++_rat_misc.C \ gmp++_int_pow.C if GIVARO_INLINE_ALL pkgincludesub_HEADERS += \ gmp++_int.C \ gmp++_rat.C \ $(COMMONFILES) else libgmppp_la_SOURCES+= \ $(COMMONFILES) endif EXTRA_DIST= gmp++.doxy givaro-4.0.2/src/kernel/gmp++/gmp++.doxy000077500000000000000000000005701274707324300176200ustar00rootroot00000000000000// Copyright(c)'2010 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. /*! @ingroup givaro * @defgroup gmp GMP * * \brief Wrapper (and more) around GMP integer interface * */ // vim:syntax=doxygen givaro-4.0.2/src/kernel/gmp++/gmp++.h000066400000000000000000000026351274707324300170650ustar00rootroot00000000000000// ======================================================================== // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Givaro version of gmp++.h // Time-stamp: <03 Aug 15 11:12:00 Jean-Guillaume.Dumas@imag.fr> // ======================================================================== #ifndef __GIVARO_GMPplusplus_H #define __GIVARO_GMPplusplus_H #include #include #include // required by gcc 4.3 #include #ifdef __GIVARO_INLINE_ALL #define giv_all_inlined inline #else #define giv_all_inlined #endif #ifndef __GIVARO__DONOTUSE_longlong__ #define __USE_64_bits__ #endif #ifndef __DONOTUSE_Givaro_SIXTYFOUR__ #define __USE_64_bits__ #endif #if !defined(GMP_VERSION_3) && !defined(GMP_NO_CXX) && !defined(__GIVARO_GMP_VERSION_3) && !defined(__GIVARO_GMP_NO_CXX) // gmpxx.h defines __GMP_PLUSPLUS__ #include #endif #ifdef __GIVARO_GMP_VERSION_3 extern "C" { #endif #include #ifdef __GIVARO_GMP_VERSION_3 } #endif #ifdef NDEBUG #ifdef DEBUG #error "NDEBUG and DEBUG both defined" #endif #endif #ifndef _GIVARO_ISPRIMETESTS_ #define _GIVARO_ISPRIMETESTS_ 5 #endif #include #include #endif // __GIVARO_GMPplusplus_H givaro-4.0.2/src/kernel/gmp++/gmp++_int.C000066400000000000000000000013061274707324300176640ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. #ifndef __GMPplusplus_INTEGER_C__ #define __GMPplusplus_INTEGER_C__ #include "gmp++_int_cstor.C" #include "gmp++_int_add.C" #include "gmp++_int_sub.C" #include "gmp++_int_mul.C" #include "gmp++_int_pow.C" #include "gmp++_int_div.C" #include "gmp++_int_mod.C" #include "gmp++_int_gcd.C" #include "gmp++_int_misc.C" #include "gmp++_int_compare.C" #include "gmp++_int_io.C" #endif // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/gmp++/gmp++_int.h000066400000000000000000002056241274707324300177420ustar00rootroot00000000000000// ======================================================================== // Copyright(c)'1994-2010 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: M. Samama, T. Gautier, JG. Dumas // Modified by: B. Boyer // Time-stamp: <22 Oct 10 15:35:39 Jean-Guillaume.Dumas@imag.fr> // ======================================================================== // Description: // Integer class definition based on Gmp (>V2.0 or 1.3.2) #ifndef __GIVARO_GMPplusplus_integer_H #define __GIVARO_GMPplusplus_integer_H /*! @file kernel/gmp++/gmp++_int.h * @ingroup integers * Core gmp++_int.h. */ #include #include #include #include // #include #include "recint/ruconvert.h" // For ruint_to_mpz() #include "recint/rconvert.h" // For rint_to_mpz() #ifndef __GIVARO_GMPplusplus_H #warning "you should include before (or prepare for the worse)" #endif #ifdef __USE_64_bits__ # define __USE_GMPPLUSPLUS_SIXTYFOUR__ #endif #ifdef __USE_ISOC99 # define __USE_GMPPLUSPLUS_SIXTYFOUR__ #endif #include namespace Givaro { //------------------------------------------------------ Friend Integer // forward declaration. class Integer; // (FILE gmp++_int_gcd.C) /*! @brief Modular inverse. * @param a * @param b * @param[out] u is set to \f$a^{-1}\f$ modulo b */ Integer& inv (Integer& u, const Integer& a, const Integer& b); Integer& invin (Integer& u, const Integer& b); Integer gcd (const Integer& a, const Integer& b); Integer gcd (Integer& u, Integer& v,const Integer& a, const Integer& b); Integer& gcd (Integer& g, const Integer& a, const Integer& b); Integer& gcd (Integer& g, Integer& u, Integer& v, const Integer& a, const Integer& b); Integer pp( const Integer& P, const Integer& Q ); Integer& lcm (Integer& g, const Integer& a, const Integer& b); Integer lcm (const Integer& a, const Integer& b); // (FILE gmp++_int_pow.C) Integer& pow(Integer& Res, const Integer& n, const int64_t l); Integer& pow(Integer& Res, const uint64_t n, const uint64_t l); Integer& pow(Integer& Res, const Integer& n, const uint64_t l); Integer& pow(Integer& Res, const Integer& n, const int32_t l) ; Integer& pow(Integer& Res, const Integer& n, const uint32_t l) ; Integer pow(const Integer& n, const int64_t l); Integer pow(const Integer& n, const uint64_t l); Integer pow(const Integer& n, const int32_t l) ; Integer pow(const Integer& n, const uint32_t l); Integer& powmod(Integer& Res, const Integer& n, const uint64_t e, const Integer& m); Integer& powmod(Integer& Res, const Integer& n, const int64_t e, const Integer& m); Integer& powmod(Integer& Res, const Integer& n, const uint32_t e, const Integer& m) ; Integer& powmod(Integer& Res, const Integer& n, const int32_t e, const Integer& m) ; Integer& powmod(Integer& Res, const Integer& n, const Integer& e, const Integer& m); Integer powmod(const Integer& n, const uint64_t e, const Integer& m); Integer powmod(const Integer& n, const int64_t e, const Integer& m); Integer powmod(const Integer& n, const uint32_t e, const Integer& m) ; Integer powmod(const Integer& n, const int32_t e, const Integer& m) ; Integer powmod(const Integer& n, const Integer& e, const Integer& m); // (FILE inline) int32_t sign (const Integer& a); // (FILE gmp++_int_compare.C) int32_t compare(const Integer& a, const Integer& b); int32_t absCompare(const Integer& a, const Integer& b); int32_t absCompare(const Integer& a, const double b); int32_t absCompare(const Integer& a, const float b); int32_t absCompare(const Integer& a, const uint64_t b); int32_t absCompare(const Integer& a, const unsigned b); int32_t absCompare(const Integer& a, const int64_t b); int32_t absCompare(const Integer& a, const int32_t b); template int32_t absCompare( const T a, const Integer & b) { return absCompare(b,a); } int32_t isZero (const Integer& a); int32_t nonZero (const Integer& a); int32_t isOne (const Integer& a); int32_t isMOne (const Integer& a); // (FILE gmp++_int_misc.C) Integer fact ( uint64_t l); Integer sqrt(const Integer& p); Integer sqrtrem(const Integer& p, Integer& rem); Integer& sqrt(Integer& r, const Integer& p); Integer& sqrtrem(Integer& r, const Integer& p, Integer& rem); bool root(Integer& q, const Integer&, uint32_t n); int64_t logp(const Integer& a, const Integer& p) ; double logtwo(const Integer& a) ; double naturallog(const Integer& a) ; void swap(Integer& , Integer&); int32_t isperfectpower (const Integer& ); Integer abs(const Integer& n); int32_t jacobi(const Integer& u, const Integer& v) ; int32_t legendre(const Integer& u, const Integer& v) ; bool isOdd(const Integer&); uint64_t length (const Integer& a); // (FILE gmp++_int_io.C) std::istream& operator >> (std::istream &i, Integer& n); std::ostream& operator << (std::ostream &o, const Integer& n); std::ostream& absOutput (std::ostream &o, const Integer& n); // The following are protected // to deal with primality, use Givaro::IntPrimeDom namespace Protected { void importWords(Integer&, size_t, int, int, int, size_t, const void*); Integer& prevprime(Integer&, const Integer& p); Integer& nextprime(Integer&, const Integer& p); int32_t probab_prime(const Integer& p, int32_t r=_GIVARO_ISPRIMETESTS_); } //------------------------------------------------------ Class Integer /*! @ingroup integers * This is the Integer class. * An Integer is represented as a GMP integer. * This class provides arithmetic on Integers. */ class Integer { public: //! vector of limbs (ie a gmp number). typedef std::vector vect_t; //--------------------------------------cstors & dstors // (FILE gmp++_cstor.C) /*! @name Constructor/Destructors. * Constructors and destructor for an Integer. */ /// Constructor form a known type. ///@param n input to be constructed from giv_all_inlined Integer(int32_t n = 0); //! @overload Givaro::Integer(int) giv_all_inlined Integer(int64_t n); //! @overload Givaro::Integer(int) giv_all_inlined Integer(unsigned char n); //! @overload Givaro::Integer(int) giv_all_inlined Integer(uint32_t n); //! @overload Givaro::Integer(int) giv_all_inlined Integer(uint64_t n); //! @overload Givaro::Integer(int) giv_all_inlined Integer(double n); //! @overload Givaro::Integer(int) giv_all_inlined Integer(const char *n); //! @overload Givaro::Integer(mpz_class) giv_all_inlined Integer(const mpz_class& a) { mpz_init_set((mpz_ptr)&gmp_rep, a.get_mpz_t()) ; } //! @overload Givaro::Integer(RecInt::ruint) template Integer(const RecInt::ruint& n) { RecInt::ruint_to_mpz_t(get_mpz(), n); } //! @overload Givaro::Integer(RecInt::ruint) template Integer(const RecInt::rint& n) { RecInt::rint_to_mpz_t(get_mpz(), n); } /*! Copy constructor * @param n input to be constructed from */ giv_all_inlined Integer(const Integer& n); /*! Creates a new Integer from pointers. * @param d array * @param sz size */ giv_all_inlined Integer(uint64_t* d, int64_t sz); /*! Creates a new Integers for a vector of limbs * @param v vector of limbs */ giv_all_inlined Integer( const vect_t &v); //! destructor giv_all_inlined ~Integer(); ///@} //------------------------------------- predefined null and one //! zero (0) static const Integer zero ; //! one (1) static const Integer one ; //! minus one (-1) static const Integer mOne ; // -- Assignment and copy operators /*! @name Assignment and copy operators */ /*! copy from an integer. * @param n integer to copy. */ ///@{ giv_all_inlined Integer& operator = (const Integer& n); giv_all_inlined Integer& logcpy(const Integer& n); giv_all_inlined Integer& copy(const Integer& n); ///@} //------------------Equalities and inequalities between integers and basic // (FILE gmp++_int_compare.C) //! @name Comparisons functions. ///@{ /*! Compares two integers. * @param a integer * @param b integer * @return \c 1 if \f$a > b\f$, \c 0 if \f$a = b\f$ and \p -1 otherwise. */ giv_all_inlined friend int32_t compare(const Integer& a, const Integer& b); /** Compare the norm of two integers. * @param a integer * @param b integer * @return \c 1 if \f$|a| > |b|\f$, \c 0 if \f$|a| = |b|\f$ and \p -1 otherwise. */ giv_all_inlined friend int32_t absCompare(const Integer& a, const Integer& b); /** @overload Integer::absCompare(Integer, Integer) */ giv_all_inlined friend int32_t absCompare(const Integer& a, const double b); /** @overload Integer::absCompare(Integer, Integer) */ giv_all_inlined friend int32_t absCompare(const Integer& a, const float b); /** @overload Integer::absCompare(Integer, Integer) */ giv_all_inlined friend int32_t absCompare(const Integer& a, const uint64_t b); /** @overload Integer::absCompare(Integer, Integer) */ giv_all_inlined friend int32_t absCompare(const Integer& a, const unsigned b); /** @overload Integer::absCompare(Integer, Integer) */ giv_all_inlined friend int32_t absCompare(const Integer& a, const int64_t b); /** @overload Integer::absCompare(Integer, Integer) */ giv_all_inlined friend int32_t absCompare(const Integer& a, const int32_t b); /** @overload Integer::absCompare(Integer, Integer) */ template giv_all_inlined friend int32_t absCompare( const T a, const Integer & b) ; //! name compare to 1 and 0 //! @param a friend giv_all_inlined int32_t isOne(const Integer& a); friend giv_all_inlined int32_t isMOne(const Integer& a); //! name compare to 1 and 0 //! @param a friend giv_all_inlined int32_t nonZero(const Integer& a); //! name compare to 1 and 0 //! @param a friend giv_all_inlined int32_t isZero(const Integer& a); //! @overload Givaro::isZero(Integer); friend giv_all_inlined int32_t isZero(const int16_t a); //! @overload Givaro::isZero(Integer); friend giv_all_inlined int32_t isZero(const int32_t a); //! @overload Givaro::isZero(Integer); friend giv_all_inlined int32_t isZero(const int64_t a); //! @overload Givaro::isZero(Integer); friend giv_all_inlined int32_t isZero(const uint16_t a); //! @overload Givaro::isZero(Integer); friend giv_all_inlined int32_t isZero(const uint32_t a); //! @overload Givaro::isZero(Integer); friend giv_all_inlined int32_t isZero(const uint64_t a); //! isleq //! @param a,b template static giv_all_inlined bool isleq(const A&a,const B&b) { return a<=b ; } ///@} /** @name Comparison operators. * @brief Compare with operators. */ ///@{ /** greater or equal. * @param l integer to be compared to */ giv_all_inlined int32_t operator >= (const Integer & l) const; /** @overload Integer::operator>=(Integer) */ giv_all_inlined int32_t operator >= (const int32_t l) const; /** @overload Integer::operator>=(Integer) */ giv_all_inlined int32_t operator >= (const int64_t l) const; /** @overload Integer::operator>=(Integer) */ giv_all_inlined int32_t operator >= (const uint64_t l) const; /** @overload Integer::operator>=(Integer) */ giv_all_inlined int32_t operator >= (const uint32_t l) const; /** @overload Integer::operator>=(Integer) */ giv_all_inlined int32_t operator >= (const double l) const; /** @overload Integer::operator>=(Integer) */ giv_all_inlined int32_t operator >= (const float l) const; //! greater or equal. /// @param l,n integers to compare giv_all_inlined friend int32_t operator >= (uint32_t l, const Integer& n); /** @overload Integer::operator>=(unsigned, Integer) */ giv_all_inlined friend int32_t operator >= (float l, const Integer& n); /** @overload Integer::operator>=(unsigned, Integer) */ giv_all_inlined friend int32_t operator >= (double l, const Integer& n); /** @overload Integer::operator>=(unsigned, Integer) */ giv_all_inlined friend int32_t operator >= (int32_t l, const Integer& n); /** @overload Integer::operator>=(unsigned, Integer) */ giv_all_inlined friend int32_t operator >= (int64_t l, const Integer& n); /** @overload Integer::operator>=(unsigned, Integer) */ giv_all_inlined friend int32_t operator >= (uint64_t l, const Integer& n); //! less or equal /// @param l integer to be compared to giv_all_inlined int32_t operator <= (const Integer & l) const; /** @overload Integer::operator<=(Integer) */ giv_all_inlined int32_t operator <= (const int32_t l) const; /** @overload Integer::operator<=(Integer) */ giv_all_inlined int32_t operator <= (const int64_t l) const; /** @overload Integer::operator<=(Integer) */ giv_all_inlined int32_t operator <= (const uint64_t l) const; /** @overload Integer::operator<=(Integer) */ giv_all_inlined int32_t operator <= (const uint32_t l) const; /** @overload Integer::operator<=(Integer) */ giv_all_inlined int32_t operator <= (const double l) const; /** @overload Integer::operator<=(Integer) */ giv_all_inlined int32_t operator <= (const float l) const; //! less or equal /// @param l,n integers to compare giv_all_inlined friend int32_t operator <= (uint32_t l, const Integer& n); /** @overload Integer::operator>=(unsigned, Integer) */ giv_all_inlined friend int32_t operator <= (float l, const Integer& n); /** @overload Integer::operator>=(unsigned, Integer) */ giv_all_inlined friend int32_t operator <= (double l, const Integer& n); /** @overload Integer::operator>=(unsigned, Integer) */ giv_all_inlined friend int32_t operator <= (int32_t l, const Integer& n); /** @overload Integer::operator>=(unsigned, Integer) */ giv_all_inlined friend int32_t operator <= (int64_t l, const Integer& n); /** @overload Integer::operator>=(unsigned, Integer) */ giv_all_inlined friend int32_t operator <= (uint64_t l, const Integer& n); /*! operator != (not equal) * @param l integer * @return \c 1 iff l == this */ giv_all_inlined int32_t operator != (const Integer & l) const; /** @overload Integer::operator!=(Integer) */ giv_all_inlined int32_t operator != (const int32_t l) const; /** @overload Integer::operator!=(Integer) */ giv_all_inlined int32_t operator != (const int64_t l) const; /** @overload Integer::operator!=(Integer) */ giv_all_inlined int32_t operator != (const uint64_t l) const; /** @overload Integer::operator!=(Integer) */ giv_all_inlined int32_t operator != (const uint32_t l) const; /** @overload Integer::operator!=(Integer) */ giv_all_inlined int32_t operator != (const double l) const; /** @overload Integer::operator!=(Integer) */ giv_all_inlined int32_t operator != (const float l) const; /*! operator != (not equal) * @param l,n integer * @return \c 1 iff l == n */ giv_all_inlined friend int32_t operator != (uint32_t l, const Integer& n); /** @overload Integer::operator!=(unsigned, Integer) */ giv_all_inlined friend int32_t operator != (float l, const Integer& n); /** @overload Integer::operator!=(unsigned, Integer) */ giv_all_inlined friend int32_t operator != (double l, const Integer& n); /** @overload Integer::operator!=(unsigned, Integer) */ giv_all_inlined friend int32_t operator != (int32_t l, const Integer& n); /** @overload Integer::operator!=(unsigned, Integer) */ giv_all_inlined friend int32_t operator != (int64_t l, const Integer& n); /** @overload Integer::operator!=(unsigned, Integer) */ giv_all_inlined friend int32_t operator != (uint64_t l, const Integer& n); //! Equality /// @param l integer to be compared to giv_all_inlined int32_t operator == (const Integer & l) const; /** @overload Integer::operator==(Integer) */ giv_all_inlined int32_t operator == (const int32_t l) const; /** @overload Integer::operator==(Integer) */ giv_all_inlined int32_t operator == (const int64_t l) const; /** @overload Integer::operator==(Integer) */ giv_all_inlined int32_t operator == (const uint64_t l) const; /** @overload Integer::operator==(Integer) */ giv_all_inlined int32_t operator == (const uint32_t l) const; /** @overload Integer::operator==(Integer) */ giv_all_inlined int32_t operator == (const double l) const; /** @overload Integer::operator==(Integer) */ giv_all_inlined int32_t operator == (const float l) const; //! Equality /// @param l,n integers to compare giv_all_inlined friend int32_t operator == (uint32_t l, const Integer& n); /** @overload Integer::operator==(unsigned, Integer) */ giv_all_inlined friend int32_t operator == (float l, const Integer& n); /** @overload Integer::operator==(unsigned, Integer) */ giv_all_inlined friend int32_t operator == (double l, const Integer& n); /** @overload Integer::operator==(unsigned, Integer) */ giv_all_inlined friend int32_t operator == (int32_t l, const Integer& n); /** @overload Integer::operator==(unsigned, Integer) */ giv_all_inlined friend int32_t operator == (int64_t l, const Integer& n); /** @overload Integer::operator==(unsigned, Integer) */ giv_all_inlined friend int32_t operator == (uint64_t l, const Integer& n); //! greater (strict) /// @param l integer to be compared to giv_all_inlined int32_t operator > (const Integer & l) const; /** @overload Integer::operator>(Integer) */ giv_all_inlined int32_t operator > (const int32_t l) const; /** @overload Integer::operator>(Integer) */ giv_all_inlined int32_t operator > (const int64_t l) const; /** @overload Integer::operator>(Integer) */ giv_all_inlined int32_t operator > (const uint64_t l) const; /** @overload Integer::operator>(Integer) */ giv_all_inlined int32_t operator > (const uint32_t l) const; /** @overload Integer::operator>(Integer) */ giv_all_inlined int32_t operator > (const double l) const; /** @overload Integer::operator>(Integer) */ giv_all_inlined int32_t operator > (const float l) const; //! greater (strict) /// @param l,n integers to compare giv_all_inlined friend int32_t operator > (uint32_t l, const Integer& n); /** @overload Integer::operator>(unsigned, Integer) */ giv_all_inlined friend int32_t operator > (float l, const Integer& n); /** @overload Integer::operator>(unsigned, Integer) */ giv_all_inlined friend int32_t operator > (double l, const Integer& n); /** @overload Integer::operator>(unsigned, Integer) */ giv_all_inlined friend int32_t operator > (int32_t l, const Integer& n); /** @overload Integer::operator>(unsigned, Integer) */ giv_all_inlined friend int32_t operator > (int64_t l, const Integer& n); /** @overload Integer::operator>(unsigned, Integer) */ giv_all_inlined friend int32_t operator > (uint64_t l, const Integer& n); //! less (strict) /// @param l integer to be compared to giv_all_inlined int32_t operator < (const Integer & l) const; /** @overload Integer::operator<(Integer) */ giv_all_inlined int32_t operator < (const int32_t l) const; /** @overload Integer::operator<(Integer) */ giv_all_inlined int32_t operator < (const int64_t l) const; /** @overload Integer::operator<(Integer) */ giv_all_inlined int32_t operator < (const uint64_t l) const; /** @overload Integer::operator<(Integer) */ giv_all_inlined int32_t operator < (const uint32_t l) const; /** @overload Integer::operator<(Integer) */ giv_all_inlined int32_t operator < (const double l) const; /** @overload Integer::operator<(Integer) */ giv_all_inlined int32_t operator < (const float l) const; //! less (strict) /// @param l,n integers to compare giv_all_inlined friend int32_t operator < (uint32_t l, const Integer& n); /** @overload Integer::operator<(unsigned, Integer) */ giv_all_inlined friend int32_t operator < (float l, const Integer& n); /** @overload Integer::operator<(unsigned, Integer) */ giv_all_inlined friend int32_t operator < (double l, const Integer& n); /** @overload Integer::operator<(unsigned, Integer) */ giv_all_inlined friend int32_t operator < (int32_t l, const Integer& n); /** @overload Integer::operator<(unsigned, Integer) */ giv_all_inlined friend int32_t operator < (int64_t l, const Integer& n); /** @overload Integer::operator<(unsigned, Integer) */ giv_all_inlined friend int32_t operator < (uint64_t l, const Integer& n); ///@} // ---------------- Bit logic // (FILE gmp++_int_misc.C) /*! @name Bit logic operators. */ ///@{ //! @brief XOR (^) //! @param a integer giv_all_inlined Integer operator^ (const Integer& a) const; // XOR /** @overload Integer::operator^(Integer) */ giv_all_inlined Integer operator^ (const uint64_t & a) const; /** @overload Integer::operator^(Integer) */ giv_all_inlined Integer operator^ (const uint32_t& a) const; //! @brief XOR inplace (^=) //! @param a integer giv_all_inlined Integer& operator^= (const Integer&a); // XOR /** @overload Integer::operator^=(Integer) */ giv_all_inlined Integer& operator^= (const uint64_t & a); // XOR /** @overload Integer::operator^=(Integer) */ giv_all_inlined Integer& operator^= (const uint32_t&a); // XOR //! OR (|) //! @param a integer giv_all_inlined Integer operator| (const Integer& a ) const; // OR /** @overload Integer::operator|(Integer) */ giv_all_inlined Integer operator| (const uint64_t & a) const; /** @overload Integer::operator|(Integer) */ giv_all_inlined Integer operator| (const uint32_t& a) const; //! OR inplace (|=) //! @param a integer giv_all_inlined Integer& operator|= (const Integer& a ); // OR /** @overload Integer::operator|=(Integer) */ giv_all_inlined Integer& operator|= (const uint64_t & a ); // OR /** @overload Integer::operator|=(Integer) */ giv_all_inlined Integer& operator|= (const uint32_t& a ); // OR //! AND (&) //! @param a integer giv_all_inlined Integer operator& (const Integer&a) const; // AND /** @overload Integer::operator&(Integer) */ giv_all_inlined uint32_t operator& (const uint32_t& a) const; /** @overload Integer::operator&(Integer) */ giv_all_inlined uint64_t operator& (const uint64_t & a) const; //! AND inplace (&=) //! @param a integer giv_all_inlined Integer& operator&= (const Integer&a); // AND /** @overload Integer::operator&=(Integer) */ giv_all_inlined Integer& operator&= (const uint64_t &a); // AND /** @overload Integer::operator&=(Integer) */ giv_all_inlined Integer& operator&= (const uint32_t&a); // AND //! complement to 1 (~) giv_all_inlined Integer operator ~ () const; // 1 complement //! left shift (<<) //! @param l shift giv_all_inlined Integer operator<< (int32_t l) const; // lshift /** @overload Integer::operator<<(int) */ giv_all_inlined Integer operator<< (int64_t l) const; // lshift /** @overload Integer::operator<<(int) */ giv_all_inlined Integer operator<< (uint32_t l) const; // lshift /** @overload Integer::operator<<(int) */ giv_all_inlined Integer operator<< (uint64_t l) const; // lshift //! left shift inplace (<<=) //! @param l shift giv_all_inlined Integer& operator<<= (int32_t l) ; // lshift /** @overload Integer::operator<<=(int) */ giv_all_inlined Integer& operator<<= (int64_t l) ; // lshift /** @overload Integer::operator<<=(Integer) */ giv_all_inlined Integer& operator<<= (uint32_t l) ; // lshift /** @overload Integer::operator<<=(Integer) */ giv_all_inlined Integer& operator<<= (uint64_t l) ; // lshift //! right shift (>>) //! @param l shift giv_all_inlined Integer operator>> (int32_t l) const; // rshift /** @overload Integer::operator>>(int) */ giv_all_inlined Integer operator>> (int64_t l) const; // rshift /** @overload Integer::operator>>(int) */ giv_all_inlined Integer operator>> (uint32_t l) const; // rshift /** @overload Integer::operator>>(int) */ giv_all_inlined Integer operator>> (uint64_t l) const; // rshift //! right shift inplace (>>=) //! @param l shift giv_all_inlined Integer& operator>>= (int32_t l) ; // rshift /** @overload Integer::operator>>=(int) */ giv_all_inlined Integer& operator>>= (int64_t l) ; // rshift /** @overload Integer::operator>>=(int) */ giv_all_inlined Integer& operator>>= (uint32_t l) ; // rshift /** @overload Integer::operator>>=(int) */ giv_all_inlined Integer& operator>>= (uint64_t l) ; // rshift ///@} // - Methods /*! @name Addition, substraction, multiplication */ ///@{ // (FILE gmp++_int_add.C) /*! Addition (inplace) * res+=n. * @param res as in the formula * @param n as in the formula */ static giv_all_inlined Integer& addin (Integer& res, const Integer& n); /** @overload Integer::addin(Integer,Integer) */ static giv_all_inlined Integer& addin (Integer& res, const int64_t n); /** @overload Integer::addin(Integer,Integer) */ static giv_all_inlined Integer& addin (Integer& res, const uint64_t n); /** @overload Integer::addin(Integer,Integer) */ static giv_all_inlined Integer& addin (Integer& res, const int32_t n) { return addin(res, (int64_t)n); } /** @overload Integer::addin(Integer,Integer) */ static giv_all_inlined Integer& addin (Integer& res, const uint32_t n) { return addin(res,(uint64_t)n); } /*! Addition * res=n1+n2. * @param res as in the formula * @param n1 as in the formula * @param n2 as in the formula */ static giv_all_inlined Integer& add (Integer& res, const Integer& n1, const Integer& n2); /** @overload Integer::add(Integer,Integer,Integer) */ static giv_all_inlined Integer& add (Integer& res, const Integer& n1, const int64_t n2); /** @overload Integer::add(Integer,Integer,Integer) */ static giv_all_inlined Integer& add (Integer& res, const Integer& n1, const uint64_t n2); static giv_all_inlined Integer& add (Integer& res, const Integer& n1, const int32_t n2) { return add(res,n1,(int64_t)n2); } /** @overload Integer::add(Integer,Integer,Integer) */ static giv_all_inlined Integer& add (Integer& res, const Integer& n1, const uint32_t n2) { return add(res,n1,(uint64_t)n2); } // (FILE gmp++_int_sub.C) /*! Substraction (inplace) * res-=n. * @param res as in the formula * @param n as in the formula */ static giv_all_inlined Integer& subin (Integer& res, const Integer& n); /** @overload Integer::subin(Integer,Integer) */ static giv_all_inlined Integer& subin (Integer& res, const int64_t n); /** @overload Integer::subin(Integer,Integer) */ static giv_all_inlined Integer& subin (Integer& res, const uint64_t n); /** @overload Integer::subin(Integer,Integer) */ static giv_all_inlined Integer& subin (Integer& res, const int32_t n) { return subin(res,(int64_t)n); } /** @overload Integer::subin(Integer,Integer) */ static giv_all_inlined Integer& subin (Integer& res, const uint32_t n) { return subin(res,(uint64_t)n); } /*! Substraction * res=n1-n2. * @param res as in the formula * @param n1 as in the formula * @param n2 as in the formula */ static giv_all_inlined Integer& sub (Integer& res, const Integer& n1, const Integer& n2); /** @overload Integer::sub(Integer,Integer,Integer) */ static giv_all_inlined Integer& sub (Integer& res, const Integer& n1, const int64_t n2); /** @overload Integer::sub(Integer,Integer,Integer) */ static giv_all_inlined Integer& sub (Integer& res, const Integer& n1, const uint64_t n2); static giv_all_inlined Integer& sub (Integer& res, const Integer& n1, const int32_t n2) { return sub(res,n1,(uint64_t)n2); } /** @overload Integer::sub(Integer,Integer,Integer) */ static giv_all_inlined Integer& sub (Integer& res, const Integer& n1, const uint32_t n2) { return sub(res,n1,(uint64_t)n2); } /*! Negation (inplace) * res=-res. * @param res as in the formula */ static giv_all_inlined Integer& negin (Integer& res); /*! Negation * res=-n. * @param n as in the formula * @param res as in the formula */ static giv_all_inlined Integer& neg (Integer& res, const Integer& n); /*! Multiplication (inplace) * res*=n. * @param res as in the formula * @param n as in the formula */ static giv_all_inlined Integer& mulin (Integer& res, const Integer& n); /** @overload Integer::mulin(Integer,Integer) */ static giv_all_inlined Integer& mulin (Integer& res, const int64_t n); /** @overload Integer::mulin(Integer,Integer) */ static giv_all_inlined Integer& mulin (Integer& res, const uint64_t n); /** @overload Integer::mulin(Integer,Integer) */ static giv_all_inlined Integer& mulin (Integer& res, const int32_t n) { return mulin(res,(int64_t)n); } /** @overload Integer::mulin(Integer,Integer) */ static giv_all_inlined Integer& mulin (Integer& res, const uint32_t n){ return mulin(res,(uint64_t)n); } /*! Multiplication * res=n1*n2. * @param res as in the formula * @param n1 as in the formula * @param n2 as in the formula */ static giv_all_inlined Integer& mul (Integer& res, const Integer& n1, const Integer& n2); /** @overload Integer::mul(Integer,Integer,Integer) */ static giv_all_inlined Integer& mul (Integer& res, const Integer& n1, const int64_t n2); /** @overload Integer::mul(Integer,Integer,Integer) */ static giv_all_inlined Integer& mul (Integer& res, const Integer& n1, const uint64_t n2); /** @overload Integer::mul(Integer,Integer,Integer) */ static giv_all_inlined Integer& mul (Integer& res, const Integer& n1, const int32_t n2) { return mul(res,n1,(int64_t)n2); } /** @overload Integer::mul(Integer,Integer,Integer) */ static giv_all_inlined Integer& mul (Integer& res, const Integer& n1, const uint32_t n2) { return mul(res,n1,(uint64_t)n2); } ///@} //----------------Elementary arithmetic between Integers and basic // (FILE gmp++_int_add.C) /*! @name Addition, substraction, multiplication operators*/ ///@{ /*! operator \c +. * @return (*this)+n * @param n as in the formula. */ giv_all_inlined Integer operator + (const Integer& n) const; /** @overload Integer::operator+(Integer) */ giv_all_inlined Integer operator + (const uint64_t n) const; /** @overload Integer::operator+(Integer) */ giv_all_inlined Integer operator + (const int64_t n) const; /** @overload Integer::operator+(Integer) */ giv_all_inlined Integer operator + (const uint32_t n) const { return this->operator+((uint64_t)n); } /** @overload Integer::operator+(Integer) */ giv_all_inlined Integer operator + (const int32_t n) const { return this->operator+((int64_t)n); } /*! operator \c += . * @param n asfriend In the formula. * @return (*this) += n. */ giv_all_inlined Integer& operator += (const Integer& n); /** @overload Integer::operator+=(Integer) */ giv_all_inlined Integer& operator += (const uint64_t n); /** @overload Integer::operator+=(Integer) */ giv_all_inlined Integer& operator += (const int64_t n); /** @overload Integer::operator+=(Integer) */ giv_all_inlined Integer& operator += (const uint32_t n) { return this->operator+=((uint64_t)n); } /** @overload Integer::operator+=(Integer) */ giv_all_inlined Integer& operator += (const int32_t n) { return this->operator+=((uint64_t)n); } /** @overload Integer::operator+=(Integer) */ template Integer& operator +=(const XXX& n) { return this->operator += ( Caster(n) ); } // - Friends //! operator +. //! @param l,n to be added friend giv_all_inlined Integer operator + (const int32_t l, const Integer& n); /** @overload friend Integer::operator+(int,Integer) */ friend giv_all_inlined Integer operator + (const uint32_t l, const Integer& n); /** @overload friend Integer::operator+(int,Integer) */ friend giv_all_inlined Integer operator + (const int64_t l, const Integer& n); /** @overload friend Integer::operator+(int,Integer) */ friend giv_all_inlined Integer operator + (const uint64_t l, const Integer& n); // (FILE gmp++_int_sub.C) /*! operator \c -. * @return (*this)-n * @param n as in the formula. */ giv_all_inlined Integer operator - (const Integer& n) const; /** @overload Integer::operator-(Integer) */ giv_all_inlined Integer operator - (const uint64_t n) const; /** @overload Integer::operator-(Integer) */ giv_all_inlined Integer operator - (const int64_t n) const; /** @overload Integer::operator+(Integer) */ giv_all_inlined Integer operator - (const uint32_t n) const { return this->operator-((uint64_t)n); } /** @overload Integer::operator+(Integer) */ giv_all_inlined Integer operator - (const int32_t n) const { return this->operator-((int64_t)n); } /*! operator \c -= . * @param n as in the formula. * @return (*this) -= n. */ giv_all_inlined Integer& operator -= (const Integer& n); /** @overload Integer::operator-=(Integer) */ giv_all_inlined Integer& operator -= (const uint64_t n); /** @overload Integer::operator-=(Integer) */ giv_all_inlined Integer& operator -= (const int64_t n); /** @overload Integer::operator-=(Integer) */ giv_all_inlined Integer& operator -= (const uint32_t n) { return this->operator-=((uint64_t)n); } /** @overload Integer::operator-=(Integer) */ giv_all_inlined Integer& operator -= (const int32_t n) { return this->operator-=((int64_t)n); } /** @overload Integer::operator-=(Integer) */ template Integer& operator -=(const XXX& n) { return this->operator -= ( (Integer)n ); } /*! Opposite. * \return -(*this). */ giv_all_inlined Integer operator -() const; //! operator - //! @param l,n to be substracted friend giv_all_inlined Integer operator - (const int32_t l, const Integer& n); /** @overload friend Integer::operator-(int,Integer) */ friend giv_all_inlined Integer operator - (const uint32_t l, const Integer& n); /** @overload friend Integer::operator-(int,Integer) */ friend giv_all_inlined Integer operator - (const int64_t l, const Integer& n); /** @overload friend Integer::operator-(int,Integer) */ friend giv_all_inlined Integer operator - (const uint64_t l, const Integer& n); // (FILE gmp++_int_mul.C) /*! operator \c *. * @return (*this)*n * @param n as in the formula. */ giv_all_inlined Integer operator * (const Integer& n) const; /** @overload Integer::operator*(Integer) */ giv_all_inlined Integer operator * (const uint64_t n) const; /** @overload Integer::operator*(Integer) */ giv_all_inlined Integer operator * (const int64_t n) const; /** @overload Integer::operator*(Integer) */ giv_all_inlined Integer operator * (const uint32_t n) const { return this->operator*((uint64_t)n); } /** @overload Integer::operator*(Integer) */ giv_all_inlined Integer operator * (const int32_t n) const { return this->operator*((int64_t)n); } /*! operator \c *= . * @param n as in the formula. * @return (*this) *= n. */ giv_all_inlined Integer& operator *= (const Integer& n); /** @overload Integer::operator*=(Integer) */ giv_all_inlined Integer& operator *= (const uint64_t n); /** @overload Integer::operator*=(Integer) */ giv_all_inlined Integer& operator *= (const int64_t n); /** @overload Integer::operator*=(Integer) */ giv_all_inlined Integer& operator *= (const uint32_t n) { return this->operator*=((uint64_t)n); } /** @overload Integer::operator*=(Integer) */ giv_all_inlined Integer& operator *= (const int32_t n) { return this->operator*=((int64_t)n); } /** @overload Integer::operator*=(Integer) */ template Integer& operator *=(const XXX& n) { return this->operator *= ( (Integer)n ); } //! operator * //! @param l,n to be multpct friend giv_all_inlined Integer operator * (const int32_t l, const Integer& n); /** @overload fried Integer::operator*(int,Integer) */ friend giv_all_inlined Integer operator * (const uint32_t l, const Integer& n); /** @overload fried Integer::operator*(int,Integer) */ friend giv_all_inlined Integer operator * (const int64_t l, const Integer& n); /** @overload fried Integer::operator*(int,Integer) */ friend giv_all_inlined Integer operator * (const uint64_t l, const Integer& n); ///@} /*! @name fused add-multiply * @brief Groups a multiplication and an addition/division in a * single function. * This is usually faster than doing the two operations * separately (and preferable to using operators). */ ///@{ /*! axpy * res = ax+y. * @param res Integers as in the forumla * @param a Integers as in the forumla * @param x Integers as in the forumla * @param y Integers as in the forumla */ static giv_all_inlined Integer& axpy (Integer& res, const Integer& a, const Integer& x, const Integer& y ); //! @overload Integer::axpy(Integer,Integer,Integer,Integer) static giv_all_inlined Integer& axpy (Integer& res, const Integer& a, const uint64_t x, const Integer& y ); /*! axpyin (inplace) * res += ax. * @param res Integers as in the formula. * @param a Integers as in the formula. * @param x Integers as in the formula. */ static giv_all_inlined Integer& axpyin (Integer& res, const Integer& a, const Integer& x); //! @overload Integer::axpyin(Integer,Integer,Integer) static giv_all_inlined Integer& axpyin (Integer& res, const Integer& a, const uint64_t x); /*! maxpy * res = y - ax. * @param res Integers as in the formula. * @param a Integers as in the formula. * @param x Integers as in the formula. * @param y Integers as in the formula. */ static giv_all_inlined Integer& maxpy (Integer& res, const Integer& a, const Integer& x, const Integer& y ); //! @overload Integer::maxpy(Integer,Integer,Integer,Integer) static giv_all_inlined Integer& maxpy (Integer& res, const Integer& a, const uint64_t x, const Integer& y ); /*! maxpyin * res -= ax. * @param res Integers as in the formula. * @param a Integers as in the formula. * @param x Integers as in the formula. */ static giv_all_inlined Integer& maxpyin (Integer& res, const Integer& a, const Integer& x ); //! @overload Integer::maxpyin(Integer,Integer,Integer) static giv_all_inlined Integer& maxpyin (Integer& res, const Integer& a, const uint64_t x ); /*! axmy * res = ax - y. * @param res Integers as in the formula. * @param a Integers as in the formula. * @param x Integers as in the formula. * @param y Integers as in the formula. */ static giv_all_inlined Integer& axmy (Integer& res, const Integer& a, const Integer& x, const Integer& y ); //! @overload Integer::axmy(Integer,Integer,Integer,Integer) static giv_all_inlined Integer& axmy (Integer& res, const Integer& a, const uint64_t x, const Integer & y ); /*! axmyin (in place) * res = ax - res. * @param res Integers as in the formula. * @param a Integers as in the formula. * @param x Integers as in the formula. */ static giv_all_inlined Integer& axmyin (Integer& res, const Integer& a, const Integer& x); //! @overload Integer::axmyin(Integer,Integer,Integer) static giv_all_inlined Integer& axmyin (Integer& res, const Integer& a, const uint64_t x); ///@} /*! @name Division/euclidean division/modulo * @brief * The convention for rounding are the following : * - q = a/b, or equivalent operations with the name \c * div or \c divin, return \c q rounded towards \c 0, in the same * manner as C's '/' (truncated division). * - r = a % b behaves like C %. The modulo function % * rounds towards 0 and the sign of the dividend is preserved. This * is : \f[ a= b q + r, \text{with } \vert r\vert < \vert b\vert * \text{ and } a r \geq 0 \f] * - r = a mod b or similar functions have the same * behaviour as GMP \c mpz_mod, that is the remainder is always * positive (>=0). This is the division algorithm convention that * is used (see \c divmod). In a formula : \f[ a= b q + r, * \text{with } 0 \leq r < \vert b\vert \f] * * @warning if q=a/b and r= a % b then * a = b q + r is always true (with in addition 0 <= |r| * < |b|). This is also true for divmod(q,a,b,r) * (and 0<=r<|b|). However, one should not mix the two * conventions and expect equalities (except if a>=0). */ // (FILE gmp++_int_div.C) ///@{ /*! Division \c q/=d. * @param q quotient * @param d divisor. * @return \c q */ static giv_all_inlined Integer& divin (Integer& q, const Integer& d); //! @overload Integer::divin(Integer,Integer) static giv_all_inlined Integer& divin (Integer& q, const int64_t d); //! @overload Integer::divin(Integer,Integer) static giv_all_inlined Integer& divin (Integer& q, const uint64_t d); /*! Division \c q=n/d. * @param q quotient * @param n dividand. * @param d divisor * @return \c q */ static giv_all_inlined Integer& div (Integer& q, const Integer& n, const Integer& d); //! @overload Integer::div(Integer,Integer,Integer) static giv_all_inlined Integer& div (Integer& q, const Integer& n, const int64_t d); //! @overload Integer::div(Integer,Integer,Integer) static giv_all_inlined Integer& div (Integer& q, const Integer& n, const int32_t d); //! @overload Integer::div(Integer,Integer,Integer) static giv_all_inlined Integer& div (Integer& q, const Integer& n, const uint64_t d); /*! Division when \c d divides \c n. * @param q exact quotient * @param n dividend * @param d divisor * @warning if quotient is not exact, the result is not predictable. */ static giv_all_inlined Integer& divexact (Integer& q, const Integer& n, const Integer& d); static giv_all_inlined Integer& divexact (Integer& q, const Integer& n, const uint64_t & d); static giv_all_inlined Integer& divexact (Integer& q, const Integer& n, const int64_t & d); /*! Division when \c d divides \c n. * @param n dividend * @param d divisor * @return exact quotient \c n/d * @warning if quotient is not exact, the result is not predictable. */ static giv_all_inlined Integer divexact (const Integer& n, const Integer& d); static giv_all_inlined Integer divexact (const Integer& n, const uint64_t & d); static giv_all_inlined Integer divexact (const Integer& n, const int64_t & d); //! Stuff static giv_all_inlined Integer& trem(Integer& r, const Integer &n , const Integer & d); static giv_all_inlined Integer& crem(Integer& r, const Integer &n , const Integer & d); static giv_all_inlined Integer& frem(Integer& r, const Integer &n , const Integer & d); //! Stuff static giv_all_inlined Integer& trem(Integer& r, const Integer &n , const uint64_t & d); static giv_all_inlined Integer& crem(Integer& r, const Integer &n , const uint64_t & d); static giv_all_inlined Integer& frem(Integer& r, const Integer &n , const uint64_t & d); //! Stuff static giv_all_inlined uint64_t trem(const Integer &n , const uint64_t & d); static giv_all_inlined uint64_t crem(const Integer &n , const uint64_t & d); static giv_all_inlined uint64_t frem(const Integer &n , const uint64_t & d); /*! Division operator. * @param d divisor */ giv_all_inlined Integer operator / (const Integer& d) const; //! @overload Integer::operator/(Integer) giv_all_inlined Integer operator / (const uint64_t d) const; //! @overload Integer::operator/(Integer) giv_all_inlined Integer operator / (const int64_t d) const; //! @overload Integer::operator/(Integer) giv_all_inlined Integer operator / (const uint32_t d) const { return this->operator/((uint64_t)d); } //! @overload Integer::operator/(Integer) giv_all_inlined Integer operator / (const int32_t d) const { return this->operator/((int64_t)d); } /*! Division operator (inplace). * @param d divisor */ giv_all_inlined Integer& operator /= (const Integer& d); //! @overload Integer::operator/=(Integer) giv_all_inlined Integer& operator /= (const uint64_t d); //! @overload Integer::operator/=(Integer) giv_all_inlined Integer& operator /= (const int64_t d); //! @overload Integer::operator/=(Integer) giv_all_inlined Integer& operator /= (const uint32_t d) { return this->operator/=((uint64_t)d); } //! @overload Integer::operator/=(Integer) giv_all_inlined Integer& operator /= (const int32_t d) { return this->operator/=((int64_t)d); } //! @overload Integer::operator/=(Integer) template Integer& operator /=(const XXX& d) { return this->operator /= ( (Integer)d ); } //! operator / friend giv_all_inlined Integer operator / (const int32_t l, const Integer& n); //! @overload Integer::operator/(int,Integer) friend giv_all_inlined Integer operator / (const int64_t l, const Integer& n); //! operator / friend giv_all_inlined Integer operator / (const uint32_t l, const Integer& n); //! @overload Integer::operator/(int,Integer) friend giv_all_inlined Integer operator / (const uint64_t l, const Integer& n); /*! Function \c mod (inplace). * \f$ r \gets r \mod n\f$ * @param r remainder * @param n modulus */ static giv_all_inlined Integer& modin (Integer& r, const Integer& n); //! @overload Integer::modin(Integer,Integer) static giv_all_inlined Integer& modin (Integer& r, const int64_t n); //! @overload Integer::modin(Integer,Integer) static giv_all_inlined Integer& modin (Integer& r, const uint64_t n); /*! Function \c mod. * \f$ r \gets n \mod d\f$ * @param r remainder * @param n integer * @param d modulus */ static giv_all_inlined Integer& mod (Integer& r, const Integer& n, const Integer& d); //! @overload Integer::mod(Integer,Integer,Integer) static giv_all_inlined Integer& mod (Integer& r, const Integer& n, const int64_t d); //! @overload Integer::mod(Integer,Integer,Integer) static giv_all_inlined Integer& mod (Integer& r, const Integer& n, const uint64_t d); //! @overload Integer::mod(Integer,Integer,Integer) static giv_all_inlined Integer& mod (Integer& r, const Integer& n, const int32_t d) { return Integer::mod(r,n,(int64_t)d); } //! @overload Integer::mod(Integer,Integer,Integer) static giv_all_inlined Integer& mod (Integer& r, const Integer& n, const uint32_t d) { return Integer::mod(r,n,(uint64_t)d); } /*! Euclidean division. * n = d q + r . * Computes both the quotient and the residue (as in quorem). * @param q as in the formula * @param r as in the formula * @param n as in the formula * @param d as in the formula * @return the quotient \c q */ static giv_all_inlined Integer& divmod (Integer& q, Integer& r, const Integer& n, const Integer& d); //! @overload Integer::divmod(Integer,Integer,Integer,Integer) static giv_all_inlined Integer& divmod (Integer& q, int64_t & r, const Integer& n, const int64_t d); //! @overload Integer::divmod(Integer,Integer,Integer,Integer) static giv_all_inlined Integer& divmod (Integer& q, uint64_t & r, const Integer& n, const uint64_t d); /*! rounding functions. * these are the same as the STL ones, except for the signature. * @param res the result * @param n the numerator * @param d the demominator */ //! @details same as std::ceil (n/d) static giv_all_inlined Integer& ceil (Integer & res, const Integer &n, const Integer & d); //! @details same as std::floor(n/d) static giv_all_inlined Integer& floor(Integer & res, const Integer &n, const Integer & d); //! @details same as std::trunc(n/d) static giv_all_inlined Integer& trunc(Integer & res, const Integer &n, const Integer & d); /*! rounding functions. * these are the same as the STL ones, except for the signature. * @param n the numerator * @param d the demominator * @return n/d rounded. */ //! @details same as std::ceil (n/d) static giv_all_inlined Integer ceil (const Integer &n, const Integer & d); //! @details same as std::floor(n/d) static giv_all_inlined Integer floor(const Integer &n, const Integer & d); //! @details same as std::trunc(n/d) static giv_all_inlined Integer trunc(const Integer &n, const Integer & d); // (FILE gmp++_int_mod.C) /*! Modulo operator. * @param n modulus * @return remainder (*this) mod n */ giv_all_inlined Integer operator % (const Integer& n) const; //! @overload Integer::operator%(Integer); giv_all_inlined int64_t operator % (const uint64_t n) const; //! @overload Integer::operator%(Integer); giv_all_inlined int64_t operator % (const int64_t n) const; //! @overload Integer::operator%(Integer); giv_all_inlined int32_t operator % (const uint32_t n) const { return (int32_t)this->operator%((uint64_t)n); } //! @overload Integer::operator%(Integer); giv_all_inlined int32_t operator % (const int32_t n) const { return (int32_t)this->operator%((int64_t)n); } //! @overload Integer::operator%(Integer); giv_all_inlined double operator % (const double n) const; //! @overload Integer::operator%(Integer); int16_t operator % (const uint16_t n) const { return (int16_t) ( this->operator % ( (uint64_t)n ) ); } //! @overload Integer::operator%(Integer); template XXX operator %(const XXX& n) const { return (XXX)this->operator % ( Integer(n) ); } /** operator % * @param l * @param n * @return n%l */ friend giv_all_inlined Integer operator % (const int64_t l, const Integer& n); //! @overload Integer::operator%(int,Integer); friend giv_all_inlined Integer operator % (const uint64_t l, const Integer& n); //! @overload Integer::operator%(int,Integer); friend giv_all_inlined Integer operator % (const int32_t l, const Integer& n); //! @overload Integer::operator%(int,Integer); friend giv_all_inlined Integer operator % (const uint32_t l, const Integer& n); //! @overload Integer::operator%(int,Integer); /*! Modulo operator (inplace). * @param n modulus * @return remainder (*this) <- (*this) mod n */ giv_all_inlined Integer& operator %= (const Integer& n); //! @overload Integer::operator%=(Integer); giv_all_inlined Integer& operator %= (const uint64_t n); //! @overload Integer::operator%=(Integer); giv_all_inlined Integer& operator %= (const int64_t n); //! @overload Integer::operator%=(Integer); giv_all_inlined Integer& operator %= (const uint32_t n) { return this->operator%=((uint64_t)n); } //! @overload Integer::operator%=(Integer); giv_all_inlined Integer& operator %= (const int32_t n) { return this->operator%=((int64_t)n); } //! @overload Integer::operator%=(Integer); template Integer& operator %=(const XXX& n) { return this->operator %= ( (Integer)n ); } ///@} // (FILE gmp++_int_gcd.C) //------------------------------------- Arithmetic functions /*! @name Arithmetic functions * @{ */ /** gcd. * @param a,b integers * @return gcd(a,b) */ friend giv_all_inlined Integer gcd (const Integer& a, const Integer& b); //! \overload Integer::gcd(const Integer&, const Integer&) friend giv_all_inlined Integer gcd ( Integer& u, Integer& v, const Integer& a, const Integer& b); //! \overload Integer::gcd(const Integer&, const Integer&) friend giv_all_inlined Integer& gcd (Integer& g, const Integer& a, const Integer& b); //! \overload Integer::gcd(const Integer&, const Integer&) friend giv_all_inlined Integer& gcd (Integer& g, Integer& u, Integer& v, const Integer& a, const Integer& b); //! Inverse. //! Compute the inverse u = a/b. /*! @param u * @param a * @param b */ friend giv_all_inlined Integer& inv (Integer& u, const Integer& a, const Integer& b); //! Compute the inverse inplace u = u/b. /*! @param u * @param b */ friend giv_all_inlined Integer& invin (Integer& u, const Integer& b); //! pp //! @param P,Q params friend giv_all_inlined Integer pp( const Integer& P, const Integer& Q ); //! lcm //! @param g,a,b //! @return g=lcm(a,b) friend giv_all_inlined Integer& lcm (Integer& g, const Integer& a, const Integer& b); //! lcm //! @param a,b friend giv_all_inlined Integer lcm (const Integer& a, const Integer& b); // (FILE gmp++_int_pow.C) //! pow. return \f$n^l\f$ //!@param Res,n,l friend giv_all_inlined Integer& pow(Integer& Res, const Integer& n, const int64_t l); //! @overload Integer::pow(Integer,Integer,int64_t) friend giv_all_inlined Integer& pow(Integer& Res, const uint64_t n, const uint64_t l); //! @overload Integer::pow(Integer,Integer,int64_t) friend giv_all_inlined Integer& pow(Integer& Res, const Integer& n, const uint64_t l); //! @overload Integer::pow(Integer,Integer,int64_t) friend giv_all_inlined Integer& pow(Integer& Res, const Integer& n, const int32_t l) { return pow(Res, n, (int64_t)l ); } //! @overload Integer::pow(Integer,Integer,int64_t) friend giv_all_inlined Integer& pow(Integer& Res, const Integer& n, const uint32_t l) { return pow(Res, n, (uint64_t)l ); } //! pow. return \f$n^l\f$ //!@param n,l friend giv_all_inlined Integer pow(const Integer& n, const int64_t l); //! @overload Integer::pow(Integer,int64_t) friend giv_all_inlined Integer pow(const Integer& n, const uint64_t l); //! @overload Integer::pow(Integer,int64_t) friend giv_all_inlined Integer pow(const Integer& n, const int32_t l) { return pow(n, (int64_t)l ); } //! @overload Integer::pow(Integer,int64_t) friend giv_all_inlined Integer pow(const Integer& n, const uint32_t l) { return pow(n, (uint64_t)l ); } ///@} //! modular pow. return \f$n^e \mod m\f$. friend giv_all_inlined Integer& powmod(Integer& Res, const Integer& n, const uint64_t e, const Integer& m); //! @overload Integer::powmod(Integer,Integer,uint64_t,Integer) friend giv_all_inlined Integer& powmod(Integer& Res, const Integer& n, const int64_t e, const Integer& m); //! @overload Integer::powmod(Integer,Integer,uint64_t,Integer) friend giv_all_inlined Integer& powmod(Integer& Res, const Integer& n, const uint32_t e, const Integer& m) { return powmod(Res, n, (uint64_t)e, m); } //! @overload Integer::powmod(Integer,Integer,uint64_t,Integer) friend giv_all_inlined Integer& powmod(Integer& Res, const Integer& n, const int32_t e, const Integer& m) { return powmod(Res, n, (int64_t)e, m); } //! @overload Integer::powmod(Integer,Integer,uint64_t,Integer) friend giv_all_inlined Integer& powmod(Integer& Res, const Integer& n, const Integer& e, const Integer& m); //! modular pow. return \f$n^e \mod m\f$. //! @param n,e,m friend giv_all_inlined Integer powmod(const Integer& n, const uint64_t e, const Integer& m); //! @overload Integer::powmod(Integer,uint64_t,Integer) friend giv_all_inlined Integer powmod(const Integer& n, const int64_t e, const Integer& m); //! @overload Integer::powmod(Integer,uint64_t,Integer) friend giv_all_inlined Integer powmod(const Integer& n, const uint32_t e, const Integer& m) { return powmod(n, (uint64_t)e, m); } //! @overload Integer::powmod(Integer,uint64_t,Integer) friend giv_all_inlined Integer powmod(const Integer& n, const int32_t e, const Integer& m) { return powmod(n, (int64_t)e, m); } //! @overload Integer::powmod(Integer,uint64_t,Integer) friend giv_all_inlined Integer powmod(const Integer& n, const Integer& e, const Integer& m); // (FILE gmp++_int_misc.C) //! fact //! @param l friend giv_all_inlined Integer fact ( uint64_t l); //! (square) roots //! @param p friend giv_all_inlined Integer sqrt(const Integer& p); //! (square) roots //! @param r,p friend giv_all_inlined Integer& sqrt(Integer& r, const Integer& p); //! (square) roots //! @param p,rem friend giv_all_inlined Integer sqrtrem(const Integer& p, Integer& rem); //! (square) roots //! @param r,p,rem friend giv_all_inlined Integer& sqrtrem(Integer& r, const Integer& p, Integer& rem); //! (square) roots //! @param q,a,n friend giv_all_inlined bool root(Integer& q, const Integer&a, uint32_t n); //! logs //! @param a,p friend giv_all_inlined int64_t logp(const Integer& a, const Integer& p) ; //! logs //! @param a friend giv_all_inlined double logtwo(const Integer& a) ; //! logs //! @param a friend giv_all_inlined double naturallog(const Integer& a) ; ///@} //-----------------------------------------Miscellaneous /*! @name Miscellaneous. */ ///@{ //! swap //! @param a,b friend giv_all_inlined void swap(Integer& a, Integer&b); //! sign //! @param a friend inline int32_t sign (const Integer& a) { return a.priv_sign(); } //! sign int32_t sign() const // BB is this usefull ? { return priv_sign(); } // but figure out the friend sign() //! private sign int32_t priv_sign() const // BB not protected anymore. { return mpz_sgn( (mpz_srcptr)&gmp_rep ); } ///@} //! @name representation ///@{ //! get representation mpz_ptr get_mpz() { return (mpz_ptr)&gmp_rep; } //! get representation (constant) mpz_srcptr get_mpz() const { return (mpz_srcptr)&gmp_rep; } mpz_srcptr get_mpz_const() const { return (mpz_srcptr)&gmp_rep; } /*! returns the number of bytes used to store *this */ //! @param a friend giv_all_inlined uint64_t length (const Integer& a); /*! returns the number of machine words used to store *this */ giv_all_inlined size_t size() const; /*! returns ceil(log_BASE(*this)). */ giv_all_inlined size_t size_in_base(int32_t B) const; /*! returns ceil(log_2(*this)) . */ giv_all_inlined size_t bitsize() const; /*! return the i-th word of the integer. Word 0 is lowest word.*/ giv_all_inlined uint64_t operator[](size_t i) const; // (FILE gmp++_int_misc.C) //! perfect power friend giv_all_inlined int32_t isperfectpower (const Integer& n ); //! absolute value friend giv_all_inlined Integer abs(const Integer& n); //! parity of an integer friend giv_all_inlined bool isOdd(const Integer&); //! @name primes ///@{ friend giv_all_inlined Integer& Protected::prevprime(Integer&, const Integer& p); friend giv_all_inlined Integer& Protected::nextprime(Integer&, const Integer& p); friend giv_all_inlined int32_t Protected::probab_prime(const Integer& p, int32_t r); friend giv_all_inlined int32_t jacobi(const Integer& u, const Integer& v) ; friend giv_all_inlined int32_t legendre(const Integer& u, const Integer& v) ; ///@} //! @name Increment/Decrement operators ///@{ Integer& operator++() { // prefix return *this+=1U; } Integer operator++(int) { // postfix Integer tmp = *this ; ++*this; return tmp; } Integer& operator--() {// prefix return *this-=1U; } Integer operator--(int) {// postfix Integer tmp = *this ; --*this; return tmp; } ///@} /** @name Cast operators. * Convert an Integer to a basic C++ type. * @warning Cast towards \b unsigned consider only the absolute * value */ ///@{ operator bool() const { return *this!=0U; } operator int16_t() const { return (int16_t)(int) *this; } operator uint16_t() const { return (uint16_t) (uint32_t) *this; } operator unsigned char() const { return (unsigned char) (uint32_t) *this; } giv_all_inlined operator uint32_t() const ; giv_all_inlined operator int32_t() const ; operator signed char() const { return (signed char) (int) *this; } giv_all_inlined operator uint64_t() const ; giv_all_inlined operator int64_t() const ; giv_all_inlined operator std::string() const ; giv_all_inlined operator float() const ; giv_all_inlined operator double() const ; giv_all_inlined operator vect_t() const ; template operator RecInt::ruint() const { RecInt::ruint r; return RecInt::mpz_t_to_ruint(r, get_mpz_const()); } template operator RecInt::rint() const { RecInt::rint r; return RecInt::mpz_t_to_rint(r, get_mpz_const()); } ///@} // (FILE gmp++_int_other.C) //! Other stuff gmp has (temporary) ///@{ ///@} // (FILE gmp++_int_rand.inl) /* BB: * if the following functions are NOT static inline, one * can use -Wl,-zmuldefs.... */ //--------------------Random Iterators /*! @name Random numbers functions */ //! Random numbers (no doc) ///@{ static inline void seeding(uint64_t s); static inline void seeding(Integer s); static inline void seeding(); #ifdef __GMP_PLUSPLUS__ static inline gmp_randclass& randstate(); #else // static __gmp_randstate_struct initializerandstate(); // static __gmp_randstate_struct* randstate(); #endif static inline bool RandBool() ; /* random <= */ template static inline Integer& random_lessthan (Integer& r, const Integer & m); static inline Integer& random_lessthan (Integer& r, const Integer & m) ; template static inline Integer& random_lessthan_2exp (Integer& r, const uint64_t & m); static inline Integer& random_lessthan_2exp (Integer& r, const uint64_t & m) ; template static inline Integer random_lessthan_2exp (const uint64_t & m); static inline Integer random_lessthan_2exp (const uint64_t & m) ; template static inline Integer& random_lessthan (Integer& r, const uint64_t & m) ; static inline Integer& random_lessthan (Integer& r, const uint64_t & m) ; template static inline Integer random_lessthan (const T & m); template static inline Integer random_lessthan (const T & m) ; /* random = */ template static inline Integer& random_exact_2exp (Integer& r, const uint64_t & m) ; static inline Integer& random_exact_2exp (Integer& r, const uint64_t & m); template static inline Integer& random_exact (Integer& r, const Integer & s) ; static inline Integer& random_exact (Integer& r, const Integer & s) ; template static inline Integer& random_exact (Integer& r, const uint64_t & m) ; static inline Integer& random_exact (Integer& r, const uint64_t & m) ; template static inline Integer& random_exact (Integer& r, const T & m) ; template static inline Integer& random_exact (Integer& r, const T & m) ; template static inline Integer random_exact (const T & s) ; template static inline Integer random_exact (const T & s) ; /* random <.< */ static inline Integer& random_between (Integer& r, const Integer& m, const Integer&M) ; static inline Integer random_between (const Integer& m, const Integer &M) ; static inline Integer& random_between_2exp (Integer& r, const uint64_t& m, const uint64_t &M) ; static inline Integer& random_between (Integer& r, const uint64_t& m, const uint64_t &M) ; static inline Integer random_between_2exp (const uint64_t & m, const uint64_t &M) ; static inline Integer random_between (const uint64_t & m, const uint64_t &M) ; template static inline Integer random_between (const R & m, const R & M) ; template static inline Integer & random_between (Integer &r, const R & m, const R & M); // useful functions : template static inline Integer& random (Integer& r, const T & m) ; template static inline Integer& random (Integer& r, const T & m) ; template static inline Integer random(const T & sz) ; template static inline Integer random(const T & sz) ; template static inline Integer random(); static inline Integer random(); template static inline Integer nonzerorandom(const T & sz) ; template static inline Integer& nonzerorandom (Integer& r, const T& size) ; template static inline Integer nonzerorandom(const T & sz) ; template static inline Integer& nonzerorandom (Integer& r, const T& size) ; static inline Integer nonzerorandom() ; ///@} //----------------------------------------------I/O /*! @name I/O */ //! Input/Output of Integers ///@{ /** in operator. * @param i input stream * @param n integer to be built */ friend giv_all_inlined std::istream& operator >> (std::istream &i, Integer& n); /** @brief out operator. * @param o output stream * @param n integer to be printed */ friend giv_all_inlined std::ostream& operator << (std::ostream &o, const Integer& n); //! nodoc //! @param o output //! @param n integer friend giv_all_inlined std::ostream& absOutput (std::ostream &o, const Integer& n); /// nodoc /*! @param x x * @param count x * @param order x * @param size x * @param endian x * @param nails x * @param op x */ friend giv_all_inlined void Protected::importWords(Integer& x , size_t count, int32_t order, int32_t size, int32_t endian, size_t nails, const void* op); /** print32_t integer. * @param o output stream. */ giv_all_inlined std::ostream& print( std::ostream& o ) const; ///@} protected: typedef __mpz_struct Rep; //!< @internal rep type Rep gmp_rep;//!< @internal rep //mpz_ptr get_mpz() //{ return (mpz_ptr)&gmp_rep; } //!@internal get representation. const Rep* get_rep() const { return &gmp_rep; } }; //----------------------------------------------- End of Class Integer //! generic sign template static inline int32_t sign (const T a) { // std::cout << ((a>0)-(a<0)) << std::endl; return (a>0)-(a<0); // if (a == 0) return 0 ; // return (a<0)?-1:1 ; } template Integer& Caster(Integer& t, const RecInt::ruint& n) { RecInt::ruint_to_mpz_t(t.get_mpz(), n); return t; } template Integer& Caster(Integer& t, const RecInt::rint& n) { RecInt::rint_to_mpz_t(t.get_mpz(), n); return t; } template RecInt::ruint& Caster(RecInt::ruint& t, const Integer& n) { return RecInt::mpz_t_to_ruint(t, n.get_mpz_const()); } template RecInt::rint& Caster(RecInt::rint& t, const Integer& n) { return RecInt::mpz_t_to_rint(t, n.get_mpz_const()); } } // Givaro // only template code is inlined #ifdef __GIVARO_INLINE_ALL #include "gmp++/gmp++_int.C" #endif #include "gmp++/gmp++_int_rand.inl" #endif // __GIVARO_GMPplusplus_integer_H // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/gmp++/gmp++_int_add.C000066400000000000000000000107751274707324300205060ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_add.C,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: M. Samama, T. Gautier // $Id: gmp++_int_add.C,v 1.5 2010-12-20 12:09:37 briceboyer Exp $ // ========================================================================== /** @file gmp++/gmp++_int_add.C * adding stuff. */ #ifndef __GIVARO_gmpxx_gmpxx_int_add_C #define __GIVARO_gmpxx_gmpxx_int_add_C #ifndef __GIVARO_INLINE_ALL #include "gmp++/gmp++.h" #endif namespace Givaro { //-------------------------------------------------- operator + Integer& Integer::addin(Integer& res, const Integer& n) { if (isZero(n)) return res; if (isZero(res)) return res = n; mpz_add( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&res.gmp_rep, (mpz_srcptr)&n.gmp_rep ); return res; } Integer& Integer::addin(Integer& res, const int64_t n) { if (isZero(n)) return res; if (isZero(res)) return res = n; int32_t sgn = Givaro::sign(n); if (sgn >0) mpz_add_ui( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, n); else mpz_sub_ui((mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, -n); return res; } Integer& Integer::addin(Integer& res, const uint64_t n) { if (isZero(n)) return res; if (isZero(res)) return res = n; mpz_add_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&res.gmp_rep, n); return res; } Integer& Integer::add(Integer& res, const Integer& n1, const Integer& n2) { if (isZero(n1)) return res = n2; if (isZero(n2)) return res = n1; mpz_add( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, (mpz_srcptr)&n2.gmp_rep); return res; } Integer& Integer::add(Integer& res, const Integer& n1, const int64_t n2) { if (isZero(n1)) return res = n2; if (isZero(n2)) return res = n1; int32_t sgn = Givaro::sign(n2); if (sgn >0) mpz_add_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, n2); else mpz_sub_ui((mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, -n2); return res; } Integer& Integer::add(Integer& res, const Integer& n1, const uint64_t n2) { if (isZero(n1)) return res = n2; if (isZero(n2)) return res = n1; mpz_add_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, n2); return res; } // -- operator + Integer& Integer::operator += (const Integer& n) { if (isZero(n)) return *this; if (isZero(*this)) return logcpy(n); mpz_add( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, (mpz_srcptr)&n.gmp_rep) ; return *this; } Integer& Integer::operator += (const uint64_t l) { if (l==0) return *this; if (isZero(*this)) return logcpy(Integer(l)); mpz_add_ui( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, l); return *this; } Integer& Integer::operator += (const int64_t l) { if (l==0) return *this; if (isZero(*this)) return logcpy(Integer(l)); int32_t sgn = Givaro::sign(l); if (sgn >0) mpz_add_ui( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, l); else mpz_sub_ui( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, -l); return *this; } Integer Integer::operator + (const Integer& n) const { if (isZero(n)) return *this; if (isZero(*this)) return n; Integer res; mpz_add( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, (mpz_srcptr)&n.gmp_rep) ; return res; } Integer Integer::operator + (const uint64_t l) const { if (l==0) return *this; if (isZero(*this)) return Integer(l); Integer res; mpz_add_ui( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, l); return res; } Integer Integer::operator + (const int64_t l) const { if (l==0) return *this; if (isZero(*this)) return Integer(l); Integer res; int32_t sgn = Givaro::sign(l); if (sgn >0) mpz_add_ui( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, l); else mpz_sub_ui( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, -l); return res; } Integer Integer::operator - () const { // JGD 18.06.1999 Integer Res ; mpz_neg((mpz_ptr)&Res.gmp_rep, (mpz_srcptr)&gmp_rep ); return Res ; } Integer operator + (const int32_t l, const Integer& n) { return n + (int64_t)l; } Integer operator + (const uint32_t l, const Integer& n) { return n + (uint64_t)l; } Integer operator + (const int64_t l, const Integer& n) { return n + l; } Integer operator + (const uint64_t l, const Integer& n) { return n + l; } } #endif // __GIVARO_gmpxx_gmpxx_int_add_C // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/gmp++/gmp++_int_compare.C000066400000000000000000000264141274707324300214010ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_compare.C,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: M. Samama, T. Gautier // $Id: gmp++_int_compare.C,v 1.6 2009-09-17 14:28:22 jgdumas Exp $ // ========================================================================== /*! @file gmp++/gmp++_int_compare.C * @brief routines to compare integers. */ #ifndef __GIVARO_gmpxx_gmpxx_int_compare_C #define __GIVARO_gmpxx_gmpxx_int_compare_C #ifndef __GIVARO_INLINE_ALL #include "gmp++/gmp++.h" #endif #include namespace Givaro { int32_t compare(const Integer &a, const Integer& b) { return mpz_cmp ( (mpz_srcptr)&a.gmp_rep, (mpz_srcptr)&b.gmp_rep ); } // absCompare int32_t absCompare(const Integer &a, const Integer &b) { return mpz_cmpabs( (mpz_srcptr)&(a.gmp_rep), (mpz_srcptr)&(b.gmp_rep)); } int32_t absCompare(const Integer &a, const double b) { return mpz_cmpabs_d( (mpz_srcptr)&(a.gmp_rep), b); } int32_t absCompare(const Integer &a, const float b) { return mpz_cmpabs_d( (mpz_srcptr)&(a.gmp_rep), (double)b); } int32_t absCompare(const Integer &a, const uint64_t b) { #if GMP_LIMB_BITS != 64 return absCompare( a, Integer(b)); #else return mpz_cmpabs_ui( (mpz_srcptr)&(a.gmp_rep), b); #endif } int32_t absCompare(const Integer &a, const uint32_t b) { return mpz_cmpabs_ui( (mpz_srcptr)&(a.gmp_rep), (uint64_t)b); } int32_t absCompare(const Integer &a, const int64_t b) { #if GMP_LIMB_BITS != 64 return absCompare( a, Integer(b)); #else return mpz_cmpabs_ui( (mpz_srcptr)&(a.gmp_rep), (uint64_t) std::abs(b)); #endif } int32_t absCompare(const Integer &a, const int32_t b) { return mpz_cmpabs_ui( (mpz_srcptr)&(a.gmp_rep), (uint64_t) std::abs(b)); } // Operator != int32_t Integer::operator != (const Integer & l) const { return mpz_cmp((mpz_srcptr)&gmp_rep, (mpz_srcptr)l.get_mpz_const()) != 0; } int32_t Integer::operator != (const double l) const { return mpz_cmp_d((mpz_srcptr)&gmp_rep, l) != 0; } int32_t Integer::operator != (const float l) const { return mpz_cmp_d((mpz_srcptr)&gmp_rep, (float) l) != 0; } int32_t Integer::operator != (const int32_t l) const { return mpz_cmp_si((mpz_srcptr)&gmp_rep, l) != 0; } int32_t Integer::operator != (const uint32_t l) const { return mpz_cmp_ui((mpz_srcptr)&gmp_rep, (uint64_t) l) != 0; } int32_t Integer::operator != (const int64_t l) const { #if GMP_LIMB_BITS != 64 return this->operator != (Integer(l)); #else return mpz_cmp_si((mpz_srcptr)&gmp_rep, l) != 0; #endif } int32_t Integer::operator != (const uint64_t l) const { #if GMP_LIMB_BITS != 64 return this->operator != (Integer(l)); #else return mpz_cmp_ui((mpz_srcptr)&gmp_rep, l) != 0; #endif } //-------------------------------------------------inline comparaison operators int32_t operator != (double l, const Integer& n) { return n.operator != (l); } int32_t operator != (float l, const Integer& n) { return n.operator != (l); } int32_t operator != (int32_t l, const Integer& n) { return n.operator != (l); } int32_t operator != (int64_t l, const Integer& n) { return n.operator != (l); } int32_t operator != (uint64_t l, const Integer& n) { return n.operator != (l); } int32_t operator != (uint32_t l, const Integer& n) { return n.operator != (l); } // operator == int32_t Integer::operator == (const Integer & l) const { return !this->operator!=(l); } int32_t Integer::operator == (const double l) const { return !this->operator!=(l); } int32_t Integer::operator == (const float l) const { return !this->operator!=(l); } int32_t Integer::operator == (const int32_t l) const { return !this->operator!=(l); } int32_t Integer::operator == (const uint32_t l) const { return !this->operator!=(l); } int32_t Integer::operator == (const int64_t l) const { return !this->operator!=(l); } int32_t Integer::operator == (const uint64_t l) const { return !this->operator!=(l); } //-------------------------------------------------inline comparaison operators int32_t operator == (double l, const Integer& n) { return n.operator == (l); } int32_t operator == (float l, const Integer& n) { return n.operator == (l); } int32_t operator == (int32_t l, const Integer& n) { return n.operator == (l); } int32_t operator == (int64_t l, const Integer& n) { return n.operator == (l); } int32_t operator == (uint64_t l, const Integer& n) { return n.operator == (l); } int32_t operator == (uint32_t l, const Integer& n) { return n.operator == (l); } // Operator > int32_t Integer::operator > (const Integer & l) const { return mpz_cmp((mpz_srcptr)&gmp_rep, (mpz_srcptr)l.get_mpz_const()) > 0; } int32_t Integer::operator > (const double l) const { return mpz_cmp_d((mpz_srcptr)&gmp_rep, l) > 0; } int32_t Integer::operator > (const float l) const { return mpz_cmp_d((mpz_srcptr)&gmp_rep, (float) l) > 0; } int32_t Integer::operator > (const int32_t l) const { return mpz_cmp_si((mpz_srcptr)&gmp_rep, l) > 0; } int32_t Integer::operator > (const uint32_t l) const { return mpz_cmp_ui((mpz_srcptr)&gmp_rep, (uint64_t) l) > 0; } int32_t Integer::operator > (const int64_t l) const { #if GMP_LIMB_BITS != 64 return mpz_cmp_si((mpz_srcptr)&gmp_rep, l) > 0; #else return this->operator > (Integer(l)); #endif } int32_t Integer::operator > (const uint64_t l) const { #if GMP_LIMB_BITS != 64 return mpz_cmp_ui((mpz_srcptr)&gmp_rep, l) > 0; #else return this->operator > (Integer(l)); #endif } //-------------------------------------------------inline comparaison operators int32_t operator > (double l, const Integer& n) { return n.operator < (l); } int32_t operator > (float l, const Integer& n) { return n.operator < (l); } int32_t operator > (int32_t l, const Integer& n) { return n.operator < (l); } int32_t operator > (int64_t l, const Integer& n) { return n.operator < (l); } int32_t operator > (uint64_t l, const Integer& n) { return n.operator < (l); } int32_t operator > (uint32_t l, const Integer& n) { return n.operator < (l); } // Operator < int32_t Integer::operator < (const Integer & l) const { return mpz_cmp((mpz_srcptr)&gmp_rep, (mpz_srcptr)l.get_mpz_const()) < 0; } int32_t Integer::operator < (const double l) const { return mpz_cmp_d((mpz_srcptr)&gmp_rep, l) < 0; } int32_t Integer::operator < (const float l) const { return mpz_cmp_d((mpz_srcptr)&gmp_rep, (float) l) < 0; } int32_t Integer::operator < (const uint32_t l) const { return mpz_cmp_ui((mpz_srcptr)&gmp_rep, (uint64_t) l) < 0; } int32_t Integer::operator < (const uint64_t l) const { #if GMP_LIMB_BITS != 64 return mpz_cmp_ui((mpz_srcptr)&gmp_rep, l) < 0; #else return this->operator < (Integer(l)); #endif } int32_t Integer::operator < (const int32_t l) const { return mpz_cmp_si((mpz_srcptr)&gmp_rep, l) < 0; } int32_t Integer::operator < (const int64_t l) const { #if GMP_LIMB_BITS != 64 return mpz_cmp_si((mpz_srcptr)&gmp_rep, l) < 0; #else return this->operator < (Integer(l)); #endif } //-------------------------------------------------inline comparaison operators int32_t operator < (double l, const Integer& n) { return n.operator > (l); } int32_t operator < (float l, const Integer& n) { return n.operator > (l); } int32_t operator < (int32_t l, const Integer& n) { return n.operator > (l); } int32_t operator < (int64_t l, const Integer& n) { return n.operator > (l); } int32_t operator < (uint64_t l, const Integer& n) { return n.operator > (l); } int32_t operator < (uint32_t l, const Integer& n) { return n.operator > (l); } // Operator >= int32_t Integer::operator >= (const Integer & l) const { return !this->operator<(l); } int32_t Integer::operator >= (const double l) const { return !this->operator<(l); } int32_t Integer::operator >= (const float l) const { return !this->operator<(l); } int32_t Integer::operator >= (const int32_t l) const { return !this->operator<(l); } int32_t Integer::operator >= (const uint32_t l) const { return !this->operator<(l); } int32_t Integer::operator >= (const int64_t l) const { return !this->operator<(l); } int32_t Integer::operator >= (const uint64_t l) const { return !this->operator<(l); } //-------------------------------------------------inline comparaison operators int32_t operator >= (double l, const Integer& n) { return n.operator <= (l); } int32_t operator >= (float l, const Integer& n) { return n.operator <= (l); } int32_t operator >= (int32_t l, const Integer& n) { return n.operator <= (l); } int32_t operator >= (int64_t l, const Integer& n) { return n.operator <= (l); } int32_t operator >= (uint64_t l, const Integer& n) { return n.operator <= (l); } int32_t operator >= (uint32_t l, const Integer& n) { return n.operator <= (l); } // Operator <= int32_t Integer::operator <= (const Integer & l) const { return !this->operator>(l); } int32_t Integer::operator <= (const double l) const { return !this->operator>(l); } int32_t Integer::operator <= (const float l) const { return !this->operator>(l); } int32_t Integer::operator <= (const uint32_t l) const { return !this->operator>(l); } int32_t Integer::operator <= (const uint64_t l) const { return !this->operator>(l); } int32_t Integer::operator <= (const int32_t l) const { return !this->operator>(l); } int32_t Integer::operator <= (const int64_t l) const { return !this->operator>(l); } //-------------------------------------------------inline comparaison operators int32_t operator <= (double l, const Integer& n) { return n.operator >= (l); } int32_t operator <= (float l, const Integer& n) { return n.operator >= (l); } int32_t operator <= (int32_t l, const Integer& n) { return n.operator >= (l); } int32_t operator <= (int64_t l, const Integer& n) { return n.operator >= (l); } int32_t operator <= (uint64_t l, const Integer& n) { return n.operator >= (l); } int32_t operator <= (uint32_t l, const Integer& n) { return n.operator >= (l); } // compare to 1 and 0 int32_t isOne(const Integer& a) { return ! mpz_cmp_ui((mpz_srcptr)&(a.gmp_rep), 1U); } int32_t isMOne(const Integer& a) { return ! mpz_cmp_si((mpz_srcptr)&(a.gmp_rep), 1); } int32_t nonZero(const Integer& a) { return mpz_cmp_ui((mpz_srcptr)&(a.gmp_rep), 0U); // return (mpz_sgn((mpz_srcptr)&(a.gmp_rep)) != 0) ; // BB which one is faster ? } int32_t isZero(const Integer& a) { return ! mpz_cmp_ui((mpz_srcptr)&(a.gmp_rep), 0U); // return (mpz_sgn((mpz_srcptr)&(a.gmp_rep)) == 0) ; // BB which one is faster ? } int32_t isZero(const int16_t a) { return a ==0; } int32_t isZero(const int32_t a) { return a ==0; } int32_t isZero(const int64_t a) { return a ==0; } int32_t isZero(const uint16_t a) { return a ==0U; } int32_t isZero(const uint32_t a) { return a ==0U; } int32_t isZero(const uint64_t a) { return a ==0U; } } #endif // __GIVARO_gmpxx_gmpxx_int_compare_C // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s givaro-4.0.2/src/kernel/gmp++/gmp++_int_cstor.C000066400000000000000000000071241274707324300211020ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_cstor.C,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: M. Samama, T. Gautier // $Id: gmp++_int_cstor.C,v 1.4 2009-09-17 14:28:22 jgdumas Exp $ // ========================================================================== /** @file gmp++/gmp++_int_cstor.C * cstoring stuff. */ #ifndef __GMPplusplus_CSTOR_C__ #define __GMPplusplus_CSTOR_C__ #include #ifndef __GIVARO_INLINE_ALL #include "gmp++/gmp++.h" #endif namespace Givaro { //-----------------------------~Integer() Integer::~Integer() { mpz_clear((mpz_ptr)&gmp_rep) ; } //-------------------------------Integer(const Integer &n) Integer::Integer(const Integer &n) { mpz_init_set ( (mpz_ptr)&gmp_rep, (mpz_srcptr)&(n.gmp_rep)) ; } //-----------------------------Integer(int32_t n) Integer::Integer(int32_t n) { mpz_init_set_si((mpz_ptr)&gmp_rep, n) ; } //-----------------------------Integer(uint32_t n) Integer::Integer(unsigned char n) { mpz_init_set_ui((mpz_ptr)&gmp_rep, n) ; } //-----------------------------Integer(uint32_t n) Integer::Integer(uint32_t n) { mpz_init_set_ui((mpz_ptr)&gmp_rep, n) ; } //-----------------------------Integer(int64_t n) Integer::Integer(int64_t n) { #if GMP_LIMB_BITS != 64 // 64 bits is less than 20 digits char * tmp = new char[23]; sprintf(tmp,"%lld",n); mpz_init_set_str((mpz_ptr)&gmp_rep, tmp, 10) ; delete [] tmp; #else mpz_init_set_si((mpz_ptr)&gmp_rep, n) ; #endif } //-----------------------------Integer(uint64_t n) Integer::Integer(uint64_t n) { #if GMP_LIMB_BITS != 64 // 64 bits is less than 20 digits char * tmp = new char[23]; sprintf(tmp,"%llu",n); mpz_init_set_str((mpz_ptr)&gmp_rep, tmp, 10) ; delete [] tmp; #else mpz_init_set_ui((mpz_ptr)&gmp_rep, n) ; #endif } //-----------------------------Integer(double) Integer::Integer(double d) { mpz_init_set_d((mpz_ptr)&gmp_rep, d) ; } // -- Integer(const char *s) Integer::Integer(const char *s) { mpz_init_set_str((mpz_ptr)&gmp_rep, s, 10); } //------------------------------------------operator = (const Integer &n) Integer& Integer::logcpy(const Integer &n) { if (this == &n) return *this; mpz_set ( (mpz_ptr)&gmp_rep, (mpz_srcptr)&(n.gmp_rep)) ; return *this; } // same as logcopy Integer& Integer::operator = (const Integer &n) { return logcpy(n) ; } Integer& Integer::copy(const Integer &n) { if (this == &n) return *this; mpz_set ( (mpz_ptr)&gmp_rep, (mpz_srcptr)&(n.gmp_rep)) ; return *this ; } namespace Protected { void importWords(Integer& x, size_t count, int32_t order, int32_t size, int32_t endian, size_t nails, const void* op) { mpz_import( (mpz_ptr)&(x.gmp_rep), count, order, size, endian, nails, op); } } Integer::Integer(const vect_t & v) { size_t s = v.size(); if (s) { mpz_init_set_ui((mpz_ptr)&gmp_rep, v[0]); Integer base(256), prod, tmp; prod = base = pow(base, (uint64_t)sizeof(mp_limb_t) ); std::vector::const_iterator vi = v.begin(); for(++vi;vi != v.end();++vi) { mpz_mul_ui( (mpz_ptr)&tmp.gmp_rep, (mpz_ptr)&prod.gmp_rep, *vi); *this += tmp; prod *= base; } } else mpz_init( (mpz_ptr)&gmp_rep ); } } #endif // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/gmp++/gmp++_int_div.C000066400000000000000000000272011274707324300205300ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_div.C,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: M. Samama, T. Gautier // $Id: gmp++_int_div.C,v 1.9 2011-01-06 18:02:37 briceboyer Exp $ // ========================================================================== /** @file gmp++/gmp++_int_div.C * diving stuff. */ #ifndef __GIVARO_gmpxx_gmpxx_int_div_C #define __GIVARO_gmpxx_gmpxx_int_div_C #ifndef __GIVARO_INLINE_ALL #include "gmp++/gmp++.h" #endif #include namespace Givaro { //-------------------------------------------------- operator / Integer& Integer::divin(Integer& res, const Integer& n) { // if (isZero(n)) { // GivMathDivZero("[Integer::/]: division by zero"); // } if (isZero(res)) return res; mpz_tdiv_q( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n.gmp_rep ); return res; } Integer& Integer::divin(Integer& res, const int64_t n) { // if (n ==0) { // GivMathDivZero("[Integer::/]: division by zero"); // } if (isZero(res)) return res; int32_t sgn = Givaro::sign(n); mpz_tdiv_q_ui( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, std::abs(n)); if (sgn <0) return res = -res; // if (n<0) // mpz_fdiv_q_ui( (mpz_ptr)&(res.gmp_rep), (mpz_ptr)&res.gmp_rep, n); // else // mpz_cdiv_q_ui( (mpz_ptr)&(res.gmp_rep), (mpz_ptr)&res.gmp_rep, n); return res; } Integer& Integer::divin(Integer& res, const uint64_t n) { // if (n ==0) { // GivMathDivZero("[Integer::/]: division by zero"); // } if (isZero(res)) return res; mpz_tdiv_q_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&res.gmp_rep, n); return res; } Integer& Integer::div(Integer& res, const Integer& n1, const Integer& n2) { if (isZero(n1)) return res = Integer::zero; // if (isZero(n2)) { // GivMathDivZero("[Integer::/]: division by zero"); // } mpz_tdiv_q( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, (mpz_srcptr)&n2.gmp_rep); return res; } Integer& Integer::div(Integer& res, const Integer& n1, const int64_t n2) { if (isZero(n1)) return res = Integer::zero; // if (isZero(n2)) { // GivMathDivZero("[Integer::/]: division by zero"); // } int32_t sgn = Givaro::sign(n2); mpz_tdiv_q_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, std::abs(n2)); if (sgn <0) return res = -res; // if (n2>0) // mpz_fdiv_q_ui( (mpz_ptr)&(res.gmp_rep), (mpz_ptr)&n1.gmp_rep, n2); // else // mpz_cdiv_q_ui( (mpz_ptr)&(res.gmp_rep), (mpz_ptr)&n1.gmp_rep, n2); return res; } Integer& Integer::div(Integer& res, const Integer& n1, const int32_t n2) { return div(res,n1,int64_t(n2)); } Integer& Integer::div(Integer& res, const Integer& n1, const uint64_t n2) { if (isZero(n1)) return res = Integer::zero; // if (isZero(n2)) { // GivMathDivZero("[Integer::/]: division by zero"); // } mpz_tdiv_q_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, n2); return res; } Integer& Integer::divexact (Integer& q, const Integer& n1, const Integer& n2) { if (isZero(n1)) return q = Integer::zero; // if (isZero(n2)) { // GivMathDivZero("[Integer::/]: division by zero"); // } mpz_divexact( (mpz_ptr)&(q.gmp_rep), (mpz_srcptr)&(n1.gmp_rep), (mpz_srcptr)&(n2.gmp_rep)) ; return q; } Integer& Integer::divexact (Integer& q, const Integer& n1, const uint64_t & n2) { if (isZero(n1)) return q = Integer::zero; mpz_divexact_ui( (mpz_ptr)&(q.gmp_rep), (mpz_srcptr)&(n1.gmp_rep), (n2)) ; return q; } Integer& Integer::divexact (Integer& q, const Integer& n1, const int64_t& n2) { if (isZero(n1)) return q = Integer::zero; mpz_divexact_ui( (mpz_ptr)&(q.gmp_rep), (mpz_srcptr)&(n1.gmp_rep), std::abs(n2)) ; if (n2<0) negin(q); return q; } Integer Integer::divexact (const Integer& n1, const Integer& n2) { if (isZero(n1)) return Integer::zero; // if (isZero(n2)) { // GivMathDivZero("[Integer::/]: division by zero"); // } Integer q; mpz_divexact( (mpz_ptr)&(q.gmp_rep), (mpz_srcptr)&(n1.gmp_rep), (mpz_srcptr)&(n2.gmp_rep)) ; return q; } Integer Integer::divexact (const Integer& n1, const uint64_t& n2) { if (isZero(n1)) return Integer::zero; Integer q; mpz_divexact_ui( (mpz_ptr)&(q.gmp_rep), (mpz_srcptr)&(n1.gmp_rep), (n2)) ; return q; } Integer Integer::divexact (const Integer& n1, const int64_t& n2) { if (isZero(n1)) return Integer::zero; Integer q; mpz_divexact_ui( (mpz_ptr)&(q.gmp_rep), (mpz_srcptr)&(n1.gmp_rep), std::abs(n2)) ; if (n2<0) negin(q); return q; } Integer& Integer::operator /= (const Integer& n) { // if (isZero(n)) { // GivMathDivZero("[Integer::/]: division by zero"); // } if (isZero(*this)) return *this; mpz_tdiv_q( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, (mpz_srcptr)&n.gmp_rep) ; return *this; } Integer& Integer::operator /= (const uint64_t l) { // if (l ==0) { // GivMathDivZero("[Integer::/]: division by zero"); // } if (isZero(*this)) return *this; mpz_tdiv_q_ui( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, l); return *this; } Integer& Integer::operator /= (const int64_t l) { // if (l ==0) { // GivMathDivZero("[Integer::/]: division by zero"); // } if (isZero(*this)) return *this; int32_t sgn = Givaro::sign(l); mpz_tdiv_q_ui( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, std::abs(l)); if (sgn <0) mpz_neg( (mpz_ptr)&gmp_rep, (mpz_ptr)&(gmp_rep)); return *this; } Integer Integer::operator / (const Integer& n) const { // if (isZero(n)) { // GivMathDivZero("[Integer::/]: division by zero"); // } if (isZero(*this)) return Integer::zero; Integer res; mpz_tdiv_q( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, (mpz_srcptr)&n.gmp_rep) ; // if (n>0) // mpz_fdiv_q( (mpz_ptr)&(res.gmp_rep), (mpz_ptr)&gmp_rep, (mpz_ptr)&n.gmp_rep) ; // else // mpz_cdiv_q( (mpz_ptr)&(res.gmp_rep), (mpz_ptr)&gmp_rep, (mpz_ptr)&n.gmp_rep) ; return res; } Integer Integer::operator / (const uint64_t l) const { // if (l ==0) { // GivMathDivZero("[Integer::/]: division by zero"); // } if (isZero(*this)) return Integer::zero; Integer res; mpz_tdiv_q_ui( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, l); return res; } Integer Integer::operator / (const int64_t l) const { // if (l ==0) { // GivMathDivZero("[Integer::/]: division by zero"); // } if (isZero(*this)) return Integer::zero; Integer res; int32_t sgn = Givaro::sign(l); mpz_tdiv_q_ui( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, std::abs(l)); if (sgn <0) return negin(res); // if (l>0) // mpz_fdiv_q_ui( (mpz_ptr)&(res.gmp_rep), (mpz_ptr)&gmp_rep, l) ; // else // mpz_fdiv_q_ui( (mpz_ptr)&(res.gmp_rep), (mpz_ptr)&gmp_rep, -l ) ; return res; } // Euclidian division Integer& Integer::divmod(Integer& q, Integer& r, const Integer &a, const Integer &b) { // if (isZero(b)) { // GivMathDivZero("[Integer::divide]: division by zero"); // } mpz_tdiv_qr( (mpz_ptr)&(q.gmp_rep), (mpz_ptr)&(r.gmp_rep), (mpz_srcptr)&(a.gmp_rep), (mpz_srcptr)&(b.gmp_rep)); // if (a>0) // mpz_fdiv_qr_ui( (mpz_ptr)&(q.gmp_rep),r // (mpz_ptr)&(a.gmp_rep), b); // else // mpz_cdiv_qr_ui( (mpz_ptr)&(q.gmp_rep),r // (mpz_ptr)&(a.gmp_rep), b); if (a<0 && r) { subin(q,(int64_t)1) ; r = b - r; } return q; } Integer& Integer::divmod(Integer& q, int64_t & r, const Integer& a, const int64_t b) { // if (isZero(b)) { // GivMathDivZero("[Integer::divide]: division by zero"); // } // int32_t sgn = sign(b); r = (int64_t)mpz_tdiv_q_ui( (mpz_ptr)&(q.gmp_rep), (mpz_srcptr)&(a.gmp_rep), std::abs(b)); // if (sgn <0) return negin(q); // if (a>0) // mpz_fdiv_qr_ui( (mpz_ptr)&(q.gmp_rep),r // (mpz_ptr)&(a.gmp_rep), b); // else // mpz_cdiv_qr_ui( (mpz_ptr)&(q.gmp_rep),r // (mpz_ptr)&(a.gmp_rep), b); if (a<0 && r) { subin(q,(int64_t)1) ; r = b - r ; } return q; } Integer& Integer::divmod(Integer& q, uint64_t & r, const Integer& a, const uint64_t b) { // if (isZero(b)) { // GivMathDivZero("[Integer::divide]: division by zero"); // } r = mpz_tdiv_q_ui( (mpz_ptr)&(q.gmp_rep), (mpz_srcptr)&(a.gmp_rep), b); if (a<0 && r) { subin(q,(int64_t)1) ; r = b - r; } return q; } Integer& Integer::ceil(Integer& q, const Integer & n, const Integer & d) { mpz_cdiv_q( (mpz_ptr)&(q.gmp_rep), (mpz_srcptr)&(n.gmp_rep), (mpz_srcptr)&(d.gmp_rep)); return q ; } Integer& Integer::floor(Integer& q, const Integer & n, const Integer & d) { mpz_fdiv_q( (mpz_ptr)&(q.gmp_rep), (mpz_srcptr)&(n.gmp_rep), (mpz_srcptr)&(d.gmp_rep)); return q ; } Integer& Integer::trunc(Integer& q, const Integer & n, const Integer & d) { mpz_tdiv_q( (mpz_ptr)&(q.gmp_rep), (mpz_srcptr)&(n.gmp_rep), (mpz_srcptr)&(d.gmp_rep)); return q ; } Integer Integer::ceil( const Integer & n, const Integer & d) { Integer q; mpz_cdiv_q( (mpz_ptr)&(q.gmp_rep), (mpz_srcptr)&(n.gmp_rep), (mpz_srcptr)&(d.gmp_rep)); return q ; } Integer Integer::floor(const Integer & n, const Integer & d) { Integer q; mpz_fdiv_q( (mpz_ptr)&(q.gmp_rep), (mpz_srcptr)&(n.gmp_rep), (mpz_srcptr)&(d.gmp_rep)); return q ; } Integer Integer::trunc(const Integer & n, const Integer & d) { Integer q; mpz_tdiv_q( (mpz_ptr)&(q.gmp_rep), (mpz_srcptr)&(n.gmp_rep), (mpz_srcptr)&(d.gmp_rep)); return q ; } Integer& Integer::trem(Integer& r, const Integer &n , const Integer & d) { mpz_tdiv_r((mpz_ptr)&(r.gmp_rep), (mpz_srcptr)&(n.gmp_rep), (mpz_srcptr)&(d.gmp_rep)); return r; } Integer& Integer::crem(Integer& r, const Integer &n , const Integer & d) { mpz_cdiv_r((mpz_ptr)&(r.gmp_rep), (mpz_srcptr)&(n.gmp_rep), (mpz_srcptr)&(d.gmp_rep)); return r; } Integer& Integer::frem(Integer& r, const Integer &n , const Integer & d) { mpz_fdiv_r((mpz_ptr)&(r.gmp_rep), (mpz_srcptr)&(n.gmp_rep), (mpz_srcptr)&(d.gmp_rep)); return r; } Integer& Integer::trem(Integer& r, const Integer &n , const uint64_t& d) { mpz_tdiv_r_ui((mpz_ptr)&(r.gmp_rep), (mpz_srcptr)&(n.gmp_rep), (d)); return r; } Integer& Integer::crem(Integer& r, const Integer &n , const uint64_t & d) { mpz_cdiv_r_ui((mpz_ptr)&(r.gmp_rep), (mpz_srcptr)&(n.gmp_rep), (d)); return r; } Integer& Integer::frem(Integer& r, const Integer &n , const uint64_t & d) { mpz_fdiv_r_ui((mpz_ptr)&(r.gmp_rep), (mpz_srcptr)&(n.gmp_rep), d); return r; } uint64_t Integer::trem(const Integer &n , const uint64_t& d) { return mpz_cdiv_ui( (mpz_srcptr)&(n.gmp_rep), (d)); } uint64_t Integer::crem(const Integer &n , const uint64_t & d) { return mpz_tdiv_ui( (mpz_srcptr)&(n.gmp_rep), (d)); } uint64_t Integer::frem(const Integer &n , const uint64_t & d) { return mpz_fdiv_ui( (mpz_srcptr)&(n.gmp_rep), d); } // -- operator / Integer operator / (const int32_t l, const Integer& n) { return Integer(l)/n; } Integer operator / (const int64_t l, const Integer& n) { return Integer(l)/n; } // -- operator / Integer operator / (const uint32_t l, const Integer& n) { return Integer(l)/n; } Integer operator / (const uint64_t l, const Integer& n) { return Integer(l)/n; } } #endif // __GIVARO_gmpxx_gmpxx_int_div_C /* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/gmp++/gmp++_int_gcd.C000066400000000000000000000072541274707324300205110ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_gcd.C,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: M. Samama, T. Gautier // $Id: gmp++_int_gcd.C,v 1.4 2011-01-18 17:49:06 jgdumas Exp $ // ========================================================================== // Description: // /** @file gmp++/gmp++_int_gcd.C * gcding stuff. */ #ifndef __GIVARO_gmpxx_gmpxx_int_gcd_C #define __GIVARO_gmpxx_gmpxx_int_gcd_C #ifndef __GIVARO_INLINE_ALL #include "gmp++/gmp++.h" #endif namespace Givaro { // ========================================================================== // Computes and returns the lcm of the two integers a and b. Integer lcm(const Integer& a, const Integer& b) { Integer Res(Integer::one); mpz_lcm( (mpz_ptr)&(Res.gmp_rep), (mpz_srcptr)&(a.gmp_rep), (mpz_srcptr)&(b.gmp_rep) ) ; if (Res.priv_sign() <0) return -Res; else return Res ; } Integer& lcm(Integer& g, const Integer& a, const Integer& b) { mpz_lcm( (mpz_ptr)&(g.gmp_rep), (mpz_srcptr)&(a.gmp_rep), (mpz_srcptr)&(b.gmp_rep) ) ; if (g.priv_sign() <0) return Integer::negin(g); else return g ; } // ========================================================================== // Computes and returns the gcd of the two integers a and b. Integer gcd(const Integer& a, const Integer& b) { Integer Res(Integer::one); mpz_gcd( (mpz_ptr)&(Res.gmp_rep), (mpz_srcptr)&(a.gmp_rep), (mpz_srcptr)&(b.gmp_rep) ) ; if (Res.priv_sign() <0) return -Res; return Res ; } Integer& gcd(Integer& g, const Integer& a, const Integer& b) { mpz_gcd( (mpz_ptr)&(g.gmp_rep), (mpz_srcptr)&(a.gmp_rep), (mpz_srcptr)&(b.gmp_rep) ) ; if (g.priv_sign() <0) return Integer::negin(g); return g ; } Integer& invin(Integer& u, const Integer& b) { mpz_invert( (mpz_ptr)&(u.gmp_rep), (mpz_ptr)&(u.gmp_rep), (mpz_srcptr)&(b.gmp_rep) ) ; return u ; } Integer& inv(Integer& u, const Integer& a, const Integer& b) { mpz_invert( (mpz_ptr)&(u.gmp_rep), (mpz_srcptr)&(a.gmp_rep), (mpz_srcptr)&(b.gmp_rep) ) ; return u ; } // ========================================================================== // Computes and returns the gcd g of the two integers a and b such that // g = a*u + b*v . // The algorithm used is this of Gmp. Integer gcd (Integer& u, Integer& v, const Integer& a, const Integer& b ) { v = 1; // v must not be 0 to be computed. Integer Res(Integer::one); mpz_gcdext( (mpz_ptr)&(Res.gmp_rep), (mpz_ptr)&(u.gmp_rep), (mpz_ptr)&(v.gmp_rep), (mpz_srcptr)&(a.gmp_rep), (mpz_srcptr)&(b.gmp_rep) ) ; if (Res.priv_sign() < 0) { Integer::negin(u); Integer::negin(v); return Integer::negin(Res); } // { u = -u ; v = -v ; return -Res;} return Res; } Integer& gcd (Integer& g, Integer& u, Integer& v, const Integer& a, const Integer& b) { v = 1; // v must not be 0 to be computed. mpz_gcdext( (mpz_ptr)&(g.gmp_rep), (mpz_ptr)&(u.gmp_rep), (mpz_ptr)&(v.gmp_rep), (mpz_srcptr)&(a.gmp_rep), (mpz_srcptr)&(b.gmp_rep) ) ; if (g.priv_sign() < 0) { Integer::negin(u); Integer::negin(v); return Integer::negin(g);} return g; } Integer pp( const Integer& P, const Integer& Q ) { Integer U = P ; Integer V = gcd(P,Q) ; // -- computes the prime part U of g relatively to U while ( V != Integer::one ) { U = U / V ; V = gcd( U,V) ; } return U ; } } #endif // __GIVARO_gmpxx_gmpxx_int_gcd_C // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/gmp++/gmp++_int_io.C000066400000000000000000000070211274707324300203530ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_io.C,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: M. Samama, T. Gautier // $Id: gmp++_int_io.C,v 1.7 2009-09-17 14:28:22 jgdumas Exp $ // ========================================================================== // Description: /** @file gmp++/gmp++_int_io.C * ioing stuff. */ #ifndef __GIVARO_gmpxx_gmpxx_int_io_C #define __GIVARO_gmpxx_gmpxx_int_io_C #include #include #ifndef __GIVARO_INLINE_ALL #include "gmp++/gmp++.h" #endif #ifndef __GIVARO_GMP_NO_CXX #include #endif namespace Givaro { // Sortie nonsignee : 321321 meme si n = -321321, par exemple std::ostream& absOutput(std::ostream &o, const Integer&n) { int32_t base = 10; uint64_t strSize = mpz_sizeinbase((mpz_srcptr)&(n.gmp_rep), base) + 2; char *str = ::new char[strSize]; mpz_get_str(str, base, (mpz_srcptr)&(n.gmp_rep)); if (sign(n) < 0) { char *str1 = &(str[1]) ; o << str1; } else o << str; delete [] str ; return o; } // Sortie signee : +321321 ou -321321, par exemple std::ostream& Integer::print(std::ostream &o) const { // For some reason, ekopath does an undefined reference to the GMP-streams - A. Breust 2015-01-21 #if defined(__GIVARO_GMP_NO_CXX) || defined(__PATHCC__) int32_t base = 10; uint64_t strSize = mpz_sizeinbase((mpz_srcptr)&(gmp_rep), base) + 2; char *str = new char[strSize]; mpz_get_str(str, base, (mpz_srcptr)&(gmp_rep)); o << str; delete [] str ; return o; #else return o << (mpz_srcptr)&gmp_rep; #endif } // Entree au format de la sortie std::istream& operator>> (std::istream& inp, Integer& a) { #if defined(__GIVARO_GMP_NO_CXX) || defined(__PATHCC__) static int64_t base[10] = { 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 } ; if (!inp) return inp ; // eat white inp >> std::ws ; // Base : 10^9, we read by packet of length 9 // the char. char Tmp[10] ; int32_t counter = 0 ; // Set the returned integer a = 0 ; char ch ; int32_t sign = 1 ; // find a sign: inp.get(ch) ; if ((ch != '+') && (ch != '-') && !((ch >= '0') && (ch <= '9'))) { std::cerr << "Bad integer format: found: "<< ch ; std::cerr << ", in place of '+' '-' or a digit"<< std::endl ; return inp ; } switch (ch) { case '+' : break ; case '-' : sign = -1 ; break ; default : inp.putback(ch) ; break ; } // eat white inp >> std::ws ; int32_t noend = 1 ; while (noend) { counter = 0 ; // Read 9 digits or less while ((noend) && (counter < 9)) { inp.get(ch) ; if (inp.eof()) { noend = 0 ; } else if ((ch >= '0') && (ch <= '9')) Tmp[counter++] = ch ; else { noend = 0 ; inp.putback(ch) ; } } if (counter >0) { int64_t l ; Tmp[counter] = '\0' ; // terminate the string l = atol(Tmp) ; a = a * base[counter-1] + l ; } } if (sign == -1) a = -a ; return inp ; #else return inp >> (mpz_ptr)a.get_mpz(); #endif } //-------------------------------------------------inline >> & << operators std::ostream& operator<< (std::ostream& o, const Integer& a) { return a.print(o); } } #endif // __GIVARO_gmpxx_gmpxx_int_io_C // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/gmp++/gmp++_int_lib.C000066400000000000000000000017321274707324300205150ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_lib.C,v $ // Copyright(c)'1994-2011 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: B Boyer // $Id: gmp++_int_lib.C,v 1.4 2009-09-17 14:28:22 jgdumas Exp $ // ========================================================================== /** @file gmp++/gmp++_int_lib.C * libing stuff. */ #ifndef __GMPplusplus_LIB_C__ #define __GMPplusplus_LIB_C__ #include "gmp++/gmp++.h" namespace Givaro { //------------------------------------- predefined null and one const Integer Integer::zero(0U); const Integer Integer::one(1U); const Integer Integer::mOne(-1); } // Givaro #endif // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/gmp++/gmp++_int_misc.C000066400000000000000000000272761274707324300207150ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_misc.C,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: M. Samama, T. Gautier // $Id: gmp++_int_misc.C,v 1.16 2010-12-16 16:54:38 jgdumas Exp $ // ========================================================================== // Description: /** @file gmp++/gmp++_int_misc.C * miscing stuff. */ #ifndef __GIVARO_gmpxx_gmpxx_int_misc_C #define __GIVARO_gmpxx_gmpxx_int_misc_C #include #include #ifndef __GIVARO_INLINE_ALL #include "gmp++/gmp++.h" #endif #ifndef __GIVARO_GMP_NO_CXX #include #endif namespace Givaro { //-------------------------------------------fact (uint64_t l) Integer fact ( uint64_t l) { Integer Res ; mpz_fac_ui( (mpz_ptr)&(Res.gmp_rep), l ) ; return Res ; } //-------------------------------------------square root Integer& sqrt(Integer& q, const Integer &a) { mpz_sqrt( (mpz_ptr)&(q.gmp_rep), (mpz_srcptr)&(a.gmp_rep)) ; return q; } Integer& sqrtrem(Integer& q, const Integer &a, Integer& r) { mpz_sqrtrem( (mpz_ptr)&(q.gmp_rep), (mpz_ptr)&(r.gmp_rep), (mpz_srcptr)&(a.gmp_rep)) ; return q; } Integer sqrt(const Integer &a) { Integer q; return sqrt(q,a); } Integer sqrtrem(const Integer &a, Integer& r) { Integer q; return sqrtrem(q,a,r); } bool root(Integer& q, const Integer &a, uint32_t n) { return (bool)mpz_root ((mpz_ptr)&(q.gmp_rep), (mpz_srcptr)&(a.gmp_rep), n); } void swap(Integer& a, Integer& b) { return mpz_swap( (mpz_ptr)&(a.gmp_rep), (mpz_ptr)&(b.gmp_rep)); } // Natural logarithm of a // log(2) being close to 0.69314718055994531 double naturallog(const Integer& a) { long int exp_; double d = mpz_get_d_2exp( &exp_, (mpz_srcptr)&(a.gmp_rep) ); return (double)exp_*0.69314718055994531+log(d); } /*! Tests parity of an integer * @param a integer * @return 1 if odd, 0 if even */ bool isOdd(const Integer &a) { int32_t o = mpz_tstbit( (mpz_srcptr) &(a.gmp_rep), 0); return (o!=0); // or maybe should I write l==1 ^^ } // base p logarithm of a int64_t logp(const Integer& a, const Integer& p) { std::list< Integer > pows; Integer puiss = p, sq; do { pows.push_back( puiss ); } while ( (puiss *= puiss) <= a ); puiss = pows.back(); pows.pop_back(); int64_t res = (1 << pows.size()); while (! pows.empty() ) { if ((sq = puiss * pows.back()) <= a) { puiss = sq; pows.pop_back(); res += (1 << pows.size()); } else pows.pop_back(); } return res; } // approximation of the base 2 logarithm of a // 1/log(2) being close to 1.44269504088896341 double logtwo(const Integer& a) { long int exp; double d = mpz_get_d_2exp( &exp, (mpz_srcptr)&(a.gmp_rep) ); return (double)exp+log(d)*1.44269504088896341; } namespace Protected { //------------------------------------------GMP isprime // If this function returns 0, OP is definitely not prime. If it // returns 1, then OP is `probably' prime. The probability of a // false positive is (1/4)^r. A reasonable value of r is 25. int32_t probab_prime(const Integer &p, int32_t r) { return mpz_probab_prime_p ((mpz_srcptr)&(p.gmp_rep),r) ; } Integer& nextprime(Integer& r, const Integer &p) { mpz_nextprime ((mpz_ptr)&(r.gmp_rep), (mpz_srcptr)&(p.gmp_rep)) ; return r; } // Copied and adapted from mpz/nextprime.c Integer& prevprime(Integer& r, const Integer &p) { if (p < 3) return (r=2); if (isOdd(p)) mpz_sub_ui ( (mpz_ptr)&(r.gmp_rep), (mpz_srcptr)&(p.gmp_rep), 2 ); else mpz_sub_ui ( (mpz_ptr)&(r.gmp_rep), (mpz_srcptr)&(p.gmp_rep), 1 ); while( !mpz_probab_prime_p ( (mpz_srcptr)&(r.gmp_rep), _GIVARO_ISPRIMETESTS_ ) ) { mpz_sub_ui ( (mpz_ptr)&(r.gmp_rep), (mpz_srcptr)&(r.gmp_rep), 2 ); } return r; } } // namespace Protected // ========================================================================== // Computes and returns the Jacobi and Legendre symbols (u/v) of the integers u and v. // The algorithm used is Gmp's. int32_t jacobi(const Integer& u, const Integer& v) { return mpz_jacobi ((mpz_srcptr)&(u.gmp_rep),(mpz_srcptr)&(v.gmp_rep)) ; } int32_t legendre(const Integer& u, const Integer& v) { return mpz_legendre ((mpz_srcptr)&(u.gmp_rep),(mpz_srcptr)&(v.gmp_rep)) ; } //--------------------------------------------Integer::operator << // shift left Integer Integer::operator << (int32_t l) const { return this->operator<<( (uint64_t)l ); } Integer Integer::operator << (uint32_t l) const { return this->operator<<( (uint64_t)l ); } Integer Integer::operator << (int64_t l) const { return this->operator<<( (uint64_t)l ); } Integer Integer::operator << (uint64_t l) const { Integer tmp; mpz_mul_2exp((mpz_ptr)&(tmp.gmp_rep), (mpz_srcptr)&(gmp_rep), l ); return tmp; } //--------------------------------------------Integer::operator >> // shift right Integer Integer::operator >> (int32_t l) const { return this->operator>>( (uint64_t)l ); } Integer Integer::operator >> (int64_t l) const { return this->operator>>( (uint64_t)l ); } Integer Integer::operator >> (uint32_t l) const { return this->operator>>( (uint64_t)l ); } Integer Integer::operator >> (uint64_t l) const { Integer tmp; mpz_tdiv_q_2exp( (mpz_ptr)&(tmp.gmp_rep), (mpz_srcptr)&(gmp_rep), l ); return tmp; } //--------------------------------------------Integer::operator <<= // shift left Integer& Integer::operator <<= (int32_t l) { return this->operator<<= ( (uint64_t)l ); } Integer& Integer::operator <<= (uint32_t l) { return this->operator<<= ( (uint64_t)l ); } Integer& Integer::operator <<= (int64_t l) { return this->operator<<= ( (uint64_t)l ); } Integer& Integer::operator <<= (uint64_t l) { mpz_mul_2exp((mpz_ptr)&(gmp_rep), (mpz_srcptr)&(gmp_rep), l ); return *this; } //--------------------------------------------Integer::operator >>= // shift right Integer& Integer::operator >>= (int32_t l) { return this->operator>>= ( (uint64_t)l ); } Integer& Integer::operator >>= (int64_t l) { return this->operator>>= ( (uint64_t)l ); } Integer& Integer::operator >>= (uint32_t l) { return this->operator>>= ( (uint64_t)l ); } Integer& Integer::operator >>= (uint64_t l) { mpz_tdiv_q_2exp( (mpz_ptr)&(gmp_rep), (mpz_srcptr)&(gmp_rep), l ); return *this; } //------------------------------------------- Bit logic Integer Integer::operator^ (const Integer& a) const { // XOR Integer res(*this); return res ^= a; } Integer Integer::operator| (const Integer& a) const { // OR Integer res(*this); return res |= a; } Integer Integer::operator& (const Integer& a) const { // AND Integer res(*this); return res &= a; } Integer Integer::operator^ (const uint64_t & a) const { // XOR Integer res(*this); return res ^= a; } Integer Integer::operator| (const uint64_t & a) const { // OR Integer res(*this); return res |= a; } uint64_t Integer::operator& (const uint64_t & a) const { // AND return mpz_get_ui((mpz_srcptr)&(gmp_rep)) & a; } Integer Integer::operator^ (const uint32_t& a) const { // XOR Integer res(*this); return res ^= a; } Integer Integer::operator| (const uint32_t& a) const { // OR Integer res(*this); return res |= a; } uint32_t Integer::operator& (const uint32_t& a) const { // AND return (uint32_t) (mpz_get_ui((mpz_srcptr)&(gmp_rep)) & (uint64_t)a ); } Integer Integer::operator~ () const { // 1 complement Integer res; mpz_com( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&(gmp_rep)); return res; } Integer& Integer::operator^= (const Integer& a) { // XOR mpz_xor( (mpz_ptr)&(gmp_rep), (mpz_ptr)&(gmp_rep), (mpz_srcptr)&(a.gmp_rep)); return *this; } Integer& Integer::operator|= (const Integer& a) { // OR mpz_ior( (mpz_ptr)&(gmp_rep), (mpz_ptr)&(gmp_rep), (mpz_srcptr)&(a.gmp_rep)); return *this; } Integer& Integer::operator&= (const Integer& a) { // AND mpz_and( (mpz_ptr)&(gmp_rep), (mpz_ptr)&(gmp_rep), (mpz_srcptr)&(a.gmp_rep)); return *this; } Integer& Integer::operator^= (const uint64_t & a) { // XOR Integer au(a); mpz_xor( (mpz_ptr)&(gmp_rep), (mpz_ptr)&(gmp_rep), (mpz_srcptr)&(au.gmp_rep)); return *this; } Integer& Integer::operator|= (const uint64_t & a) { // OR Integer au(a); mpz_ior( (mpz_ptr)&(gmp_rep), (mpz_ptr)&(gmp_rep), (mpz_srcptr)&(au.gmp_rep)); return *this; } Integer& Integer::operator&= (const uint64_t & a) { // AND Integer au(a); mpz_and( (mpz_ptr)&(gmp_rep), (mpz_ptr)&(gmp_rep), (mpz_srcptr)&(au.gmp_rep)); return *this; } Integer& Integer::operator^= (const uint32_t& a) { // XOR Integer au(a); mpz_xor( (mpz_ptr)&(gmp_rep), (mpz_ptr)&(gmp_rep), (mpz_srcptr)&(au.gmp_rep)); return *this; } Integer& Integer::operator|= (const uint32_t& a) { // OR Integer au(a); mpz_ior( (mpz_ptr)&(gmp_rep), (mpz_ptr)&(gmp_rep), (mpz_srcptr)&(au.gmp_rep)); return *this; } Integer& Integer::operator&= (const uint32_t& a) { // AND Integer au(a); mpz_and( (mpz_ptr)&(gmp_rep), (mpz_ptr)&(gmp_rep), (mpz_srcptr)&(au.gmp_rep)); return *this; } //------------------------------------------- convert method //------------------------------------------- casting method Integer::operator int32_t() const { return int32_t (mpz_get_si ( (mpz_srcptr)&gmp_rep)); } Integer::operator uint32_t() const { return (uint32_t) mpz_get_ui ( (mpz_srcptr)&gmp_rep); } Integer::operator int64_t() const { #if GMP_LIMB_BITS != 64 Integer absThis = abs(*this); int64_t r = static_cast(absThis.operator uint32_t()); absThis >>= 32; r |= static_cast(absThis.operator uint32_t()) << 32; return (*this < 0)? -r : r; #else return mpz_get_si ( (mpz_srcptr)&gmp_rep); #endif } Integer::operator uint64_t() const { #if GMP_LIMB_BITS != 64 Integer absThis = abs(*this); uint64_t r = static_cast(absThis.operator uint32_t()); absThis >>= 32; return r |= static_cast(absThis.operator uint32_t()) << 32; #else return mpz_get_ui ( (mpz_srcptr)&gmp_rep); #endif } Integer::operator double() const { return mpz_get_d ( (mpz_srcptr)&gmp_rep); } Integer::operator float() const { return (float)mpz_get_d ( (mpz_srcptr)&gmp_rep); } Integer::operator std::string () const { std::ostringstream o ; print(o); return o.str(); } Integer::operator Integer::vect_t () const { size_t s = mpz_size( (mpz_srcptr)&(gmp_rep) ); std::vector v(s); std::vector::iterator vi = v.begin(); for(mp_size_t i = 0;vi != v.end();++vi, ++i) *vi = mpz_getlimbn( (mpz_srcptr)& (gmp_rep) ,i); return v; } uint64_t length(const Integer& a) { //! @bug JGD 23.04.2012: shouldn't it be "mp_limb_t" instead of "uint64_t"? return mpz_size( (mpz_srcptr)&(a.gmp_rep) ) * sizeof(uint64_t); } Integer abs(const Integer &n) { if (sign(n) >= 0) return n; return -n; } size_t Integer::size() const { return mpz_size( (mpz_srcptr)&gmp_rep ) ; } size_t Integer::size_in_base(int32_t BASE) const { return mpz_sizeinbase ((mpz_srcptr)&gmp_rep, BASE); } size_t Integer::bitsize() const { return mpz_sizeinbase ((mpz_srcptr)&gmp_rep, 2); } uint64_t Integer::operator[](size_t i) const { if ( mpz_size( (mpz_srcptr)&gmp_rep ) > i) return mpz_getlimbn( (mpz_srcptr)&gmp_rep, i); else return 0; } } #endif // __GIVARO_gmpxx_gmpxx_int_misc_C // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/gmp++/gmp++_int_mod.C000066400000000000000000000152771274707324300205370ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_mod.C,v $ // Copyright(c)'1994-2010 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: M. Samama, T. Gautier // Modified: JG. Dumas, BB. // $Id: gmp++_int_mod.C,v 1.17 2010-12-22 13:47:45 jgdumas Exp $ // ========================================================================== /** @file gmp++/gmp++_int_mod.C * moding stuff. */ #ifndef __GIVARO_gmpxx_gmpxx_int_mod_C #define __GIVARO_gmpxx_gmpxx_int_mod_C #ifndef __GIVARO_INLINE_ALL #include "gmp++/gmp++.h" #endif #include #ifndef GIVABS #define GIVABS(a) ((a)>0?(a):-(a)) #endif namespace Givaro { //-------------------------------------------------- operator / Integer& Integer::modin(Integer& res, const Integer& n) { if (isZero(res)) return res; // mpz_tdiv_r( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, (mpz_ptr)&n.gmp_rep ); mpz_mod( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n.gmp_rep ); return res; } Integer& Integer::modin(Integer& res, const uint64_t n) { if (isZero(res)) return res; // mpz_tdiv_r_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&res.gmp_rep, n); mpz_mod_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&res.gmp_rep, n); return res; } Integer& Integer::modin(Integer& res, const int64_t n) { if (isZero(res)) return res; // int32_t sgn = sign(n); // mpz_tdiv_r_ui( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, abs(n)); // if (sgn <0) return res = -res; if (n>0) mpz_mod_ui( (mpz_ptr)&(res.gmp_rep), (mpz_ptr)&res.gmp_rep, n); else mpz_mod_ui( (mpz_ptr)&(res.gmp_rep), (mpz_ptr)&res.gmp_rep, -n); return res; } Integer& Integer::mod(Integer& res, const Integer& n1, const Integer& n2) { if (isZero(n1)) return res = Integer::zero; // mpz_tdiv_r( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&n1.gmp_rep, (mpz_ptr)&n2.gmp_rep); mpz_mod( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, (mpz_srcptr)&n2.gmp_rep); assert(!(res<0) && (res0) mpz_mod_ui( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&n1.gmp_rep, n2); else mpz_mod_ui( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&n1.gmp_rep, -n2); assert(!(res<0) && (res0)?1:-1; #endif mpz_tdiv_r_ui( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, l); #ifdef DEBUG assert((*this -GIVABS(l)) && (sgn_this*(*this).priv_sign()>=0)) ; #endif return *this; } Integer& Integer::operator %= (const int64_t l) { if (isZero(*this)) return *this; #ifdef DEBUG int32_t sgn_this = (*this>0)?1:-1; #endif int32_t sgn = Givaro::sign(l); mpz_tdiv_r_ui( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, std::abs(l)); if (sgn <0) mpz_neg( (mpz_ptr)&gmp_rep, (mpz_ptr)&(gmp_rep) ); #ifdef DEBUG assert((*this -GIVABS(l)) && (sgn_this*(*this).priv_sign()>=0)) ; #endif return *this; } Integer Integer::operator % (const Integer& n) const { if (isZero(*this)) return Integer::zero; Integer res; mpz_tdiv_r( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, (mpz_srcptr)&n.gmp_rep) ; // std::cout << res << ',' << n << ',' << *this << std::endl; assert((res -GIVABS(n)) && (res.priv_sign()*(*this).priv_sign()>=0)) ; return res; } int64_t Integer::operator % (const uint64_t l) const { #if 0 if (isZero(*this)) return 0U; if (this->priv_sign()>0) return mpz_tdiv_ui( (mpz_ptr)&gmp_rep, l); else { Integer Neg; mpz_neg( (mpz_ptr)&(Neg.gmp_rep), (mpz_ptr)&gmp_rep ); uint64_t res = mpz_tdiv_ui( (mpz_ptr)&(Neg.gmp_rep), l); if (res > 0U) return (l-res); else return 0U; } #endif if (isZero(*this)) return 0U; bool isneg = (*this)<0 ; //CONDITION: mpz_tdiv_ui does NOT consider the sign of gmp_rep uint64_t res = mpz_tdiv_ui( (mpz_srcptr)&gmp_rep, l); #ifdef DEBUG Integer toto = res; if (isneg) toto = -(int64_t)res ; // std::cout << toto << ',' << l << ',' << ',' << *this << std::endl; assert((toto=0)) ; #endif if (!res) return (int64_t)res ; if (isneg) return (-(int64_t)res) ; return (int64_t)res ; } int64_t Integer::operator % (const int64_t l) const { #if 0 if (l ==0) { GivMathDivZero("[Integer::/]: division by zero"); } #endif int64_t res ; if (l>0) { res = static_cast(this->operator%( static_cast(l) ) ); } else { res = static_cast(this->operator%( static_cast( -l ) ) ); } // std::cout << res << ',' << l << ',' << *this << std::endl; assert((res -GIVABS(l)) && (((res>0)?1:((res==0)?0:-1))*(*this).priv_sign()>=0)) ; return res; } double Integer::operator % (const double l) const { double res ; if (l>0) res = static_cast(this->operator%( static_cast(l) ) ); else{ res = static_cast(this->operator%( static_cast(-l) ) ); } assert((res -GIVABS(l)) && (((res>0)?1:((res==0)?0:-1))*(*this).priv_sign()>=0)) ; return res; } // -- operator % Integer operator % (const int32_t l, const Integer& n) { return Integer(l) % n; } Integer operator % (const int64_t l, const Integer& n) { return Integer(l) % n; } Integer operator % (const uint32_t l, const Integer& n) { return Integer(l) % n; } Integer operator % (const uint64_t l, const Integer& n) { return Integer(l) % n; } } #endif // __GIVARO_gmpxx_gmpxx_int_mod_C /* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen:foldmethod=syntax givaro-4.0.2/src/kernel/gmp++/gmp++_int_mul.C000066400000000000000000000210051274707324300205370ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_mul.C,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: M. Samama, T. Gautier // $Id: gmp++_int_mul.C,v 1.11 2011-01-20 08:19:15 jgdumas Exp $ // ========================================================================== /** @file gmp++/gmp++_int_mul.C * muling stuff. */ #ifndef __GIVARO_gmpxx_gmpxx_int_mul_C #define __GIVARO_gmpxx_gmpxx_int_mul_C #ifndef __GIVARO_INLINE_ALL #include "gmp++/gmp++.h" #endif namespace Givaro { //-------------------------------------------------- operator * Integer& Integer::mulin(Integer& res, const Integer& n) { if (isZero(n)) return res = Integer::zero; if (isZero(res)) return res; mpz_mul( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n.gmp_rep ); return res; } Integer& Integer::mulin(Integer& res, const int64_t n) { if (isZero(n)) return res = Integer::zero; if (isZero(res)) return res; // int32_t sgn = sign(n); // int32_t sgn = sign(n); // mpz_mul_ui( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, abs(n)); // if (sgn <0) res.gmp_rep.size = -res.gmp_rep.size; // if (sgn <0) return res = -res; mpz_mul_si( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, n); return res; } Integer& Integer::mulin(Integer& res, const uint64_t n) { if (isZero(n)) return res = Integer::zero; if (isZero(res)) return res; mpz_mul_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&res.gmp_rep, n); return res; } Integer& Integer::mul(Integer& res, const Integer& n1, const Integer& n2) { if (isZero(n1)) return res = Integer::zero; if (isZero(n2)) return res = Integer::zero; mpz_mul( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, (mpz_srcptr)&n2.gmp_rep); return res; } Integer& Integer::mul(Integer& res, const Integer& n1, const int64_t n2) { if (isZero(n1)) return res = Integer::zero; if (isZero(n2)) return res = Integer::zero; // int32_t sgn = sign(n2); // mpz_mul_ui( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&n1.gmp_rep, abs(n2)); // if (sgn <0) res.gmp_rep.size = -res.gmp_rep.size; // if (sgn <0) return res = -res; mpz_mul_si( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, n2); return res; } Integer& Integer::mul(Integer& res, const Integer& n1, const uint64_t n2) { if (isZero(n1)) return res = Integer::zero; if (isZero(n2)) return res = Integer::zero; mpz_mul_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, n2); return res; } Integer& Integer::axpy(Integer& res, const Integer& a, const Integer& x, const Integer& b) { if (&res == &b) return Integer::axpyin(res,a,x); if (isZero(a) || isZero(x)) return res = b; mpz_mul( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&a.gmp_rep, (mpz_srcptr)&x.gmp_rep); mpz_add( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&b.gmp_rep); return res; } Integer& Integer::axpy(Integer& res, const Integer& a, const uint64_t x, const Integer& b) { if (&res == &b) return Integer::axpyin(res,a,x); if (isZero(a) || isZero(x)) return res = b; mpz_mul_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&a.gmp_rep, x); mpz_add( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&b.gmp_rep); return res; } Integer& Integer::axpyin(Integer& res, const Integer& a, const Integer& x) { if (isZero(a) || isZero(x)) return res; mpz_addmul( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&a.gmp_rep, (mpz_srcptr)&x.gmp_rep); return res; } Integer& Integer::axpyin(Integer& res, const Integer& a, const uint64_t x) { if (isZero(a) || isZero(x)) return res; mpz_addmul_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&a.gmp_rep, x); return res; } Integer& Integer::maxpy(Integer& res, const Integer& a, const Integer& x, const Integer& b) { if (isZero(a) || isZero(x)) return res=b; if (&res == &b) return Integer::maxpyin(res,a,x); mpz_mul( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&a.gmp_rep, (mpz_srcptr)&x.gmp_rep); mpz_sub( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&b.gmp_rep, (mpz_ptr)&res.gmp_rep); return res; } Integer& Integer::maxpy(Integer& res, const Integer& a, const uint64_t x, const Integer& b) { if (isZero(a) || isZero(x)) return res=b; if (&res == &b) return Integer::maxpyin(res,a,x); mpz_mul_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&a.gmp_rep, x); mpz_sub( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&b.gmp_rep, (mpz_ptr)&res.gmp_rep); return res; } Integer& Integer::axmy(Integer& res, const Integer& a, const Integer& x, const Integer& b) { if (&res == &b) return Integer::axmyin(res,a,x); if (isZero(a) || isZero(x)) return Integer::neg(res,b); mpz_mul( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&a.gmp_rep, (mpz_srcptr)&x.gmp_rep); mpz_sub( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&b.gmp_rep); return res; } Integer& Integer::axmy(Integer& res, const Integer& a, const uint64_t x, const Integer& b) { if (&res == &b) return Integer::axmyin(res,a,x); if (isZero(a) || isZero(x)) return Integer::neg(res,b); mpz_mul_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&a.gmp_rep, x); mpz_sub( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&b.gmp_rep); return res; } Integer& Integer::axmyin(Integer& res, const Integer& a, const Integer& x) { Integer::maxpyin(res,a,x); Integer::negin(res); return res ; } Integer& Integer::axmyin(Integer& res, const Integer& a, const uint64_t x) { Integer::maxpyin(res,a,x); Integer::negin(res); return res ; } Integer& Integer::maxpyin(Integer& res, const Integer& a, const Integer& x) { if (isZero(a) || isZero(x)) return res; mpz_submul( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&a.gmp_rep, (mpz_srcptr)&x.gmp_rep); return res; } Integer& Integer::maxpyin(Integer& res, const Integer& a, const uint64_t x) { if (isZero(a) || isZero(x)) return res; mpz_submul_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&a.gmp_rep, x); return res; } Integer& Integer::operator *= (const Integer& n) { if (isZero(n)) return *this = Integer::zero; if (isZero(*this)) return *this; // Rep (res.gmp_rep)( MAX(SZ_REP(n.gmp_rep),SZ_REP(gmp_rep)) ); Integer res; mpz_mul( (mpz_ptr)&(res.gmp_rep), (mpz_ptr)&gmp_rep, (mpz_srcptr)&n.gmp_rep) ; return *this = res; } Integer& Integer::operator *= (const uint64_t l) { if (l==0) return *this = Integer::zero; if (isZero(*this)) return *this; // Rep (res.gmp_rep)( MAX(SZ_REP(gmp_rep),1) ); mpz_mul_ui( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, l); return *this; } Integer& Integer::operator *= (const int64_t l) { if (l==0) return *this =Integer::zero; if (isZero(*this)) return *this; // Rep (res.gmp_rep)( MAX(SZ_REP(gmp_rep),1) ); // int32_t sgn = sign(l); // mpz_mul_ui( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, abs(l)); // if (sgn <0) mpz_neg( (mpz_ptr)&gmp_rep, (mpz_ptr)&(gmp_rep) ); mpz_mul_si( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, l); return *this; } Integer Integer::operator * (const Integer& n) const { if (isZero(n)) return Integer::zero; if (isZero(*this)) return Integer::zero; // Rep (res.gmp_rep)( MAX(SZ_REP(n.gmp_rep),SZ_REP(gmp_rep)) ); Integer res; mpz_mul( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, (mpz_srcptr)&n.gmp_rep) ; return res; } Integer Integer::operator * (const uint64_t l) const { if (l==0) return Integer::zero; if (isZero(*this)) return Integer::zero; // Rep (res.gmp_rep)( MAX(SZ_REP(gmp_rep),1) ); Integer res; mpz_mul_ui( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, l); return res; } Integer Integer::operator * (const int64_t l) const { if (l==0) return Integer::zero; if (isZero(*this)) return Integer::zero; // Rep (res.gmp_rep)( MAX(SZ_REP(gmp_rep),1) ); Integer res; // int32_t sgn = sign(l); // mpz_mul_ui( (mpz_ptr)&(res.gmp_rep), (mpz_ptr)&gmp_rep, abs(l)); // if (sgn <0) (res.gmp_rep).size = -(res.gmp_rep).size; // return Integer((res.gmp_rep)); // if (sgn <0) mpz_neg( (mpz_ptr)&(res.gmp_rep), (mpz_ptr)&(res.gmp_rep) ); mpz_mul_si( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, l); return res; } // -- operator * Integer operator * (const int32_t l, const Integer& n) { return n * (int64_t)l; } Integer operator * (const uint32_t l, const Integer& n) { return n * (uint64_t)l; } Integer operator * (const int64_t l, const Integer& n) { return n * l; } Integer operator * (const uint64_t l, const Integer& n) { return n * l; } } #endif // __GIVARO_gmpxx_gmpxx_int_mul_C // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s givaro-4.0.2/src/kernel/gmp++/gmp++_int_pow.C000066400000000000000000000054561274707324300205630ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_pow.C,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: JG Dumas // $Id: gmp++_int_pow.C,v 1.4 2009-09-17 14:28:22 jgdumas Exp $ // ========================================================================== // Description: /** @file gmp++/gmp++_int_pow.C * powing stuff. */ #ifndef __GIVARO_gmpxx_gmpxx_int_pow_C #define __GIVARO_gmpxx_gmpxx_int_pow_C #ifndef __GIVARO_INLINE_ALL #include "gmp++/gmp++.h" #endif #include namespace Givaro { int32_t isperfectpower(const Integer& n) { return mpz_perfect_power_p((mpz_srcptr)&(n.gmp_rep)); } Integer& pow(Integer& Res, const uint64_t n, const uint64_t p) { mpz_ui_pow_ui( (mpz_ptr)&(Res.gmp_rep), n, p); return Res; } Integer& pow(Integer& Res, const Integer& n, const uint64_t p) { __gmpz_pow_ui( (mpz_ptr)&(Res.gmp_rep), (mpz_srcptr)&n.gmp_rep, p); return Res; } Integer pow(const Integer& n, const uint64_t p) { if (p == 0) return Integer::one; Integer Res; return pow(Res,n,p); } Integer& pow(Integer& Res, const Integer& n, const int64_t l) { // Beware of negative values return pow(Res, n, (uint64_t) std::abs(l) ); } Integer pow(const Integer& n, const int64_t l) { if (l < 0) return Integer::zero; return pow(n, (uint64_t) std::abs(l) ); } Integer& powmod(Integer& Res, const Integer& n, const uint64_t p, const Integer& m) { mpz_powm_ui( (mpz_ptr)&(Res.gmp_rep), (mpz_srcptr)&n.gmp_rep, p, (mpz_srcptr)&m.gmp_rep); return Res; } Integer powmod(const Integer& n, const uint64_t p, const Integer& m) { if (p == 0) return Integer::one; Integer Res; return powmod(Res,n,p,m); } Integer& powmod(Integer& Res, const Integer& n, const int64_t e, const Integer& m) { if (e < 0) { inv(Res, n, m); return powmod(Res, Res, (uint64_t)std::abs(e), m); } else { return powmod (Res, n, (uint64_t)(e), m); } } Integer powmod(const Integer& n, const int64_t e, const Integer& m) { Integer Res; return powmod(Res, n, e, m); } Integer& powmod(Integer& Res, const Integer& n, const Integer& e, const Integer& m) { mpz_powm( (mpz_ptr)&(Res.gmp_rep), (mpz_srcptr)&n.gmp_rep, (mpz_srcptr)&e.gmp_rep, (mpz_srcptr)&m.gmp_rep); return Res; } Integer powmod(const Integer& n, const Integer& e, const Integer& m) { if (e == 0) return Integer::one; if (e < 0) return Integer::zero; Integer Res; return powmod(Res, n, e, m); } } #endif // __GIVARO_gmpxx_gmpxx_int_pow_C // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/gmp++/gmp++_int_rand.inl000066400000000000000000000243001274707324300212670ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_add.C,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: B. Boyer // $Id: gmp++_int_random.C,v 1.5 2011-09-16 12:09:37 briceboyer Exp $ // ========================================================================== // #include "gmp++/gmp++.h" /** @file gmp++/gmp++_int_rand.inl * randing stuff. */ #ifndef __GIVARO_gmpxx_gmpxx_int_rand_INL #define __GIVARO_gmpxx_gmpxx_int_rand_INL #include #include #include #include namespace Givaro { //----------------------------------------------------- //----------------------- Random integers ------------- //----------------------------------------------------- /* ********************** */ /* seeding, initialising */ /* ********************** */ #ifdef __GMP_PLUSPLUS__ gmp_randclass& Integer::randstate() { static gmp_randclass randstate(gmp_randinit_default); return static_cast(randstate); } #else #error "not implemented" #error "please include gmp++/gmp++.h very high in your include list" #endif inline void Integer::seeding(uint64_t s) { Integer::randstate().seed( (unsigned long)s) ; } void Integer::seeding(Integer s) { Integer::randstate().seed((mpz_class) (mpz_srcptr) &(s.gmp_rep) ) ; } void Integer::seeding() { Integer::seeding( (uint64_t) BaseTimer::seed() ); } // BB : good seeding but not so efficient... bool Integer::RandBool() { if (Integer::random(1U)) return true; else return false ; } /* ****************************** */ /* random number smaller than m */ /* ****************************** */ //! returns a random integer \p r in the intervall [[x, m-1]] //! where x = 0 or -(m-1) according to \p ALWAYSPOSITIVE //! @bug m \b has to be an integer here. //@{ #ifdef __GMP_PLUSPLUS__ template Integer& Integer::random_lessthan (Integer& r, const Integer & m) { mpz_set( (mpz_ptr) &(r.gmp_rep) , ( (mpz_class)Integer::randstate().get_z_range((mpz_class) (mpz_srcptr) &(m.gmp_rep)) ).get_mpz_t() ); if(!ALWAYSPOSITIVE) if (Integer::RandBool()) Integer::negin(r); return r; } #else template Integer& Integer::random_lessthan (Integer& r, const Integer & m) { mpz_urandomm((mpz_ptr) &(r.gmp_rep),Integer::randstate(),(mpz_srcptr)&(m.gmp_rep)); if(!ALWAYSPOSITIVE) if (Integer::RandBool()) Integer::negin(r); return r; } #endif Integer& Integer::random_lessthan (Integer& r, const Integer & m) { return random_lessthan(r,m); } //@} /* ******************************** */ /* random number smaller than 2^m */ /* ******************************** */ //! returns a random integer \p r in the intervall [[x, 2^m-1]] //! where x = 0 or -(2^m-1) according to \p ALWAYSPOSITIVE //! returns a random integer \p r of at most \p m bits //@{ #ifdef __GMP_PLUSPLUS__ template Integer& Integer::random_lessthan_2exp (Integer& r, const uint64_t & m) { mpz_set( (mpz_ptr) &(r.gmp_rep) , ((mpz_class)Integer::randstate().get_z_bits(m)).get_mpz_t() ); if(!ALWAYSPOSITIVE) { if (Integer::RandBool()) Integer::negin(r); } return r; } #else template Integer& Integer::random_lessthan_2exp (Integer& r, const uint64_t & m) { mpz_urandomb((mpz_ptr) &(r.gmp_rep),Integer::randstate(),m) ; if(!ALWAYSPOSITIVE) if (Integer::RandBool()) Integer::negin(r); return r; } #endif template Integer Integer::random_lessthan_2exp (const uint64_t & m) { Integer r ; random_lessthan_2exp(r,m); return r; } /* synonyms CAREFULL: when m is integer, meaning is different*/ template Integer& Integer::random_lessthan (Integer& r, const uint64_t & m) { return Integer::random_lessthan_2exp(r,m); } template Integer Integer::random_lessthan (const T & m) { Integer res ; return Integer::random_lessthan(res,(typename Signed_Trait::unsigned_type)m); } Integer& Integer::random_lessthan_2exp (Integer& r, const uint64_t & m) { return random_lessthan_2exp(r,m); } Integer Integer::random_lessthan_2exp (const uint64_t & m) { return random_lessthan_2exp(m); } Integer& Integer::random_lessthan (Integer& r, const uint64_t & m) { return random_lessthan(r,m); } template Integer Integer::random_lessthan (const T & m) { return random_lessthan(m); } //@} /* ********************************* */ /* random number of same size as s */ /* ********************************* */ //! returns a reference to a random number \p r of the size of \p s, exactly. template Integer& Integer::random_exact (Integer& r, const Integer & s) { size_t t = s.bitsize() ; Integer::random_exact_2exp(r,t); return r; } Integer& Integer::random_exact (Integer& r, const uint64_t & m) { return Integer::random_exact(r,m); } Integer& Integer::random_exact (Integer& r, const Integer & s) { return Integer::random_exact(r,s); } template Integer& Integer::random_exact (Integer& r, const T & m) { return Integer::random_exact(r,static_cast(m)); } template Integer& Integer::random_exact (Integer& r, const T & m) { return Integer::random_exact(r,static_cast(m)); } template Integer Integer::random_exact (const T & s) { return Integer::random_exact(s) ; } /* ************************* */ /* random number of size m */ /* ************************* */ //! returns a reference to a random number \p r of the size \p m bits, exactly. template Integer& Integer::random_exact_2exp (Integer& r, const uint64_t & m) { if (m) random_lessthan_2exp(r,m-1_ui64); mpz_setbit( (mpz_ptr) &(r.gmp_rep) , m-1_ui64); if(!ALWAYSPOSITIVE) if (Integer::RandBool()) Integer::negin(r); return r; } Integer& Integer::random_exact_2exp (Integer& r, const uint64_t & m) { return Integer::random_exact(r,m); } // synonym template Integer& Integer::random_exact (Integer& r, const uint64_t & m) { return Integer::random_exact_2exp(r,m) ; } template Integer Integer::random_exact (const T & s) { Integer res ; return random_exact(res,s); } /* **************************** */ /* random number in [[m,M-1]] */ /* **************************** */ Integer& Integer::random_between (Integer& r, const Integer& m, const Integer&M) { assert(M > m); random_lessthan(r,Integer(M-m)); r += m ; return (r); } Integer Integer::random_between (const Integer& m, const Integer &M) { Integer r ; return random_between(r,m,M); } template Integer Integer::random_between (const R & m, const R & M) { return Integer::random_between(static_cast(m), static_cast(M)); } template Integer & Integer::random_between (Integer &r, const R & m, const R & M) { return Integer::random_between(r,static_cast(m), static_cast(M)); } /* ******************************** */ /* random number in [[2^m,2^M-1]] */ /* ******************************** */ // todo : template Integer& Integer::random_between_2exp (Integer& r, const uint64_t& m, const uint64_t &M) { assert(M > m); r = nonzerorandom((uint64_t)M-m); Integer r1 = random_lessthan_2exp(m); r <<= m ; r+= r1 ; return (r); } Integer Integer::random_between_2exp (const uint64_t & m, const uint64_t &M) { Integer r ; return random_between_2exp(r,m,M); } // synonym. Integer Integer::random_between (const uint64_t & m, const uint64_t &M) { return random_between_2exp(m,M) ; } Integer& Integer::random_between (Integer& r, const uint64_t& m, const uint64_t &M) { return random_between_2exp(r,m,M); } /* **************/ /* short hand */ /* **************/ //! returns a random integer less than... template Integer& Integer::random (Integer& r, const T & m) { return Integer::random_lessthan(r, (typename Signed_Trait::unsigned_type) m) ; } //! returns a random integer less than... template Integer Integer::random(const T & sz) { return Integer::random_lessthan(sz); } Integer Integer::random() { return Integer::random(sizeof(mp_limb_t)*8) ; } template Integer Integer::random() { Integer rez = Integer::random(sizeof(mp_limb_t)*8) ; if (!ALWAYSPOSITIVE) if (Integer::RandBool()) negin(rez); return rez; } template Integer& Integer::random (Integer& r, const T & m) { return Integer::random(r,m); } template Integer Integer::random(const T & sz) { return Integer::random(sz); } /* *******************/ /* Non Zero random */ /* *******************/ template Integer Integer::nonzerorandom(const T & sz) { Integer r; while(isZero(Integer::random(r, sz) )) {} ; return r; } // BB: It's also 1+random(sz-1)... template Integer& Integer::nonzerorandom (Integer& r, const T& size) { while (isZero(Integer::random(r,size))) {} ; return r; } template Integer Integer::nonzerorandom(const T & sz) { return Integer::nonzerorandom(sz); } template Integer& Integer::nonzerorandom (Integer& r, const T& size) { return Integer::nonzerorandom(r,size); } Integer Integer::nonzerorandom() { Integer rez = Integer::nonzerorandom(sizeof(mp_limb_t)*8) ; // if (!ALWAYSPOSITIVE) if (Integer::RandBool()) negin(rez); return rez; } } #endif // __GIVARO_gmpxx_gmpxx_int_rand_INL // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/gmp++/gmp++_int_sub.C000066400000000000000000000117221274707324300205400ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_sub.C,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: M. Samama, T. Gautier // $Id: gmp++_int_sub.C,v 1.4 2009-09-17 14:28:22 jgdumas Exp $ // ========================================================================== /** @file gmp++/gmp++_int_sub.C * subing stuff. */ #ifndef __GIVARO_gmpxx_gmpxx_int_sub_C #define __GIVARO_gmpxx_gmpxx_int_sub_C #ifndef __GIVARO_INLINE_ALL #include "gmp++/gmp++.h" #endif namespace Givaro { //-------------------------------------------------- operator - Integer& Integer::subin(Integer& res, const Integer& n) { if (isZero(n)) return res; if (isZero(res)) return res = - n; mpz_sub( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n.gmp_rep ); return res; } Integer& Integer::subin(Integer& res, const int64_t n) { if (isZero(n)) return res; if (isZero(res)) return res = - n; int32_t sgn = Givaro::sign(n); if (sgn >0) mpz_sub_ui( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, n); else mpz_add_ui((mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, -n); return res; } Integer& Integer::subin(Integer& res, const uint64_t n) { if (isZero(n)) return res; if (isZero(res)) return res = - n; mpz_sub_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&res.gmp_rep, n); return res; } Integer& Integer::sub(Integer& res, const Integer& n1, const Integer& n2) { if (isZero(n1)) return res = - n2; if (isZero(n2)) return res = n1; mpz_sub( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, (mpz_srcptr)&n2.gmp_rep); return res; } Integer& Integer::sub(Integer& res, const Integer& n1, const int64_t n2) { if (isZero(n1)) return res = - n2; if (isZero(n2)) return res = n1; int32_t sgn = Givaro::sign(n2); if (sgn >0) mpz_sub_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, n2); else mpz_add_ui((mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, -n2); return res; } Integer& Integer::sub(Integer& res, const Integer& n1, const uint64_t n2) { if (isZero(n1)) return res = - n2; if (isZero(n2)) return res = n1; mpz_sub_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, n2); return res; } Integer& Integer::neg(Integer& res, const Integer& n) { mpz_neg( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n.gmp_rep); return res; } Integer& Integer::negin(Integer& res) { mpz_neg( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep); return res; } Integer& Integer::operator -= (const Integer& n) { if (isZero(n)) return *this; if (isZero(*this)) return logcpy(-n); // Rep (res.gmp_rep)( MAX(SZ_REP(n.gmp_rep),SZ_REP(gmp_rep)) ); mpz_sub( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, (mpz_srcptr)&n.gmp_rep) ; return *this; } Integer& Integer::operator -= (const uint64_t l) { if (l==0) return *this; if (isZero(*this)) return logcpy(Integer(-l)); // Rep (res.gmp_rep)( MAX(SZ_REP(gmp_rep),1) ); mpz_sub_ui( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, l); return *this; } Integer& Integer::operator -= (const int64_t l) { if (l==0) return *this; if (isZero(*this)) return logcpy(Integer(-l)); // Rep (res.gmp_rep)( MAX(SZ_REP(gmp_rep),1) ); int32_t sgn = Givaro::sign(l); if (sgn >0) mpz_sub_ui( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, l); else mpz_add_ui( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, -l); return *this; } Integer Integer::operator - (const Integer& n) const { if (isZero(n)) return *this; if (isZero(*this)) return -n; // Rep (res.gmp_rep)( MAX(SZ_REP(n.gmp_rep),SZ_REP(gmp_rep)) ); Integer res; mpz_sub( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, (mpz_srcptr)&n.gmp_rep) ; return res; } Integer Integer::operator - (const uint64_t l) const { if (l==0) return *this; if (isZero(*this)) return Integer(-l); // Rep (res.gmp_rep)( MAX(SZ_REP(gmp_rep),1) ); Integer res; mpz_sub_ui( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, l); return res; } Integer Integer::operator - (const int64_t l) const { if (l==0) return *this; if (isZero(*this)) return Integer(-l); // Rep (res.gmp_rep)( MAX(SZ_REP(gmp_rep),1) ); Integer res; int32_t sgn = Givaro::sign(l); if (sgn >0) mpz_sub_ui( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, l); else mpz_add_ui( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, -l); return res; } // -- operator - Integer operator - (const int32_t l, const Integer& n) { return -(n - (int64_t)l); } Integer operator - (const uint32_t l, const Integer& n) { return -(n - (uint64_t)l); } Integer operator - (const int64_t l, const Integer& n) { return -(n - l); } Integer operator - (const uint64_t l, const Integer& n) { return -(n - l); } } #endif // __GIVARO_gmpxx_gmpxx_int_sub_C // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/gmp++/gmp++_rat.C000066400000000000000000000012441274707324300176610ustar00rootroot00000000000000// Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. #ifndef __GMPplusplus_RATIONAL_C__ #define __GMPplusplus_RATIONAL_C__ // #include "gmp++/gmp++.h" #include "gmp++_rat_cstor.C" #include "gmp++_rat_add.C" // #include "gmp++_rat_sub.C" // #include "gmp++_rat_mul.C" // #include "gmp++_rat_pow.C" // #include "gmp++_rat_div.C" // #include "gmp++_rat_mod.C" // #include "gmp++_rat_gcd.C" #include "gmp++_rat_misc.C" #include "gmp++_rat_compare.C" #include "gmp++_rat_io.C" #endif givaro-4.0.2/src/kernel/gmp++/gmp++_rat.h000066400000000000000000000206371274707324300177350ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_Rationel.h,v $ // Copyright(c)'1994-2011 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: Brice Boyer (briceboyer) // $Id: givRationel.h,v 0.0 2011-09-15 18:23:56 briceboyer Exp $ // ========================================================================== #ifndef __GIVARO_GMPplusplus_Rationel_H #define __GIVARO_GMPplusplus_Rationel_H // #define __GIVARO_Rationel_H /*! @file gmp++/gmp++_rat.h * @ingroup Rationel * Core Rationel from GMP */ #include namespace Givaro { class Rationel ; Rationel abs(const Rationel& n); std::istream& operator >> (std::istream &i, Rationel& n); std::ostream& operator << (std::ostream &o, const Rationel& n); std::ostream& absOutput (std::ostream &o, const Rationel& n); namespace Protected { void importWords(Rationel&, size_t, int, int, int, size_t, const void*); } class Rationel { public: enum reduceFlag { Reduce = 0x1, NoReduce = 0x0 } ; // enum ReducedFlag { Reduced = 0x2, NoReduced = 0x3 } ; protected: typedef __mpq_struct Rep; typedef __mpz_struct RawRep ; Rep gmp_rep; RawRep * num ; RawRep * den ; int32_t privSign() const; const Rep* get_rep() const { return &gmp_rep; } public : // CONSTRUCTORS (gmp++_rat_cstor.C) //! default constructor (0/1). giv_all_inlined Rationel() ; //! constructors from a single numerator. //!@param n numerator, will make fraction n/1 //@{ giv_all_inlined Rationel( Integer & n) ; giv_all_inlined Rationel( int32_t n) ; giv_all_inlined Rationel( uint32_t n) ; giv_all_inlined Rationel( int64_t n) ; giv_all_inlined Rationel( uint64_t n) ; //@} //! constructors from a numerator and a denominator. /*! @param n numerator * @param d denominator, will produce fraction \c n/d * @param reduceFlag by defaut, noting is reduced. * @pre we suppose \c d!=0. this is not asserted in \c NDEBUG mode ! */ //@{ giv_all_inlined Rationel( Integer & n, Integer & d, enum reduceFlag = NoReduce) ; giv_all_inlined Rationel( int32_t n, int32_t d, enum reduceFlag = NoReduce) ; giv_all_inlined Rationel( uint32_t n, int32_t d, enum reduceFlag = NoReduce) ; giv_all_inlined Rationel( int64_t n, int32_t d, enum reduceFlag = NoReduce) ; giv_all_inlined Rationel( uint64_t n, int32_t d, enum reduceFlag = NoReduce) ; giv_all_inlined Rationel( int32_t n, uint32_t d, enum reduceFlag = NoReduce) ; giv_all_inlined Rationel( int32_t n, int64_t d, enum reduceFlag = NoReduce) ; giv_all_inlined Rationel( int32_t n, uint64_t d, enum reduceFlag = NoReduce) ; giv_all_inlined Rationel( uint32_t n, uint32_t d, enum reduceFlag = NoReduce); giv_all_inlined Rationel( uint32_t n, int64_t d, enum reduceFlag = NoReduce) ; giv_all_inlined Rationel( uint32_t n, uint64_t d, enum reduceFlag = NoReduce); giv_all_inlined Rationel( uint64_t n, uint32_t d, enum reduceFlag = NoReduce) ; giv_all_inlined Rationel( int64_t n, uint32_t d, enum reduceFlag = NoReduce) ; giv_all_inlined Rationel( int64_t n, int64_t d, enum reduceFlag = NoReduce) ; giv_all_inlined Rationel( uint64_t n, int64_t d, enum reduceFlag = NoReduce) ; giv_all_inlined Rationel( int64_t n, uint64_t d, enum reduceFlag = NoReduce) ; giv_all_inlined Rationel( uint64_t n, uint64_t d, enum reduceFlag = NoReduce) ; template giv_all_inlined Rationel( Integer & n, T d, enum reduceFlag = NoReduce) ; template giv_all_inlined Rationel( T n, Integer & d, enum reduceFlag = NoReduce) ; template giv_all_inlined Rationel( T n, U d, enum reduceFlag = NoReduce) ; template giv_all_inlined Rationel( T & n, U & d, enum reduceFlag = NoReduce) ; //@} //! constructors from another Rationel /*! @param f the Rationel to be represented * @param reduceFlag a flag to start reduction or not. */ //@{ giv_all_inlined Rationel( Rationel & f, enum reduceFlag = NoReduce) ; giv_all_inlined Rationel( float f, enum reduceFlag = NoReduce) ; giv_all_inlined Rationel( double f, enum reduceFlag = NoReduce) ; giv_all_inlined Rationel( long double f, enum reduceFlag = NoReduce) ; //@} // destructors /*! Destructor. * Clearing the \c mpq representation. */ ~Rationel() { mpq_clear((mpq_ptr)&gmp_rep); } // ADD static giv_all_inlined Rationel& addin(Rationel& res, const Rationel& n); static giv_all_inlined Rationel& addin(Rationel& res, const Integer& n) ; // SUB static giv_all_inlined Rationel& negin (Rationel& res) { mpq_neg((mpq_ptr)res.get_mpq(), (mpq_ptr)res.get_mpq()); return res ; } giv_all_inlined Rationel& negin () { mpq_neg((mpq_ptr)&gmp_rep,(mpq_ptr)&gmp_rep); return *this; } // Conversions/Casts (gmp++_rat_cast.C) giv_all_inlined operator std::string() const ; // (gmp++_rat_compare.C) friend giv_all_inlined Rationel abs(const Rationel& n); // Input/output of Rationels (gmp++_rat_io.C) /*! @name I/O */ //@{ friend giv_all_inlined std::istream& operator >> (std::istream &i, Rationel & n); friend giv_all_inlined std::ostream& operator << (std::ostream &o, const Rationel & n); friend giv_all_inlined std::ostream& absOutput (std::ostream &o, const Rationel& n); // friend void Protected::importWords(Integer&, size_t, int, int, int, size_t, const void*); giv_all_inlined std::ostream& print( std::ostream& o ) const; //@} // basic acessing operations and other tools (gmp++_rat_misc.C) /*! Gets the denominator of a \c Rationel. * @return the \c Integer denominator. */ giv_all_inlined Integer getDenom() const ; /*! Gets the numerator of a \c Rationel. * @return the \c Integer numerator . */ giv_all_inlined Integer getNumer() const ; /*! Retrieve the GMP representation of a Rationel. * @return a pointer to this representation. */ giv_all_inlined mpq_ptr get_mpq() ; giv_all_inlined mpq_srcptr get_mpq_const() const ; /*! Retrieve the GMP representation of the denominator of a Rationel. * @return a pointer to this denominator (integer). */ giv_all_inlined mpz_ptr get_mpq_den() const ; /*! Retrieve the GMP representation of the numerator of a Rationel. * @return a pointer to this numerator (integer). */ giv_all_inlined mpz_ptr get_mpq_num() const ; /*! Reduces (inplace) a fraction to a canonical representation. * @return a reference to self. */ giv_all_inlined Rationel& reduce(); /*! Reduces a fraction to a canonical representation. * @param r a \c Rationel * @return a reference to the reduced \p r. */ static giv_all_inlined Rationel& reduce(Rationel & r) ;//const static inline int32_t isZero(const Rationel &n) { return (mpq_sgn((mpq_srcptr)&n.gmp_rep) == 0) ; } giv_all_inlined int32_t isZero() { return (mpq_sgn((mpq_srcptr)&gmp_rep) == 0); } //------------------------------------------operator = (const Integer &n) giv_all_inlined Rationel& logcpy(const Rationel &n) { if (this == &n) return *this; mpq_set ( (mpq_ptr)&gmp_rep, (mpq_srcptr)&(n.gmp_rep)) ; return *this; } // same as logcopy giv_all_inlined Rationel& operator = (const Rationel &n) { return logcpy(n) ; } giv_all_inlined Rationel& operator = (const Integer &n) { mpq_set_z ( (mpq_ptr)&gmp_rep, (mpz_srcptr)(n.get_mpz_const())) ; return *this; } static giv_all_inlined void setInteger(Rationel &f, const Integer & n) { // (( (mpq_ptr)&f.gmp_rep )->_mp_num ) = (mpz_srcptr) n.get_mpz_const() ; // mpz_t a ; // mpz_init(a); // mpz_ptr a = mpq_numref( (mpq_ptr)&f.gmp_rep ); // a = const_cast( n.get_mpz_const() ); mpz_set( (mpz_ptr)&(f.gmp_rep._mp_num), const_cast( n.get_mpz_const() ) ) ; } protected: static reduceFlag flags ; //!< flag that indicates reduction is done or not after an operation. By default, this is Reduce (as in GMP). }; } #ifdef __GIVARO_INLINE_ALL #include "gmp++_rat.C" #endif #include "gmp++_rat.inl" #endif // __GIVARO_GMPplusplus_Rationel_H // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/gmp++/gmp++_rat.inl000066400000000000000000000046051274707324300202650ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_cstor.C,v $ // Copyright(c)'1994-2011 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: B. Boyer // $Id: gmp++_rat_cstor.C,v 1.4 2011-09-16 14:28:22 briceboyer Exp $ // ========================================================================== #ifndef __GIVARO_gmpxx_gmpxx_rat_INL #define __GIVARO_gmpxx_gmpxx_rat_INL namespace Givaro { // Integer constructors fallbacks template Rationel::Rationel( Integer & n, T d, enum reduceFlag red) { assert(nonZero(d)); //! @todo nonZero() ? mpq_init((mpq_ptr)&gmp_rep); mpq_set_z((mpq_ptr)&gmp_rep,(mpz_srcptr)n.get_mpz_const()); mpq_set_den((mpq_ptr)&gmp_rep,(mpz_ptr)Integer(d).get_mpz()); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } template Rationel::Rationel( T n, Integer & d, enum reduceFlag red) { assert(nonZero(d)); //! @todo nonZero() ? mpq_init((mpq_ptr)&gmp_rep); mpq_set_z((mpq_ptr)&gmp_rep,(mpz_ptr)Integer(n).get_mpz()); mpq_set_den((mpq_ptr)&gmp_rep,(mpz_srcptr)d.get_mpz_const()); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } template Rationel::Rationel( T n, U d, enum reduceFlag red) { assert(nonZero(d)); //! @todo nonZero() ? mpq_init((mpq_ptr)&gmp_rep); mpq_set_z((mpq_ptr)&gmp_rep,(mpz_ptr)Integer(n).get_mpz()); mpq_set_den((mpq_ptr)&gmp_rep,(mpz_ptr)Integer(d).get_mpz()); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } template Rationel::Rationel( T & n, U & d, enum reduceFlag red) { assert(nonZero(d)); //! @todo nonZero() ? mpq_init((mpq_ptr)&gmp_rep); mpq_set_z((mpq_ptr)&gmp_rep,(mpz_ptr)Integer(n).get_mpz()); mpq_set_den((mpq_ptr)&gmp_rep,(mpz_ptr)Integer(d).get_mpz()); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } } #endif // __GIVARO_gmpxx_gmpxx_rat_INL // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/gmp++/gmp++_rat_add.C000066400000000000000000000120731274707324300204730ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_add.C,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: M. Samama, T. Gautier // $Id: gmp++_int_add.C,v 1.5 2010-12-20 12:09:37 briceboyer Exp $ // ========================================================================== #ifndef __GIVARO_gmpxx_gmpxx_rat_add_C #define __GIVARO_gmpxx_gmpxx_rat_add_C #ifndef __GIVARO_INLINE_ALL #include "gmp++/gmp++.h" #endif namespace Givaro { //-------------------------------------------------- operator + Rationel& Rationel::addin(Rationel& res, const Rationel& n) { if (isZero(n)) return res; if (isZero(res)) return res = n; mpq_add( (mpq_ptr)&res.gmp_rep, (mpq_srcptr)&res.gmp_rep, (mpq_srcptr)&n.gmp_rep ); return res; } Rationel& Rationel::addin(Rationel& res, const Integer& n) { if (Givaro::isZero(n)) return res; Rationel nn ; setInteger(nn,n); if (isZero(res)) return res = nn; mpq_add( (mpq_ptr)&res.gmp_rep, (mpq_srcptr)&res.gmp_rep, (mpq_srcptr)&nn.gmp_rep ); return res; } #if 0 Rationel& Rationel::addin(Rationel& res, const int64_t n) { if (isZero(n)) return res; if (isZero(res)) return res = n; int32_t sgn = sign(n); if (sgn >0) mpz_add_ui( (mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, n); else mpz_sub_ui((mpz_ptr)&res.gmp_rep, (mpz_ptr)&res.gmp_rep, -n); return res; } Rationel& Rationel::addin(Rationel& res, const uint64_t n) { if (isZero(n)) return res; if (isZero(res)) return res = n; mpz_add_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&res.gmp_rep, n); return res; } Rationel& Rationel::add(Rationel& res, const Integer& n1, const Integer& n2) { if (isZero(n1)) return res = n2; if (isZero(n2)) return res = n1; mpz_add( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, (mpz_srcptr)&n2.gmp_rep); return res; } Rationel& Rationel::add(Rationel& res, const Integer& n1, const int64_t n2) { if (isZero(n1)) return res = n2; if (isZero(n2)) return res = n1; int32_t sgn = sign(n2); if (sgn >0) mpz_add_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, n2); else mpz_sub_ui((mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, -n2); return res; } Rationel& Rationel::add(Rationel& res, const Integer& n1, const uint64_t n2) { if (isZero(n1)) return res = n2; if (isZero(n2)) return res = n1; mpz_add_ui( (mpz_ptr)&res.gmp_rep, (mpz_srcptr)&n1.gmp_rep, n2); return res; } // -- operator + Integer& Integer::operator += (const Integer& n) { if (isZero(n)) return *this; if (isZero(*this)) return logcpy(n); mpz_add( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, (mpz_srcptr)&n.gmp_rep) ; return *this; } Integer& Integer::operator += (const uint64_t l) { if (l==0) return *this; if (isZero(*this)) return logcpy(Integer(l)); mpz_add_ui( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, l); return *this; } Integer& Integer::operator += (const int64_t l) { if (l==0) return *this; if (isZero(*this)) return logcpy(Integer(l)); int32_t sgn = sign(l); if (sgn >0) mpz_add_ui( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, l); else mpz_sub_ui( (mpz_ptr)&(gmp_rep), (mpz_ptr)&gmp_rep, -l); return *this; } Integer Integer::operator + (const Integer& n) const { if (isZero(n)) return *this; if (isZero(*this)) return n; Integer res; mpz_add( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, (mpz_srcptr)&n.gmp_rep) ; return res; } Integer Integer::operator + (const uint64_t l) const { if (l==0) return *this; if (isZero(*this)) return Integer(l); Integer res; mpz_add_ui( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, l); return res; } Integer Integer::operator + (const int64_t l) const { if (l==0) return *this; if (isZero(*this)) return Integer(l); Integer res; int32_t sgn = sign(l); if (sgn >0) mpz_add_ui( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, l); else mpz_sub_ui( (mpz_ptr)&(res.gmp_rep), (mpz_srcptr)&gmp_rep, -l); return res; } Integer Integer::operator - () const { // JGD 18.06.1999 Integer Res ; mpz_neg((mpz_ptr)&Res.gmp_rep, (mpz_srcptr)&gmp_rep ); return Res ; } Integer operator + (const int32_t l, const Integer& n) { return n + (int64_t)l; } Integer operator + (const uint32_t l, const Integer& n) { return n + (uint64_t)l; } Integer operator + (const int64_t l, const Integer& n) { return n + l; } Integer operator + (const uint64_t l, const Integer& n) { return n + l; } Integer operator + (const Integer& n, const int32_t l) { return n + (int64_t)l; } Integer operator + (const Integer& n, const uint32_t l) { return n + (uint64_t)l; } Integer& operator += (Integer& n, const int32_t l) { return n += (int64_t)l; } Integer& operator += (Integer& n, const uint32_t l) { return n += (uint64_t)l; } #endif } #endif // __GIVARO_gmpxx_gmpxx_int_add_C // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/gmp++/gmp++_rat_compare.C000066400000000000000000000053051274707324300213710ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_compare.C,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: M. Samama, T. Gautier // $Id: gmp++_int_compare.C,v 1.6 2009-09-17 14:28:22 jgdumas Exp $ // ========================================================================== /*! @file gmp++/gmp++_rat_compare.C * @brief routines to compare integers. */ #ifndef __GIVARO_gmpxx_gmpxx_rat_compare_C #define __GIVARO_gmpxx_gmpxx_rat_compare_C #ifndef __GIVARO_INLINE_ALL #include "gmp++/gmp++.h" #endif #if 0 namespace Givaro { /*! Compares two integers. * @param a integer * @param b integer * @return \c 1 if \f$a > b\f$, \c 0 if \f$a = b\f$ and \p -1 otherwise. */ int32_t compare(const Integer &a, const Integer& b) { return mpz_cmp ( (mpz_srcptr)&a.gmp_rep, (mpz_srcptr)&b.gmp_rep ); } /*! Compare the norm of two integers. * @param a integer * @param b integer * @return \c 1 if \f$|a| > |b|\f$, \c 0 if \f$|a| = |b|\f$ and \p -1 otherwise. */ int32_t absCompare(const Integer &a, const Integer &b) { return mpz_cmpabs( (mpz_srcptr)&(a.gmp_rep), (mpz_srcptr)&(b.gmp_rep)); } int32_t Integer::operator != (const int32_t l) const { return mpz_cmp_si ( (mpz_srcptr)&gmp_rep, l ) != 0; } int32_t Integer::operator != (const int64_t l) const { return mpz_cmp_si ( (mpz_srcptr)&gmp_rep, l ) != 0; } //uint64_t ops added by Dan Roche, 6-26-04 int32_t Integer::operator != (const uint64_t l) const { return mpz_cmp_ui ( (mpz_srcptr)&gmp_rep, l ) != 0; } int32_t Integer::operator > (const uint64_t l) const { return mpz_cmp_ui((mpz_srcptr)&gmp_rep, l) > 0; } int32_t Integer::operator < (const uint64_t l) const { return mpz_cmp_ui((mpz_srcptr)&gmp_rep, l) < 0; } int32_t Integer::operator > (const int32_t l) const { return mpz_cmp_si((mpz_srcptr)&gmp_rep, l) > 0; } int32_t Integer::operator > (const int64_t l) const { return mpz_cmp_si((mpz_srcptr)&gmp_rep, l) > 0; } int32_t Integer::operator < (const int32_t l) const { return mpz_cmp_si((mpz_srcptr)&gmp_rep, l) < 0; } int32_t Integer::operator < (const int64_t l) const { return mpz_cmp_si((mpz_srcptr)&gmp_rep, l) < 0; } } #endif namespace Givaro { Rationel abs(const Rationel& f) { Rationel absf ; mpq_abs((mpq_ptr)absf.get_mpq(),(mpq_srcptr)f.get_mpq_const()); return absf ; } } #endif // __GIVARO_gmpxx_gmpxx_rat_compare_C // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s givaro-4.0.2/src/kernel/gmp++/gmp++_rat_cstor.C000066400000000000000000000217231274707324300210770ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_cstor.C,v $ // Copyright(c)'1994-2011 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: B. Boyer // $Id: gmp++_rat_cstor.C,v 1.4 2011-09-16 14:28:22 briceboyer Exp $ // ========================================================================== #ifndef __GMPplusplus_rat_cstor_C__ #define __GMPplusplus_rat_cstor_C__ #include #ifndef __GIVARO_INLINE_ALL #include "gmp++/gmp++.h" #endif namespace Givaro { // CONSTRUCTORS FROM INTEGERS Rationel::Rationel() { mpq_init((mpq_ptr)&gmp_rep); } Rationel::Rationel( Integer & n) { mpq_init((mpq_ptr)&gmp_rep); mpq_set_z((mpq_ptr)&gmp_rep,(mpz_srcptr)n.get_mpz_const()); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } Rationel::Rationel( int32_t n) { mpq_init((mpq_ptr)&gmp_rep); mpq_set_si((mpq_ptr)&gmp_rep,(int64_t) n, 1) ; num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } Rationel::Rationel( uint32_t n) { mpq_init((mpq_ptr)&gmp_rep); mpq_set_ui((mpq_ptr)&gmp_rep,(uint64_t) n, 1U) ; num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } Rationel::Rationel( int64_t n) { mpq_init((mpq_ptr)&gmp_rep); mpq_set_si((mpq_ptr)&gmp_rep, n, 1) ; num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } Rationel::Rationel( uint64_t n) { mpq_init((mpq_ptr)&gmp_rep); mpq_set_ui((mpq_ptr)&gmp_rep, n, 1U) ; num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } // CONSTRUCTORS FROM RationelS Rationel::Rationel( float f, enum reduceFlag red) { mpq_init((mpq_ptr)&gmp_rep); mpq_set_d((mpq_ptr)&gmp_rep,(double)f); std::cout<< "max precision OR best approximation ?" << std::endl; num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } Rationel::Rationel( double f, enum reduceFlag red) { mpq_init((mpq_ptr)&gmp_rep); mpq_set_d((mpq_ptr)&gmp_rep,f); // XXX std::cout<< "max precision OR best approximation ?" << std::endl; if (red) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } Rationel::Rationel(long double f, enum reduceFlag red) { mpq_init((mpq_ptr)&gmp_rep); // XXX throw "Rationel constructor from long double is not implemented yet"; if (red) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } //!@todo Initialise Rationels from mpq_f and mpfr types. Rationel::Rationel( Rationel & n, enum reduceFlag red) { mpq_init((mpq_ptr)&gmp_rep); mpq_set( (mpq_ptr)&gmp_rep, (mpq_srcptr)n.get_mpq() ); if (red == Reduce) reduce(); } // CONSTRUCTORS FROM NUM AND DEN Rationel::Rationel( Integer & n, Integer & d, enum reduceFlag red) { assert(nonZero(d)); //! @todo nonZero() ? mpq_init((mpq_ptr)&gmp_rep); mpq_set_z((mpq_ptr)&gmp_rep,(mpz_srcptr)n.get_mpz_const()); mpq_set_den((mpq_ptr)&gmp_rep,(mpz_srcptr)d.get_mpz_const()); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } /* * * d\n | I U L UL * ----------------------- * I | si si si ui * U | si ui si ui * L | si si ?? ?? * UL | si ui ?? ui */ // castable to long int/long int // INT Rationel::Rationel( int32_t n, int32_t d, enum reduceFlag red) { assert(nonZero(d)); mpq_init((mpq_ptr)&gmp_rep); if (d < 0) mpq_set_si((mpq_ptr)&gmp_rep,(int64_t)-n, (uint64_t)-d); else mpq_set_si((mpq_ptr)&gmp_rep,(int64_t)n, (uint64_t)d); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } Rationel::Rationel( uint32_t n, int32_t d, enum reduceFlag red) { assert(nonZero(d)); mpq_init((mpq_ptr)&gmp_rep); if (d < 0) mpq_set_si((mpq_ptr)&gmp_rep,(int64_t)-n, (uint64_t)-d); else mpq_set_si((mpq_ptr)&gmp_rep,(int64_t)n, (uint64_t)d); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } Rationel::Rationel( int64_t n, int32_t d, enum reduceFlag red) { assert(nonZero(d)); mpq_init((mpq_ptr)&gmp_rep); if (d < 0) mpq_set_si((mpq_ptr)&gmp_rep,-n, (uint64_t)-d); else mpq_set_si((mpq_ptr)&gmp_rep,n, (uint64_t)d); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } Rationel::Rationel( uint64_t n, int32_t d, enum reduceFlag red) { assert(nonZero(d)); mpq_init((mpq_ptr)&gmp_rep); if (d < 0) { mpq_set_ui((mpq_ptr)&gmp_rep,n, (uint64_t)-d); negin(*this); } else mpq_set_ui((mpq_ptr)&gmp_rep,n, (uint64_t)d); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } Rationel::Rationel( int32_t n, uint32_t d, enum reduceFlag red) { assert(nonZero(d)); mpq_init((mpq_ptr)&gmp_rep); mpq_set_si((mpq_ptr)&gmp_rep,(int64_t)n, (uint64_t)d); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } Rationel::Rationel( int32_t n, int64_t d, enum reduceFlag red) { assert(nonZero(d)); mpq_init((mpq_ptr)&gmp_rep); if (d < 0 ) mpq_set_si((mpq_ptr)&gmp_rep,(int64_t)-n, (uint64_t)-d); else mpq_set_si((mpq_ptr)&gmp_rep,(int64_t)n, (uint64_t)d); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } Rationel::Rationel( int32_t n, uint64_t d, enum reduceFlag red) { assert(nonZero(d)); mpq_init((mpq_ptr)&gmp_rep); mpq_set_si((mpq_ptr)&gmp_rep,(int64_t)n, (uint64_t)d); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } // U Rationel::Rationel( uint32_t n, uint32_t d, enum reduceFlag red) { assert(nonZero(d)); mpq_init((mpq_ptr)&gmp_rep); mpq_set_ui((mpq_ptr)&gmp_rep,(uint64_t)n, (uint64_t)d); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } Rationel::Rationel( uint32_t n, uint64_t d, enum reduceFlag red) { assert(nonZero(d)); mpq_init((mpq_ptr)&gmp_rep); mpq_set_ui((mpq_ptr)&gmp_rep,(uint64_t)n, d); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } Rationel::Rationel( uint32_t n, int64_t d, enum reduceFlag red) { assert(nonZero(d)); mpq_init((mpq_ptr)&gmp_rep); if (d < 0) { mpq_set_si((mpq_ptr)&gmp_rep,(uint64_t)-n, (uint64_t)-d); } if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } Rationel::Rationel( int64_t n, uint32_t d, enum reduceFlag red) { assert(nonZero(d)); mpq_init((mpq_ptr)&gmp_rep); mpq_set_si((mpq_ptr)&gmp_rep, n, (uint64_t)d); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } Rationel::Rationel( uint64_t n, uint32_t d, enum reduceFlag red) { assert(nonZero(d)); mpq_init((mpq_ptr)&gmp_rep); mpq_set_ui((mpq_ptr)&gmp_rep, n, (uint64_t)d); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } // L Rationel::Rationel( int64_t n, int64_t d, enum reduceFlag red) { assert(nonZero(d)); mpq_init((mpq_ptr)&gmp_rep); if (d < 0) mpq_set_si((mpq_ptr)&gmp_rep, -n, (uint64_t)-d); else mpq_set_si((mpq_ptr)&gmp_rep, n, (uint64_t)d); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } Rationel::Rationel( int64_t n, uint64_t d, enum reduceFlag red) { assert(nonZero(d)); mpq_init((mpq_ptr)&gmp_rep); mpq_set_si((mpq_ptr)&gmp_rep, n, d); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } Rationel::Rationel( uint64_t n, int64_t d, enum reduceFlag red) { assert(nonZero(d)); mpq_init((mpq_ptr)&gmp_rep); if (d < 0) { mpq_set_ui((mpq_ptr)&gmp_rep, (uint64_t)n, (uint64_t)-d); negin(*this); } else mpq_set_ui((mpq_ptr)&gmp_rep, (uint64_t)n, (uint64_t)d); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } // UL Rationel::Rationel( uint64_t n, uint64_t d, enum reduceFlag red) { assert(nonZero(d)); mpq_init((mpq_ptr)&gmp_rep); mpq_set_ui((mpq_ptr)&gmp_rep,n, d); if (red == Reduce) reduce(); num = mpq_numref((mpq_ptr)&gmp_rep) ; den = mpq_denref((mpq_ptr)&gmp_rep) ; } } #endif // __GMPplusplus_rat_cstor_C__ // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/gmp++/gmp++_rat_io.C000066400000000000000000000047101274707324300203510ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_io.C,v $ // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: B. Boyer // $Id: gmp++_int_io.C,v 1.7 2011-09-17 14:28:22 briceboyer Exp $ // ========================================================================== // Description: #ifndef __GIVARO_gmpxx_gmpxx_rat_io_C #define __GIVARO_gmpxx_gmpxx_rat_io_C #include #include #include #ifndef __GIVARO_INLINE_ALL #include "gmp++/gmp++.h" #endif namespace Givaro { // Sortie nonsignee : 321321 meme si n = -321321, par exemple std::ostream& absOutput(std::ostream &o, const Rationel &n) { mpq_out_str(reinterpret_cast(&o),10,(mpq_srcptr)abs(n).get_mpq()); return o; } // Sortie signee : +321321 ou -321321, par exemple std::ostream& Rationel::print(std::ostream &o) const { // mpq_out_str(reinterpret_cast(&o),10,(mpq_srcptr)&gmp_rep); // return o; return o << (mpq_srcptr)&gmp_rep; } Rationel::operator std::string () const { std::ostringstream s; print(s); return s.str(); } #if 0 Rationel::Rationel(const std::vector& v) { size_t s = v.size(); if (s) { mpz_init_set_ui((mpz_ptr)&gmp_rep, v[0]); Integer base(256), prod, tmp; prod = base = pow(base, (uint64_t)sizeof(mp_limb_t) ); std::vector::const_iterator vi = v.begin(); for(++vi;vi != v.end();++vi) { mpz_mul_ui( (mpz_ptr)&tmp.gmp_rep, (mpz_ptr)&prod.gmp_rep, *vi); *this += tmp; prod *= base; } } else mpz_init( (mpz_ptr)&gmp_rep ); } Rationel::operator std::vector () const { size_t s = mpz_size( (mpz_srcptr)&(gmp_rep) ); std::vector v(s); std::vector::iterator vi = v.begin(); for(mp_size_t i = 0;vi != v.end();++vi, ++i) *vi = mpz_getlimbn( (mpz_srcptr)& (gmp_rep) ,i); return v; } #endif // Entree au format de la sortie std::istream& operator>> (std::istream& inp, Rationel& a) { return inp >> (mpq_ptr)a.get_mpq(); } std::ostream& operator<< (std::ostream& outp, const Rationel& a) { return a.print(outp) ; } } #endif // __GIVARO_gmpxx_gmpxx_rat_io_C // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/gmp++/gmp++_rat_misc.C000066400000000000000000000030711274707324300206740ustar00rootroot00000000000000// ========================================================================== // $Source: /var/lib/cvs/Givaro/src/kernel/gmp++/gmp++_int_cstor.C,v $ // Copyright(c)'1994-2011 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: B. Boyer // $Id: gmp++_rat_cstor.C,v 1.4 2011-09-16 14:28:22 briceboyer Exp $ // ========================================================================== #ifndef __GMPplusplus_rat_misc_C__ #define __GMPplusplus_rat_misc_C__ #include #ifndef __GIVARO_INLINE_ALL #include "gmp++/gmp++.h" #endif namespace Givaro { Integer Rationel::getDenom() const { Integer d ; mpq_get_den(d.get_mpz(), (mpq_srcptr)&gmp_rep); return d; } Integer Rationel::getNumer() const { Integer n ; mpq_get_num(n.get_mpz(), (mpq_srcptr)&gmp_rep); return n; } mpq_ptr Rationel::get_mpq() { return (mpq_ptr)&gmp_rep; } mpq_srcptr Rationel::get_mpq_const() const { return (mpq_srcptr)&gmp_rep; } mpz_ptr Rationel::get_mpq_den() const { return (mpz_ptr)den; } mpz_ptr Rationel::get_mpq_num() const { return (mpz_ptr)num; } Rationel& Rationel::reduce() { mpq_canonicalize( (mpq_ptr)&gmp_rep ); return *this ; } Rationel& Rationel::reduce(Rationel & r) //const { mpq_canonicalize( (mpq_ptr)(r.get_mpq()) ); return r ; } } #endif // __GMPplusplus_rat_misc_C__ // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen givaro-4.0.2/src/kernel/integer/000077500000000000000000000000001274707324300165215ustar00rootroot00000000000000givaro-4.0.2/src/kernel/integer/Makefile.am000066400000000000000000000017551274707324300205650ustar00rootroot00000000000000# Copyright(c)'1994-2009 by The Givaro group # This file is part of Givaro. # Givaro is governed by the CeCILL-B license under French law # and abiding by the rules of distribution of free software. # see the COPYRIGHT file for more details. AM_CPPFLAGS=-I$(top_srcdir) ${GMP_VERSION} AM_CXXFLAGS = @DEFAULT_CFLAGS@ AM_CPPFLAGS+= -I$(top_srcdir)/src/kernel/memory -I$(top_srcdir)/src/kernel/system -I$(top_srcdir)/src/kernel -I$(top_srcdir)/src/kernel/ring pkginclude_HEADERS= \ givinteger.h \ random-integer.h \ givintfactor.h \ givintprime.h \ givintnumtheo.h \ givintrsa.h \ givintrns.h \ givintprime.inl \ givintnumtheo.inl \ givintrsa.inl \ givintfactor.inl \ givintsqrootmod.h \ givintsqrootmod.inl \ givintrns_convert.inl \ givintrns_cstor.inl \ givspyinteger.h noinst_LTLIBRARIES=libgivinteger.la EXTRA_DIST=integer.doxy libgivinteger_la_SOURCES=givintprime.C #EXTRA_DIST= integer.doxy givaro-4.0.2/src/kernel/integer/givinteger.h000066400000000000000000000225721274707324300210450ustar00rootroot00000000000000// ============================================================= // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Authors: T. Gautier, J.-G. Dumas // ============================================================= /*! @file givinteger.h * @ingroup integers * @brief Integer Domain class definition. */ #ifndef __GIVARO_integer_H #define __GIVARO_integer_H #include "givaro-config.h" #include "gmp++/gmp++.h" #include "givaro/givbasictype.h" #include "givaro/givinit.h" #include "givaro/giverror.h" #include "givaro/givranditer.h" #include "givaro/random-integer.h" #include "givaro/ring-interface.h" #include namespace Givaro { //------------------------------------ Class IntegerDom //! Integer Domain. class IntegerDom : public RingInterface { public: using Self_t = IntegerDom; typedef Integer Rep; typedef Rep Element; IntegerDom() : one(1), mOne(-1), zero(0U) {} IntegerDom(const IntegerDom&) : one(1), mOne(-1), zero(0U) {} int operator==( const IntegerDom&) const { return 1; } int operator!=( const IntegerDom&) const { return 0; } // -- Constants: const Integer one; const Integer mOne; const Integer zero; Integer characteristic() const { return zero; } Integer& characteristic(Integer& p) const { return p = zero; } // -- assignement Rep& init ( Rep& a ) const { return a; } Rep& init ( Rep& a, const Rep& b) const { return a = b ; } Rep& read( Rep& a, const int64_t i) const { return a = Integer(i) ; } Rep& read( Rep& a, const uint64_t i) const { return a = Integer(i) ; } Rep& read( Rep& a, const int32_t i) const { return a = Integer(i) ; } Rep& read( Rep& a, const uint32_t i) const { return a = Integer(i) ; } Rep& convert( Rep& a, const Rep& b) const { return a = b ; } Rep& assign( Rep& a, const Rep& b) const { return a = b ; } // -- access const Rep& access(const Rep& a) const { return a; } template XXX& convert(XXX& x, const Rep& a) const { return Caster(x,a); } // -- arithmetic operators Rep& mul( Rep& r, const Rep& a, const Rep& b ) const { return Integer::mul(r,a,b); } Rep& div( Rep& r, const Rep& a, const Rep& b ) const { return Integer::div(r,a,b); } Rep& mod( Rep& r, const Rep& a, const Rep& b ) const { return Integer::mod(r,a,b); } Rep& add( Rep& r, const Rep& a, const Rep& b ) const { return Integer::add(r,a,b); } Rep& sub( Rep& r, const Rep& a, const Rep& b ) const { return Integer::sub(r,a,b); } Rep& divmod( Rep& q, Rep& r, const Rep& a, const Rep& b ) const { return Integer::divmod(q,r,a,b); } Rep& divexact( Rep& q, const Rep& a, const Rep& b ) const { return Integer::divexact(q,a,b); } Rep& mulin( Rep& r, const Rep& a) const { return r *= a; } Rep& divin( Rep& r, const Rep& a) const { return r /= a; } Rep& modin( Rep& r, const Rep& a) const { return r %= a; } Rep& addin( Rep& r, const Rep& a) const { return r += a; } Rep& subin( Rep& r, const Rep& a) const { return r -= a; } Rep& axpy( Rep& r, const Rep& a, const Rep& b, const Rep& c ) const { return Integer::axpy(r,a,b,c); } Rep& maxpy( Rep& r, const Rep& a, const Rep& b, const Rep& c ) const { return Integer::maxpy(r,a,b,c); } Rep& maxpyin( Rep& r, const Rep& a, const Rep& b) const { return Integer::maxpyin(r,a,b); } Rep& axmy( Rep& r, const Rep& a, const Rep& b, const Rep& c ) const { return Integer::axmy(r,a,b,c); } Rep& axpyin( Rep& r, const Rep& a, const Rep& b ) const { return Integer::axpyin(r,a,b); } Rep& axmyin( Rep& r, const Rep& a, const Rep& b ) const { return Integer::axmyin(r,a,b); } // -- unary methods Rep& neg( Rep& r, const Rep& a ) const { return Integer::neg(r,a); } Rep& negin( Rep& r ) const { return Integer::negin(r); } // -- extended gcd q = gcd(a,b) = u*a+v*b; Rep& gcd( Rep& g, Rep& u, Rep& v, const Rep& a, const Rep& b ) const { return ::Givaro::gcd(g, u, v, a, b); } Rep& gcd( Rep& g, const Rep& a, const Rep& b ) const { return ::Givaro::gcd(g, a, b); } Rep& gcdin( Rep& g, const Rep& a) const { Rep tmp(g); return ::Givaro::gcd(g, tmp, a); } Rep& lcm( Rep& l, const Rep& a, const Rep& b ) const { return ::Givaro::lcm(l, a, b); } Rep& lcmin( Rep& l, const Rep& a) const { Rep tmp(l); return lcm(l, tmp, a); } Rep& inv(Rep& u, const Rep& a, const Rep& b) const { return ::Givaro::inv(u,a,b); } Rep& invin(Rep& u, const Rep& b) const { return ::Givaro::invin(u,b); } // - return n^l Rep& pow(Rep& r, const Rep& n, const int64_t l) const { return r = ::Givaro::pow(n, l); } Rep& pow(Rep& r, const Rep& n, const uint64_t l) const { return r = ::Givaro::pow(n, l); } Rep& pow(Rep& r, const Rep& n, const int32_t l) const { return r = ::Givaro::pow(n, (int64_t)l); } Rep& pow(Rep& r, const Rep& n, const uint32_t l) const { return r = ::Givaro::pow(n, (uint64_t)l); } // - return square root of n Rep& sqrt(Rep& s, const Rep& n) const { return ::Givaro::sqrt(s,n); } Rep& sqrt(Rep& s, Rep& r, const Rep& n) const { return ::Givaro::sqrtrem(s,n, r); } // - base p logarithm of a int64_t logp(const Rep& a, const Rep& p) const { return ::Givaro::logp(a,p); } // - return n^e % m Rep& powmod(Rep& r, const Rep& n, const int64_t e, const Rep& m) const { return r = ::Givaro::powmod(n, e, m); } Rep& powmod(Rep& r, const Rep& n, const Rep& e, const Rep& m) const { return r = ::Givaro::powmod(n, e, m); } // - Misc uint64_t length (const Rep& a) const { return ::Givaro::length(a); } int sign (const Rep& a) const { return ::Givaro::sign(a); } bool isZero (const Rep& a) const { return ::Givaro::isZero(a); } bool isOne (const Rep& a) const { return ::Givaro::isOne(a); } bool isMOne (const Rep& a) const { return ::Givaro::isMOne(a); } /// isUnit inline bool isUnit (const Rep& x) const { return ::Givaro::isOne(x) || ::Givaro::isMOne(x); } /** @brief isDivisor (a, b) * Test if b | a. */ inline bool isDivisor (const Element& a, const Element& b) const { Element r; return ::Givaro::isZero(mod(r,a,b)); } Element& abs(Element& x, const Element& a) const { return x=::Givaro::abs(a); } int32_t compare(const Rep& a, const Rep& b) const { return ::Givaro::compare(a,b); } bool areEqual (const Rep& a, const Rep& b) const { return ::Givaro::compare(a,b) ==0; } bool areNEqual(const Rep& a, const Rep& b) const { return ::Givaro::compare(a,b) !=0; } bool areAssociates(const Element &x, const Element &y) const { return ::Givaro::abs(x) == ::Givaro::abs(y); } bool isgeq(const Rep& a, const Rep& b) const { return ::Givaro::compare(a,b) >= 0; } bool isleq(const Rep& a, const Rep& b) const { return ::Givaro::compare(a,b) <= 0; } bool isgeq(const int64_t b,const Rep& a ) const { return this->isgeq(Rep(b),a); } bool isleq(const int64_t b,const Rep& a ) const { return this->isleq(Rep(b),a); } bool isgeq(const Rep& a, const int64_t b) const { return this->isgeq(a,Rep(b)); } bool isleq(const Rep& a, const int64_t b) const { return this->isleq(a,Rep(b)); } bool isgt(const Rep& a, const Rep& b) const { return ::Givaro::compare(a,b) > 0; } bool islt(const Rep& a, const Rep& b) const { return ::Givaro::compare(a,b) < 0; } bool isgt(const int64_t b,const Rep& a ) const { return this->isgt(Rep(b),a); } bool islt(const int64_t b,const Rep& a ) const { return this->islt(Rep(b),a); } bool isgt(const Rep& a, const int64_t b) const { return this->isgt(a,Rep(b)); } bool islt(const Rep& a, const int64_t b) const { return this->islt(a,Rep(b)); } #ifdef __GMP_PLUSPLUS__ void seeding(unsigned long s = 0) const { Integer::seeding(s) ; } #endif typedef RandomIntegerIterator RandIter; typedef GeneralRingNonZeroRandIter NonZeroRandIter; template< class MyRandIter > Rep& random(MyRandIter&, Rep& r, long s = 1) const { return Integer::random(r,s); } template< class MyRandIter > Rep& random(MyRandIter&, Rep& r, const Rep& b) const { return Integer::random(r,b); } template< class MyRandIter > Rep& nonzerorandom(MyRandIter&, Rep& r, long s = 1) const { return Integer::nonzerorandom(r,s); } template< class MyRandIter > Rep& nonzerorandom (MyRandIter&,Rep& r, const Rep& b) const { return Integer::nonzerorandom(r,b); } // -- IO std::istream& read ( std::istream& i ) { char ch; i >> std::ws >> ch; // JGD 22.03.03 // if (ch != 'I') // GivError::throw_error(GivBadFormat("IntegerDom::read: bad signature domain")); return i; } std::ostream& write( std::ostream& o ) const { return o << 'I'; } std::istream& read ( std::istream& i, Rep& n) const { return i >> n; } std::ostream& write( std::ostream& o, const Rep& n) const { return o << n; } }; } // Givaro #endif //__GIVARO_integer_H // vim:sts=4:sw=4:ts=4:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s givaro-4.0.2/src/kernel/integer/givintfactor.h000066400000000000000000000130161274707324300213720ustar00rootroot00000000000000// =================================================================== // // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Needs Container structures : stl ones for instance // Time-stamp: <16 Jun 15 16:05:40 Jean-Guillaume.Dumas@imag.fr> // =================================================================== // /*! @file givintfactor.h * @ingroup integers * @brief factorisation *- Prime numbers * - Factor sets : * - Pollard's rho method for factorization * - Elliptic curves factorization by Lenstra * . */ #ifndef __GIVARO_factorisation_H #define __GIVARO_factorisation_H #include #include "givaro/givinteger.h" #include "givaro/givintprime.h" #include "givaro/givrandom.h" // #define BOUNDARY_factor TABMAX2 #define factor_first_primes(tmp,n) (tmp = isZero(mod(tmp,n,23))?23:( isZero(mod(tmp,n,19))?19:( isZero(mod(tmp,n,17))?17: (isZero(mod(tmp,n,2))?2:( isZero(mod(tmp,n,3))?3:( isZero(mod(tmp,n,5))?5:( isZero(mod(tmp,n,7))?7: ( isZero(mod(tmp,n,11))?11:13 )))))))) #define factor_second_primes(tmp,n) (tmp = isZero(mod(tmp,n,31))?31:( isZero(mod(tmp,n,29))?29: ( isZero(mod(tmp,n,37))?37: ( isZero(mod(tmp,n,41))?41:( isZero(mod(tmp,n,43))?43: ( isZero(mod(tmp,n,71))?71:( isZero(mod(tmp,n,67))?67:( isZero(mod(tmp,n,61))?61:( isZero(mod(tmp,n,59))?59: ( isZero(mod(tmp,n,53))?53:( isZero(mod(tmp,n,47))?47: ( isZero(mod(tmp,n,97))?97: ( isZero(mod(tmp,n,89))?89:( isZero(mod(tmp,n,83))?83:( isZero(mod(tmp,n,79))?79:73))))))))))))))) namespace Givaro { // =================================================================== // // Set or Container of divisors, factors. // =================================================================== // //! Integer Factor Domain. template class IntFactorDom : public IntPrimeDom { private: // 2*3*5*7*11*13*17*19*23 const int PROD_first_primes; // 29*31*37*41*43*47*53*59*61*67*71*73*79*83*89*97 const Rep PROD_second_primes; protected: MyRandIter _g; public: typedef MyRandIter random_generator; IntFactorDom(MyRandIter g = MyRandIter()) : IntPrimeDom(), PROD_first_primes(223092870), PROD_second_primes("10334565887047481278774629361"), _g(g) { } // loops defaulted to 0 forces Pollard's factorization to // be complete Rep& factor(Rep& r, const Rep& n, unsigned long loops = 0) const { if (isOne(gcd(r,n,PROD_first_primes))) if (isOne(gcd(r,n,PROD_second_primes))) { #ifdef GIVARO_LENSTRA return Lenstra((const MyRandIter&)_g, r, n); #else return Pollard((const MyRandIter&)_g, r, n, loops); #endif } else return factor_second_primes(r,n); else return factor_first_primes(r,n); } // Factors are checked for primality Rep& iffactorprime (Rep& r, const Rep& n, unsigned long loops = 0) const { if (factor(r, n, loops) != 1) { if (! isprime(r,_GIVARO_ISPRIMETESTS_) ) { Rep nn = r; factor(r,nn, loops); } while (! isprime(r,_GIVARO_ISPRIMETESTS_) ) { Rep nn = r; if (isOne(gcd(r,nn,PROD_first_primes))) { if (isOne(gcd(r,nn,PROD_second_primes))) { Pollard((const MyRandIter&)_g, r, nn, loops); } else { factor_second_primes(r,nn); } } else { factor_first_primes(r,nn); } if (r == nn) { Lenstra((const MyRandIter&)_g, r, nn) ; break; // In case Lenstra fails also } } } return r; } Rep& primefactor(Rep& r, const Rep& n) const { while ((iffactorprime(r,n,0) == 1) && (! isprime(n, _GIVARO_ISPRIMETESTS_)) ) {} return r; } /// Factors with primes // loops defaulted to 0 forces factorization to be complete // otherwise returns if factorization is complete or not // Factors are checked for primality template bool set ( Container1& setint, Container2& setpwd, const Rep& a, unsigned long loops = 0) const ; /// template void set( Container&, const Rep&) const ; /// template void Erathostene(Container&, const Rep&) const ; /// template Container& divisors(Container& L, const Cont2& Lf, const Cont3& Le) const; template Container& divisors(Container&, const Rep& ) const ; /// returns a small factor Rep& Erathostene(Rep&, const Rep& p ) const ; // Pollard with a bound on the number of loops // Bound 0 is without bound Rep& Pollard(const MyRandIter&, Rep&, const Rep& n, unsigned long threshold = 0) const ; // returns a factor by Lenstra's elliptic curves method Rep& Lenstra(const MyRandIter&, Rep&, const Rep& n, const Rep& B1 = 10000000, const unsigned long curves = 30) const ; std::ostream& write(std::ostream& o, const Rep& n) const; template std::ostream& write(std::ostream& o, Array&, const Rep& n) const; private: // Those are parameters for Pollard's algorithms // Pollard_fctin : must be somewhat a "random" function in Z/nZ // Pollard_cst can be a slight alternative for the Pfct x^2+1 #ifndef Pollard_cst #define Pollard_cst 1 #endif Rep& Pollard_fctin(Rep & x, const Rep& n) const { mulin(x,x); addin(x,Pollard_cst); return modin(x,n); } }; } // Givaro #include "givaro/givintfactor.inl" #endif // __GIVARO_factorisation_H /* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s givaro-4.0.2/src/kernel/integer/givintfactor.inl000066400000000000000000000340031274707324300217240ustar00rootroot00000000000000// =================================================================== // // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // Time-stamp: <18 Jun 15 18:30:38 Jean-Guillaume.Dumas@imag.fr> // =================================================================== // #ifndef __GIVARO_factorisation_INL #define __GIVARO_factorisation_INL #include "givaro/givinteger.h" #include "givaro/givintprime.h" #include "givaro/givintfactor.h" #include #include namespace Givaro { template std::ostream& IntFactorDom::write(std::ostream& o, const Rep& n) const { std::vector Lf; return write(o, Lf, n); } template template std::ostream& IntFactorDom::write(std::ostream& o, Array& Lf, const Rep& n) const { // // n = * Lf[i] ^ Lo[i] // // But Lf[i] might not be prime (cf. factor probability) Rep nn,g,r,u; nn = n; long c; bool flag = 0; Integer tmp; if (GIVARO_ISLT(nn,zero)) { nn = -n; o << "-"; } if (GIVARO_ISLEQ(nn,1)) { Lf.push_back(nn); return IntegerDom::write(o,nn); } while( GIVARO_ISGT(nn,1) ) { primefactor(g,nn); if (flag) o << " * "; else flag = 1; Lf.push_back(g); IntegerDom::write(o,g); c=0;r=0; Rep::divexact(u, nn,g); for(;isZero(r); ++c) { nn.copy(u); Rep::divmod( u, r, nn,g ); } if (c>1) o << "^" << c; } return o; } // =================================================================== // // Set or Container of divisors, factors. // =================================================================== // // #ifndef __ECC // template // template< template class Container> bool // IntFactorDom::set(Container& Lf, Container& Lo, const Rep& n, unsigned long loops) const // #else template template bool IntFactorDom::set(Container1& Lf, Container2& Lo, const Rep& n, unsigned long loops) const //#endif { // n = * Lf[i] ^ Lo[i] bool factocomplete = true; Rep nn,g,r,u; if (n<0) Rep::neg(nn,n); else nn=n; unsigned long c; while(nn > 1) { iffactorprime(g,nn,loops); if (g == 1) { factocomplete = false; g = nn; } Lf.push_back(g); c=0;r=zero; Rep::divexact(u, nn,g); while(r == 0) { // nn = nn / g; // r = nn % g; nn.copy(u); Rep::divmod( u, r, nn,g ); c++; } Lo.push_back( c ); } return factocomplete; } // #ifndef __ECC // template // template< template class Container> // void IntFactorDom::Erathostene(Container& Lf, const Rep& p) const // #else template template void IntFactorDom::Erathostene(Container& Lf, const Rep& p) const //#endif { // Deterministic algorithm // Valid for p < BOUNDARY_factor // Lf is the Container of factors uint64_t n = (uint64_t)p; if (Integer(n) != p) std::cerr << "*** Erathostene with " << p << " too large, using " << n << " instead ***" << std::endl; if (! (n & 0x1)) { Lf.push_back(Rep(2)); do n >>= 1; while (!(n & 0x1)); } short * Ip = new short[(size_t)n+1]; int i; for(int ii=(int)n+1;ii--;) Ip[ii] = 0; i=3; int j, ii; Rep sq; while (i<=sqrt(sq,Rep(n))) { ii= i << 1; j = i+ii; while (j<=n) { Ip[j] = 1; j+=ii; } if ((j-ii) == n) { Lf.push_back(Rep(i)); do n /= i; while (!(n%i)); } j = i+1; while (Ip[++j]) { j++;} i = j; } if (!(Ip[n]) && (n>1)) Lf.push_back(Rep(n)); delete [] Ip; } // #ifndef __ECC // template // template< template class Container> // void IntFactorDom::set( Container& Lf, const Rep& n) const // #else template template void IntFactorDom::set( Container& Lf, const Rep& n) const //#endif { // big_factor is executed until // a (sometimes probably) prime factor is found. // Lf is a Container of divisors // Lf is a Container of factors with probability -- TO EXPLICIT // something like : 1 - (big_factor to be composite)*(big_isprime) Rep nn,g,r,u; nn = n; while(nn > 1) { primefactor(g,nn); r=0; Rep::divexact(u, nn,g); while(r == 0) { nn.copy(u); Rep::divmod( u, r, nn,g ); } // gcc 3.3.3 (Debian 20040422) : internal compiler error !!! Lf.push_back(g); //Lf.resize(Lf.size()+1); //Lf.back() = g; } } // #ifndef __ECC // template // template< template class Container, template class Cont2> Container< typename IntFactorDom::Rep >& IntFactorDom::divisors( Container& L, const Cont2& Lf, const Cont2& Le) const // { // typename Cont2::const_iterator li = Lf.begin(); // typename Cont2::const_iterator lj = Le.begin(); // Container Res(1,Rep(1)); // Container Res2; // typename Container::iterator lr; // #else template template Container& IntFactorDom::divisors( Container& L, const Cont2& Lf, const Cont3& Le) const { typename Cont2::const_iterator li = Lf.begin(); typename Cont3::const_iterator lj = Le.begin(); Container Res(1,Rep(1)); Container Res2; typename Container::iterator lr; //#endif Rep Itmp; for(;li!=Lf.end();++li,++lj) { for(lr = Res.begin();lr!=Res.end();++lr) { Itmp = *lr; for(unsigned long i=*lj;i--;) { Itmp = Itmp * *li; Res2.push_back( Itmp ); } } Res.splice(Res.end(),Res2); } return L = Res; } // #ifndef __ECC // template // template< template class Container> Container::Rep>& IntFactorDom::divisors( Container& L, const Rep& n) const // { // Container Lf; // Container Le; // #else template template Container& IntFactorDom::divisors( Container& L, const Rep& n) const { Container Lf; std::vector Le; //#endif IntFactorDom::set(Lf,Le,n); return divisors(L, Lf, Le); } template typename IntFactorDom::Rep& IntFactorDom::Pollard(const MyRandIter& gen, Rep& g, const Rep& n, const unsigned long threshold) const { // average number of iterations < 13/8*sqrt( Pi*n/2) // Sometimes the factor isn't prime -- TO EXPLICIT if (GIVARO_ISLT(n,3)) return g=n; if ( isprime(n, _GIVARO_ISPRIMETESTS_) ) return g=n; g=1; Rep m(zero), x, y, p(one), t; this->random(gen, y, n); if (threshold) { unsigned long c = 0; while( this->isOne(g) && (++c < threshold)) { if( areEqual(p, addin(m,one)) ) { x=y; mulin(p,2); } Pollard_fctin(y,n); this->gcd(g,sub(t,y,x),n); } if ((g == n)&&(cisOne(g)) { if( areEqual(p, addin(m,one)) ) { x=y; mulin(p,2); } Pollard_fctin(y,n); this->gcd(g,sub(t,y,x),n); } if (g == n) // Failure with the initial value Pollard(gen, g, n, 0); } return g; } // =================================================================== // // Elliptic curves routines // =================================================================== // inline void Add_Curve( const Integer& n, const Integer A, const Integer& ax, const Integer& az, Integer& cx, Integer& cz) { Integer t1,t2; // t1 = ((ax+az)*(ax+az))%n; // t2 = ((ax-az)*(ax-az))%n; t1 = ax+az; t1 *= t1; t1 %= n; t2 = ax-az; t2 *= t2; t2 %= n; cx = t1*t2; cx %= n; t1 -= t2; cz = A; cz *= t1; cz += t2; cz %= n; // cz = ((A*t1+t2) % n); cz *= t1; cz %= n; } inline void one_Mul_Curve( const Integer& n, const Integer A, const Integer& mm, const Integer& nn, const Integer& px, const Integer& pz, Integer& ax, Integer& az) { Integer bx, bz, cx, cz, tmpx, tmpz, d, e, t2; cx = px; cz = pz; e = mm; d = nn; d -= mm; if (e typename IntFactorDom::Rep& IntFactorDom::Lenstra(const MyRandIter& gen, Rep& g, const Rep& n, const Rep& B1, const unsigned long curves) const { if (n<3) return g=n; if ( isprime(n,5) ) return g=n; if (isZero(n % 2)) return g=2; if (isZero(n % 3)) return g=3; Rep * A = new Rep[curves] , * X = new Rep[curves] , * Z = new Rep[curves]; Rep r,a,asq,kg,kgg; for (unsigned long c=0; cgcd(g,u,v,two,n); Rep inv2 = u; assign(four,4); this->gcd(g,u,v,four,n); Rep inv4 = u, sixt; assign(sixt,16); this->gcd(g,u,v,sixt,n); Rep inv16 = u,inva; // Initialize # curves for (unsigned long i=0;irandom(gen,r,n); // kg = r*r + 6; mul(kg,r,r); addin(kg,6); // kgg = this->gcd(kg,n); this->gcd(kgg,kg,n); if (this->isOne(kgg)) { // g = this->gcd(kg,n,u,v); if (! this->isOne(g)) { delete [] A, X, Z; return g; } this->gcd(g,u,v,kg,n); if (! this->isOne(g)) { delete [] A; delete [] X; delete [] Z; return g; } a = (6*r*u)% n; asq = (a * a) % n ; } else return g=kgg; } // g = this->gcd(a,n,u,v); if (! this->isOne(g)) { delete [] A; delete [] X; delete [] Z; return g; } this->gcd(g,u,v,a,n); if (! this->isOne(g)) { delete [] A; delete [] X; delete [] Z; return g; } // A[i] = ( (8-3*a + (1-6*a*a)*u*u*u )*inv16 ) % n; A[i] = ( inv2 + ( (1-3*asq*asq-6*asq) %n )* (u*u*u*inv16 % n) ) % n ; X[i] = (3*a*inv4)%n; } // .5*sqrt(5)-.5, 37 digits // Rep s("618033988749894848204586834370"); // Rep si("1000000000000000000000000000000"); // Rep s("6180339887498948482045868343656381177"); // Rep si("10000000000000000000000000000000000000"); Rep s(618033988U); Rep si(1000000000U); // Begins search with curves on primes up to B1 Rep prime = 2, sp, f; while (prime <= B1) { //std::cerr << "p: " << prime << std::endl; sp = (prime*s)/si; Mul_Curve(n,A[0],sp,prime,B1,X[0],Z[0]); f = Z[0]; for(unsigned long i=1;igcd(f,n); Rep ftm; this->gcd(ftm,f,n); f = ftm; if (this->isOne(f)) { nextprime(ftm,prime); prime = ftm; // prime = nextprime(prime); } else { delete [] A; delete [] X; delete [] Z; return g=f; } } std::cerr << "*** Elliptic curves with " << curves << " curves, threshold " << B1 << " failed ***" << std::endl; delete [] A; delete [] X; delete [] Z; return neg(g,one); } } // namespace Givaro { #endif // __GIVARO_factorisation_INL /* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ // vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s givaro-4.0.2/src/kernel/integer/givintnumtheo.h000066400000000000000000000104371274707324300215770ustar00rootroot00000000000000// =================================================================== // // Copyright(c)'1994-2009 by The Givaro group // This file is part of Givaro. // Givaro is governed by the CeCILL-B license under French law // and abiding by the rules of distribution of free software. // see the COPYRIGHT file for more details. // // Time-stamp: <16 Jun 15 16:05:31 Jean-Guillaume.Dumas@imag.fr> // =================================================================== // /*! @file givintnumtheo.h * @ingroup integers * @brief num theory. * - Euler's phi function * - Primitive roots * - RSA scheme. * . */ #ifndef __GIVARO_numtheory_H #define __GIVARO_numtheory_H #include #include "givaro/givinteger.h" #include "givaro/givintprime.h" #include "givaro/givintfactor.h" #include "givaro/givrandom.h" #include "givaro/udl.h" namespace Givaro { //! Num theory Domain. template class IntNumTheoDom : public IntFactorDom { public: typedef IntFactorDom Father_t; typedef typename IntFactorDom::Rep Rep; IntNumTheoDom(MyRandIter g = MyRandIter()) : IntFactorDom(g) {} // =================================================================== // //! Euler's phi function // =================================================================== // template