view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
$args{path} = $args{name};
$args{path} =~ s!::!/!g;
}
$args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm";
bless( \%args, $class );
}
sub call {
my ($self, $method) = @_;
my $obj = $self->load($method) or return;
view all matches for this distribution
view release on metacpan or search on metacpan
t/000-report-versions.t view on Meta::CPAN
# Implementation
# Create an empty YAML::Tiny object
sub new {
my $class = shift;
bless [ @_ ], $class;
}
# Create an object from a file
sub read {
my $class = ref $_[0] ? ref shift : shift;
t/000-report-versions.t view on Meta::CPAN
}
# Create an object from a string
sub read_string {
my $class = ref $_[0] ? ref shift : shift;
my $self = bless [], $class;
my $string = $_[0];
unless ( defined $string ) {
return $self->_error("Did not provide a string to load");
}
t/000-report-versions.t view on Meta::CPAN
# Failed to load Scalar::Util
eval <<'END_PERL';
sub refaddr {
my $pkg = ref($_[0]) or return undef;
if (!!UNIVERSAL::can($_[0], 'can')) {
bless $_[0], 'Scalar::Util::Fake';
} else {
$pkg = undef;
}
"$_[0]" =~ /0x(\w+)/;
my $i = do { local $^W; hex $1 };
bless $_[0], $pkg if defined $pkg;
$i;
}
END_PERL
} else {
Scalar::Util->import('refaddr');
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Evolutionary/Fitness.pm view on Meta::CPAN
=cut
sub new {
my $class = shift;
my $self = {};
bless $self, $class;
$self->initialize();
return $self;
}
=head2 initialize()
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Evolutionary/Experiment.pm view on Meta::CPAN
push @{$self->{_pop}}, $indi;
}
};
@_ || croak "Can't find an algorithm";
push @{$self->{_algo}}, @_;
bless $self, $class;
return $self
}
=head2 go
view all matches for this distribution
view release on metacpan or search on metacpan
examples/ArrayEvolver.pm view on Meta::CPAN
sub new {
my $pkg = shift;
my $array = shift
|| arr_random($configs{gene_length}, $configs{alphabet});
return bless { _gene => $array }, $pkg;
}
sub crossover {
my ($pkg, $c1, $c2) = @_;
return map { $pkg->new($_) }
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
use Carp;
use File::Basename;
use Math::Random;
use Graphics::GnuplotIF;
use Math::GSL::Matrix;
use Scalar::Util 'blessed';
our $VERSION = '1.22';
# from perl docs:
my $_num_regex = '^[+-]?\ *(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$';
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
my ($class, %args) = @_;
my @params = keys %args;
croak "\nYou have used a wrong name for a keyword argument " .
"--- perhaps a misspelling\n"
if check_for_illegal_params(@params) == 0;
bless {
_datafile => $args{datafile} || croak("datafile required"),
_mask => $args{mask} || croak("mask required"),
_K => $args{K} || croak("number of clusters required"),
_terminal_output => $args{terminal_output} || 0,
_seeding => $args{seeding} || 'random',
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
my $outer_product = outer_product( $class_mean_minus_global_mean,
$class_mean_minus_global_mean );
$S_b += $self->{_class_priors}->[$cluster_index] * $outer_product;
}
my $fisher = matrix_multiply($S_w->inverse, $S_b);
return $fisher unless defined blessed($fisher);
return matrix_trace($fisher);
}
sub display_seeding_stats {
my $self = shift;
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
display_matrix( "datavec minus mean is ", $datavec_minus_mean ) if $self->{_debug};
my $exponent = undef;
if ($self->{_data_dimensions} > 1) {
$exponent = -0.5 * vector_matrix_multiply( transpose($datavec_minus_mean),
matrix_vector_multiply( $covar_ref->inverse(), $datavec_minus_mean ) );
} elsif (defined blessed($covar_ref)) {
my @data_minus_mean = $datavec_minus_mean->as_list;
my $data_minus_mean_val = $data_minus_mean[0];
my @covar_as_matrix = $covar_ref->as_list;
my $covar_val = $covar_as_matrix[0];
$exponent = -0.5 * ($data_minus_mean_val ** 2) / $covar_val;
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
print "\nThe value of the exponent is: $exponent\n\n" if $self->{_debug};
my $coefficient = undef;
if ($self->{_data_dimensions} > 1) {
$coefficient = 1.0 / sqrt( ((2 * $Math::GSL::Const::M_PI) ** $self->{_data_dimensions}) *
$covar_ref->det()) ;
} elsif (!defined blessed($covar_ref)) {
$coefficient = 1.0 / sqrt(2 * $covar_ref * $Math::GSL::Const::M_PI);
} else {
my @covar_as_matrix = $covar_ref->as_list;
my $covar_val = $covar_as_matrix[0];
$coefficient = 1.0 / sqrt(2 * $covar_val * $Math::GSL::Const::M_PI);
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
}
sub display_matrix {
my $message = shift;
my $matrix = shift;
if (!defined blessed($matrix)) {
print "display_matrix called on a scalar value: $matrix\n";
return;
}
my $nrows = $matrix->rows();
my $ncols = $matrix->cols();
view all matches for this distribution
view release on metacpan or search on metacpan
"not ok 13\t# $@\n");
}
my $c;
package TieTest;
sub TIEARRAY {bless []}
sub FETCHSIZE {5}
sub FETCH { ++$c; $_[1]}
sub c {$c}
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
$args{path} =~ s!::!/!g;
}
$args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm";
$args{wrote} = 0;
bless( \%args, $class );
}
sub call {
my ($self, $method) = @_;
my $obj = $self->load($method) or return;
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
$args{path} =~ s!::!/!g;
}
$args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm";
$args{wrote} = 0;
bless( \%args, $class );
}
sub call {
my ($self, $method) = @_;
my $obj = $self->load($method) or return;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Functional/BFS.pm view on Meta::CPAN
victory_func => $opts{victory_func},
include_start_node => $opts{include_start_node},
one_result => $opts{one_result},
);
bless(\%self, $class);
}
=head2 search($start_node)
Perform a breadth-first-search from the specified node until the depth at
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
$args{path} =~ s!::!/!g;
}
$args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm";
$args{wrote} = 0;
bless( \%args, $class );
}
sub call {
my ($self, $method) = @_;
my $obj = $self->load($method) or return;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/GaussianElimination/GF2.pm view on Meta::CPAN
use warnings;
sub new {
my $class = shift;
my $self = { eqs => [] };
bless $self, $class;
}
sub _add_equation {
my ($self, $eq) = @_;
push @{$self->{eqs}}, $eq;
lib/Algorithm/GaussianElimination/GF2.pm view on Meta::CPAN
package Algorithm::GaussianElimination::GF2::Equation;
sub _new {
my $class = shift;
my $self = ['', 0, 0];
bless $self, $class;
if (@_) {
$self->[1] = (pop @_ ? 1 : 0);
for my $ix (0..$#_) {
vec($self->[0], $ix, 1) = $_[$ix]
}
lib/Algorithm/GaussianElimination/GF2.pm view on Meta::CPAN
}
sub clone {
my $self = shift;
my @self = @$self;
bless \@self, ref $self;
}
1;
__END__
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/GenerateSequence.pm view on Meta::CPAN
my @values = @_;
my @counters = (0) x @values;
my ($started, $ended);
bless sub {
return if $ended;
if ($started++) {
my $max = $#counters;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Genetic/Diploid/Base.pm view on Meta::CPAN
delete $self{'experiment'};
}
# create the object
my $obj = \%self;
bless $obj, $package;
# maybe the object was the experiment?
if ( $obj->isa('Algorithm::Genetic::Diploid::Experiment') ) {
$experiment = $obj;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/GoldenSection.pm view on Meta::CPAN
sub new {
my ( $class, $h_ref ) = @_;
croak qq{\nArguments must be passed as HASH reference.} if ( ( $h_ref ) && ( ref $h_ref ne q{HASH} ) );
my $self = {};
bless $self, $class;
$self->_check_options($h_ref);
return $self;
}
sub _check_options {
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
$args{path} = $args{name};
$args{path} =~ s!::!/!g;
}
$args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm";
bless( \%args, $class );
}
sub call {
my ($self, $method) = @_;
my $obj = $self->load($method) or return;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/HITS.pm view on Meta::CPAN
our $VERSION = '0.04';
use fields qw(graph graph_t size hub_v aut_v);
sub new { bless {}, $_[0] }
use PDL;
use List::Util;
#use Data::Dumper;
use PDL::IO::Dumper;
view all matches for this distribution
view release on metacpan or search on metacpan
sv_2uv_flags||5.009001|
sv_2uv|5.004000||p
sv_add_arena|||
sv_add_backref|||
sv_backoff|||
sv_bless|||
sv_cat_decode||5.008001|
sv_catpv_flags||5.013006|
sv_catpv_mg|5.004050||p
sv_catpv_nomg||5.013006|
sv_catpvf_mg_nocontext|||pvn
view all matches for this distribution
view release on metacpan or search on metacpan
max_length_encoding_key => max( map length, keys %encode ),
max_length_decoding_key => max( map length, keys %decode ),
min_length_decoding_key => min( map length, keys %decode )
};
bless $self, $class;
}
sub encode_hash {
my $self = shift;
$self->{encode};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/HyperLogLog/PP.pm view on Meta::CPAN
k => $k,
m => $m,
registers => $registers,
alphaMM => $alpha * $m * $m,
};
bless $self, $class;
return $self;
}
sub _new_from_dump {
my ( $class, $k, $data ) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/IRCSRP2/Exchange.pm view on Meta::CPAN
# ABSTRACT: utility functions
use Moose::Role;
# core
use Scalar::Util qw(blessed);
foreach my $k (qw(I x a A b B S u K1 K2 M1 M2 P s v)) {
has $k => (
'isa' => 'Any',
'is' => 'rw',
lib/Algorithm/IRCSRP2/Exchange.pm view on Meta::CPAN
my $formatstr = sub {
my ($string) = @_;
my $retstr;
if (blessed($string)) {
$retstr = (blessed($string) eq 'Math::BigInt') ? $string->bstr : $retstr;
}
elsif (!defined($string)) {
$retstr = 'undef';
}
else {
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
$args{path} = $args{name};
$args{path} =~ s!::!/!g;
}
$args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm";
bless( \%args, $class );
}
sub call {
my ($self, $method) = @_;
my $obj = $self->load($method) or return;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/KMeans.pm view on Meta::CPAN
my ($class, %args) = @_;
my @params = keys %args;
croak "\nYou have used a wrong name for a keyword argument " .
"--- perhaps a misspelling\n"
if check_for_illegal_params(@params) == 0;
bless {
_datafile => $args{datafile} || croak("datafile required"),
_mask => $args{mask} || croak("mask required"),
_K => $args{K} || 0,
_K_min => $args{Kmin} || 'unknown',
_K_max => $args{Kmax} || 'unknown',
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/KNN/XS.pm view on Meta::CPAN
$ANN_SPLIT_RULE{$args{split_rule}},
$ANN_SHRINK_RULE{$args{shrink_rule}},
),
};
bless $self, $class;
return $self;
}
=over 4
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
$args{path} =~ s!::!/!g;
}
$args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm";
$args{wrote} = 0;
bless( \%args, $class );
}
sub call {
my ($self, $method) = @_;
my $obj = $self->load($method) or return;
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
$args{path} =~ s!::!/!g;
}
$args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm";
$args{wrote} = 0;
bless( \%args, $class );
}
sub call {
my ($self, $method) = @_;
my $obj = $self->load($method) or return;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Knap01DP.pm view on Meta::CPAN
};
croak "Profits and Weights don't have the same size"
unless scalar(@{$self->{weights}}) == scalar(@{$self->{profits}});
bless $self, $class;
}
sub Knap01DP {
my $self = shift();
my $M = $self->{capacity};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Knapsack.pm view on Meta::CPAN
weights => [], # weights to be packed into the knapsack
@_,
solutions => [], # lol of indexes to weights
emptiness => 0, # capacity minus sum of weights in a solution
};
bless $self, $class;
}
=item B<compute>
$knapsack->compute();
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
$args{path} = $args{name};
$args{path} =~ s!::!/!g;
}
$args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm";
bless( \%args, $class );
}
sub call {
my ($self, $method) = @_;
my $obj = $self->load($method) or return;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/LDA.pm view on Meta::CPAN
$numWords = $self->{_numWords};
$stop = $self->{_stop};
@{$self->{documents}} = ();
bless $self, $class;
init();
return $self;
}
view all matches for this distribution