view release on metacpan or search on metacpan
ConstructDFA.xs view on Meta::CPAN
Automaton automaton;
map<StatesId, set<StatesId>> predecessors;
map<StatesId, bool> accepting;
for (auto s = start_states.begin(); s != start_states.end(); ++s) {
States& start_state = s->second;
sub_temp.clear();
for (auto i = start_state.begin(); i != start_state.end(); ++i) {
sub_temp.insert(*i);
ConstructDFA.xs view on Meta::CPAN
by_label[label[*i]].insert(*i);
}
for (auto i = by_label.begin(); i != by_label.end(); ++i) {
States destination;
auto second = i->second;
auto current_label = i->first;
sub_temp.clear();
for (auto j = second.begin(); j != second.end(); ++j) {
auto x = successors[*j];
for (auto k = x.begin(); k != x.end(); ++k) {
sub_temp.insert(*k);
}
}
ConstructDFA.xs view on Meta::CPAN
States sink;
for (auto s = automaton.begin(); s != automaton.end(); /* */) {
StatesId src = s->first.first;
Label label = s->first.second;
StatesId dst = s->second;
if (reachable.find(src) == reachable.end()) {
vector<State> x = m.id_to_states(src);
sink.insert(x.begin(), x.end());
s = automaton.erase(s);
ConstructDFA.xs view on Meta::CPAN
map<StatesId, size_t> start_ix_to_state_map_id;
for (auto s = start_states.begin(); s != start_states.end(); ++s) {
auto startIx = s->first;
auto state = s->second;
auto startId = m.states_to_id(state);
if (reachable.find(startId) == reachable.end()) {
croak("start state %u unreachable", startIx);
}
ConstructDFA.xs view on Meta::CPAN
}
map<size_t, StatesId> state_map_r;
for (auto s = state_map.begin(); s != state_map.end(); ++s) {
state_map_r[s->second] = s->first;
}
// If multiple start states are passed to the construction function and
// they either are identical, or turn out to be equivalent once all the
// epsilon-reachable states are added to them, mapping distinct states
ConstructDFA.xs view on Meta::CPAN
// tion is that states 1..n in the generated DFA correspond to the 1..n
// start state in the input, the duplicates have to be generated here.
for (auto s = start_states.begin(); s != start_states.end(); ++s) {
auto startIx = s->first;
auto state = s->second;
auto startId = m.states_to_id(state);
state_map_r[startIx] = startId;
}
multimap<StatesId, HV*> id_to_hvs;
ConstructDFA.xs view on Meta::CPAN
AV* combines_av = newAV();
SV* combines_rv = newRV_noinc((SV*)combines_av);
HV* next_over_hv = newHV();
SV* next_over_rv = newRV_noinc((SV*)next_over_hv);
auto he1 = hv_store(state_hv, "Accepts", 7, newSVuv(accepting[s->second]), 0);
auto he2 = hv_store(state_hv, "Combines", 8, combines_rv, 0);
auto he3 = hv_store(state_hv, "NextOver", 8, next_over_rv, 0);
vector<State> x = m.id_to_states(s->second);
for (auto k = x.begin(); k != x.end(); ++k) {
av_push(combines_av, newSVuv(*k));
}
dfa[s->first] = state_hv;
id_to_hvs.insert(make_pair(s->second, state_hv));
}
for (auto s = automaton.begin(); s != automaton.end(); ++s) {
StatesId srcId = s->first.first;
Label label = s->first.second;
StatesId dstId = s->second;
if (dfa.find(state_map[srcId]) == dfa.end()) {
croak("...");
}
for (auto p = id_to_hvs.find(srcId); p != id_to_hvs.end(); ++p) {
if (p->first != srcId)
break;
SV** next_over_svp = hv_fetch(p->second, "NextOver", 8, 0);
if (!next_over_svp)
croak("...");
SV* label_sv = newSVuv(label);
ConstructDFA.xs view on Meta::CPAN
auto dfa = build_dfa(accepts_sv, args);
SPAGAIN;
for (auto i = dfa.begin(); i != dfa.end(); ++i) {
mXPUSHs(newSVuv(i->first));
mXPUSHs(newRV_noinc((SV*)(i->second)));
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/ConstructDFA.pm view on Meta::CPAN
A subroutine returning a boolean indicating whether this is an
accepting final state of the automaton. It is passed all the
vertices the states combines. For single-vertex acceptance, it
would usually C<grep> over the arguments. Having access to all
the states of the input automaton allows more complex acceptance
conditions (e.g. to compute the intersection of two graphs).
=item is_nullable
A subroutine returning a boolean indicating whether the automaton
can move past the supplied state without consuming any input.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/CouponCode.pm view on Meta::CPAN
=item *
The checkdigit algorithm takes into account the position of the part being
keyed. So for example '1K7Q' might be valid in the first part but not in the
second so if a user typed the parts in the wrong boxes then their error could
be highlighted.
=item *
The code generation algorithm avoids 'undesirable' codes. For example any code
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Cron.pm view on Meta::CPAN
use strict;
use warnings;
our $VERSION = '0.10';
my @FIELDS = qw( sec min hour mday mon year wday );
my @FIELDS_CTOR = grep { $_ ne "year" } @FIELDS;
use Carp;
use POSIX qw( mktime strftime setlocale LC_TIME );
use Time::timegm qw( timegm );
lib/Algorithm/Cron.pm view on Meta::CPAN
As per F<cron(8)> behaviour, this algorithm looks for a match of the C<min>,
C<hour> and C<mon> fields, and at least one of the C<mday> or C<mday> fields.
If both C<mday> and C<wday> are specified, a match of either will be
sufficient.
As an extension, seconds may be provided either by passing six space-separated
fields in the C<crontab> string, or as an additional C<sec> field. If not
provided it will default to C<0>. If six fields are provided, the first gives
the seconds.
=head2 Time Base
C<Algorithm::Cron> supports using either UTC or the local timezone when
comparing against the given schedule.
=cut
# mday field starts at 1, others start at 0
my %MIN = (
sec => 0,
min => 0,
hour => 0,
mday => 1,
mon => 0
);
# These don't have to be real maxima, as the algorithm will cope. These are
# just the top end of the range expansions
my %MAX = (
sec => 59,
min => 59,
hour => 23,
mday => 31,
mon => 11,
wday => 6,
lib/Algorithm/Cron.pm view on Meta::CPAN
=item crontab => STRING
Gives the crontab schedule in 5 or 6 space-separated fields.
=item sec => STRING, min => STRING, ... mon => STRING
Optional. Gives the schedule in a set of individual fields, if the C<crontab>
field is not specified.
=back
lib/Algorithm/Cron.pm view on Meta::CPAN
@fields = ( "0", @fields ) if @fields < 6;
@params{ @FIELDS_CTOR } = @fields;
}
$params{sec} = 0 unless exists $params{sec};
my $self = bless {
base => $base,
}, $class;
lib/Algorithm/Cron.pm view on Meta::CPAN
=head1 METHODS
=cut
=head2 @seconds = $cron->sec
=head2 @minutes = $cron->min
=head2 @hours = $cron->hour
lib/Algorithm/Cron.pm view on Meta::CPAN
my $self = shift;
my ( $time ) = @_;
my $funcs = $time_funcs{$self->{base}};
# Always need to add at least 1 second
my @t = $funcs->[EXTRACT]->( $time + 1 );
RESTART:
$self->next_time_field( \@t, TM_MON ) or goto RESTART;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/CurveFit/Simple.pm view on Meta::CPAN
# fit() - only public function for this distribution
# Given at least parameter "xy", generate a best-fit curve within a time limit.
# Output: max deviation, avg deviation, implementation source string (perl or C, for now).
# Optional parameters and their defaults:
# terms => 3 # number of terms in formula, max is 10
# time_limit => 3 # number of seconds to try for better fit
# inv => 1 # invert sense of curve-fit, from x->y to y->x
# impl_lang => 'perl' # programming language used for output implementation: perl, c
# impl_name => 'x2y' # name given to output implementation function
sub fit {
my %p = @_;
lib/Algorithm/CurveFit/Simple.pm view on Meta::CPAN
} else {
$time_limit = $p{time_limit} // $time_limit;
$n_iter = 10000 * $time_limit; # will use this to figure out how long it -really- takes.
}
my ($n_sec, $params_ar_ar);
if ($iter_mode eq 'time') {
($n_sec, $params_ar_ar) = _try_fit($formula, $parameters, $xdata, $ydata, $n_iter, $p{fitter_class});
$STATS_H{iter_mode} = $iter_mode;
$STATS_H{fit_calib_iter} = $n_iter;
$STATS_H{fit_calib_time} = $n_sec;
$STATS_H{fit_calib_parar} = $params_ar_ar;
$n_iter = int(($time_limit / $n_sec) * $n_iter + 1);
}
($n_sec, $params_ar_ar) = _try_fit($formula, $parameters, $xdata, $ydata, $n_iter, $p{fitter_class});
$STATS_H{fit_iter} = $n_iter;
$STATS_H{fit_time} = $n_sec;
$STATS_H{fit_parar} = $params_ar_ar;
my $coderef = _implement_formula($params_ar_ar, "coderef", "", $xdata, \%p);
my ($max_dev, $avg_dev) = _calculate_deviation($coderef, $xdata, $ydata);
my $impl_lang = $p{impl_lang} // 'perl';
lib/Algorithm/CurveFit/Simple.pm view on Meta::CPAN
my $impl = $coderef;
$impl = _implement_formula($params_ar_ar, $impl_lang, $impl_name, $xdata, \%p) unless($impl_lang eq 'coderef');
return ($max_dev, $avg_dev, $impl);
}
# ($n_sec, $params_ar_ar) = _try_fit($formula, $parameters, $xdata, $ydata, $n_iter, $p{fitter_class});
sub _try_fit {
my ($formula, $parameters, $xdata, $ydata, $n_iter, $fitter_class) = @_;
$fitter_class //= "Algorithm::CurveFit";
my $params_ar_ar = [map {[@$_]} @$parameters]; # making a copy because curve_fit() is destructive
my $tm0 = Time::HiRes::time();
lib/Algorithm/CurveFit/Simple.pm view on Meta::CPAN
There is no need to specify initial C<k>. It will be calculated from C<xydata>.
=item C<fit(time_limit =E<gt> 3)>
If a time limit is given (in seconds), C<fit()> will spend no more than that long trying to fit the data. It may return in much less time. The default is 3.
=item C<fit(iterations =E<gt> 10000)>
If an iteration count is given, C<fit()> will ignore any time limit and iterate up to C<iterations> times trying to fit the curve. Same as L<Algorithm::CurveFit> parameter of the same name.
lib/Algorithm/CurveFit/Simple.pm view on Meta::CPAN
=item C<deviation_max_offset_datum>: The x data point corresponding with returned maximum deviation.
=item C<fit_calib_parar>: Arrayref of formula parameters as returned by L<Algorithm::CurveFit> after a short fitting attempt used for timing calibration.
=item C<fit_calib_time>: The number of seconds L<Algorithm::CurveFit> spent in the calibration run.
=item C<fit_iter>: The iterations parameter passed to L<Algorithm::CurveFit>.
=item C<fit_parar>: Arrayref of formula parameters as returned by L<Algorithm::CurveFit>.
=item C<fit_time>: The number of seconds L<Algorithm::CurveFit> actually spent fitting the formula.
=item C<impl_exception>: The exception thrown when the implementation was used to calculate the deviations, or the empty string if none.
=item C<impl_formula>: The formula part of the implementation.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/DBSCAN.pm view on Meta::CPAN
my ($self) = @_;
$self->{nb_visited_points}++;
$self->{start_time} = time() unless ($self->{start_time});
my $eta = time() + ((time() - $self->{start_time})/$self->{nb_visited_points})*(500000);
my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($eta);
say "ETA:".sprintf("%04d-%02d-%02d %02d:%02d:%02d",$year+1900,$mon+1,$mday,$hour,$min,$sec);
say "nb visited:".$self->{nb_visited_points};
}
=head1 AUTHOR
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Damm.pm view on Meta::CPAN
This module implements the Damm algorithm for calculating a check
digit.
You can find information about the algorithm by searching the web for
"Damm ECC". In particular, see the L<SEE ALSO> section (below).
=head1 FUNCTIONS
=over 4
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/BoostedDecisionTree.pm view on Meta::CPAN
if ($self->{_stagedebug}) {
print "\nTraining samples for stage $stage_index: @{$self->{_training_samples}->{$stage_index}}\n\n";
my $num_of_training_samples = @{$self->{_training_samples}->{$stage_index}};
print "\nNumber of training samples this stage $num_of_training_samples\n\n";
}
# find intersection of two sets:
my %misclassified_samples = map {$_ => 1} @{$self->{_misclassified_samples}->{$stage_index-1}};
my @training_samples_selection_check = grep $misclassified_samples{$_}, @{$self->{_training_samples}->{$stage_index}};
if ($self->{_stagedebug}) {
my @training_in_misclassified = sort {sample_index($a) <=> sample_index($b)} @training_samples_selection_check;
print "\nTraining samples in the misclassified set: @training_in_misclassified\n";
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
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
lib/Algorithm/Dependency/Source/File.pm view on Meta::CPAN
# Parse and build the item list
my @Items = ();
foreach my $line ( @content ) {
# Split the line by non-word characters
my @sections = grep { length $_ } split /\W+/, $line;
return undef unless scalar @sections;
# Create the new item
my $Item = Algorithm::Dependency::Item->new( @sections ) or return undef;
push @Items, $Item;
}
\@Items;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/DependencySolver/Solver.pm view on Meta::CPAN
my $C = List::Compare->new(\@node_ids, \@pred_ids);
if ($C->is_LsubsetR) {
# We're good; we have a nice linear ordering
next AFFECT;
} else {
my @intersection = $C->get_intersection;
if (@intersection > @sequentials) {
@sequentials = @intersection;
}
}
}
# Nondeterministic affect!
view all matches for this distribution
view release on metacpan or search on metacpan
A "covered work" means either the unmodified Program or a work based on the
Program.
To "propagate" a work means to do anything with it that, without permission,
would make you directly or secondarily liable for infringement under
applicable copyright law, except executing it on a computer or modifying a
private copy. Propagation includes copying, distribution (with or without
modification), making available to the public, and in some countries other
activities as well.
behalf, under your direction and control, on terms that prohibit them from
making any copies of your copyrighted material outside their relationship
with you.
Conveying under any other circumstances is permitted solely under the
conditions stated below. Sublicensing is not allowed; section 10 makes it
unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure
You may convey 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; keep intact all notices
stating that this License and any non-permissive terms added in accord with
section 7 apply to the code; keep intact all notices of the absence of any
warranty; and give all recipients a copy of this License along with the
Program.
You may charge any price or no price for each copy that you convey, and you
may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce
it from the Program, in the form of source code under the terms of section
4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and
giving a relevant date.
b) The work must carry prominent notices stating that it is released under
this License and any conditions added under section 7. This requirement
modifies the requirement in section 4 to "keep intact all notices".
c) You must license the entire work, as a whole, under this License to
anyone who comes into possession of a copy. This License will therefore
apply, along with any applicable section 7 additional terms, to the whole
of the work, and all its parts, regardless of how they are packaged. This
License gives no permission to license the work in any other way, but it
does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of
sections 4 and 5, provided that you also convey the machine-readable
Corresponding Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including
a physical distribution medium), accompanied by the Corresponding Source
fixed on a durable physical medium customarily used for software
interchange.
(2) access to copy the Corresponding Source from a network server at no
charge.
c) Convey individual copies of the object code with a copy of the written
offer to provide the Corresponding Source. This alternative is allowed
only occasionally and noncommercially, and only if you received the
object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis
or for a charge), and offer equivalent access to the Corresponding Source
in the same way through the same place at no further charge. You need not
require recipients to copy the Corresponding Source along with the object
code. If the place to copy the object code is a network server, the
Corresponding Source, you remain obligated to ensure that it is available
for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you
inform other peers where the object code and Corresponding Source of the
work are being offered to the general public at no charge under
subsection 6d.
A separable portion of the object code, whose source code is excluded from
the Corresponding Source as a System Library, need not be included in
conveying the object code work.
modified versions of a covered work in that User Product from a modified
version of its Corresponding Source. The information must suffice to ensure
that the continued functioning of the modified object code is in no case
prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as part of
a transaction in which the right of possession and use of the User Product
is transferred to the recipient in perpetuity or for a fixed term
(regardless of how the transaction is characterized), the Corresponding
Source conveyed under this section must be accompanied by the Installation
Information. But this requirement does not apply if neither you nor any
third party retains the ability to install modified object code on the User
Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a
be denied when the modification itself materially and adversely affects the
operation of the network or violates the rules and protocols for
communication across the network.
Corresponding Source conveyed, and Installation Information provided, in
accord with this section must be in a format that is publicly documented
(and with an implementation available to the public in source code form),
and must require no special password or key for unpacking, reading or
copying.
7. Additional Terms.
Notwithstanding any other provision of this License, for material you add to
a covered work, you may (if authorized by the copyright holders of that
material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of
sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author
attributions in that material or in the Appropriate Legal Notices
displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in reasonable
contractual assumptions of liability to the recipient, for any liability
that these contractual assumptions directly impose on those licensors and
authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further restriction,
you may remove that term. If a license document contains a further
restriction but permits relicensing or conveying under this License, you may
add to a covered work material governed by the terms of that license
document, provided that the further restriction does not survive such
relicensing or conveying.
If you add terms to a covered work in accord with this section, you must
place, in the relevant source files, a statement of the additional terms
that apply to those files, or a notice indicating where to find the
applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of
8. Termination.
You may not propagate or modify a covered work except as expressly provided
under this License. Any attempt otherwise to propagate or modify it is void,
and will automatically terminate your rights under this License (including
any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from
a particular copyright holder is reinstated
(a) provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and
permanently if the copyright holder notifies you of the violation by some
reasonable means, this is the first time you have received notice of
violation of this License (for any work) from that copyright holder, and you
cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under this
License. If your rights have been terminated and not permanently reinstated,
you do not qualify to receive new licenses for the same material under
section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a
copy of the Program. Ancillary propagation of a covered work occurring
Notwithstanding any other provision of this License, you have permission to
link or combine any covered work with a work licensed under version 3 of the
GNU Affero General Public License into a single combined work, and to convey
the resulting work. The terms of this License will continue to apply to the
part which is the covered work, but the special requirements of the GNU
Affero General Public License, section 13, concerning interaction through a
network will apply to the combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the
view all matches for this distribution
view release on metacpan or search on metacpan
t/80optsimple.t view on Meta::CPAN
my $derived2 = [qw{a b c d e f 1 2 3 h i j k l m n o p q}];
my $changes2 = diff($original, $derived2);
$result = join(':', apply_diffs($original, {optimisers => TEST_OPTIMISERS},
'_03_third' => $changes2,
'_02_second' => $changes, # }__ identical
'_01_first' => $changes, # }
));
ok($result =~ />>>/);
ok($result =~ />>>\s+_01_first/);
ok($result !~ />>>\s+_02_second/);
ok($result =~ />>>\s+_03_third/);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Diff/JSON.pm view on Meta::CPAN
C<diff> function:
=head2 json_diff
This takes two list-ref arguments. It returns a JSON array describing the
changes needed to transform the first into the second.
This function may be exported. If you want to export it with a different name
then you can do so:
use Algorithm::Diff::JSON 'json_diff' => { -as => 'something_else };
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install/Metadata.pm view on Meta::CPAN
}
$self->version_from($file) unless $self->version;
$self->perl_version_from($file) unless $self->perl_version;
# The remaining probes read from POD sections; if the file
# has an accompanying .pod, use that instead
my $pod = $file;
if ( $pod =~ s/\.pm$/.pod/i and -e $pod ) {
$file = $pod;
}
inc/Module/Install/Metadata.pm view on Meta::CPAN
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
$hunk->{"end1"} += $num_added;
$hunk->{"end2"} += $num_added;
}
# Is there an overlap between hunk arg0 and old hunk arg1?
# Note: if end of old hunk is one less than beginning of second, they overlap
sub does_overlap {
my ($hunk, $oldhunk) = @_;
return "" unless $oldhunk; # first time through, $oldhunk is empty
# Do I actually need to test both?
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install/Metadata.pm view on Meta::CPAN
}
$self->version_from($file) unless $self->version;
$self->perl_version_from($file) unless $self->perl_version;
# The remaining probes read from POD sections; if the file
# has an accompanying .pod, use that instead
my $pod = $file;
if ( $pod =~ s/\.pm$/.pod/i and -e $pod ) {
$file = $pod;
}
inc/Module/Install/Metadata.pm view on Meta::CPAN
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
lib/Algorithm/DistanceMatrix.pm view on Meta::CPAN
Where C<mydistance> receives two objects as it's first two arguments.
If you need to pass special parameters to your method:
$matrix->metric(sub{my($x,$y)=@_;mydistance(first=>$x,second=>$y,mode=>'fast')};
You may use any metric, and may return any number or object. Note that if you
plan to use this with L<Algorithm::Cluster> this needs to be a distance metric.
So, if you're measure how similar two things are, on a scale of 1-10, then you
should return C<10-$similarity> to get a distance.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Easing.pm view on Meta::CPAN
my $b = 0;
# change
my $c = 0;
# time passed in seconds as a real positive integer between each frame
my $frame_time = 0.0625;
my @p = [319,0];
for(my $t = 0; $t < 2.5; $t += 0.0625) {
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/Evolutionary/Simple.pm view on Meta::CPAN
my $offspring_size = shift || croak "Population size needed";
my @population = ();
my $population_size = scalar( @$pool );
for ( my $i = 0; $i < $offspring_size/2; $i++ ) {
my $first = $pool->[rand($population_size)];
my $second = $pool->[rand($population_size)];
push @population, crossover( $first, $second );
}
map( $_ = mutate($_), @population );
return @population;
}
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/Evolutionary/Hash_Wheel.pm view on Meta::CPAN
for ( sort keys %probs ) { $acc += $probs{$_};}
for ( sort keys %probs ) { $probs{$_} /= $acc;} #Normalizes array
#Now creates the accumulated array, putting the accumulated
#probability in the first element arrayref element, and the object
#in the second
my $aux = 0;
for ( sort keys %probs ) {
push @{$self->{_accProbs}}, [$probs{$_} + $aux,$_ ];
$aux += $probs{$_};
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Evolve.pm view on Meta::CPAN
=head2 Adding Selection/Replacement Methods
To add your own selection and replacement methods, simply declare them in
the C<Algorithm::Evolve::selection> or C<Algorithm::Evolve::replacement>
namespaces, respectively. The first argument will be the population object,
and the second will be the number of critters to choose for
selection/replacement. You should return a list of the I<indices> you chose.
use Algorithm::Evolve;
sub Algorithm::Evolve::selection::reverse_absolute {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
my $model_complexity_penalty = 0.5 * $L * log( $self->{_N} );
my $mdl_criterion = -1 * $log_likelihood + $model_complexity_penalty;
return $mdl_criterion;
}
# For our second measure of clustering quality, we use `trace( SW^-1 . SB)' where SW
# is the within-class scatter matrix, more commonly denoted S_w, and SB the
# between-class scatter matrix, more commonly denoted S_b (the underscore means
# subscript). This measure can be thought of as the normalized average distance
# between the clusters, the normalization being provided by average cluster
# covariance SW^-1. Therefore, the larger the value of this quality measure, the
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
die "\n\nABORTED: The width of the visualization mask (including " .
"all its 1s and 0s) must equal the width of the original mask " .
"used for reading the data file (counting only the 1's)"
if $visualization_mask_width != $data_field_width;
my $visualization_data_field_width = scalar grep {$_ eq '1'} @v_mask;
# The following section is for the superimposed one-Mahalanobis-distance-unit
# ellipses that are shown only for 2D plots:
if ($visualization_data_field_width == 2) {
foreach my $cluster_index (0..$self->{_K}-1) {
my $contour_filename = "__contour_" . $cluster_index . ".dat";
my $mean = $self->{_cluster_means}->[$cluster_index];
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
my $datafile = "mydatafile.csv";
# Next, set the mask to indicate which columns of the datafile to use for
# clustering and which column contains a symbolic ID for each data record. For
# example, if the symbolic name is in the first column, you want the second column
# to be ignored, and you want the next three columns to be used for 3D clustering:
my $mask = "N0111";
# Now construct an instance of the clusterer. The parameter `K' controls the
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
probabilities at each of the data points; (2) Using the updated posterior class
probabilities, first update the class priors; (3) Using the updated class priors,
update the class means and the class covariances; and go back to Step (1). Ideally,
the iterations should terminate when the expected log-likelihood of the observed data
has reached a maximum and does not change with any further iterations. The stopping
rule used in this module is the detection of no change over three consecutive
iterations in the values calculated for the priors.
This module provides three different choices for seeding the clusters: (1) random,
(2) kmeans, and (3) manual. When random seeding is chosen, the algorithm randomly
selects C<K> data elements as cluster seeds. That is, the data vectors associated
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
increases. The form of the MDL criterion in this module uses for the penalty term
the Bayesian Information Criterion (BIC) of G. Schwartz, "Estimating the Dimensions
of a Model," The Annals of Statistics, 1978. In general, the smaller the value of
MDL quality measure, the better the clustering of the data.
For our second measure of clustering quality, we use `trace( SW^-1 . SB)' where SW is
the within-class scatter matrix, more commonly denoted S_w, and SB the between-class
scatter matrix, more commonly denoted S_b (the underscore means subscript). This
measure can be thought of as the normalized average distance between the clusters,
the normalization being provided by average cluster covariance SW^-1. Therefore, the
larger the value of this quality measure, the better the separation between the
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
clustering is decided by the string value of the mask. For
example, if we wanted to cluster on the basis of the entries
in just the 3rd, the 4th, and the 5th columns above, the
mask value would be C<N0111> where the character C<N>
indicates that the ID tag is in the first column, the
character C<0> that the second column is to be ignored, and
the C<1>'s that follow that the 3rd, the 4th, and the 5th
columns are to be used for clustering.
If instead of random seeding, you wish to use the kmeans
based seeding, just replace the option C<random> supplied
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
Math::Random
Graphics::GnuplotIF
Math::GSL::Matrix
the first for generating the multivariate random numbers, the second for the
visualization of the clusters, and the last for access to the Perl wrappers for the
GNU Scientific Library. The C<Matrix> module of this library is used for various
algebraic operations on the covariance matrices of the Gaussians.
=head1 EXPORT
view all matches for this distribution
view release on metacpan or search on metacpan
Prepares to decode C<data_blocks> of blocks (see C<set_encode_blocks> for
the C<array_of_blocks> parameter).
Since these are not usually the original data blocks, an array of
indices (ranging from C<0> to C<encoded_blocks-1>) must be supplied as
the second arrayref.
Both arrays must have exactly C<data_blocks> entries.
This method also reorders the blocks and index array in place (if
necessary) to reflect the order the blocks will have in the decoded
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
inc/Module/Install/AutoInstall.pm view on Meta::CPAN
$self->makemaker_args( Module::AutoInstall::_make_args() );
my $class = ref($self);
$self->postamble(
"# --- $class section:\n" .
Module::AutoInstall::postamble()
);
}
sub auto_install_now {
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