view release on metacpan or search on metacpan
GooglePolylineEncoding.pm view on Meta::CPAN
# nothing to do here, we don't calculate with binary strings...
# 4. Left-shift the binary value one bit:
# 11111101 11011010 10111100 00011110
$number <<= 1;
$number &= 0xffffffff; # to assure 32 bit
# 5. If the original decimal value is negative, invert this encoding:
# 00000010 00100101 01000011 11100001
if ($is_negative) {
$number = (~$number);
$number &= 0xffffffff;
}
GooglePolylineEncoding.pm view on Meta::CPAN
# Temporary variable to hold each ASCII byte.
my $b;
do {
# The `ord(substr($encoded, $index++))` statement returns
# the ASCII code for the character at $index. Subtract 63
# to get the original value. (63 was added to ensure
# proper ASCII characters are displayed in the encoded
# polyline string, which is `human` readable)
$b = ord(substr($encoded, $index++, 1)) - 63;
# AND the bits of the byte with 0x1f to get the original
# 5-bit `chunk. Then left shift the bits by the required
# amount, which increases by 5 bits each time. OR the
# value into $results, which sums up the individual 5-bit
# chunks into the original value. Since the 5-bit chunks
# were reversed in order during encoding, reading them in
# this way ensures proper summation.
$result |= ($b & 0x1f) << $shift;
$shift += 5;
}
GooglePolylineEncoding.pm view on Meta::CPAN
}
# The actual latitude and longitude values were multiplied by
# 1e5 before encoding so that they could be converted to a 32-bit
# integer representation. (With a decimal accuracy of 5 places)
# Convert back to original values.
push @points, {lat => $lat * 1e-5, lon => $lng * 1e-5};
}
@points;
}
view all matches for this distribution
view release on metacpan or search on metacpan
t/01-floyd_warshall.t view on Meta::CPAN
use Storable qw(dclone);
use Algorithm::Graphs::TransitiveClosure::Tiny qw(floyd_warshall);
{
note "Taken from original but with integers as keys";
my $graph = {
0 => {0 => undef},
1 => {1 => undef, 2 => undef, 3 => undef},
2 => {1 => undef, 2 => undef},
3 => {0 => undef, 2 => undef, 3 => undef},
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Graphs/TransitiveClosure.pm view on Meta::CPAN
This is an implementation of the well known I<Floyd-Warshall> algorithm. [1,2]
The subroutine C<floyd_warshall> takes a directed graph, and calculates
its transitive closure, which will be returned. The given graph is
actually modified, so be sure to pass a copy of the graph to the routine
if you need to keep the original graph.
The subroutine takes graphs in one of the two following formats:
=over
view all matches for this distribution
view release on metacpan or search on metacpan
Revision history for Perl extension Algorithm-HITS.
0.01 Sat, 21 Aug 2004 07:22:53 +0800
- original version
0.02 Sat, 21 Aug 2004 11:52:52 +0800
- corrected my previous moronic computation error
view all matches for this distribution
view release on metacpan or search on metacpan
### Fetch the 2 Hamming codes
$ham_text = unpack("B*",$chars_in);
$ham_text1 = substr($ham_text,0,12);
$ham_text2 = substr($ham_text,12);
### Convert each code into the original byte
($char_out1,$err) = unhamchar($ham_text1);
$err_all += $err;
($char_out2,$err) = unhamchar($ham_text2);
$err_all += $err;
### Fetch the Hamming code
$ham_text = unpack("B*",$chars_in);
$ham_text1 = substr($ham_text,0,12);
### Convert the code to the original byte
($char_out1,$err) = unhamchar($ham_text1);
$err_all += $err;
### Add byte to output
$output .= $char_out1;
Returns the Hamming code from the provided input data.
=item unhamming (SCALAR)
Returns the original data from the provided Hamming code. Single bit errors
are auto corrected.
=item unhamming_err (SCALAR)
Returns the original data from the provided Hamming code, and a number counting
the number of bytes that were corrected. Single bit errors are auto corrected.
=back
=head1 OTHER SUBROUTINES
use Algorithm::Hamming::Perl qw(hamming unhamming);
$data = "Hello";
$hamcode = hamming($data);
$original = unhamming($hamcode);
=head1 LIMITATIONS
This is Perl only and can be slow. The Hamming encoding used can only
repair a single bit error within a byte - ie if two bits are damaged within
view all matches for this distribution
view release on metacpan or search on metacpan
0.02 Sun Aug 26 2018
- Doc fixes
0.01 Sun Aug 26 2018
- original version; created by h2xs 1.23 with options
-A -n Algorithm::Heapify::XS
view all matches for this distribution
view release on metacpan or search on metacpan
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.
The precise terms and conditions for copying, distribution and
modification follow.
5. By copying, distributing or modifying 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.
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.
7. The Free Software Foundation may publish revised and/or new versions
recipients of the item may redistribute it under the same conditions they
received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications derived
from the Public Domain or from the Copyright Holder. A Package modified in such
a way shall still be considered the Standard Version.
view all matches for this distribution
view release on metacpan or search on metacpan
Revision history for Perl extension Algorithm::HowSimilar.
0.01 Wed Sep 10 14:54:36 2003
- original version; created by h2xs 1.21 with options
-X Algorithm::HowSimilar
view all matches for this distribution
view release on metacpan or search on metacpan
Please look to the description of C<encode_bitstring> for details.
=item $huff->decode_bitstring($bitstring)
Decodes a bitstring of '1' and '0' to the original string.
Allthough the encoding could be a bit ambigious,
the decoding is alway unambigious.
Please take care that only ones and zeroes are in the bitstring.
The method will die otherwise.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/HyperLogLog/PP.pm view on Meta::CPAN
for my $i ( 0 .. ( $m - 1 ) ) {
$rank = $self->{registers}[$i];
$sum += 1.0 / ( 2.0**$rank );
}
my $estimate = $self->{alphaMM} * ( 1.0 / $sum ); # E in the original paper
if ( $estimate <= 2.5 * $m ) {
my $v = 0;
for my $i ( 0 .. ( $m - 1 ) ) {
if ( $self->{registers}[$i] == 0 ) {
$v++;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/IRCSRP2.pm view on Meta::CPAN
L<http://www.bjrn.se/ircsrp/ircsrp.2.0.txt>.
From the specification:
IRCSRP is based on the SRP-6 protocol [3] for password-authenticated key
agreement. While SRP was originally designed for establishing a secure,
authenticated channel between a user and a host, it can be adapted for group
communcations, as described in this document.
See L<https://gitorious.org/ircsrp/ircsrp> for a working version used in Pidgin.
view all matches for this distribution
view release on metacpan or search on metacpan
Revision history for Perl extension Algorithm::InversionList.
0.01 Thu May 1 15:05:39 2003
- original version; created by h2xs 1.21 with options
-X Algorithm::InversionList
view all matches for this distribution
view release on metacpan or search on metacpan
examples/cluster_and_visualize.pl view on Meta::CPAN
# In most cases, you would not change the value of the mask between clustering and
# visualization. But, if you are clustering multi-dimensional data and you wish to
# visualize the projection of of the data on each plane separately, you can do so by
# changing the value of the visualization mask. The number of on bits in the
# visualization must not exceed the number of on bits in the original data mask.
my $vmask = "111"; # for mydatafile1.dat and mydatafile2.dat
#my $vmask = "11"; # for mydatafile3.dat
$clusterer->visualize_clusters( $vmask );
view all matches for this distribution
view release on metacpan or search on metacpan
=head2 --copy=I<suffix>
If this option is given, a copy of each file will be saved with
the given suffix that contains the suggested changes. This does
not require any external programs. Note that this does not
automagially add a dot between the original filename and the
suffix. If you want the dot, you have to include it in the option
argument.
If neither C<--patch> or C<--copy> are given, the default is to
simply print the diffs for each file. This requires either
$self =~ s/^SKIP.*(?=^__DATA__)/SKIP
if (\@ARGV && \$ARGV[0] eq '--unstrip') {
eval { require Devel::PPPort };
\$@ and die "Cannot require Devel::PPPort, please install.\\n";
if (eval \$Devel::PPPort::VERSION < $VERSION) {
die "$0 was originally generated with Devel::PPPort $VERSION.\\n"
. "Your Devel::PPPort is only version \$Devel::PPPort::VERSION.\\n"
. "Please install a newer version, or --unstrip will not work.\\n";
}
Devel::PPPort::WriteFile(\$0);
exit 0;
}
print <<END;
Sorry, but this is a stripped version of \$0.
To be able to use its original script and doc functionality,
please try to regenerate this file using:
\$^X \$0 --unstrip
END
view all matches for this distribution
view release on metacpan or search on metacpan
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.
The precise terms and conditions for copying, distribution and
modification follow.
5. By copying, distributing or modifying 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.
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.
7. The Free Software Foundation may publish revised and/or new versions
recipients of the item may redistribute it under the same conditions they
received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications derived
from the Public Domain or from the Copyright Holder. A Package modified in such
a way shall still be considered the Standard Version.
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install/Repository.pm view on Meta::CPAN
sub _find_repo {
my ($execute) = @_;
if (-e ".git") {
# TODO support remote besides 'origin'?
if ($execute->('git remote show -n origin') =~ /URL: (.*)$/m) {
# XXX Make it public clone URL, but this only works with github
my $git_url = $1;
$git_url =~ s![\w\-]+\@([^:]+):!git://$1/!;
return $git_url;
} elsif ($execute->('git svn info') =~ /URL: (.*)$/m) {
view all matches for this distribution
view release on metacpan or search on metacpan
0.03 Fri Oct 16 11:27:00 2009
- declare the dependency on constant explicity
for old version of constants.pm (< ver.1.03)
0.01 Tue Oct 6 10:48:22 2009
- original version
view all matches for this distribution
view release on metacpan or search on metacpan
Revision history for Perl extension Algorithm::Knap01DP.
0.01 Mon May 16 18:27:54 2005
- original version; created by h2xs 1.23 with options
-XA -n Algorithm::Knap01DP
view all matches for this distribution
view release on metacpan or search on metacpan
0.02 Sat Oct 23 14:48:50 EDT 2004
- Bug fix in filesack that caused size not to be printed
0.01 Fri Oct 8 23:34:32 2004
- original version; created by h2xs 1.19
view all matches for this distribution
view release on metacpan or search on metacpan
0.02 Fri Jan 11 14:22:00 2008
- corrected some documentation typos
0.01 Tue Jan 8 15:31:18 2008
- original version; created by h2xs 1.23 with options
-An Algorithm::LBFGS
view all matches for this distribution
view release on metacpan or search on metacpan
1.00 Sat Aug 9 17:32:28 EDT 2003
- roll CPAN release
0.01 Thu Aug 7 03:40:54 2003
- original version; created by h2xs 1.22 with options
-Afn Algorithm::LCS
view all matches for this distribution
view release on metacpan or search on metacpan
Revision history for Perl extension Algorithm::LCSS.
0.01 Wed Sep 10 02:15:25 2003
- original version; created by h2xs 1.21 with options
-X Algorithm::LCSS
view all matches for this distribution
view release on metacpan or search on metacpan
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.
The precise terms and conditions for copying, distribution and
modification follow.
5. By copying, distributing or modifying 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.
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.
7. The Free Software Foundation may publish revised and/or new versions
recipients of the item may redistribute it under the same conditions they
received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications derived
from the Public Domain or from the Copyright Holder. A Package modified in such
a way shall still be considered the Standard Version.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/LUHN_XS.pm view on Meta::CPAN
=pod
=head1 NAME
Algorithm::LUHN_XS - Very Fast XS Version of the original Algorithm::LUHN
=head1 SYNOPSIS
use Algorithm::LUHN_XS qw/check_digit is_valid/;
lib/Algorithm/LUHN_XS.pm view on Meta::CPAN
$c = check_digit("A2C4E6G8");
print "It worked again\n" if is_valid("A2C4E6G8$c");
=head1 DESCRIPTION
This module is an XS version of the original Perl Module Algorithm::LUHN, which
was written by Tim Ayers. It should work exactly the same, only substantially
faster. The supplied check_digit() routine is 100% compatible with the pure
Perl Algorithm::LUHN module, while the faster check_digit_fast() and really fast
check_digit_rff() are not.
lib/Algorithm/LUHN_XS.pm view on Meta::CPAN
C<check_digit_fast: 2 secs ( 1.68 usr 0.00 sys) 59.52/s>
C<check_digit_rff: 1 secs ( 1.29 usr 0.00 sys) 77.52/s>
So, it's 35x to 53x faster than the original pure Perl module, depending on
how much compatibility with the original module you need.
The rest of the documentation is mostly a copy of the original docs, with some
additions for functions that are new.
This module calculates the Modulus 10 Double Add Double checksum, also known as
the LUHN Formula. This algorithm is used to verify credit card numbers and
Standard & Poor's security identifiers such as CUSIP's and CSIN's.
lib/Algorithm/LUHN_XS.pm view on Meta::CPAN
=item is_valid_fast CHECKSUMMED_NUM
=cut
=item is_valid_rff CHECKSUMMED_NUM
As with check_digit(), we have 3 versions of is_valid(), each one progressively
faster than the check_digit() that comes in the original pure Perl
Algorithm::LUHN module. Here's a benchmark of 1M total calls to is_valid():
C<Benchmark: timing 100 iterations>
C<Algorithm::LUHN: 100 secs (100.29 usr 0.01 sys) 1.00/s>
lib/Algorithm/LUHN_XS.pm view on Meta::CPAN
C<is_valid_fast: 2 secs ( 2.38 usr 0.05 sys) 41.15/s>
C<is_valid_rff: 2 secs ( 1.97 usr 0.08 sys) 48.78/s>
Algorithm::LUHN_XS varies from 38x to 48x times faster than the original
pure perl Algorithm::LUHN module. The is_valid() routine is 100% compatible
with the original, returning either '1' for success or the empty string ''
for failure. The is_valid_fast() routine returns 1 for success and 0 for
failure. Finally, the is_valid_rff() function also returns 1 for success
and 0 for failure, but only works with numeric input. If you supply any
alpha characters, it will return 0.
lib/Algorithm/LUHN_XS.pm view on Meta::CPAN
This module, because of how valid_chars() stores data in the XS portion,
is NOT thread safe.
The _fast and _rff versions of is_valid() and check_digit() don't have the
same return values for failure as the original Algorithm::LUHN module.
Specifically:
=over 4
=item * is_valid_fast() and is_valid_rff() return 0 on failure, but
lib/Algorithm/LUHN_XS.pm view on Meta::CPAN
Try to keep things in "string context".
=head1 SEE ALSO
L<Algorithm::LUHN> is the original pure perl module this is based on.
L<Algorithm::CheckDigits> provides a front-end to a large collection
of modules for working with check digits.
L<Business::CreditCard> provides three functions for checking credit
lib/Algorithm/LUHN_XS.pm view on Meta::CPAN
This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
=head1 CREDITS
Tim Ayers, for the original pure perl version of Algorithm::LUHN.
Neil Bowers, the current maintainer of Algorithm::LUHN.
The inspiration for this module was a PerlMonks post I made here:
L<https://perlmonks.org/?node_id=1226543>, and I received help
view all matches for this distribution
view release on metacpan or search on metacpan
# Revision history for Perl extension Algorithm::LatticePoints.
$Revision: 0.1 $ $Date: 2007/02/04 05:45:16 $
0.01 Sun Feb 4 13:58:05 2007
- original version; created by h2xs 1.23 with options
-XA -n Algorithm::LatticePoints
view all matches for this distribution
view release on metacpan or search on metacpan
Revision history for Perl extension Algorithm::LeakyBucket.
0.01 Wed Jul 18 16:10:11 2012
- original version; created by h2xs 1.23 with options
-AX -n Algorithm::LeakyBucket
0.06 Fri Jul 20 11:07:30 EDT 2012
- Removed old namspace base tricks.
view all matches for this distribution
view release on metacpan or search on metacpan
src/liblinear/linear.cpp view on Meta::CPAN
// this function returns the number of iterations
//
// See Yuan et al. (2010) and appendix of LIBLINEAR paper, Fan et al. (2008)
//
// To not regularize the bias (i.e., regularize_bias = 0), a constant feature = 1
// must have been added to the original data. (see -B and -R option)
#undef GETI
#define GETI(i) (y[i]+1)
// To support weights for instances, use GETI(i) (i)
src/liblinear/linear.cpp view on Meta::CPAN
// this function returns the number of iterations
//
// See Yuan et al. (2011) and appendix of LIBLINEAR paper, Fan et al. (2008)
//
// To not regularize the bias (i.e., regularize_bias = 0), a constant feature = 1
// must have been added to the original data. (see -B and -R option)
#undef GETI
#define GETI(i) (y[i]+1)
// To support weights for instances, use GETI(i) (i)
src/liblinear/linear.cpp view on Meta::CPAN
*x_space_ret = x_space;
delete [] col_ptr;
}
// label: label name, start: begin of each class, count: #data of classes, perm: indices to the original data
// perm, length l, must be allocated before calling this subroutine
static void group_classes(const problem *prob, int *nr_class_ret, int **label_ret, int **start_ret, int **count_ret, int *perm)
{
int l = prob->l;
int max_nr_class = 16;
view all matches for this distribution
view release on metacpan or search on metacpan
Line/Bresenham/C/C.pm view on Meta::CPAN
=over 8
=item Algorithm::Line::Bresenham
The original pure perl version.
=head1 AUTHOR and LICENSE
Lilo Huang, kenwu@cpan.org
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Line/Bresenham.pm view on Meta::CPAN
Variable thickness lines are implemented as described in
http://kt8216.unixcab.org/murphy/index.html ; This allows passing of
two subroutine references (so the left side and the right sides of the
line can have differently varying thicknesses) along with a
user originated parameter. The subroutine reference example is shown below:
my $leftFn=sub{
my ($arg,$p,$l)=@_;
# C<$arg> is passed by calling routine,
# C<$p> is point on line
view all matches for this distribution
view release on metacpan or search on metacpan
=head2 --copy=I<suffix>
If this option is given, a copy of each file will be saved with
the given suffix that contains the suggested changes. This does
not require any external programs. Note that this does not
automagically add a dot between the original filename and the
suffix. If you want the dot, you have to include it in the option
argument.
If neither C<--patch> or C<--copy> are given, the default is to
simply print the diffs for each file. This requires either
$self =~ s/^SKIP.*(?=^__DATA__)/SKIP
if (\@ARGV && \$ARGV[0] eq '--unstrip') {
eval { require Devel::PPPort };
\$@ and die "Cannot require Devel::PPPort, please install.\\n";
if (eval \$Devel::PPPort::VERSION < $VERSION) {
die "$0 was originally generated with Devel::PPPort $VERSION.\\n"
. "Your Devel::PPPort is only version \$Devel::PPPort::VERSION.\\n"
. "Please install a newer version, or --unstrip will not work.\\n";
}
Devel::PPPort::WriteFile(\$0);
exit 0;
}
print <<END;
Sorry, but this is a stripped version of \$0.
To be able to use its original script and doc functionality,
please try to regenerate this file using:
\$^X \$0 --unstrip
END
# define D_PPP_TO_FOLD_CALLEE(s,r,l) \
Perl__to_utf8_fold_flags(aTHX_ s, r, l, FOLD_FLAGS_FULL, NULL)
# endif
/* The actual implementation of the backported macros. If too short, croak,
* otherwise call the original that doesn't have an upper limit parameter */
# define D_PPP_GENERIC_MULTI_ARG_TO(name, s, e,r,l) \
(((((e) - (s)) <= 0) \
/* We could just do nothing, but modern perls croak */ \
? (croak("Attempting case change on zero length string"), \
0) /* So looks like it returns something, and will compile */ \
D_PPP_GENERIC_MULTI_ARG_TO(FOLD,s,e,r,l)
#endif
#elif (PERL_BCDVERSION >= 0x5006000)
/* Here we have UTF-8 support, but using the original API where the case
* changing functions merely returned the changed code point; hence they
* couldn't handle multi-character results. */
# ifdef uvchr_to_utf8
# define D_PPP_UV_TO_UTF8 uvchr_to_utf8
view all matches for this distribution