diff -Nru pyecm-2.0.2/CHANGELOG.txt pyecm-2.0.3/CHANGELOG.txt --- pyecm-2.0.2/CHANGELOG.txt 2013-09-05 00:21:51.000000000 +0000 +++ pyecm-2.0.3/CHANGELOG.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -2.0.2 - - Now supports gmpy2, as well as gmpy. - -2.0.1 - - Fixed minor bug with factoring negative numbers on the command-line. - -2.0 - - Made asymptotic improvements at the expense of a constant factor. It -should now be faster for numbers greater than 30 or so digits but slower -for numbers less than that. - - Added ability to type expressions instead of plain numbers. For example, -the program will now factor "2^30-1" instead of making you type "1073741823". - - Added capability to run pyecm in parallel. - - Added command line switches, such as a verbose mode and an ability to -select sigma (an internal parameter) randomly. - - Improved compatibility with installations lacking gmpy and/or psyco. - -1.2.2: - - Made pyecm a tiny bit faster - - Fixed the bug where the version is reported incorrectly as 1.2 - - Included the GPL with the source - -1.2.1: - - Fixed a silly typo in fastprime. This should make it a little bit faster. - - Removed silly spaces after lines - -1.2: - - pyecm now uses gmpy if it's installed on your system (highly recommended: -HUGE speed increase when used). If it's not installed, it continues as normal. - -1.1.2: - - Silly bug with not using psyco fixed - -1.1.1: - - Minor bug fixes - - Minor speed improvement - -1.1: - - More speed improvements - -1.0: - - Massive speed improvements - -0.2: - - Many bugfixes - - Speed improvements - -0.1: - - Initial release diff -Nru pyecm-2.0.2/COPYING.txt pyecm-2.0.3/COPYING.txt --- pyecm-2.0.2/COPYING.txt 2013-09-05 00:21:51.000000000 +0000 +++ pyecm-2.0.3/COPYING.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff -Nru pyecm-2.0.2/debian/changelog pyecm-2.0.3/debian/changelog --- pyecm-2.0.2/debian/changelog 2018-08-01 02:47:32.000000000 +0000 +++ pyecm-2.0.3/debian/changelog 2019-09-01 19:34:10.000000000 +0000 @@ -1,3 +1,19 @@ +pyecm (2.0.3-1) unstable; urgency=medium + + [ Ondřej Nový ] + * Use debhelper-compat instead of debian/compat. + + [ Martin Kelly ] + * New upstream release. + * update to standards-version 4.4.0 + * watch: remove unneeded "" string + * override debian-watch-does-not-check-gpg-signature + * override upstream-metadata-file-is-missing + * add autopkgtest + * depend on only python3 + + -- Martin Kelly Sun, 01 Sep 2019 12:34:10 -0700 + pyecm (2.0.2-4) unstable; urgency=medium * remove ancient X-Python-Version diff -Nru pyecm-2.0.2/debian/compat pyecm-2.0.3/debian/compat --- pyecm-2.0.2/debian/compat 2018-08-01 02:47:32.000000000 +0000 +++ pyecm-2.0.3/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -11 diff -Nru pyecm-2.0.2/debian/control pyecm-2.0.3/debian/control --- pyecm-2.0.2/debian/control 2018-08-01 02:47:32.000000000 +0000 +++ pyecm-2.0.3/debian/control 2019-09-01 19:34:10.000000000 +0000 @@ -2,16 +2,16 @@ Section: math Priority: optional Maintainer: Martin Kelly -Build-Depends: debhelper (>= 11), dh-python -Build-Depends-Indep: python (>= 2.6.5) -Standards-Version: 4.1.5 +Build-Depends: debhelper-compat (= 11), dh-python +Build-Depends-Indep: python3 +Standards-Version: 4.4.0 Homepage: https://github.com/martingkelly/pyecm Vcs-Git: https://salsa.debian.org/python-team/modules/pyecm.git Vcs-Browser: https://salsa.debian.org/python-team/modules/pyecm Package: pyecm Architecture: all -Depends: ${python:Depends}, ${misc:Depends}, python-gmpy2 +Depends: ${python3:Depends}, ${misc:Depends}, python3-gmpy2 Description: integer factorization with the Elliptic Curve Method (ECM) pyecm is a Python program to factor numbers using the Elliptic Curve Method (ECM). It is relatively fast in that it can quickly factors numbers up to 50 diff -Nru pyecm-2.0.2/debian/rules pyecm-2.0.3/debian/rules --- pyecm-2.0.2/debian/rules 2018-08-01 02:47:32.000000000 +0000 +++ pyecm-2.0.3/debian/rules 2019-09-01 19:34:10.000000000 +0000 @@ -15,7 +15,7 @@ dh_testdir dh_testroot dh_installdirs - install pyecm.py $(CURDIR)/debian/pyecm/usr/bin/pyecm + install -v pyecm.py $(CURDIR)/debian/pyecm/usr/bin/pyecm binary-indep: install dh_testdir @@ -25,7 +25,7 @@ dh_installman dh_compress dh_fixperms - dh_python2 + dh_python3 dh_installdeb dh_gencontrol dh_md5sums diff -Nru pyecm-2.0.2/debian/source/lintian-overrides pyecm-2.0.3/debian/source/lintian-overrides --- pyecm-2.0.2/debian/source/lintian-overrides 1970-01-01 00:00:00.000000000 +0000 +++ pyecm-2.0.3/debian/source/lintian-overrides 2019-09-01 19:34:10.000000000 +0000 @@ -0,0 +1,2 @@ +pyecm: debian-watch-does-not-check-gpg-signature +source: upstream-metadata-file-is-missing diff -Nru pyecm-2.0.2/debian/tests/control pyecm-2.0.3/debian/tests/control --- pyecm-2.0.2/debian/tests/control 1970-01-01 00:00:00.000000000 +0000 +++ pyecm-2.0.3/debian/tests/control 2019-09-01 19:34:10.000000000 +0000 @@ -0,0 +1 @@ +Test-Command: ./test /usr/bin/pyecm diff -Nru pyecm-2.0.2/debian/watch pyecm-2.0.3/debian/watch --- pyecm-2.0.2/debian/watch 2018-08-01 02:47:32.000000000 +0000 +++ pyecm-2.0.3/debian/watch 2019-09-01 19:34:10.000000000 +0000 @@ -1,4 +1,3 @@ -# Compulsory line, this is a version 3 file -version=3 - -https://github.com/martingkelly/pyecm/archive/(.*)\.tar\.gz +version=4 +opts=filenamemangle=s/.+\/v?(\d\S+)\.tar\.gz/pyecm-$1\.tar\.gz/ \ + https://github.com/martingkelly/pyecm/tags .*/v?(\d\S+)\.tar\.gz diff -Nru pyecm-2.0.2/.gitignore pyecm-2.0.3/.gitignore --- pyecm-2.0.2/.gitignore 1970-01-01 00:00:00.000000000 +0000 +++ pyecm-2.0.3/.gitignore 2019-09-01 18:38:05.000000000 +0000 @@ -0,0 +1,2 @@ +__pycache__/** +*.pyc diff -Nru pyecm-2.0.2/LICENSE pyecm-2.0.3/LICENSE --- pyecm-2.0.2/LICENSE 1970-01-01 00:00:00.000000000 +0000 +++ pyecm-2.0.3/LICENSE 2019-09-01 18:38:05.000000000 +0000 @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff -Nru pyecm-2.0.2/pyecm.py pyecm-2.0.3/pyecm.py --- pyecm-2.0.2/pyecm.py 2013-09-05 00:21:51.000000000 +0000 +++ pyecm-2.0.3/pyecm.py 2019-09-01 18:38:05.000000000 +0000 @@ -1,10 +1,10 @@ -#!/usr/bin/env python +#!/usr/bin/python3 ''' You should install psyco and gmpy if you want maximal speed. Filename: pyecm -Authors: Eric Larson , Martin Kelly , +Authors: Eric Larson , Martin Kelly , Matt Ford License: GNU GPL (see for more information. Description: Factors a number using the Elliptic Curve Method, a fast algorithm for numbers < 50 digits. @@ -45,7 +45,8 @@ def gcd(a, b): '''Computes the Greatest Common Divisor of a and b using the standard quadratic time improvement to the Euclidean Algorithm. - Returns the GCD of a and b.''' +Returns the GCD of a and b.''' + if b == 0: return a elif a == 0: @@ -177,7 +178,7 @@ continue p = 1 - for i in xrange(int(math.log(n) / LOG_2), 0, -1): + for i in range(int(math.log(n) / LOG_2), 0, -1): p <<= (n >> i) & 1 p = (p * p) % n @@ -234,9 +235,9 @@ ONE = mpz(1) SMALL = 2.0**(-30) SMALLEST_COUNTEREXAMPLE_FASTPRIME = 2047 -T = (type(mpz(1)), type(1), type(1L)) +T = (type(mpz(1)), type(1), type(1)) DUMMY = 'dummy' # Dummy value throughout the program -VERSION = '2.0.2' +VERSION = '2.0.3 (Python 3)' _12_LOG_2_OVER_49 = 12 * math.log(2) / 49 RECORD = 1162795072109807846655696105569042240239 @@ -261,7 +262,7 @@ while len(b_) < len(a_): b_.append(0) - for i in xrange(len(a_)): + for i in range(len(a_)): self.coefficients.append(a_[i] + b_[i]) self.acc = a.acc @@ -269,7 +270,7 @@ def ev(self, x): '''Returns a(x)''' answer = 0 - for i in xrange(len(self.coefficients) - 1, -1, -1): + for i in range(len(self.coefficients) - 1, -1, -1): answer *= x answer += self.coefficients[i] return answer @@ -277,7 +278,7 @@ def evh(self): '''Returns a(1/2)''' answer = 0 - for i in xrange(len(self.coefficients) - 1, -1, -1): + for i in range(len(self.coefficients) - 1, -1, -1): answer >>= 1 answer += self.coefficients[i] return answer @@ -285,7 +286,7 @@ def evmh(self): '''Returns a(-1/2)''' answer = 0 - for i in xrange(len(self.coefficients) - 1, -1, -1): + for i in range(len(self.coefficients) - 1, -1, -1): answer = - answer >> 1 answer += self.coefficients[i] return answer @@ -293,21 +294,21 @@ def int(self): '''Replaces a by an integral of a''' self.coefficients = [0] + self.coefficients - for i in xrange(1, len(self.coefficients)): - self.coefficients[i] /= i + for i in range(1, len(self.coefficients)): + self.coefficients[i] = self.coefficients[i] // i def lindiv(self, a): '''a.lindiv(k) -- sets a/(x-k/2) for integer k''' - for i in xrange(len(self.coefficients) - 1): + for i in range(len(self.coefficients) - 1): self.coefficients[i] <<= 1 - self.coefficients[i] /= a + self.coefficients[i] = self.coefficients[i] // a self.coefficients[i + 1] -= self.coefficients[i] self.coefficients[-1] <<= 1 - self.coefficients[-1] /= a + self.coefficients[-1] = self.coefficients[-1] // a def neg(self): '''Sets a to -a''' - for i in xrange(len(self.coefficients)): + for i in range(len(self.coefficients)): self.coefficients[i] = - self.coefficients[i] def set(self, a): @@ -317,14 +318,14 @@ def simp(self): '''Turns a into a type of Taylor series that can be fed into ev, but cannot be computed with further.''' - for i in xrange(len(self.coefficients)): + for i in range(len(self.coefficients)): shift = max(0, int(math.log(abs(self.coefficients[i]) + 1) / LOG_2) - 1000) self.coefficients[i] = float(self.coefficients[i] >> shift) shift = self.acc - shift - for _ in xrange(shift >> 9): + for _ in range(shift >> 9): self.coefficients[i] /= BIG self.coefficients[i] /= 2.0**(shift & 511) - if abs(self.coefficients[i] / self.coefficients[0]) <= SMALL: + if (abs(self.coefficients[i] / self.coefficients[0]) <= SMALL): self.coefficients = self.coefficients[:i] break @@ -334,9 +335,9 @@ '''Adds first argument to second (second argument is not preserved). The arguments are points on an elliptic curve. The first argument may be a tuple instead of a list. The addition is thus done pointwise. This function has bizzare input/output because there are fast algorithms for inverting a bunch of numbers at once. Returns a list of the addition results.''' - inv = range(len(p1)) + inv = list(range(len(p1))) - for i in xrange(len(p1)): + for i in range(len(p1)): inv[i] = p1[i][0] - p2[i][0] inv = parallel_invert(inv, n) @@ -344,7 +345,7 @@ if not isinstance(inv, list): return inv - for i in xrange(len(p1)): + for i in range(len(p1)): m = ((p1[i][1] - p2[i][1]) * inv[i]) % n p2[i][0] = (m * m - p1[i][0] - p2[i][0]) % n p2[i][1] = (m * (p1[i][0] - p2[i][0]) - p1[i][1]) % n @@ -356,10 +357,10 @@ p1[i] + p2[i] and p1[i] - p2[i] for each i. Returns two lists, the first being the sums and the second the differences.''' - sums = range(len(p1)) - difs = range(len(p1)) + sums = list(range(len(p1))) + difs = list(range(len(p1))) - for i in xrange(len(p1)): + for i in range(len(p1)): sums[i] = p2[i][0] - p1[i][0] sums = parallel_invert(sums, n) @@ -367,7 +368,7 @@ if not isinstance(sums, list): return (sums, None) - for i in xrange(len(p1)): + for i in range(len(p1)): ms = ((p2[i][1] - p1[i][1]) * sums[i]) % n md = ((p2[i][1] + p1[i][1]) * sums[i]) % n sums[i] = (ms * ms - p1[i][0] - p2[i][0]) % n @@ -412,7 +413,7 @@ return False if n == 2: return True - if not n & 1: + if not int(n) & 1: return False product = ONE @@ -424,7 +425,7 @@ prime_bound = 0 prime = 3 - for _ in xrange(bound): + for _ in range(bound): p = [] prime_bound += log_n while prime <= prime_bound: @@ -440,9 +441,8 @@ '''Doubles each point in the input list. Much like the add function, we take advantage of fast inversion. Returns the doubled list.''' - inv = range(len(p)) - - for i in xrange(len(p)): + inv = list(range(len(p))) + for i in range(len(p)): inv[i] = p[i][1] << 1 inv = parallel_invert(inv, n) @@ -450,13 +450,12 @@ if not isinstance(inv, list): return inv - for i in xrange(len(p)): + for i in range(len(p)): x = p[i][0] m = (x * x) % n m = ((m + m + m + p[i][2]) * inv[i]) % n p[i][0] = (m * m - x - x) % n p[i][1] = (m * (x - p[i][0]) - p[i][1]) % n - return p def fastprime(n): @@ -486,7 +485,7 @@ if p in (n - 1, n + 1): return True - for _ in xrange(j): + for _ in range(j): p = (p * p) % n if p == 1: @@ -508,18 +507,17 @@ phi_product *= prime - 1 product *= prime - n_max = (phi_max * product) / phi_product - - phi_values = range(n_max) + n_max = (phi_max * product) // phi_product + phi_values = list(range(n_max)) prime = 2 while prime <= n_max: - for i in xrange(0, n_max, prime): - phi_values[i] -= phi_values[i] / prime + for i in range(0, n_max, prime): + phi_values[i] -= phi_values[i] // prime prime = next_prime(prime) - for i in xrange(n_max - 1, 0, -1): + for i in range(n_max - 1, 0, -1): if phi_values[i] <= phi_max: return i @@ -534,7 +532,7 @@ -1's with 3's, and interprets the result base 4. Returns the result interpreted as if in base 4.''' - g = 0L + g = 0 while d: g <<= 2 g ^= ((d & 2) & (d << 1)) ^ (d & 1) @@ -547,7 +545,7 @@ Returns the list with all elements inverted modulo 3(n-1).''' l_ = l[:] - for i in xrange(len(l)-1): + for i in range(len(l)-1): l[i+1] = (l[i] * l[i+1]) % n try: @@ -557,7 +555,7 @@ if inv == 0: return gcd(l[-1], n) - for i in xrange(len(l)-1, 0, -1): + for i in range(len(l)-1, 0, -1): l[i] = (inv * l[i-1]) % n inv = (inv * l_[i]) % n l[0] = inv @@ -573,7 +571,7 @@ jump = 1 while jump < len(p): - for i in xrange(0, len(p) - jump, jump << 1): + for i in range(0, len(p) - jump, jump << 1): p[i] *= p[i + jump] p[i + jump] = None @@ -593,18 +591,18 @@ Returns a list of Taylor series.''' f = ts(10, 10, []) answer = [ts(10, 10, [1])] - for _ in xrange(n): + for _ in range(n): answer.append(ts(10, 10, [1])) deg = 5 acc = 50 + n * int(1 + math.log(1 + n) + math.log(math.log(3 + n))) r = 1 rho_series = ts(1, 10, [0]) while r != rho_series.coefficients[0]: - deg = (deg + (deg << 2)) / 3 + deg = (deg + (deg << 2)) // 3 r = rho_series.coefficients[0] - rho_series = ts(deg, acc, [(1L) << acc]) + rho_series = ts(deg, acc, [(1) << acc]) center = 0.5 - for i in xrange(1, n+1): + for i in range(1, n+1): f.set(rho_series) center += 1 f.lindiv(int(2*center)) @@ -629,7 +627,7 @@ while not (f % 3): yield 3 - f /= 3 + f = f // 3 if isprime(f): yield f @@ -645,7 +643,7 @@ if g not in (1, f): for factor in sub_sub_sure_factors(g, u, curve_parameter): yield factor - for factor in sub_sub_sure_factors(f/g, u, curve_parameter): + for factor in sub_sub_sure_factors(f//g, u, curve_parameter): yield factor return @@ -653,7 +651,7 @@ if g2 not in (1, f): for factor in sub_sub_sure_factors(g2, u, curve_parameter): yield factor - for factor in sub_sub_sure_factors(f / g2, u, curve_parameter): + for factor in sub_sub_sure_factors(f // g2, u, curve_parameter): yield factor return @@ -668,7 +666,7 @@ if p1 != f: for factor in sub_sub_sure_factors(p1, u, curve_parameter): yield factor - for factor in sub_sub_sure_factors(f/p1, u, curve_parameter): + for factor in sub_sub_sure_factors(f//p1, u, curve_parameter): yield factor return else: @@ -683,13 +681,13 @@ while prime < u2: prime = next_prime(prime) should_break = False - for _ in xrange(int(log_mo / math.log(prime))): + for _ in range(int(log_mo / math.log(prime))): p1 = multiply(p1, prime, f) if not isinstance(p1, list): if p1 != f: for factor in sub_sub_sure_factors(p1, u, curve_parameter): yield factor - for factor in sub_sub_sure_factors(f/p1, u, curve_parameter): + for factor in sub_sub_sure_factors(f//p1, u, curve_parameter): yield factor return @@ -701,11 +699,11 @@ if should_break: break - for i in xrange(2, int(math.log(f) / LOG_2) + 2): + for i in range(2, int(math.log(f) / LOG_2) + 2): r = root(f, i) if r[1]: for factor in sub_sub_sure_factors(r[0], u, curve_parameter): - for _ in xrange(i): + for _ in range(i): yield factor return @@ -764,9 +762,9 @@ '''Given two points on an elliptic curve, subtract them pointwise. Returns the resulting point.''' - inv = range(len(p1)) + inv = list(range(len(p1))) - for i in xrange(len(p1)): + for i in range(len(p1)): inv[i] = p2[i][0] - p1[i][0] inv = parallel_invert(inv, n) @@ -774,7 +772,7 @@ if not isinstance(inv, list): return inv - for i in xrange(len(p1)): + for i in range(len(p1)): m = ((p1[i][1] + p2[i][1]) * inv[i]) % n p2[i][0] = (m * m - p1[i][0] - p2[i][0]) % n p2[i][1] = (m * (p1[i][0] - p2[i][0]) + p1[i][1]) % n @@ -787,8 +785,8 @@ Returns nothing.''' if veb and f > RECORD: - print 'Congratulations! You may have found a record factor via pyecm!' - print 'Please email the Mainloop call to Eric Larson ' + print('Congratulations! You may have found a record factor via pyecm!') + print('Please email the Mainloop call to Eric Larson ') return @@ -802,35 +800,34 @@ return if veb: - print 'Found factor:', f - print 'Mainloop call was:', n, u, curve_params + print('Found factor:', f) + print('Mainloop call was:', n, u, curve_params) if isprime(f): congrats(f, veb) yield f - n /= f + n = n//f if isprime(n): yield n if veb: - print '(factor processed)' + print('(factor processed)') return - for factor in sub_sure_factors(f, u, curve_params): if isprime(factor): congrats(f, veb) yield factor else: if veb: - print 'entering new ecm loop to deal with stubborn factor:', factor + print('entering new ecm loop to deal with stubborn factor:', factor) for factor_of_factor in ecm(factor, True, ov, veb, tdb, pr): yield factor_of_factor - n /= factor + n = n//factor if isprime(n): yield n if veb: - print '(factor processed)' + print('(factor processed)') return def to_tuple(p): @@ -844,17 +841,17 @@ return tuple(answer) def mainloop(n, u, p1): - ''' Input: n -- an integer to (try) to factor. - u -- the phase 1 smoothness bound - p1 -- a list of sigma parameters to try + ''' Input: n -- an integer to (try) to factor. + u -- the phase 1 smoothness bound + p1 -- a list of sigma parameters to try - Output: A factor of n. (1 is returned on faliure). + Output: A factor of n. (1 is returned on faliure). Notes: - 1. Other parameters, such as the phase 2 smoothness bound are selected by the mainloop function. - 2. This function uses batch algorithms, so if p1 is not long enough, there will be a loss in efficiency. - 3. Of course, if p1 is too long, then the mainloop will have to use more memory. - [The memory is polynomial in the length of p1, log u, and log n].''' + 1. Other parameters, such as the phase 2 smoothness bound are selected by the mainloop function. + 2. This function uses batch algorithms, so if p1 is not long enough, there will be a loss in efficiency. + 3. Of course, if p1 is too long, then the mainloop will have to use more memory. + [The memory is polynomial in the length of p1, log u, and log n].''' k = inv_const(n) log_u = math.log(u) log_log_u = math.log(log_u) @@ -869,30 +866,29 @@ w = min(w, int((m - 2 * math.log(m) + LOG_3_MINUS_LOG_LOG_2) / LOG_2)) w = max(w, 1) max_order = n + sqrt(n << 2) + 1 # By Hasse's theorem. - det_bound = ((1 << w) - 1 + ((w & 1) << 1)) / 3 + det_bound = ((1 << w) - 1 + ((w & 1) << 1)) // 3 log_mo = math.log(max_order) - p = range(number_of_primes) + p = list(range(number_of_primes)) prime = mpz(2) - p1 = get_points(p1, n) if not isinstance(p1, list): return p1 - for _ in xrange(int(log_mo / LOG_2)): + for _ in range(int(log_mo / LOG_2)): p1 = double(p1, n) if not isinstance(p1, list): return p1 - for i in xrange(1, det_bound): + for i in range(1, det_bound): prime = (i << 1) + 1 if isprime(prime): - for _ in xrange(int(log_mo / math.log(prime))): + for _ in range(int(log_mo / math.log(prime))): p1 = multiply(p1, prime, n) if not isinstance(p1, list): return p1 while prime < sqrt(u) and isinstance(p1, list): - for i in xrange(number_of_primes): + for i in range(number_of_primes): prime = next_prime(prime) p[i] = prime ** max(1, int(log_u / math.log(prime))) p1 = fast_multiply(p1, prod(p), n, w) @@ -901,7 +897,7 @@ return p1 while prime < u and isinstance(p1, list): - for i in xrange(number_of_primes): + for i in range(number_of_primes): prime = next_prime(prime) p[i] = prime p1 = fast_multiply(p1, prod(p), n, w) @@ -911,9 +907,9 @@ del p - small_jump = int(greatest_n((1 << (w + 2)) / 3)) + small_jump = int(greatest_n((1 << (w + 2)) // 3)) small_jump = max(120, small_jump) - big_jump = 1 + (int(sqrt((5 << w) / 21)) << 1) + big_jump = 1 + (int(sqrt((5 << w) // 21)) << 1) total_jump = small_jump * big_jump big_multiple = max(total_jump << 1, ((int(next_prime(prime)) - (total_jump >> 1)) / total_jump) * total_jump) big_jump_2 = big_jump >> 1 @@ -933,12 +929,12 @@ return pgiant_step small_multiples = [None] - for i in xrange(1, small_jump >> 1): + for i in range(1, small_jump >> 1): if gcd(i, small_jump) == 1: tmp = multiply(p1, i, n) if not isinstance(tmp, list): return tmp - for i in xrange(len(tmp)): + for i in range(len(tmp)): tmp[i] = tmp[i][0] small_multiples.append(tuple(tmp)) else: @@ -946,7 +942,7 @@ small_multiples = tuple(small_multiples) big_multiples = [None] - for i in xrange(1, (big_jump + 1) >> 1): + for i in range(1, (big_jump + 1) >> 1): tmp = multiply(psmall_jump, i, n) if not isinstance(tmp, list): return tmp @@ -967,12 +963,12 @@ prime_up = next_prime(big_multiple - small_jump_2) while prime_up < big_multiple + small_jump_2: s = small_multiples[abs(int(prime_up) - big_multiple)] - for j in xrange(ncurves): + for j in range(ncurves): product *= pgiant_step[j][0] - s[j] product %= n prime_up = next_prime(prime_up) - for i in xrange(1, big_jump_2 + 1): + for i in range(1, big_jump_2 + 1): center_up += small_jump center_down -= small_jump @@ -982,7 +978,7 @@ while prime_up < center_up + small_jump_2: s = small_multiples[abs(int(prime_up) - center_up)] - for j in xrange(ncurves): + for j in range(ncurves): product *= pmed_step_up[j] - s[j] product %= n prime_up = next_prime(prime_up) @@ -990,7 +986,7 @@ prime_down = next_prime(center_down - small_jump_2) while prime_down < center_down + small_jump_2: s = small_multiples[abs(int(prime_down) - center_down)] - for j in xrange(ncurves): + for j in range(ncurves): product *= pmed_step_down[j] - s[j] product %= n prime_down = next_prime(prime_down) @@ -1007,13 +1003,13 @@ Returns the list p multiplied by d.''' mask = (1 << (w << 1)) - 1 - flop = mask / 3 + flop = mask // 3 g = naf(d) >> 4 precomp = {} m = copy(p) p = double(p, n) - for i in xrange((flop >> w) + (w & 1)): + for i in range((flop >> w) + (w & 1)): key = naf((i << 1) + 1) precomp[key] = to_tuple(m) precomp[((key & flop) << 1) ^ key] = precomp[key] @@ -1023,7 +1019,7 @@ if g & 1: t = g & mask sh = 1 + int(math.log(t) / LOG_4) - for _ in xrange(sh): + for _ in range(sh): p = double(p, n) if g & 2: @@ -1049,7 +1045,7 @@ invs = p1[:] ncurves = len(p1) - for j in xrange(ncurves): + for j in range(ncurves): sigma = mpz(p1[j]) u = (sigma**2 - 5) % n v = sigma << 2 @@ -1061,7 +1057,7 @@ if not isinstance(invs, list): return invs - for j in xrange(ncurves): + for j in range(ncurves): u, v, i = p1[j] inv = invs[j] @@ -1074,8 +1070,8 @@ while a % 3: a += n - x_0 = (x_0 + a * b / 3) % n - c = (y_0 * ((1 - a**2 / 3) % n)) % n + x_0 = (x_0 + a * b // 3) % n + c = (y_0 * ((1 - a**2 // 3) % n)) % n p1[j] = [x_0, y_0, c] @@ -1107,7 +1103,7 @@ if p == 1 or p == n - 1: continue - for _ in xrange(j): + for _ in range(j): p = (p * p) % n if p == 1: @@ -1166,9 +1162,9 @@ else: sigma = 6 - for factor in sure_factors(n, k, range(sigma, sigma + k), veb, ra, ov, tdb, pr): + for factor in sure_factors(n, k, list(range(sigma, sigma + k)), veb, ra, ov, tdb, pr): yield factor - n /= factor + n = n//factor if n == 1: return @@ -1184,13 +1180,13 @@ nc = 1 + int(_12_LOG_2_OVER_49 * ov * ov * k) eff_nc = nc / pr - for i in xrange(1 + (int(math.log(n)) >> 1)): + for i in range(1 + (int(math.log(n)) >> 1)): if i < math.log(tdb): prime_probs.append(0) else: prime_probs.append(1.0/i) - for i in xrange(len(prime_probs)): + for i in range(len(prime_probs)): p_success = rho_ev((i - 2.65) / math.log(k), t) p_fail = max(0, (1 - p_success * math.log(math.log(k)))) ** (k / pr) prime_probs[i] = p_fail * prime_probs[i] / (p_fail * prime_probs[i] + 1 - prime_probs[i]) @@ -1202,7 +1198,7 @@ u = (high + low) >> 1 sum = 0 log_u = math.log(u) - for i in xrange(len(prime_probs)): + for i in range(len(prime_probs)): log_p = i - 2.65 log_u = math.log(u) quot = log_p / log_u @@ -1217,11 +1213,11 @@ else: sigma += nc - for factor in sure_factors(n, u, range(sigma, sigma + nc), veb, ra, ov, tdb, pr): + for factor in sure_factors(n, u, list(range(sigma, sigma + nc)), veb, ra, ov, tdb, pr): yield factor - n /= factor + n = n // factor - for i in xrange(len(prime_probs)): + for i in range(len(prime_probs)): p_success = rho_ev((i - 2.65) / math.log(u), t) p_fail = max(0, (1 - p_success * math.log(math.log(u)))) ** eff_nc prime_probs[i] = p_fail * prime_probs[i] / (p_fail * prime_probs[i] + 1 - prime_probs[i]) @@ -1229,7 +1225,7 @@ if veb and n != 1: m = max(prime_probs) - for i in xrange(len(prime_probs)): + for i in range(len(prime_probs)): if prime_probs[i] == m: break @@ -1237,7 +1233,7 @@ new_looking_for += new_looking_for << 2 if new_looking_for != looking_for: looking_for = new_looking_for - print 'Searching for primes around', looking_for, 'digits' + print('Searching for primes around', looking_for, 'digits') return @@ -1260,7 +1256,7 @@ if type(n) not in T: - raise ValueError, 'Number given must be integer or long.' + raise ValueError('Number given must be integer or long.') if not 0 < pr <= 1: yield 'Error: pr must be between 0 and 1' @@ -1278,7 +1274,7 @@ while prime < trial_division_bound: prime = next_prime(prime) while not n % prime: - n /= prime + n = n//prime yield prime if isprime(n): @@ -1298,7 +1294,7 @@ Returns True or False.''' - for i in xrange(len(s)): + for i in range(len(s)): if s[i] != '-': break @@ -1335,43 +1331,43 @@ return True def help(): - print '''\ + print( '''\ Usage: pyecm [OPTION] [expression to factor] Factor numbers using the Elliptic Curve Method. - --portion=num Does only part of the work for factoring, corresponding to +--portion=num Does only part of the work for factoring, corresponding to what fraction of the total work the machine is doing. Useful for working in parallel. For example, if there are three machines: 1GHz, 1GHz, and 2GHz, print should be set to 0.25 for the 1GHz machines and 0.5 for the 2GHz machine. Implies -r and -v. -r is needed to avoid duplicating work and -v is needed to report results. - --ov=num Sets the value of the internal parameter ov, which +--ov=num Sets the value of the internal parameter ov, which determines the trade-off between memory and time usage. Do not touch if you do not know what you are doing. Please read all the documentation and understand the full implications of the parameter before using this switch. - -n, --noverbose Terse. On by default. Needed to cancel the -v from the +-n, --noverbose Terse. On by default. Needed to cancel the -v from the --portion or --random switches. If both -n and -v are specified, the one specified last takes precedence. - -r, --random Chooses random values for sigma, an internal parameter in +-r, --random Chooses random values for sigma, an internal parameter in the calculation. Implies -v; if you're doing something random, you want to know what's happening. - -v, --verbose Explains what is being done with intermediate calculations +-v, --verbose Explains what is being done with intermediate calculations and results. With no integers to factor given via command-line, read standard input. -Please report bugs to Eric Larson .''' +Please report bugs to Eric Larson .''') sys.exit() def command_line(veb, ra, ov, pr): l = len(sys.argv) - for i in xrange(1, l): + for i in range(1, l): if not is_switch(sys.argv[i]): break - for j in xrange(i, l): # Start with the first non-switch + for j in range(i, l): # Start with the first non-switch if j != i: # Pretty printing - print + print( '') response = sys.argv[j] if valid_input(response): response = response.replace('^', '**') @@ -1383,60 +1379,60 @@ else: help() - print 'Factoring %d:' % n + print('Factoring {0}:'.format(n)) if n < 0: - print -1 + print(-1) n = -n if n == 0: - print '0 does not have a well-defined factorization.' + print( '0 does not have a well-defined factorization.') continue elif n == 1: - print 1 + print( 1) continue if ov == DUMMY: ov = 2*math.log(math.log(n)) for factor in factors(n, veb, ra, ov, pr): - print factor + print(factor) def interactive(veb, ra, ov, pr): - print 'pyecm v. %s (interactive mode):' % VERSION - print 'Type "exit" at any time to quit.' - print - - response = raw_input() - while response != 'exit' and response != 'quit': - if valid_input(response): - response = response.replace('^', '**') + print('pyecm v. {0} (interactive mode):'.format(VERSION)) + print('Type "exit" at any time to quit.') + print() + + user_input = input() + while user_input != 'exit' and user_input != 'quit': + if valid_input(user_input): + user_input = user_input.replace('^', '**') try: - n = eval(response) + n = eval(user_input) int(n) except (SyntaxError, TypeError, ValueError): help() else: help() - print 'Factoring number %d:' % n + print('Factoring number %d:' % n) if n < 0: - print -1 + print( -1) n = -n if n == 0: - print '0 does not have a well-defined factorization.' - print - response = raw_input() + print('0 does not have a well-defined factorization.') + print() + user_input = input() continue elif n == 1: - print 1 - print - response = raw_input() + print(1) + print() + user_input = input() continue if ov == DUMMY: ov = 2*math.log(math.log(n)) for factor in factors(n, veb, ra, ov, pr): - print factor - print - response = raw_input() + print(factor) + print() + user_input = input() def main(): ra = veb = False @@ -1468,8 +1464,8 @@ veb = True else: if not valid_input(item): - print 'I am confused about the following: "%s". Here\'s the help page:' % item - print + print('I am confused about the following: "{0}". Here\'s the help page:'.format(item)) + print() help() if len(sys.argv) > 1 and not is_switch(sys.argv[-1]): diff -Nru pyecm-2.0.2/README.md pyecm-2.0.3/README.md --- pyecm-2.0.2/README.md 1970-01-01 00:00:00.000000000 +0000 +++ pyecm-2.0.3/README.md 2019-09-01 18:38:05.000000000 +0000 @@ -0,0 +1,30 @@ +# Pyecm +Pyecm factors large integers (up to 50 digits) using the Elliptic Curve Method +(ECM), a fast factoring algorithm. + +Pyecm was a high-school project for myself (Martin Kelly) and my friend, Eric +Larson. Eric did more of the math and I did most of the code. Although the code +is not very clean by my standards today, it works and is quite fast. It was also +a nice illustration of how Python can be used for performance-critical code, if +the bottlenecks are clearly identified and implemented in C. In our case, we do +this via the wonderful gmpy. + +# How to run pyecm + +## All platforms +- First, make sure python (>= 2.3) is installed and working. You can always get +the latest release from http://python.org +- For speed increases, you may optionally install gmpy and/or psyco. Both are +highly recommended, especially gmpy, as they result in massive speed increases. + +## Unix, Linux, Mac +- You can either use *python pyecm.py* to run it or change the filename to pyecm +and execute it as a script. + +## Windows +- Just run pyecm.py as you would any other python program. + +# Related projects +- Old home for pyecm on Sourceforge (https://sourceforge.net/projects/pyecm) +- gmpy (https://github.com/aleaxit/gmpy) +- psyco (http://psyco.sourceforge.net/) diff -Nru pyecm-2.0.2/README.txt pyecm-2.0.3/README.txt --- pyecm-2.0.2/README.txt 2013-09-05 00:21:51.000000000 +0000 +++ pyecm-2.0.3/README.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -HOW TO RUN PYECM: - -ALL PLATFORMS: -- First, make sure python (>= 2.3) is installed and working. You can always get -the latest release from http://python.org -- For speed increases, you may optionally install gmpy and/or psyco. Both are -highly recommended, especially gmpy, as they result in massive speed increases. -UNIX, LINUX, MAC: -- You can either use python pyecm.py to run it or change the filename to pyecm -and execute it as a script. - -WINDOWS: -- Just run pyecm.py as you would any other python program. - -PROJECT LINKS: -gmpy (http://code.google.com/p/gmpy/) -psyco (http://psyco.sourceforge.net/) diff -Nru pyecm-2.0.2/test pyecm-2.0.3/test --- pyecm-2.0.2/test 1970-01-01 00:00:00.000000000 +0000 +++ pyecm-2.0.3/test 2019-09-01 18:38:05.000000000 +0000 @@ -0,0 +1,21 @@ +#!/usr/bin/python3 + +import os +import sys + +if len(sys.argv) != 2: + print('Usage: ./test PYECM_PATH') + sys.exit(-1) +parent_dir = os.path.realpath(os.path.join(sys.argv[1], os.pardir)) +sys.path.insert(0, parent_dir) + +from pyecm import * + +for n in range(1, 1001): + prod = 1 + for factor in factors(n, False, False, 7.97308847044, 1.0): + prod *= factor + if prod != n: + print('Failed to factor %d.' % n, file=sys.stderr) + sys.exit(1) +print('All tests passed.')