view release on metacpan or search on metacpan
join(",", @{$diffs{&CB_C}}) ne join(",", @{$diffs{&BC_C}}))
{
@bdoc_save = splice @{$bdoc}, $target_len;
@cdoc_save = splice @{$cdoc}, $target_len;
carp "Algorithm::Diff::diff is not symmetric for second and third sequences - results might not be correct";
}
@diffs{(BC_B, BC_C)} = ([], []);
$left = BC_B; $right = BC_C;
Algorithm::Diff::traverse_sequences( $bdoc, $cdoc, $ts_callbacks, $keyGen, @_);
This module complements L<Algorithm::Diff|Algorithm::Diff> by
providing three-way merge and diff functions.
In this documentation, the first list to C<diff3>, C<merge>, and
C<traverse_sequences3> is
called the `original' list. The second list is the `left' list. The
third list is the `right' list.
The optional key generation arguments are the same as in
L<Algorithm::Diff|Algorithm::Diff>. See L<Algorithm::Diff> for more
information.
the work.
The only callback currently used is C<CONFLICT> which should be a
reference to a subroutine that accepts two array references. The
first array reference is to a list of elements from the left list.
The second array reference is to a list of elements from the right list.
This callback should return a list of elements to place in the merged
list in place of the conflict.
The default C<CONFLICT> callback returns the following:
If one argument, then only the element at the given position from the
first sequence is not in either of the other two sequences.
If two arguments, then there is no element in the first sequence that
corresponds to the elements at the given positions in the second and
third sequences.
If three arguments, then the element at the given position in the first
sequence is different than the corresponding element in the other two
sequences, but the other two sequences have corresponding elements.
=item B_DIFF
This is called if the second sequence is different than the other two
sequences at the current position.
This callback will be called with one, two, or three arguments.
If one argument, then only the element at the given position from the
second sequence is not in either of the other two sequences.
If two arguments, then there is no element in the second sequence that
corresponds to the elements at the given positions in the first and
third sequences.
If three arguments, then the element at the given position in the second
sequence is different than the corresponding element in the other two
sequences, but the other two sequences have corresponding elements.
=item C_DIFF
If one argument, then only the element at the given position from the
third sequence is not in either of the other two sequences.
If two arguments, then there is no element in the third sequence that
corresponds to the elements at the given positions in the first and
second sequences.
If three arguments, then the element at the given position in the third
sequence is different than the corresponding element in the other two
sequences, but the other two sequences have corresponding elements.
example does not work, send it to <jsmith@cpan.org> or report it on
<http://rt.cpan.org/>, the CPAN bug tracker.
L<Algorithm::Diff|Algorithm::Diff>'s implementation of
C<traverse_sequences> may not be symmetric with respect to the input
sequences if the second and third sequence are of different lengths.
Because of this, C<traverse_sequences3> will calculate the diffs of
the second and third sequences as passed and swapped. If the differences
are not the same, it will issue an `Algorithm::Diff::diff is not symmetric
for second and third sequences...' warning. It will try to handle
this, but there may be some cases where it can't.
=head1 SEE ALSO
L<Algorithm::Diff>.
view all matches for this distribution
view release on metacpan or search on metacpan
at most 3n/2 - 2 comparisons, where n is the number of elements of the
array.
=head1 RETURN
Returns an array where the first entry is the minimum and the second
entry the maximum of the given array.
If minmax is called with an empty array, minmax will also return an
empty array.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/MinPerfHashTwoLevel.pm view on Meta::CPAN
This module implements an algorithm to construct (relatively efficiently) a
minimal perfect hash using the "two level" algorithm. A perfect hash is one
which has no collisions for any keys, a minimal perfect hash has exactly the
same number of buckets as it has keys. The "two level" algorithm involves
computing two hash values for each key. The first is used as an initial lookup
into the bucket array to find a mask value which is used to modify the second
hash value to determine the actual bucket to read from. This module computes
the appropriate mask values.
In this implementation only one 64 bit hash value is computed, but the high
and low 32 bits are used as if there were two hash values. The hash function
lib/Algorithm/MinPerfHashTwoLevel.pm view on Meta::CPAN
The raw bytes of the normalized key. (See val_is_utf8).
=item xor_val
The mask to be xor'ed with the second hash (h2) to determine
the actual lookup bucket. If the xor_val for a given bucket
is 0 then the key is not in the hash.
=back
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Munkres.pm view on Meta::CPAN
The input matrix should be in a two dimensional array(array of
array) and the 'assign' subroutine expects a reference to this
array and not the complete array.
eg:assign(\@inp_mat, \@out_mat);
The second argument to the assign subroutine is the reference
to the output array.
=head1 OUTPUT
The assign subroutine expects references to two arrays as its
input paramenters. The second parameter is the reference to the
output array. This array is populated by assign subroutine. This
array is single dimensional Nx1 matrix.
For above example the output array returned will be:
(0,
2,
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/NaiveBayes/Util.pm view on Meta::CPAN
$var += ($_ - $mean)**2 foreach @$array;
return $var / (@$array - 1);
}
sub add_hash {
my ($first, $second) = @_;
foreach my $k (keys %$second) {
$first->{$k} += $second->{$k};
}
}
sub rescale {
my ($scores) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/NeedlemanWunsch.pm view on Meta::CPAN
your sequences don't satisfy these requirements, consider using local
alignment, which, strictly speaking, isn't Needleman-Wunsch, but is
similar enough to be implemented in this module as well - see below
for details.
In the example above, the second alignment has more gaps than the
first, but perhaps your a's are structurally important and you like
them lined up so much that you'd still prefer the second
alignment. Conversely, if c is "almost the same" as g, it might be the
first alignment that matches better. Needleman-Wunsch formalizes such
considerations into a I<similarity matrix>, assigning payoffs to each
(ordered, but the matrix is normally symmetrical so that the order
doesn't matter) pair of possible sequence items, plus a I<gap
lib/Algorithm/NeedlemanWunsch.pm view on Meta::CPAN
preference of pairings over gaps is expressed by a low (relative to
the similarity matrix values, normally negative) gap penalty.
The alignment score is then defined as the sum, over the positions
where at least one sequence has an item, of the similarity matrix
values indexed by the first and second item (when both are defined)
and gap penalties (for items aligned with a gap). For example, if C<S>
is the similarity matrix and C<g> denotes the gap penalty, the
alignment
sequence A: a a t t c c
lib/Algorithm/NeedlemanWunsch.pm view on Meta::CPAN
The constructor. Takes one mandatory argument, which is a coderef to a
sub implementing the similarity matrix, plus an optional gap penalty
argument. If the gap penalty isn't specified as a constructor
argument, the C<Algorithm::NeedlemanWunsch> object gets it by calling
the scoring sub without arguments; apart from that case, the sub is
called with 2 arguments, which are items from the first and second
sequence, respectively, passed to
C<Algorithm::NeedlemanWunsch::align>. Note that the sub must be pure,
i.e. always return the same value when called with the same arguments.
=head3 align(\@a, \@b [, \%callbacks ])
lib/Algorithm/NeedlemanWunsch.pm view on Meta::CPAN
which are the positions of the paired items in C<\@a> and C<\@b>,
respectively.
=item shift_a
Aligns an item of the first sequence with a gap in the second
sequence. The callback is called with 1 argument, which is the
position of the item in C<\@a>.
=item shift_b
Aligns a gap in the first sequence with an item of the second
sequence. The callback is called with 1 argument, which is the
position of the item in C<\@b>.
=item select_align
lib/Algorithm/NeedlemanWunsch.pm view on Meta::CPAN
items in C<\@a> and C<\@b>, respectively.
=item shift_a
If this key exists, the optimal alignment may align an item of the
first sequence with a gap in the second sequence. The key's value is
the position of the item in C<\@a>.
=item shift_b
If this key exists, the optimal alignment may align a gap in the first
sequence with an item of the second sequence. The key's value is
the position of the item in C<\@b>.
=back
All keys are optional, but the hash will always have at least one. The
lib/Algorithm/NeedlemanWunsch.pm view on Meta::CPAN
=head3 local
When this flag is set before calling
C<Algorithm::NeedlemanWunsch::align>, the alignment scoring doesn't
charge the gap penalty for gaps at the beginning (i.e. before the
first item) and end (after the last item) of the second sequence
passed to C<align>, so that for example the optimal (with identity
matrix as similarity matrix and a negative gap penalty) alignment of
C<a b c d e f g h> and C<b c h> becomes
sequence A: a b c d e f g h
lib/Algorithm/NeedlemanWunsch.pm view on Meta::CPAN
approach. Biologists, for example, looking for gaps longer than one
DNA sequence base, typically want to distinguish a gap opening
(costly) from more missing items following it (shouldn't cost so
much). That requirement can be modelled by charging 2 gap penalties:
C<gap_open_penalty> for the first gap, and then C<gap_extend_penalty>
for each consecutive gap on the same sequence.
Note that you must set both these properties if you set any of them
and that C<gap_open_penalty> must be less than C<gap_extend_penalty>
(if you know of a use case where the gap opening penalty should be
preferred to gap extension, let me know). With such penalties set
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Networksort.pm view on Meta::CPAN
=item
Joe Celko, I<Joe Celko's SQL For Smarties> (third edition). Implementing
Bose-Nelson sorting network in SQL.
This material isn't in either the second or fourth edition of the book.
=item
Joe Celko, I<Joe Celko's Thinking in Sets: Auxiliary, Temporal, and Virtual Tables in SQL>.
lib/Algorithm/Networksort.pm view on Meta::CPAN
=over 3
=item
Code for Kenneth Batcher's Merge Exchange algorithm was derived from Knuth's
The Art of Computer Programming, Vol. 3, section 5.2.2.
=back
=head2 Batcher's Bitonic algorithm
lib/Algorithm/Networksort.pm view on Meta::CPAN
L<http://www.iti.fh-flensburg.de/lang/algorithmen/sortieren/bitonic/bitonicen.htm>
=item
T. H. Cormen, E. E. Leiserson, R. L. Rivest, Introduction to Algorithms,
first edition, McGraw-Hill, 1990, section 28.3.
=item
T. H. Cormen, E. E. Leiserson, R. L. Rivest, C. Stein, Introduction to Algorithms,
2nd edition, McGraw-Hill, 2001, section 27.3.
=back
=head2 Algorithm discussion
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Nhash.pm view on Meta::CPAN
This is an implementation of the Exim nhash algorithm. It also supports an
arbitrary number of divisors and not just the one or two that Exim permits.
The nash algorithm is a fast and simple hashing algorithm that attempts to
evenly-distribute values but does not attempt to avoid collisions. Thus, it
should not be used in place of a cryptographically-secure algorithm such as
Digest::SHA. It is mainly intended for hashing filenames into directories to
avoid placing too many files into a single directory.
If nhash is not given any divisors, then the hash result is returned as-is.
If one divisor is given, the hash result is given modulo that divisor. If
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Numerical/Sample.pm view on Meta::CPAN
C<k>. For the proof that the sampling is unbiased, we refer to [3].
(Section 3.4.2, Exercise 3).
=head2 Algorithm B.
It is easy to see that the second algorithm returns the correct
number of elements. For a sample of size C<n>, the first C<n>
elements go into the reservoir, and after that, the reservoir
never grows or shrinks in size; elements only get replaced.
A detailed proof of the fairness of the algorithm appears in [3].
(Section 3.4.2, Exercise 7).
lib/Algorithm/Numerical/Sample.pm view on Meta::CPAN
=head1 LITERATURE
Both algorithms are discussed by Knuth [3] (Section 3.4.2).
The first algoritm, I<Selection sampling technique>, was
discovered by Fan, Muller and Rezucha [1], and independently
by Jones [2]. The second algorithm, I<Reservoir sampling>,
is due to Waterman.
=head1 REFERENCES
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/PageRank/XS.pm view on Meta::CPAN
=back
=head1 SPEED
This module is pretty fast. I ran this on a 1 million node set with 4.5 million arcs in 57 seconds on my 32-bit 1.8GHz laptop. Let me know if you have any performance tips.
Below are the tables for the current iteration in trials per second and arcs per second. Keep in mind that for some of these there are large numbers of arcs (C<.2%> load with C<100,000> nodes means C<20,000,000> arcs!
+-----------------+-----------------+-----------------+---------------+---------------+
| test | XS trials / sec | PL trials / sec | XS arcs / sec | PL arcs / sec |
+-----------------+-----------------+-----------------+---------------+---------------+
| 10 nodes @50% | 4533.207 | 53.741 | 6890.474 | 81.687 |
| 10 nodes @100% | 3822.595 | 46.084 | 13761.342 | 165.901 |
| 1000 @10% | 4.542 | 0.120 | 18109.287 | 2390.898 |
| 1000 @50% | 1.055 | 0.031 | 21082.599 | 15720.595 |
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Pair/Best2.pm view on Meta::CPAN
return wantarray ? @results : \@results;
}
# find best pairing of @idxs. try the first item in @idxs against every
# other item in the array. after picking the first and the current second
# item, recursively find the best arrangement of all the remaining items.
# the return values are the score followed by the new arrangment.
sub _r_best {
my ($self, $depth, $best_score, @idxs) = @_;
lib/Algorithm/Pair/Best2.pm view on Meta::CPAN
## $idx,
## $trial_score,
## $self->print_items($trial_0, $trial_1, @trial_tail) if ($depth < 2);
}
# hold $trial_0 in slot 0, rotate all items below it
push @tail, $trial_1; # add second item to end of tail
$trial_1 = shift @tail; # move third item into second slot
### pop @head;
}
### pop @head;
### my $key = $self->make_key(@best_trial);
### print "best: $key = $best_score\n" if ($depth == 0);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Pair/Swiss.pm view on Meta::CPAN
a previous call to $pair-E<gt>B<pairs>. The selection given is added
to previously excluded pairs.
If there was an odd number of parties, the lowest ranked party will be
paired with 'undef', unless it has already been paired with 'undef'. In
that case, the second-lowest ranked party will get that pairing. Etcetera,
etcetera. 'Lowest-ranked' is defined as being last in the party-list after
sorting. In MTG terms, being paired with 'undef' would mean getting a bye
(and getting the full three points for that round as a consequence).
=cut
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Partition.pm view on Meta::CPAN
=head1 FUNCTIONS
=head2 partition(@integers);
Given a list of integers, this function will return two values. If the
first value is C<undef>, then no solution was found and the second value
is a string explaining why. Otherwise, two array references are returned
which point to the two resulting sets.
The algorithm is meant for relatively small sets of integers with relatively
small values. Beware.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Permute.pm view on Meta::CPAN
I've collected some Perl routines and modules which implement permutation,
and do some simple benchmark. The whole result is the following.
Permutation of B<eight> scalars:
Abigail's : 9 wallclock secs ( 8.07 usr + 0.30 sys = 8.37 CPU)
Algorithm::Permute : 5 wallclock secs ( 5.72 usr + 0.00 sys = 5.72 CPU)
Algorithm::Permute qw(permute): 2 wallclock secs ( 1.65 usr + 0.00 sys = 1.65 CPU)
List::Permutor : 27 wallclock secs (26.73 usr + 0.01 sys = 26.74 CPU)
Memoization : 32 wallclock secs (32.55 usr + 0.02 sys = 32.57 CPU)
perlfaq4 : 36 wallclock secs (35.27 usr + 0.02 sys = 35.29 CPU)
Permutation of B<nine> scalars (the Abigail's routine is commented out, because
it stores all of the result in memory, swallows all of my machine's memory):
Algorithm::Permute : 43 wallclock secs ( 42.93 usr + 0.04 sys = 42.97 CPU)
Algorithm::Permute qw(permute): 15 wallclock secs ( 14.82 usr + 0.00 sys = 14.82 CPU)
List::Permutor : 227 wallclock secs (226.46 usr + 0.22 sys = 226.68 CPU)
Memoization : 307 wallclock secs (306.69 usr + 0.43 sys = 307.12 CPU)
perlfaq4 : 272 wallclock secs (271.93 usr + 0.33 sys = 272.26 CPU)
The benchmark script is included in the bench directory. I understand that
speed is not everything. So here is the list of URLs of the alternatives, in
case you hate this module.
view all matches for this distribution
view release on metacpan or search on metacpan
The default namespace is C<DPPP_>.
=back
The good thing is that most of the above can be checked by running
F<ppport.h> on your source code. See the next section for
details.
=head1 EXAMPLES
To verify whether F<ppport.h> is needed for your module, whether you
invlist_contents|5.023008||Viu
_invlist_dump|5.019003||cViu
_invlistEQ|5.023006||cViu
invlist_extend|5.013010||Viu
invlist_highest|5.017002||Vniu
_invlist_intersection|5.015001||Viu
_invlist_intersection_maybe_complement_2nd|5.015008||cViu
_invlist_invert|5.015001||cViu
invlist_is_iterating|5.017008||Vniu
invlist_iterfinish|5.017008||Vniu
invlist_iterinit|5.015001||Vniu
invlist_iternext|5.015001||Vniu
PL_scopestack|5.005000||Viu
PL_scopestack_ix|5.005000||Viu
PL_scopestack_max|5.005000||Viu
PL_scopestack_name|5.011002||Viu
PL_SCX_invlist|5.027008||Viu
PL_secondgv|5.005000||Viu
PL_setlocale_buf|5.027009||Viu
PL_setlocale_bufsize|5.027009||Viu
PL_sharehook|5.007003||Viu
PL_sighandler1p|5.031007||Viu
PL_sighandler3p|5.031007||Viu
ssc_clear_locale|5.019005||Vniu
ssc_cp_and|5.019005||Viu
ssc_finalize|5.019005||Viu
SSCHECK|5.003007||Viu
ssc_init|5.019005||Viu
ssc_intersection|5.019005||Viu
ssc_is_anything|5.019005||Vniu
ssc_is_cp_posixl_init|5.019005||Vniu
SSC_MATCHES_EMPTY_STRING|5.021004||Viu
ssc_or|5.019005||Viu
ssc_union|5.019005||Viu
my $f;
my $count = 0;
my $match = $opt{'api-info'} =~ m!^/(.*)/$! ? $1 : "^\Q$opt{'api-info'}\E\$";
# Sort the names, and split into two classes; one for things that are part of
# the API; a second for things that aren't.
my @ok_to_use;
my @shouldnt_use;
for $f (sort dictionary_order keys %API) {
next unless $f =~ /$match/;
my $base = int_parse_version($API{$f}{base}) if $API{$f}{base};
* 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts"
* 2. Declare a typedef named my_cxt_t that is a structure that contains
* all the data that needs to be interpreter-local.
* 3. Use the START_MY_CXT macro after the declaration of my_cxt_t.
* 4. Use the MY_CXT_INIT macro such that it is called exactly once
* (typically put in the BOOT: section).
* 5. Use the members of the my_cxt_t structure everywhere as
* MY_CXT.member.
* 6. Use the dMY_CXT macro (a declaration) in all the functions that
* access MY_CXT.
*/
* Versions before 5.35.10 dereferenced empty input without checking */
# undef utf8_to_uvchr_buf
#endif
/* This implementation brings modern, generally more restricted standards to
* utf8_to_uvchr_buf. Some of these are security related, and clearly must
* be done. But its arguable that the others need not, and hence should not.
* The reason they're here is that a module that intends to play with the
* latest perls should be able to work the same in all releases. An example is
* that perl no longer accepts any UV for a code point, but limits them to
* IV_MAX or below. This is for future internal use of the larger code points.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/QuadTree.pm view on Meta::CPAN
=head1 DESCRIPTION
Algorithm::QuadTree implements a quadtree algorithm (QTA) in pure Perl.
Essentially, a I<QTA> is used to access a particular area of a map very quickly.
This is especially useful in finding objects enclosed in a given region, or
in detecting intersection among objects. In fact, I wrote this module to rapidly
search through objects in a L<Tk::Canvas> widget, but have since used it in other
non-Tk programs successfully. It is a classic memory/speed trade-off.
Lots of information about QTAs can be found on the web. But, very briefly,
a quadtree is a hierarchical data model that recursively decomposes a map into
lib/Algorithm/QuadTree.pm view on Meta::CPAN
In the above diagrams I show only the nodes through the first branch of
each level. The same structure exists under each node. This quadtree has a
depth of 4.
Each object in the map is assigned to the nodes that it intersects. For example,
if we have an object that overlaps regions I<AAA> and I<AAC>, it will be
assigned to the nodes I<ROOT>, I<A>, I<AA>, I<AAA> and I<AAC>. Now, suppose we
want to find all the objects that intersect a given area. Instead of checking all
objects, we check to see which children of the ROOT node intersect the area. For
each of those nodes, we recursively check I<their> children nodes, and so on
until we reach the leaves of the tree. Finally, we find all the objects that are
assigned to those leaf nodes and check them for overlap with the initial area.
=head1 CLASS METHODS
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/QuineMcCluskey.pm view on Meta::CPAN
# Recursive divide-and-conquer solver
#
# "To reduce the complexity of the prime implicant chart:
#
# 1. Select all the essential prime impliciants. If these PIs cover all
# minterms, stop; otherwise go the second step.
#
# 2. Apply Rules 1 and 2 to eliminate redundant rows and columns from
# the PI chart of non-essential PIs. When the chart is thus reduced,
# some PIs will become essential (i.e., some columns will have a single
# 'x'. Go back to step 1."
lib/Algorithm/QuineMcCluskey.pm view on Meta::CPAN
#
##### Least Covered term: $term
##### Covered by: @ta
#
# Make a copy of the section of the prime implicants
# table that don't cover that term.
#
my %r = map {
$_ => [ grep { $_ ne $term } @{ $primes{$_} } ]
} keys %primes;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/RabinKarp.pm view on Meta::CPAN
=head1 DESCRIPTION
This is an implementation of Rabin and Karp's streaming hash, as
described in "Winnowing: Local Algorithms for Document Fingerprinting" by
Schleimer, Wilkerson, and Aiken. Following the suggestion of Schleimer,
I am using their second equation:
$H[ $c[2..$k + 1] ] = (( $H[ $c[1..$k] ] - $c[1] ** $k ) + $c[$k+1] ) * $k
The results of this hash encodes information about the next k values in
the stream (hense k-gram.) This means for any given stream of length n
view all matches for this distribution
view release on metacpan or search on metacpan
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
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
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
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/RandomPointGenerator.pm view on Meta::CPAN
# This subroutine is for reading from a text file the horizontal and the vertical
# limits of the bounding box in which the randomly generated points must reside. The
# file can either be in the CSV format or the white-space-separated format. Apart
# from any comment lines that begin with the hash mark, this must must contain
# exactly two lines, the first indicated the x-axis points that define the horizontal
# span of the bounding box and the second indicating the y-axis points that define
# the vertical span of the same.
sub read_file_for_bounding_box {
my $self = shift;
my $histref = $self->{_input_histogram};
my $filename = $self->{_bbox_file};
lib/Algorithm/RandomPointGenerator.pm view on Meta::CPAN
-71.772016, -70.431923
-34.254251, -33.203240
Apart from any comment lines, there must exist exactly two lines in the bounding-box
file, with the first line indicating the left and the right limits of the horizontal
coordinates and the second line indicating the lower and the upper limits of the
vertical coordinates. (The values shown above are the longitude and the latitude
limits for a region in Chile, in case you are curious.)
=back
lib/Algorithm/RandomPointGenerator.pm view on Meta::CPAN
This required parameter supplies the name of the file that contains the bounding box
information. By bounding box is meant the part of the XY-plane that corresponds to
the histogram supplied through the C<input_histogram_file> option. Apart from any
comment lines, this file must contain exactly two lines and each line must contain
exactly two numeric entries. Additionally, the first entry in each of the two lines
must be smaller than the second entry in the same line. The two entries in the first
line define the lower and the upper bounds on the x-axis and the two entries in the
second line do the same for the y-axis.
=item C<number_of_points>:
This parameter specifies the number of random points that you want the module to
generate.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/RateLimiter/TokenBucket.pm view on Meta::CPAN
use v5.40;
use feature 'class';
no warnings 'experimental::class';
#
class Algorithm::RateLimiter::TokenBucket v1.0.0 {
field $limit : param : reader //= 0; # Bytes per second, 0 = unlimited
field $tokens : reader = $limit;
field $max_burst = $limit * 2; # Allow some burst, but not too much
#
method set_limit ($new_limit) {
view all matches for this distribution
view release on metacpan or search on metacpan
The default namespace is C<DPPP_>.
=back
The good thing is that most of the above can be checked by running
F<ppport.h> on your source code. See the next section for
details.
=head1 EXAMPLES
To verify whether F<ppport.h> is needed for your module, whether you
* 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts"
* 2. Declare a typedef named my_cxt_t that is a structure that contains
* all the data that needs to be interpreter-local.
* 3. Use the START_MY_CXT macro after the declaration of my_cxt_t.
* 4. Use the MY_CXT_INIT macro such that it is called exactly once
* (typically put in the BOOT: section).
* 5. Use the members of the my_cxt_t structure everywhere as
* MY_CXT.member.
* 6. Use the dMY_CXT macro (a declaration) in all the functions that
* access MY_CXT.
*/
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Retry.pm view on Meta::CPAN
description => <<'_',
If set to true, will take into account the actual delay (timestamp difference).
For example, when using the Constant strategy of delay=2, you log failure()
again right after the previous failure() (i.e. specify the same timestamp).
failure() will then return ~2+2 = 4 seconds. On the other hand, if you waited 2
seconds before calling failure() again (i.e. specify the timestamp that is 2
seconds larger than the previous timestamp), failure() will return 2 seconds.
And if you waited 4 seconds or more, failure() will return 0.
_
},
);
our %attr_max_attempts = (
max_attempts => {
summary => 'Maximum number consecutive failures before giving up',
schema => 'uint*',
default => 0,
description => <<'_',
0 means to retry endlessly without ever giving up. 1 means to give up after a
lib/Algorithm/Retry.pm view on Meta::CPAN
},
);
our %attr_delay_on_success = (
delay_on_success => {
summary => 'Number of seconds to wait after a success',
schema => 'ufloat*',
default => 0,
},
);
our %attr_max_delay = (
max_delay => {
summary => 'Maximum delay time, in seconds',
schema => 'ufloat*',
},
);
$SPEC{new} = {
lib/Algorithm/Retry.pm view on Meta::CPAN
my $ar = Algorithm::Retry::Constant->new(
delay => 2, # required
#delay_on_success => 0, # optional, default 0
);
# 2. log success/failure and get a new number of seconds to delay, timestamp is
# optional but must be monotonically increasing.
my $secs = $ar->failure(); # => 2
my $secs = $ar->success(); # => 0
my $secs = $ar->failure(); # => 2
=head1 DESCRIPTION
This distribution provides several classes that implement various retry/backoff
strategies.
lib/Algorithm/Retry.pm view on Meta::CPAN
(1+jitter_factor). Jitters are usually added to avoid so-called "thundering
herd" problem.
=item * B<max_attempts> => I<uint> (default: 0)
Maximum number consecutive failures before giving up.
0 means to retry endlessly without ever giving up. 1 means to give up after a
single failure (i.e. no retry attempts). 2 means to retry once after a failure.
Note that after a success, the number of attempts is reset (as expected). So if
max_attempts is 3, and if you fail twice then succeed, then on the next failure
lib/Algorithm/Retry.pm view on Meta::CPAN
=head2 success
Usage:
my $secs = $obj->success([ $timestamp ]);
Log a successful attempt. If not specified, C<$timestamp> defaults to current
time. Will return the suggested number of seconds to wait before doing another
attempt.
=head2 failure
Usage:
my $secs = $obj->failure([ $timestamp ]);
Log a failed attempt. If not specified, C<$timestamp> defaults to current time.
Will return the suggested number of seconds to wait before doing another
attempt, or -1 if it suggests that one gives up (e.g. if C<max_attempts>
parameter has been exceeded).
=head1 HOMEPAGE
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/SVM/DataSet.pm view on Meta::CPAN
The attribute method is used to set dataset attribute values. If a single
value is provided, the method will return the corresponding value. If
two value are provided, the method will set the first parameter to the
value of the second.
$ds->asArray();
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install/Metadata.pm view on Meta::CPAN
my $name = shift;
my $features = ( $self->{values}->{features} ||= [] );
my $mods;
if ( @_ == 1 and ref( $_[0] ) ) {
# The user used ->feature like ->features by passing in the second
# argument as a reference. Accomodate for that.
$mods = $_[0];
} else {
$mods = \@_;
}
view all matches for this distribution
view release on metacpan or search on metacpan
# max_steps => 40000,
# solutions_to_find=>1,
# search_type => 'bfs',
# do_not_repeat_values => 1,
# });
# is($fifteen_search->{steps}, 25211, 'number of steps a second time');
$fifteen_search->search({search_this=>$puzzle,
max_steps => 20000,
solutions_to_find=>1,
search_type => 'bfs',
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Shape/RandomTree.pm view on Meta::CPAN
A detailed synopsis with examples will be released soon.
=head1 EXPORT
A list of functions that can be exported. You can delete this section
if you don't export anything, such as for a purely object-oriented module.
=head1 SUBROUTINES/METHODS
=head2 calc_new_deltas
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/SixDegrees.pm view on Meta::CPAN
A linked data type must return identifiers that relate across the
link; that is, for an actor/movie relationship, an actor subroutine
should return movies, and a movie subroutine should return actors.
Additional arguments can be provided; these will be stored in the
object and passed through as the second and further arguments to
the subroutine. This may be useful, for example, if you're using
some form of results caching and need to pass a C<tie>d handle
around.
If you return explicit undef, please set C<$Algorithm::SixDegrees::ERROR>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/SkipList.pm view on Meta::CPAN
($cmp == 0) ? $node->value : undef;
}
sub _first_node { # actually this is the second node
my $self = shift;
my $list = $self->list;
my $node = $list->header()->[0];
}
lib/Algorithm/SkipList.pm view on Meta::CPAN
=head1 DESCRIPTION
This is an implementation of I<skip lists> in Perl.
Skip lists are similar to linked lists, except that they have random
links at various I<levels> that allow searches to skip over sections
of the list, like so:
4 +---------------------------> +----------------------> +
| | |
3 +------------> +------------> +-------> +-------> +--> +
lib/Algorithm/SkipList.pm view on Meta::CPAN
Skip lists generally perform as well as balanced trees for searching
but do not have the overhead with respect to inserting new items. See
the included file C<Benchmark.txt> for a comparison of performance
with other Perl modules.
For more information on skip lists, see the L</"SEE ALSO"> section below.
Only alphanumeric keys are supported "out of the box". To use numeric
or other types of keys, see L</"Customizing the Node Class"> below.
=head2 Methods
lib/Algorithm/SkipList.pm view on Meta::CPAN
customized L<comparison|/"key_cmp"> routines, you will need to specify a
different class:
$list = new Algorithm::SkipList( node_class => 'MyNodeClass' );
See the L</"Customizing the Node Class"> section below.
Specialized internal parameters may be configured:
$list = new Algorithm::SkipList( max_level => 32 );
lib/Algorithm/SkipList.pm view on Meta::CPAN
You can enable duplicate keys by using the following:
$list = new Algorithm::SkipList( duplicates => 1 );
This is an experimental feature. See the L</KNOWN ISSUES> section
below.
=item insert
$list->insert( $key, $value );
lib/Algorithm/SkipList.pm view on Meta::CPAN
$list->k( $k );
Sets the I<k> value.
Higher values will on the average have less pointers per node, but
take longer for searches. See the section on the L<P|/p> value.
=item p
$plevel = $list->p;
lib/Algorithm/SkipList.pm view on Meta::CPAN
The probability that a particular node will have a forward pointer at
level I<i> is: I<p**(i+k-1)>.
For more information, consult the references below in the
L</"SEE ALSO"> section.
=item max_level
$max = $list->max_level;
lib/Algorithm/SkipList.pm view on Meta::CPAN
=item _first_node
$node = $list->_first_node;
Returns the first node with a key (the second node) in a list. This
is used by the L</first_key>, L</least>, L</append> and L</merge>
methods.
=item _greatest_node
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/SpiralSearch.pm view on Meta::CPAN
croak 'A valid input/output funtion reference must be passed in'
unless $f =~ /CODE/;
croak 'Two or more iterations are required : ' if $iters < 2;
croak 'Upper boundary on first parameter must be non-zero : ' if $ubx == 0.0;
croak 'Upper boundary on second parameter must be non-zero : '
if $uby == 0.0;
croak 'Final parameter must be set to MAX or MIN : '
unless $max_or_min =~ /MAX|MIN/i;
view all matches for this distribution