Permalink
Browse files

Merge branch 'dzil'

  • Loading branch information...
2 parents b1d1d42 + a32aee2 commit 3c7d110a441b33e3e3297b9975ee3f4b13fca09b @leto committed Sep 30, 2012
Showing with 109 additions and 99 deletions.
  1. +0 −17 Build.PL
  2. +0 −10 MANIFEST
  3. +5 −5 README → README.md
  4. +33 −0 dist.ini
  5. +71 −67 lib/Math/Factoring.pm
View
@@ -1,17 +0,0 @@
-use strict;
-use warnings;
-use Module::Build;
-
-my $builder = Module::Build->new(
- module_name => 'Math::Factoring',
- license => 'perl',
- dist_author => 'Jonathan Leto <jonathan@leto.net>',
- dist_version_from => 'lib/Math/Factoring.pm',
- build_requires => {
- 'Test::More' => 0,
- },
- add_to_cleanup => [ 'Math::Factoring-*' ],
- create_makefile_pl => 'traditional',
-);
-
-$builder->create_build_script();
View
@@ -1,10 +0,0 @@
-Build.PL
-Changes
-lib/Math/Factoring.pm
-MANIFEST
-MANIFEST.SKIP
-README
-t/00-load.t
-t/01-basic.t
-t/boilerplate.t
-t/pod.t
View
@@ -1,8 +1,8 @@
-Math::Factoring
+# Math::Factoring
This module implements factoring algorithms for BigInts, provided by Math::GMPz.
-INSTALLATION
+# Installation
To install this module, run the following commands:
@@ -11,7 +11,7 @@ To install this module, run the following commands:
./Build test
./Build install
-SUPPORT AND DOCUMENTATION
+# Support and Documentation
After installing, you can find documentation for this module with the
perldoc command.
@@ -33,9 +33,9 @@ You can also look for information at:
http://search.cpan.org/dist/Math::Factoring
-COPYRIGHT AND LICENCE
+# Copyright and License
-Copyright (C) 2009 Jonathan Leto
+Copyright (C) 2009-2012 Jonathan "Duke" Leto
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
View
@@ -0,0 +1,33 @@
+name = Math-Factoring
+author = Jonathan "Duke" Leto <jonathan@leto.net>
+license = Perl_5
+copyright_holder = Leto Labs LLC
+copyright_year = 2012
+
+[PkgVersion]
+
+[MetaResources]
+homepage = http://github.com/leto/Math-Factoring
+repository.web = http://github.com/leto/Math-Factoring
+repository.url = http://github.com/leto/Math-Factoring.git
+repository.type = git
+;x_mailing_list =
+
+[PruneCruft]
+; we maintain a Build.PL in the repository to be able to work without dzil,
+; but for the distribution we let dzil generate a Build.PL with the proper
+; dependencies and such
+[PruneFiles]
+filenames = Build.PL
+
+[@Git]
+
+[Git::NextVersion]
+first_version = 0.01
+
+[@Basic]
+
+[AutoPrereqs]
+
+[PodWeaver]
+
View
@@ -21,17 +21,69 @@ my @small_primes = qw/
/;
my %small_primes = map { $_ => 1 } @small_primes;
-=head1 NAME
+# ABSTRACT: Math::Factoring - Advanced Factoring Algorithms
-Math::Factoring - Advanced Factoring Algorithms
+=head1 SYNOPSIS
+
+ use Math::Factoring;
+ my $n = 42;
+ my @factors = factor(42); # 2 3 7
-=head1 VERSION
+=head1 AUTHOR
-Version 0.01
+Jonathan "Duke" Leto, C<< <jonathan at leto.net> >>
-=cut
+=head1 BUGS
-our $VERSION = '0.01';
+Please report any bugs or feature requests to C<bug-math-factoring at rt.cpan.org>, or through
+the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Math::Factoring>. I will be notified, and then you'll
+automatically be notified of progress on your bug as I make changes.
+
+You can also submit patches or file a Github issue:
+https://github.com/leto/Math-Factoring
+
+
+=head1 SUPPORT
+
+You can find documentation for this module with the perldoc command.
+
+ perldoc Math::Factoring
+
+
+You can also look for information at:
+
+=over 4
+
+=item * RT: CPAN's request tracker
+
+L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Math::Factoring>
+
+=item * AnnoCPAN: Annotated CPAN documentation
+
+L<http://annocpan.org/dist/Math::Factoring>
+
+=item * CPAN Ratings
+
+L<http://cpanratings.perl.org/d/Math::Factoring>
+
+=item * Search CPAN
+
+L<http://search.cpan.org/dist/Math::Factoring>
+
+=back
+
+=head1 ACKNOWLEDGEMENTS
+
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2009-2012 Jonathan "Duke" Leto, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+
+=cut
sub _random()
{
@@ -82,6 +134,13 @@ sub _factor_pollard_rho($$$)
}
+=head2 factor($number)
+
+Returns the prime factors of $number as an array. Currently this falls back to trial division.
+The values in the array are plain Perl string variables, not Math::GMPz objects.
+
+=cut
+
sub factor($)
{
my ($n) = @_;
@@ -133,6 +192,12 @@ sub factor_trial($)
return sort { $a <=> $b } @factors;
}
+=head2 factor_pollard_rho($number)
+
+Return the factors of $number as an array using the Pollard-Rho algorithm.
+
+=cut
+
sub factor_pollard_rho($)
{
my $n = GMP->new($_[0]);
@@ -154,66 +219,5 @@ sub factor_pollard_rho($)
return sort { $a <=> $b } @factors;
}
-=head1 SYNOPSIS
-
- use Math::Factoring;
- my $n = 42;
- my @factors = factor(42); # 2 3 7
-
-=head1 AUTHOR
-
-Jonathan Leto, C<< <jonathan at leto.net> >>
-
-=head1 BUGS
-
-Please report any bugs or feature requests to C<bug-math-factoring at rt.cpan.org>, or through
-the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Math::Factoring>. I will be notified, and then you'll
-automatically be notified of progress on your bug as I make changes.
-
-
-
-
-=head1 SUPPORT
-
-You can find documentation for this module with the perldoc command.
-
- perldoc Math::Factoring
-
-
-You can also look for information at:
-
-=over 4
-
-=item * RT: CPAN's request tracker
-
-L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Math::Factoring>
-
-=item * AnnoCPAN: Annotated CPAN documentation
-
-L<http://annocpan.org/dist/Math::Factoring>
-
-=item * CPAN Ratings
-
-L<http://cpanratings.perl.org/d/Math::Factoring>
-
-=item * Search CPAN
-
-L<http://search.cpan.org/dist/Math::Factoring>
-
-=back
-
-
-=head1 ACKNOWLEDGEMENTS
-
-
-=head1 COPYRIGHT & LICENSE
-
-Copyright 2009 Jonathan Leto, all rights reserved.
-
-This program is free software; you can redistribute it and/or modify it
-under the same terms as Perl itself.
-
-
-=cut
1; # End of Math::Factoring

0 comments on commit 3c7d110

Please sign in to comment.