view release on metacpan or search on metacpan
JumpHash.xs view on Meta::CPAN
int32_t
jumphash_numeric(uint64_t key, int32_t num_buckets)
CODE:
RETVAL = JumpConsistentHash(key, num_buckets);
OUTPUT: RETVAL
int32_t
jumphash_siphash(SV *str, uint64_t num_buckets)
CODE:
{
JumpHash.xs view on Meta::CPAN
/* FIXME */
const char * strval = SvPVbyte(str, len);
const uint64_t hashval = siphash_2_4_from_perl(strval, len);
RETVAL = JumpConsistentHash(hashval, num_buckets);
}
OUTPUT: RETVAL
view all matches for this distribution
view release on metacpan or search on metacpan
xs/Ketama.xs view on Meta::CPAN
mXPUSHp( "Algorithm::ConsistentHash::Ketama::Bucket", 41 );
mXPUSHp( "label", 5 );
mXPUSHp( s.label, strlen(s.label) );
mXPUSHp( "weight", 6 );
mXPUSHi( s.weight );
PUTBACK;
call_method("new", G_SCALAR);
SPAGAIN;
sv = POPs;
SvREFCNT_inc(sv);
PUTBACK;
FREETMPS;
LEAVE;
}
XPUSHs( sv );
}
view all matches for this distribution
view release on metacpan or search on metacpan
ConstructDFA.xs view on Meta::CPAN
for (auto i = s.begin(); i != s.end(); ++i) {
mXPUSHs(newSVuv(*i));
}
PUTBACK;
I32 count = call_sv(accept_sv, G_SCALAR);
SPAGAIN;
ConstructDFA.xs view on Meta::CPAN
result = (bool)POPi;
} else {
warn("bad accept");
}
PUTBACK;
FREETMPS;
LEAVE;
return result;
}
ConstructDFA.xs view on Meta::CPAN
PREINIT:
AV* args;
PPCODE:
args = (AV*)SvRV(args_sv);
PUTBACK;
auto dfa = build_dfa(accepts_sv, args);
SPAGAIN;
for (auto i = dfa.begin(); i != dfa.end(); ++i) {
mXPUSHs(newSVuv(i->first));
view all matches for this distribution
view release on metacpan or search on metacpan
Examples/classify_test_data_in_a_file.pl view on Meta::CPAN
my (@all_class_names, @feature_names, %class_for_sample_hash, %feature_values_for_samples_hash,
%features_and_values_hash, %features_and_unique_values_hash,
%numeric_features_valuerange_hash, %feature_values_how_many_uniques_hash);
get_test_data_from_csv();
open OUTPUTHANDLE, ">$outputfile"
or die "Unable to open the file $outputfile for writing out the classification results: $!";
if ($show_hard_classifications && ($outputfile !~ /\.csv$/i)) {
print OUTPUTHANDLE "\nOnly the most probable class shown for each test sample\n\n";
} elsif (!$show_hard_classifications && ($outputfile !~ /\.csv$/i)) {
print OUTPUTHANDLE "\nThe classification result for each sample ordered in decreasing order of probability\n\n";
}
if ($outputfile =~ /\.csv$/i) {
my $class_names_csv = join ',', sort @{$dt->{_class_names}};
my $output_string = "sample_index,$class_names_csv\n";
print OUTPUTHANDLE "$output_string";
foreach my $sample (sort {sample_index($a) <=> sample_index($b)}
keys %feature_values_for_samples_hash) {
my @test_sample = @{$feature_values_for_samples_hash{$sample}};
my %classification = %{$dt->classify($root_node, \@test_sample)};
my $sample_index = sample_index($sample);
Examples/classify_test_data_in_a_file.pl view on Meta::CPAN
$which_class =~ /=(.*)/;
my $class_name = $1;
my $valuestring = $classification{$which_class};
$output_string .= ",$valuestring";
}
print OUTPUTHANDLE "$output_string\n";
}
} else {
foreach my $sample (sort {sample_index($a) <=> sample_index($b)}
keys %feature_values_for_samples_hash) {
my @test_sample = @{$feature_values_for_samples_hash{$sample}};
Examples/classify_test_data_in_a_file.pl view on Meta::CPAN
my $which_class = $which_classes[0];
$which_class =~ /=(.*)/;
my $class_name = $1;
my $valuestring = sprintf("%-20s", $classification{$which_class});
$result_string .= "$class_name => $valuestring ";
print OUTPUTHANDLE "$result_string\n";
} else {
foreach my $which_class (@which_classes) {
$which_class =~ /=(.*)/;
my $class_name = $1;
my $valuestring = sprintf("%-20s", $classification{$which_class});
$result_string .= "$class_name => $valuestring ";
}
print OUTPUTHANDLE "$result_string\n";
}
}
}
sub get_test_data_from_csv {
view all matches for this distribution
view release on metacpan or search on metacpan
PUSHmortal|5.009002||p
PUSHn|||
PUSHp|||
PUSHs|||
PUSHu|5.004000||p
PUTBACK|||
PerlIO_clearerr||5.007003|
PerlIO_close||5.007003|
PerlIO_eof||5.007003|
PerlIO_error||5.007003|
PerlIO_fileno||5.007003|
eval_sv(sv, G_SCALAR);
SvREFCNT_dec(sv);
SPAGAIN;
sv = POPs;
PUTBACK;
if (croak_on_error && SvTRUE(GvSV(errgv)))
croak(SvPVx(GvSV(errgv), na));
return sv;
view all matches for this distribution
view release on metacpan or search on metacpan
unshift (@{$hunk->{"blocks"}}, @{$oldhunk->{"blocks"}});
}
# DIFF OUTPUT ROUTINES. THESE ROUTINES CONTAIN DIFF FORMATTING INFO...
sub output_diff {
if (defined $main::opt_u) {&output_unified_diff(@_)}
elsif (defined $main::opt_c) {&output_context_diff(@_)}
else {die "unknown diff"}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
my $mask = $self->{_mask};
my @mask = split //, $mask;
$self->{_data_dimensions} = scalar grep {$_ eq '1'} @mask;
print "data dimensionality: $self->{_data_dimensions} \n"
if $self->{_terminal_output};
open INPUT, $datafile
or die "unable to open file $datafile: $!";
chomp( my @raw_data = <INPUT> );
close INPUT;
# Transform strings into number data
foreach my $record (@raw_data) {
next unless $record;
next if $record =~ /^#/;
my @data_fields;
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
}
my $K = scalar @{$self->{_clusters}};
my $filename = basename($master_datafile);
my $temp_file = "__temp_" . $filename;
unlink $temp_file if -e $temp_file;
open OUTPUT, ">$temp_file"
or die "Unable to open a temp file in this directory: $!";
foreach my $cluster (@{$self->{_clusters}}) {
foreach my $item (@$cluster) {
print OUTPUT "@{$visualization_data{$item}}";
print OUTPUT "\n";
}
print OUTPUT "\n\n";
}
close OUTPUT;
my $plot;
if (!defined $pause_time) {
$plot = Graphics::GnuplotIF->new( persist => 1 );
} else {
$plot = Graphics::GnuplotIF->new();
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
$arg_string .= "\"$temp_file\" index $i using 1:2 title \"Cluster (naive Bayes) $i\" with points lt $j pt $j, ";
my $ellipse_filename = "__contour_" . $i . ".dat";
$arg_string .= "\"$ellipse_filename\" with line lt $j title \"\", ";
}
} elsif ($visualization_data_field_width == 1 ) {
open INPUT, "$temp_file" or die "Unable to open a temp file in this directory: $!";
my @all_data = <INPUT>;
close INPUT;
@all_data = map {chomp $_; $_ =~ /\d/ ? $_ : "SEPERATOR" } @all_data;
my $all_joined_data = join ':', @all_data;
my @separated = split /:SEPERATOR:SEPERATOR/, $all_joined_data;
my (@all_clusters_for_hist, @all_minvals, @all_maxvals, @all_minmaxvals);
foreach my $i (0..@separated-1) {
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
$plot->gnuplot_cmd("set xtics rotate by 90 offset 0,-5 out nomirror");
foreach my $cindex (0..@all_clusters_for_hist-1) {
my $filename = basename($master_datafile);
my $temp_file = "__temp1dhist_" . "$cindex" . "_" . $filename;
unlink $temp_file if -e $temp_file;
open OUTPUT, ">$temp_file" or die "Unable to open a temp file in this directory: $!";
print OUTPUT "Xstep histval\n";
my @histogram = (0) x 100;
foreach my $i (0..@{$all_clusters_for_hist[$cindex]}-1) {
$histogram[int( ($all_clusters_for_hist[$cindex][$i] - $abs_minval) / $delta )]++;
}
foreach my $i (0..@histogram-1) {
print OUTPUT "$i $histogram[$i]\n";
}
$arg_string .= "\"$temp_file\" using 2:xtic(1) ti col smooth frequency with boxes lc $cindex, ";
close OUTPUT;
}
}
$arg_string = $arg_string =~ /^(.*),[ ]+$/;
$arg_string = $1;
if ($visualization_data_field_width > 2) {
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
}
my $K = scalar @{$self->{_clusters}};
my $filename = basename($master_datafile);
my $temp_file = "__temp_" . $filename;
unlink $temp_file if -e $temp_file;
open OUTPUT, ">$temp_file"
or die "Unable to open a temp file in this directory: $!";
foreach my $cluster (@{$self->{_clusters}}) {
foreach my $item (@$cluster) {
print OUTPUT "@{$visualization_data{$item}}";
print OUTPUT "\n";
}
print OUTPUT "\n\n";
}
close OUTPUT;
my $plot;
if (!defined $pause_time) {
$plot = Graphics::GnuplotIF->new( persist => 1 );
} else {
$plot = Graphics::GnuplotIF->new();
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
$arg_string .= "\"$temp_file\" index $i using 1:2 title \"Cluster (naive Bayes) $i\" with points lt $j pt $j, ";
my $ellipse_filename = "__contour_" . $i . ".dat";
$arg_string .= "\"$ellipse_filename\" with line lt $j title \"\", ";
}
} elsif ($visualization_data_field_width == 1 ) {
open INPUT, "$temp_file" or die "Unable to open a temp file in this directory: $!";
my @all_data = <INPUT>;
close INPUT;
@all_data = map {chomp $_; $_ =~ /\d/ ? $_ : "SEPERATOR" } @all_data;
my $all_joined_data = join ':', @all_data;
my @separated = split /:SEPERATOR:SEPERATOR/, $all_joined_data;
my (@all_clusters_for_hist, @all_minvals, @all_maxvals, @all_minmaxvals);
foreach my $i (0..@separated-1) {
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
$plot->gnuplot_cmd("set xtics rotate by 90 offset 0,-5 out nomirror");
foreach my $cindex (0..@all_clusters_for_hist-1) {
my $filename = basename($master_datafile);
my $temp_file = "__temp1dhist_" . "$cindex" . "_" . $filename;
unlink $temp_file if -e $temp_file;
open OUTPUT, ">$temp_file" or die "Unable to open a temp file in this directory: $!";
print OUTPUT "Xstep histval\n";
my @histogram = (0) x 100;
foreach my $i (0..@{$all_clusters_for_hist[$cindex]}-1) {
$histogram[int( ($all_clusters_for_hist[$cindex][$i] - $abs_minval) / $delta )]++;
}
foreach my $i (0..@histogram-1) {
print OUTPUT "$i $histogram[$i]\n";
}
# $arg_string .= "\"$temp_file\" using 1:2 ti col smooth frequency with boxes lc $cindex, ";
$arg_string .= "\"$temp_file\" using 2:xtic(1) ti col smooth frequency with boxes lc $cindex, ";
close OUTPUT;
}
}
$arg_string = $arg_string =~ /^(.*),[ ]+$/;
$arg_string = $1;
if ($visualization_data_field_width > 2) {
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
$visualization_data{ $record_id } = \@data_fields;
}
my $filename = basename($self->{_datafile});
my $temp_file = "__temp2_" . $filename;
unlink $temp_file if -e $temp_file;
open OUTPUT, ">$temp_file"
or die "Unable to open a temp file in this directory: $!";
my @class_distributions;
foreach my $cluster_index (0..$self->{_K}-1) {
push @class_distributions, [];
}
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
if $self->{_expected_class_probs}->{$data_tag}->[$cluster_index] > 0.2;
}
}
foreach my $distribution (@class_distributions) {
foreach my $item (@$distribution) {
print OUTPUT "@$item";
print OUTPUT "\n";
}
print OUTPUT "\n\n";
}
close OUTPUT;
my $plot;
if (!defined $pause_time) {
$plot = Graphics::GnuplotIF->new( persist => 1 );
} else {
$plot = Graphics::GnuplotIF->new();
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
$arg_string .= "\"$temp_file\" index $i using 1:2 title \"Cluster $i (based on posterior probs)\" with points lt $j pt $j, ";
my $ellipse_filename = "__contour2_" . $i . ".dat";
$arg_string .= "\"$ellipse_filename\" with line lt $j title \"\", ";
}
} elsif ($visualization_data_field_width == 1 ) {
open INPUT, "$temp_file" or die "Unable to open a temp file in this directory: $!";
my @all_data = <INPUT>;
close INPUT;
@all_data = map {chomp $_; $_ =~ /\d/ ? $_ : "SEPERATOR" } @all_data;
my $all_joined_data = join ':', @all_data;
my @separated = split /:SEPERATOR:SEPERATOR/, $all_joined_data;
my (@all_clusters_for_hist, @all_minvals, @all_maxvals, @all_minmaxvals);
foreach my $i (0..@separated-1) {
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
$plot->gnuplot_cmd("set xtics rotate by 90 offset 0,-5 out nomirror");
foreach my $cindex (0..@all_clusters_for_hist-1) {
my $localfilename = basename($filename);
my $temp_file = "__temp1dhist_" . "$cindex" . "_" . $localfilename;
unlink $temp_file if -e $temp_file;
open OUTPUT, ">$temp_file" or die "Unable to open a temp file in this directory: $!";
print OUTPUT "Xstep histval\n";
my @histogram = (0) x 100;
foreach my $i (0..@{$all_clusters_for_hist[$cindex]}-1) {
$histogram[int( ($all_clusters_for_hist[$cindex][$i] - $abs_minval) / $delta )]++;
}
foreach my $i (0..@histogram-1) {
print OUTPUT "$i $histogram[$i]\n";
}
# $arg_string .= "\"$temp_file\" using 1:2 ti col smooth frequency with boxes lc $cindex, ";
$arg_string .= "\"$temp_file\" using 2:xtic(1) ti col smooth frequency with boxes lc $cindex, ";
close OUTPUT;
}
}
$arg_string = $arg_string =~ /^(.*),[ ]+$/;
$arg_string = $1;
if ($visualization_data_field_width > 2) {
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
$visualization_data{ $record_id } = \@data_fields;
}
my $filename = basename($self->{_datafile});
my $temp_file = "__temp2_" . $filename;
unlink $temp_file if -e $temp_file;
open OUTPUT, ">$temp_file"
or die "Unable to open a temp file in this directory: $!";
my @class_distributions;
foreach my $cluster_index (0..$self->{_K}-1) {
push @class_distributions, [];
}
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
if $self->{_expected_class_probs}->{$data_tag}->[$cluster_index] > 0.2;
}
}
foreach my $distribution (@class_distributions) {
foreach my $item (@$distribution) {
print OUTPUT "@$item";
print OUTPUT "\n";
}
print OUTPUT "\n\n";
}
close OUTPUT;
my $plot;
if (!defined $pause_time) {
$plot = Graphics::GnuplotIF->new( persist => 1 );
} else {
$plot = Graphics::GnuplotIF->new();
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
$arg_string .= "\"$temp_file\" index $i using 1:2 title \"Cluster $i (based on posterior probs)\" with points lt $j pt $j, ";
my $ellipse_filename = "__contour2_" . $i . ".dat";
$arg_string .= "\"$ellipse_filename\" with line lt $j title \"\", ";
}
} elsif ($visualization_data_field_width == 1 ) {
open INPUT, "$temp_file" or die "Unable to open a temp file in this directory: $!";
my @all_data = <INPUT>;
close INPUT;
@all_data = map {chomp $_; $_ =~ /\d/ ? $_ : "SEPERATOR" } @all_data;
my $all_joined_data = join ':', @all_data;
my @separated = split /:SEPERATOR:SEPERATOR/, $all_joined_data;
my (@all_clusters_for_hist, @all_minvals, @all_maxvals, @all_minmaxvals);
foreach my $i (0..@separated-1) {
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
$plot->gnuplot_cmd("set xtics rotate by 90 offset 0,-5 out nomirror");
foreach my $cindex (0..@all_clusters_for_hist-1) {
my $localfilename = basename($filename);
my $temp_file = "__temp1dhist_" . "$cindex" . "_" . $localfilename;
unlink $temp_file if -e $temp_file;
open OUTPUT, ">$temp_file" or die "Unable to open a temp file in this directory: $!";
print OUTPUT "Xstep histval\n";
my @histogram = (0) x 100;
foreach my $i (0..@{$all_clusters_for_hist[$cindex]}-1) {
$histogram[int( ($all_clusters_for_hist[$cindex][$i] - $abs_minval) / $delta )]++;
}
foreach my $i (0..@histogram-1) {
print OUTPUT "$i $histogram[$i]\n";
}
$arg_string .= "\"$temp_file\" using 2:xtic(1) ti col smooth frequency with boxes lc $cindex, ";
close OUTPUT;
}
}
$arg_string = $arg_string =~ /^(.*),[ ]+$/;
$arg_string = $1;
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
}
my $filename = basename($master_datafile);
my $temp_file;
$temp_file = "__temp_data_" . $filename;
unlink $temp_file if -e $temp_file;
open OUTPUT, ">$temp_file"
or die "Unable to open a temp file in this directory: $!";
foreach my $datapoint (values %visualization_data) {
print OUTPUT "@$datapoint";
print OUTPUT "\n";
}
close OUTPUT;
my $plot = Graphics::GnuplotIF->new( persist => 1 );
$plot->gnuplot_cmd( "set noclip" );
$plot->gnuplot_cmd( "set pointsize 2" );
my $plot_title = '"original data provided for EM"';
my $arg_string ;
if ($visualization_data_field_width > 2) {
$arg_string = "\"$temp_file\" using 1:2:3 title $plot_title with points lt -1 pt 1";
} elsif ($visualization_data_field_width == 2) {
$arg_string = "\"$temp_file\" using 1:2 title $plot_title with points lt -1 pt 1";
} elsif ($visualization_data_field_width == 1 ) {
open INPUT, "$temp_file" or die "Unable to open a temp file in this directory: $!";
my @all_data = <INPUT>;
close INPUT;
@all_data = map {chomp $_; $_} @all_data;
@all_data = grep $_, @all_data;
my ($minval,$maxval) = minmax(\@all_data);
my $delta = ($maxval - $minval) / 100.0;
$plot->gnuplot_cmd("set boxwidth 3");
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
$plot->gnuplot_cmd("set title 'Overall distribution of 1D data'");
$plot->gnuplot_cmd("set xtics rotate by 90 offset 0,-5 out nomirror");
my $localfilename = basename($filename);
my $temp_file = "__temp1dhist_" . $localfilename;
unlink $temp_file if -e $temp_file;
open OUTPUT, ">$temp_file" or die "Unable to open a temp file in this directory: $!";
print OUTPUT "Xstep histval\n";
my @histogram = (0) x 100;
foreach my $i (0..@all_data-1) {
$histogram[int( ($all_data[$i] - $minval) / $delta )]++;
}
foreach my $i (0..@histogram-1) {
print OUTPUT "$i $histogram[$i]\n";
}
$arg_string = "\"$temp_file\" using 2:xtic(1) ti col smooth frequency with boxes lc rgb 'green'";
close OUTPUT;
}
if ($visualization_data_field_width > 2) {
$plot->gnuplot_cmd( "splot $arg_string" );
} elsif ($visualization_data_field_width == 2) {
$plot->gnuplot_cmd( "plot $arg_string" );
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
}
my $filename = basename($master_datafile);
my $temp_file;
$temp_file = "__temp_data_" . $filename;
unlink $temp_file if -e $temp_file;
open OUTPUT, ">$temp_file"
or die "Unable to open a temp file in this directory: $!";
foreach my $datapoint (values %visualization_data) {
print OUTPUT "@$datapoint";
print OUTPUT "\n";
}
close OUTPUT;
my $plot = Graphics::GnuplotIF->new( persist => 1 );
$plot->gnuplot_cmd( "set noclip" );
$plot->gnuplot_cmd( "set pointsize 2" );
my $plot_title = '"original data provided for EM"';
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
if ($visualization_data_field_width > 2) {
$arg_string = "\"$temp_file\" using 1:2:3 title $plot_title with points lt -1 pt 1";
} elsif ($visualization_data_field_width == 2) {
$arg_string = "\"$temp_file\" using 1:2 title $plot_title with points lt -1 pt 1";
} elsif ($visualization_data_field_width == 1 ) {
open INPUT, "$temp_file" or die "Unable to open a temp file in this directory: $!";
my @all_data = <INPUT>;
close INPUT;
@all_data = map {chomp $_; $_} @all_data;
@all_data = grep $_, @all_data;
my ($minval,$maxval) = minmax(\@all_data);
my $delta = ($maxval - $minval) / 100.0;
$plot->gnuplot_cmd("set boxwidth 3");
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
$plot->gnuplot_cmd("set title 'Overall distribution of 1D data'");
$plot->gnuplot_cmd("set xtics rotate by 90 offset 0,-5 out nomirror");
my $localfilename = basename($filename);
my $temp_file = "__temp1dhist_" . $localfilename;
unlink $temp_file if -e $temp_file;
open OUTPUT, ">$temp_file" or die "Unable to open a temp file in this directory: $!";
print OUTPUT "Xstep histval\n";
my @histogram = (0) x 100;
foreach my $i (0..@all_data-1) {
$histogram[int( ($all_data[$i] - $minval) / $delta )]++;
}
foreach my $i (0..@histogram-1) {
print OUTPUT "$i $histogram[$i]\n";
}
$arg_string = "\"$temp_file\" using 2:xtic(1) ti col smooth frequency with boxes lc rgb 'green'";
close OUTPUT;
}
if ($visualization_data_field_width > 2) {
$plot->gnuplot_cmd( 'set terminal png',
'set output "data_scatter_plot.png"');
$plot->gnuplot_cmd( "splot $arg_string" );
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
my $output_file = $args{output_datafile};
my $N = $args{total_number_of_data_points};
my @all_params;
my $param_string;
if (defined $input_parameter_file) {
open INPUT, $input_parameter_file || "unable to open parameter file: $!";
@all_params = <INPUT>;
@all_params = grep { $_ !~ /^[ ]*#/ } @all_params;
chomp @all_params;
$param_string = join ' ', @all_params;
} else {
# Just for testing. Used in t/test.t
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
my $label = $point_labels[$i];
@new_data = map {unshift @$_, $label.$i; $i++; $_} @new_data;
push @data_dump, @new_data;
}
fisher_yates_shuffle( \@data_dump );
open OUTPUT, ">$output_file";
print OUTPUT "\#Data generated from the parameter file: $input_parameter_file\n"
if $input_parameter_file;
print OUTPUT "\#Total number of data points in this file: $N\n";
print OUTPUT "\#Prior class probabilities for this data: @priors\n";
foreach my $ele (@data_dump) {
foreach my $coord ( @$ele ) {
print OUTPUT "$coord ";
}
print OUTPUT "\n";
}
print "Data written out to file $output_file\n";
close OUTPUT;
}
sub add_point_coords {
my $self = shift;
my @arr_of_ids = @{shift @_}; # array of data element names
lib/Algorithm/ExpectationMaximization.pm view on Meta::CPAN
the data space. The visualization mask is used to select the
subspace for the PNG image.
=back
=head1 HOW THE CLUSTERS ARE OUTPUT
This module produces two different types of clusters: the "hard" clusters and the
"soft" clusters. The hard clusters correspond to the naive Bayes' classification of
the data points on the basis of the Gaussian distributions and the class priors
estimated by the EM algorithm. Such clusters partition the data into disjoint
view all matches for this distribution
view release on metacpan or search on metacpan
RETVAL->imp = imp;
RETVAL->code = code;
RETVAL->sz = blocksize;
RETVAL->dp = data_packets;
RETVAL->ep = encoded_packets;
OUTPUT:
RETVAL
void
set_encode_blocks (self, blocks)
Algorithm::FEC self
SvCUR_set (RETVAL, self->sz);
self->imp->fec_encode (self->code, self->b_addr,
SvPVX (RETVAL), block_index, self->sz);
OUTPUT:
RETVAL
void
set_decode_blocks (self, blocks, indices)
Algorithm::FEC self
view all matches for this distribution
view release on metacpan or search on metacpan
GDiffDelta.xs view on Meta::CPAN
XPUSHs(f);
/* TODO - possibly use newSVpvn_share to avoid the memcpy
* and extra allocation for buf? */
XPUSHs(sv_2mortal(buf = newSVpvn("", 0)));
XPUSHs(sv_2mortal(newSVuv(size)));
PUTBACK;
n = call_method("read", G_SCALAR);
assert(n == 0 || n == 1);
SPAGAIN;
ret = n ? POPs : &PL_sv_undef;
if (!SvOK(ret))
GDiffDelta.xs view on Meta::CPAN
if (!SvPOK(buf) || SvCUR(buf) != size)
croak("'read' method left buffer badly set up", from);
str = SvPV(buf, len);
assert(len == size);
memcpy(ptr, str, size);
PUTBACK;
FREETMPS;
LEAVE;
}
else {
int r = PerlIO_read(IoIFP(sv_2io(f)), ptr, size);
GDiffDelta.xs view on Meta::CPAN
SAVETMPS;
PUSHMARK(SP);
XPUSHs(f);
XPUSHs(sv_2mortal(newSVpvn(ptr, size)));
XPUSHs(sv_2mortal(newSVuv(size)));
PUTBACK;
n = call_method("write", G_SCALAR);
assert(n == 0 || n == 1);
SPAGAIN;
ret = n ? POPs : &PL_sv_no;
n = SvTRUE(ret);
PUTBACK;
FREETMPS;
LEAVE;
if (!n)
croak("error writing to %s: %s", to,
SvPV_nolen(get_sv("!", FALSE)));
GDiffDelta.xs view on Meta::CPAN
SAVETMPS;
PUSHMARK(SP);
XPUSHs(f);
XPUSHs(sv_2mortal(newSVuv(offset)));
XPUSHs(sv_2mortal(newSVuv(whence)));
PUTBACK;
n = call_method("seek", G_SCALAR);
assert(n == 0 || n == 1);
SPAGAIN;
ret = n ? POPs : &PL_sv_undef;
n = SvTRUE(ret);
PUTBACK;
FREETMPS;
LEAVE;
if (!n)
croak("error seeking in %s: %s", from,
SvPV_nolen(get_sv("!", FALSE)));
GDiffDelta.xs view on Meta::CPAN
dSP;
ENTER;
SAVETMPS;
PUSHMARK(SP);
XPUSHs(f);
PUTBACK;
n = call_method("tell", G_SCALAR);
assert(n == 0 || n == 1);
SPAGAIN;
offset = (Off_t) -1;
if (n) {
ret = POPs;
if (SvOK(ret))
offset = SvUV(ret);
}
PUTBACK;
FREETMPS;
LEAVE;
if (offset == (Off_t) -1)
croak("error getting position in %s: %s", from,
SvPV_nolen(get_sv("!", FALSE)));
GDiffDelta.xs view on Meta::CPAN
if (size <= 246)
buf[headsz++] = size;
else if (size <= QEF_USHORT_MAX) {
buf[headsz++] = 247;
QEF_BE16_PUT(buf, headsz, size);
}
else {
buf[headsz++] = 248;
QEF_BE32_PUT(buf, headsz, size);
}
/* Write the opcode and size argument (if any). */
careful_fwrite(buf, headsz, delta, "delta");
GDiffDelta.xs view on Meta::CPAN
assert(size > 0);
if (offset <= QEF_USHORT_MAX) {
if (size <= QEF_UBYTE_MAX) {
buf[headsz++] = 249;
QEF_BE16_PUT(buf, headsz, offset);
buf[headsz++] = size;
}
else if (size <= QEF_USHORT_MAX) {
buf[headsz++] = 250;
QEF_BE16_PUT(buf, headsz, offset);
QEF_BE16_PUT(buf, headsz, size);
}
else if (size <= QEF_INT_MAX) {
buf[headsz++] = 251;
QEF_BE16_PUT(buf, headsz, offset);
QEF_BE32_PUT(buf, headsz, size);
}
else {
/* TODO - break copy ops for bigger than 2Gb into smaller ones */
assert(0);
}
}
else if (offset <= QEF_INT_MAX) {
if (size <= QEF_UBYTE_MAX) {
buf[headsz++] = 252;
QEF_BE32_PUT(buf, headsz, offset);
buf[headsz++] = size;
}
else if (size <= QEF_USHORT_MAX) {
buf[headsz++] = 253;
QEF_BE32_PUT(buf, headsz, offset);
QEF_BE16_PUT(buf, headsz, size);
}
else if (size <= QEF_INT_MAX) {
buf[headsz++] = 254;
QEF_BE32_PUT(buf, headsz, offset);
QEF_BE32_PUT(buf, headsz, size);
}
else {
/* TODO - break copy ops for bigger than 2Gb into smaller ones */
assert(0);
}
GDiffDelta.xs view on Meta::CPAN
STRLEN len;
const unsigned char *buf;
CODE:
buf = (unsigned char *) SvPV(s, len);
RETVAL = adler32(init, buf, len);
OUTPUT:
RETVAL
void
qefgdiff_gdiff_delta (SV *orig, SV *changed, SV *delta)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/HITS.pm view on Meta::CPAN
2 => 1,
]
);
=head2 ITERATE THROUGH COMPUTATION
Iterate 1000 times.
$h->iterate(1000);
view all matches for this distribution
view release on metacpan or search on metacpan
PUSHmortal|5.009002||p
PUSHn|||
PUSHp|||
PUSHs|||
PUSHu|5.004000||p
PUTBACK|||
PerlIO_clearerr||5.007003|
PerlIO_close||5.007003|
PerlIO_context_layers||5.009004|
PerlIO_eof||5.007003|
PerlIO_error||5.007003|
eval_sv(sv, G_SCALAR);
SvREFCNT_dec(sv);
SPAGAIN;
sv = POPs;
PUTBACK;
if (croak_on_error && SvTRUE(GvSV(errgv)))
croak(SvPVx(GvSV(errgv), na));
return sv;
view all matches for this distribution
view release on metacpan or search on metacpan
misc/make_manifest.pl view on Meta::CPAN
font-size : 9.0pt;
list-style-type : disc;
margin-left : 16.0pt;
margin-top : -14.0pt;
}
INPUT {
font: bold small verdana, arial, helvetica, sans-serif;
color: black;
background-color: white;
}
TEXTAREA {
view all matches for this distribution
view release on metacpan or search on metacpan
HLL T_PTROBJ_HLL
uint32_t T_UV
################################################################
INPUT
T_PTROBJ_HLL
$var = GET_HLLPTR($arg);
OUTPUT
T_PTROBJ_HLL
sv_setref_pv($arg, klass, (void*)$var);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/KMeans.pm view on Meta::CPAN
my $datafile = $self->{_datafile};
my $mask = $self->{_mask};
my @mask = split //, $mask;
$self->{_data_dimensions} = scalar grep {$_ eq '1'} @mask;
print "data dimensionality: $self->{_data_dimensions} \n"if $self->{_terminal_output};
open INPUT, $datafile or die "unable to open file $datafile: $!\n";
chomp( my @raw_data = <INPUT> );
close INPUT;
# Transform strings into number data
foreach my $record (@raw_data) {
next unless $record;
next if $record =~ /^#/;
my @data_fields;
lib/Algorithm/KMeans.pm view on Meta::CPAN
my @all_data_ids = @{$self->{_data_id_tags}};
my $K = scalar @{$self->{_clusters}};
my $filename = basename($master_datafile);
my $temp_file = "__temp_" . $filename;
unlink $temp_file if -e $temp_file;
open OUTPUT, ">$temp_file"
or die "Unable to open a temp file in this directory: $!\n";
foreach my $cluster (@{$self->{_clusters}}) {
foreach my $item (@$cluster) {
print OUTPUT "@{$visualization_data{$item}}";
print OUTPUT "\n";
}
print OUTPUT "\n\n";
}
close OUTPUT;
my $plot;
my $hardcopy_plot;
if (!defined $pause_time) {
$plot = Graphics::GnuplotIF->new( persist => 1 );
$hardcopy_plot = Graphics::GnuplotIF->new();
lib/Algorithm/KMeans.pm view on Meta::CPAN
$temp_file = "__temp_normed_data_" . $filename;
} else {
croak "ABORTED: Improper call to visualize_data()";
}
unlink $temp_file if -e $temp_file;
open OUTPUT, ">$temp_file"
or die "Unable to open a temp file in this directory: $!\n";
foreach my $datapoint (values %visualization_data) {
print OUTPUT "@$datapoint";
print OUTPUT "\n";
}
close OUTPUT;
my $plot = Graphics::GnuplotIF->new( persist => 1 );
$plot->gnuplot_cmd( "set noclip" );
$plot->gnuplot_cmd( "set pointsize 2" );
my $plot_title = $datatype eq 'original' ? '"data"' : '"normed data"';
my $arg_string ;
lib/Algorithm/KMeans.pm view on Meta::CPAN
my $output_file = $args{output_datafile};
my $N = $args{number_data_points_per_cluster};
my @all_params;
my $param_string;
if (defined $input_parameter_file) {
open INPUT, $input_parameter_file || "unable to open parameter file: $!";
@all_params = <INPUT>;
@all_params = grep { $_ !~ /^[ ]*#/ } @all_params;
chomp @all_params;
$param_string = join ' ', @all_params;
} else {
# Just for testing. Used in t/test.t
lib/Algorithm/KMeans.pm view on Meta::CPAN
my $label = $point_labels[$i];
@new_data = map {unshift @$_, $label.$i; $i++; $_} @new_data;
push @data_dump, @new_data;
}
fisher_yates_shuffle( \@data_dump );
open OUTPUT, ">$output_file";
foreach my $ele (@data_dump) {
foreach my $coord ( @$ele ) {
print OUTPUT "$coord ";
}
print OUTPUT "\n";
}
print "Data written out to file $output_file\n";
close OUTPUT;
}
sub add_point_coords {
my $self = shift;
my @arr_of_ids = @{shift @_}; # array of data element names
lib/Algorithm/KMeans.pm view on Meta::CPAN
definite. Should the covariances in your parameter file not obey this condition, the
C<Math::Random> module will let you know.
=back
=head1 HOW THE CLUSTERS ARE OUTPUT
When the option C<terminal_output> is set in the call to the constructor, the
clusters are displayed on the terminal screen.
When the option C<write_clusters_to_files> is set in the call to the constructor, the
view all matches for this distribution
view release on metacpan or search on metacpan
perlobject.map view on Meta::CPAN
# TYPEMAPs
#
# HV * -> unblessed Perl HV object.
# AV * -> unblessed Perl AV object.
#
# INPUT/OUTPUT maps
#
# O_* -> opaque blessed objects
# T_* -> opaque blessed or unblessed objects
#
# O_OBJECT -> link an opaque C or C++ object to a blessed Perl object.
perlobject.map view on Meta::CPAN
HV * T_HvRV
AV * T_AvRV
######################################################################
OUTPUT
# The Perl object is blessed into 'CLASS', which should be a
# char* having the name of the package for the blessing.
O_OBJECT
sv_setref_pv( $arg, CLASS, (void*)$var );
perlobject.map view on Meta::CPAN
T_AvRV
$arg = newRV((SV*)$var);
######################################################################
INPUT
O_OBJECT
if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) )
$var = ($type)SvIV((SV*)SvRV( $arg ));
else{
view all matches for this distribution
view release on metacpan or search on metacpan
Algorithm-LBFGS.xs view on Meta::CPAN
SAVETMPS;
PUSHMARK(SP);
XPUSHs(sv_2mortal(newRV_noinc((SV*)av_x)));
XPUSHs(sv_2mortal(newSVnv(step)));
XPUSHs(user_data);
PUTBACK;
TRACE("lbfgs_evaluation_cb: finish arguments preparation");
call_sv(lbfgs_eval, G_ARRAY);
TRACE("lbfgs_evaluation_cb: finish calling");
SPAGAIN;
av_g = (AV*)SvRV(POPs);
sv_f = POPs;
f = SvNV(sv_f);
for (i = 0; i < n; i++)
g[i] = SvNV(*av_fetch(av_g, i, 0));
PUTBACK;
FREETMPS;
LEAVE;
/* clean up (for non-mortal return values) */
if (SvREFCNT(av_g) > 0) av_undef(av_g);
if (SvREFCNT(sv_f) > 0) SvREFCNT_dec(sv_f);
Algorithm-LBFGS.xs view on Meta::CPAN
XPUSHs(sv_2mortal(newSVnv(gnorm)));
XPUSHs(sv_2mortal(newSVnv(step)));
XPUSHs(sv_2mortal(newSViv(k)));
XPUSHs(sv_2mortal(newSViv(ls)));
XPUSHs(user_data);
PUTBACK;
TRACE("lbfgs_progress_cb: finish arguments preparation");
call_sv(lbfgs_prgr, G_ARRAY);
TRACE("lbfgs_progress_cb: finish calling");
SPAGAIN;
sv_r = POPs;
r = SvIV(sv_r);
PUTBACK;
FREETMPS;
LEAVE;
/* clean up (for non-mortal return values) */
if (SvREFCNT(sv_r) > 0) SvREFCNT_dec(sv_r);
TRACE("lbfgs_progress_cb: leave");
Algorithm-LBFGS.xs view on Meta::CPAN
CODE:
((SV**)instance)[0] = lbfgs_eval; /* ref to Perl eval callback */
((SV**)instance)[1] = lbfgs_prgr; /* ref to Perl monitor callback */
((SV**)instance)[2] = user_data; /* ref to Perl user data */
RETVAL = instance;
OUTPUT:
RETVAL
void
destroy_lbfgs_instance(li)
void* li
Algorithm-LBFGS.xs view on Meta::CPAN
PREINIT:
void* lp = malloc(sizeof(lbfgs_parameter_t));
CODE:
lbfgs_parameter_init((lbfgs_parameter_t*)lp);
RETVAL = lp;
OUTPUT:
RETVAL
void
destroy_lbfgs_param(lp)
void* lp
Algorithm-LBFGS.xs view on Meta::CPAN
else if (strcmp(name, "orthantwise_c") == 0) {
if (SvNOK(val)) p->orthantwise_c = SvNV(val);
r = newSVnv(p->orthantwise_c);
}
RETVAL = r;
OUTPUT:
RETVAL
SV*
do_lbfgs(param, instance, x0)
void* param
Algorithm-LBFGS.xs view on Meta::CPAN
/* store the result back to the Perl array ref x0 */
for (i = 0; i < n; i++) av_store(av_x0, i, newSVnv(carr_x0[i]));
/* release the C array */
free(carr_x0);
RETVAL = newSViv(s);
OUTPUT:
RETVAL
SV*
status_2pv(status)
int status
Algorithm-LBFGS.xs view on Meta::CPAN
case LBFGSERR_INCREASEGRADIENT:
RETVAL = newSVpv_("LBFGSERR_INCREASEGRADIENT"); break;
default:
RETVAL = newSVpv_(""); break;
}
OUTPUT:
RETVAL
view all matches for this distribution
view release on metacpan or search on metacpan
misc/make_manifest.pl view on Meta::CPAN
font-size : 9.0pt;
list-style-type : disc;
margin-left : 16.0pt;
margin-top : -14.0pt;
}
INPUT {
font: bold small verdana, arial, helvetica, sans-serif;
color: black;
background-color: white;
}
TEXTAREA {
view all matches for this distribution
view release on metacpan or search on metacpan
=head1 USAGE
Usage: lda.pl DIR
=head1 INPUT
=head2 DIR
The directory of text documents
view all matches for this distribution
view release on metacpan or search on metacpan
src/liblinear.xs view on Meta::CPAN
struct parameter * T_LIBLINEAR_TRAINING_PARAMETER
struct problem * T_LIBLINEAR_PROBLEM
INPUT
T_LIBLINEAR_MODEL
if (SvROK($arg) &&
sv_derived_from($arg, \"Algorithm::LibLinear::Model::Raw\")) {
IV tmp = SvIV((SV*)SvRV($arg));
$var = INT2PTR($type,tmp);
src/liblinear.xs view on Meta::CPAN
Perl_croak(aTHX_ \"%s: %s is not of type %s\",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
\"$var\", \"$ntype\");
}
OUTPUT
T_LIBLINEAR_MODEL
sv_setref_pv($arg, \"Algorithm::LibLinear::Model::Raw\", (void*)$var);
T_LIBLINEAR_TRAINING_PARAMETER
sv_setref_pv(
src/liblinear.xs view on Meta::CPAN
struct problem *problem_;
struct parameter *parameter_;
CODE:
validate_parameter(aTHX_ problem_, parameter_);
RETVAL = train(problem_, parameter_);
OUTPUT:
RETVAL
struct model *
ll_load(klass, filename)
const char *filename;
CODE:
RETVAL = load_model(filename);
if (!RETVAL) {
Perl_croak(aTHX_ "Failed to load a model from file: %s.", filename);
}
OUTPUT:
RETVAL
double
ll_bias(self, label)
struct model *self;
int label;
CODE:
RETVAL = get_decfun_bias(self, label);
OUTPUT:
RETVAL
AV *
ll_class_labels(self)
struct model *self;
src/liblinear.xs view on Meta::CPAN
RETVAL = newAV();
av_extend(RETVAL, self->nr_class - 1);
for (int i = 0; i < self->nr_class; ++i) {
av_push(RETVAL, newSViv(self->label[i]));
}
OUTPUT:
RETVAL
double
ll_coefficient(self, feature, label)
struct model *self;
int feature;
int label;
CODE:
RETVAL = get_decfun_coef(self, feature, label);
OUTPUT:
RETVAL
bool
ll_is_oneclass_model(self)
struct model* self;
CODE:
RETVAL = check_oneclass_model(self);
OUTPUT:
RETVAL
bool
ll_is_probability_model(self)
struct model *self;
CODE:
RETVAL = check_probability_model(self);
OUTPUT:
RETVAL
bool
ll_is_regression_model(self)
struct model *self;
CODE:
RETVAL = check_regression_model(self);
OUTPUT:
RETVAL
int
ll_num_classes(self)
struct model *self;
CODE:
RETVAL = get_nr_class(self);
OUTPUT:
RETVAL
int
ll_num_features(self)
struct model *self;
CODE:
RETVAL = get_nr_feature(self);
OUTPUT:
RETVAL
SV *
ll_predict(self, feature_hash)
struct model *self;
src/liblinear.xs view on Meta::CPAN
struct feature_node *feature_vector = hv2feature(aTHX_ feature_hash);
double prediction = predict(self, feature_vector);
Safefree(feature_vector);
RETVAL = is_regression_solver(&self->param) ?
newSVnv(prediction) : newSViv((int)prediction);
OUTPUT:
RETVAL
AV *
ll_predict_probability(self, feature_hash)
struct model *self;
src/liblinear.xs view on Meta::CPAN
av_push(RETVAL, newSVnv(estimated_probabilities[i]));
}
Safefree(feature_vector);
Safefree(estimated_probabilities);
}
OUTPUT:
RETVAL
AV *
ll_predict_values(self, feature_hash)
struct model *self;
src/liblinear.xs view on Meta::CPAN
for (int i = 0; i < num_decision_values; ++i) {
av_push(RETVAL, newSVnv(decision_values[i]));
}
Safefree(decision_values);
Safefree(feature_vector);
OUTPUT:
RETVAL
double
ll_rho(self)
struct model *self;
CODE:
RETVAL = get_decfun_rho(self);
OUTPUT:
RETVAL
void
ll_save(self, filename)
struct model *self;
src/liblinear.xs view on Meta::CPAN
} XCPT_TRY_END
XCPT_CATCH {
free_parameter(aTHX_ RETVAL);
XCPT_RETHROW;
}
OUTPUT:
RETVAL
AV *
ll_cross_validation(self, problem_, num_folds)
struct parameter *self;
src/liblinear.xs view on Meta::CPAN
av_extend(RETVAL, problem_->l - 1);
for (int i = 0; i < problem_->l; ++i) {
av_push(RETVAL, newSVnv(targets[i]));
}
Safefree(targets);
OUTPUT:
RETVAL
AV *
ll_find_parameters(self, problem_, num_folds, initial_C, initial_p, update)
struct parameter *self;
src/liblinear.xs view on Meta::CPAN
av_push(RETVAL, newSVnv(best_C));
av_push(
RETVAL,
is_regression_model ? newSVnv(best_p) : newSVsv(&PL_sv_undef));
av_push(RETVAL, newSVnv(accuracy));
OUTPUT:
RETVAL
bool
ll_is_regression_solver(self)
struct parameter *self;
CODE:
RETVAL = is_regression_solver(self);
OUTPUT:
RETVAL
double
ll_cost(self)
struct parameter *self;
CODE:
RETVAL = self->C;
OUTPUT:
RETVAL
double
ll_epsilon(self)
struct parameter *self;
CODE:
RETVAL = self->eps;
OUTPUT:
RETVAL
double
ll_loss_sensitivity(self)
struct parameter *self;
CODE:
RETVAL = self->p;
OUTPUT:
RETVAL
int
ll_solver_type(self)
struct parameter *self;
CODE:
RETVAL = self->solver_type;
OUTPUT:
RETVAL
AV *
ll_weights(self)
struct parameter *self;
src/liblinear.xs view on Meta::CPAN
RETVAL = newAV();
av_extend(RETVAL, self->nr_weight - 1);
for (int i = 0; i < self->nr_weight; ++i) {
av_push(RETVAL, newSVnv(self->weight[i]));
}
OUTPUT:
RETVAL
AV *
ll_weight_labels(self)
struct parameter *self;
src/liblinear.xs view on Meta::CPAN
RETVAL = newAV();
av_extend(RETVAL, self->nr_weight - 1);
for (int i = 0; i < self->nr_weight; ++i) {
av_push(RETVAL, newSViv(self->weight_label[i]));
}
OUTPUT:
RETVAL
void
ll_DESTROY(self)
struct parameter *self;
src/liblinear.xs view on Meta::CPAN
} XCPT_TRY_END
XCPT_CATCH {
free_problem(aTHX_ RETVAL);
XCPT_RETHROW;
}
OUTPUT:
RETVAL
double
ll_bias(self)
struct problem *self;
CODE:
RETVAL = self->bias;
OUTPUT:
RETVAL
int
ll_data_set_size(self)
struct problem *self;
CODE:
RETVAL = self->l;
OUTPUT:
RETVAL
int
ll_num_features(self)
struct problem *self;
CODE:
RETVAL = self->n;
OUTPUT:
RETVAL
void
ll_DESTROY(self)
struct problem *self;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Line/Lerp.xs view on Meta::CPAN
err += dx;
y0 += sy;
}
}
RETVAL = newRV_noinc((SV*)theline);
OUTPUT:
RETVAL
SV *
line(SV* sp1, SV* sp2)
PROTOTYPE: $$
lib/Algorithm/Line/Lerp.xs view on Meta::CPAN
av_push(point, newSViv(lround(y)));
av_push(theline, newRV_noinc((SV*)point));
}
}
RETVAL = newRV_noinc((SV*)theline);
OUTPUT:
RETVAL
view all matches for this distribution
view release on metacpan or search on metacpan
examples/data_visualizer.pl view on Meta::CPAN
my $datafile = shift;
my $filename = File::Basename::basename($datafile);
my $temp_file = "__temp_" . $filename;
$temp_file =~ s/\.\w+$/\.txt/;
unlink $temp_file if -e $temp_file;
open OUTPUT, ">$temp_file"
or die "Unable to open a temp file in this directory: $!";
open INPUT, "< $filename" or die "Unable to open $filename: $!";
local $/ = undef;
my @all_records = split /\s+/, <INPUT>;
my %clusters;
foreach my $record (@all_records) {
my @splits = split /,/, $record;
my $record_name = shift @splits;
$record_name =~ /(\w+?)_.*/;
my $primary_cluster_label = $1;
push @{$clusters{$primary_cluster_label}}, \@splits;
}
foreach my $key (sort {"\L$a" cmp "\L$b"} keys %clusters) {
map {print OUTPUT "$_"} map {"@$_\n"} @{$clusters{$key}};
print OUTPUT "\n\n";
}
my @sorted_cluster_keys = sort {"\L$a" cmp "\L$b"} keys %clusters;
close OUTPUT;
my $plot = Graphics::GnuplotIF->new( persist => 1 );
my $arg_string = "";
$plot->gnuplot_cmd( "set noclip" );
$plot->gnuplot_cmd( "set hidden3d" );
view all matches for this distribution
view release on metacpan or search on metacpan
im->dictionary = g_hash_table_new(g_str_hash, g_str_equal);
im->chains = g_hash_table_new(g_str_hash, g_str_equal);
SvREADONLY_on(obj);
RETVAL = obj;
OUTPUT:
RETVAL
void
_c_destroy (obj)
SV* obj;
CODE:
IM* im = (IM*) SvIV(phash_value(SvRV(obj), "_cstuff"));
RETVAL = im->longest;
OUTPUT:
RETVAL
int
sequence_known (obj, stub)
SV* obj;
char *stub;
CODE:
IM* im = (IM*) SvIV(phash_value(SvRV(obj), "_cstuff"));
RETVAL = (int) g_hash_table_lookup(im->chains, stub);
OUTPUT:
RETVAL
char*
random_sequence (obj)
g_hash_table_foreach(im->chains, get_keys, keys);
nkeys = (1.0 * nkeys * rand()) / (1.0*RAND_MAX);
RETVAL = keys[nkeys];
g_free(keys);
OUTPUT:
RETVAL
view all matches for this distribution
view release on metacpan or search on metacpan
PUSHmortal|5.009002||p
PUSHn|||
PUSHp|||
PUSHs|||
PUSHu|5.004000||p
PUTBACK|||
PerlIO_clearerr||5.007003|
PerlIO_close||5.007003|
PerlIO_context_layers||5.009004|
PerlIO_eof||5.007003|
PerlIO_error||5.007003|
eval_sv(sv, G_SCALAR);
SvREFCNT_dec(sv);
SPAGAIN;
sv = POPs;
PUTBACK;
if (croak_on_error && SvTRUE(GvSV(errgv)))
croak(SvPVx(GvSV(errgv), na));
return sv;
view all matches for this distribution
view release on metacpan or search on metacpan
MinPerfHashTwoLevel.xs view on Meta::CPAN
if (state_len != MPH_STATE_BYTES) {
croak("Error: state vector must be at exactly %d bytes",(int)MPH_SEED_BYTES);
}
RETVAL= mph_hash_with_state(state_pv,str_pv,str_len);
}
OUTPUT:
RETVAL
SV *
seed_state(base_seed_sv)
MinPerfHashTwoLevel.xs view on Meta::CPAN
SvCUR_set(RETVAL,MPH_STATE_BYTES);
SvPOK_on(RETVAL);
state_pv= (U8 *)SvPV(RETVAL,state_len);
mph_seed_state(seed_pv,state_pv);
}
OUTPUT:
RETVAL
UV
compute_xs(self_hv)
MinPerfHashTwoLevel.xs view on Meta::CPAN
variant= SvUV(HeVAL(he));
} else {
croak("panic: no variant in self?");
}
he= hv_fetch_ent_with_keysv(self_hv,MPH_KEYSV_COMPUTE_FLAGS,0);
if (he) {
compute_flags= SvUV(HeVAL(he));
} else {
croak("panic: no compute_flags in self?");
}
MinPerfHashTwoLevel.xs view on Meta::CPAN
by_length_av= idx_by_length(aTHX_ keybuckets_av);
RETVAL= solve_collisions_by_length(aTHX_ bucket_count, max_xor_val, by_length_av, h2_packed_av, keybuckets_av,
variant, buckets_av);
}
OUTPUT:
RETVAL
MODULE = Algorithm::MinPerfHashTwoLevel PACKAGE = Tie::Hash::MinPerfHashTwoLevel::OnDisk
MinPerfHashTwoLevel.xs view on Meta::CPAN
SvCUR_set(sv_buf, str_buf_pos - start);
SvPOK_on(sv_buf);
RETVAL= sv_buf;
}
OUTPUT:
RETVAL
SV*
mount_file(file_sv,error_sv,flags)
SV* file_sv
MinPerfHashTwoLevel.xs view on Meta::CPAN
/* copy obj into a new SV which we can return */
RETVAL= newSVpvn((char *)&obj,sizeof(struct mph_obj));
SvPOK_on(RETVAL);
SvREADONLY_on(RETVAL);
}
OUTPUT:
RETVAL
void
unmount_file(mount_sv)
SV* mount_sv
MinPerfHashTwoLevel.xs view on Meta::CPAN
if (items > 4)
croak("Error: passed too many arguments to "
"Tie::Hash::MinPerfHashTwoLevel::OnDisk::fetch_by_index(mount_sv, index, key_sv, val_sv)");
RETVAL= lookup_bucket(aTHX_ obj->header,index,key_sv,val_sv);
}
OUTPUT:
RETVAL
int
fetch_by_key(mount_sv,key_sv,...)
SV* mount_sv
MinPerfHashTwoLevel.xs view on Meta::CPAN
if (items > 3)
croak("Error: passed too many arguments to "
"Tie::Hash::MinPerfHashTwoLevel::OnDisk::fetch_by_key(mount_sv, index, key_sv)");
RETVAL= lookup_key(aTHX_ obj->header,key_sv,val_sv);
}
OUTPUT:
RETVAL
SV *
get_comment(self_hv)
MinPerfHashTwoLevel.xs view on Meta::CPAN
case 9: RETVAL= newSVuv(obj->header->table_checksum); break;
case 10: RETVAL= newSVuv(obj->header->str_buf_checksum); break;
case 11: RETVAL= newSVpvn(start + obj->header->state_ofs, MPH_STATE_BYTES); break;
}
}
OUTPUT:
RETVAL
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Munkres.pm view on Meta::CPAN
=head1 EXPORT
"assign" function by default.
=head1 INPUT
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.
view all matches for this distribution
view release on metacpan or search on metacpan
p->dim_map = newHV();
p->rev_map = newHV();
p->main_table = table_init();
SvREFCNT_inc(RETVAL);
OUTPUT:
RETVAL
void
add_arc(pagerank p, ...)
hv_store(results, reskey, len, curval, 0);
}
array_delete(result);
RETVAL = newRV((SV *)results);
clear(aTHX_ p);
OUTPUT:
RETVAL
void
DESTROY(pagerank p)
PREINIT:
view all matches for this distribution
view release on metacpan or search on metacpan
if(!reset_combination(RETVAL, av, r)) {
XSRETURN_UNDEF;
}
}
OUTPUT:
RETVAL
void
next(self)
Permute *self
view all matches for this distribution
view release on metacpan or search on metacpan
}
find_nodes(root->node, ret, ¶m);
RETVAL = newRV_noinc((SV*) ret);
OUTPUT:
RETVAL
void
_AQT_delete(self, object)
SV *self
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/RandomMatrixGeneration.pm view on Meta::CPAN
0 8.469 1 3.565 2 0.839 3 0.127
0 2.719 1 2.748 2 0.604 3 6.929
0 0.946 1 3.771 2 5.939 3 1.344
0 1.638 1 11.346 2 0.016
=head1 INPUTS
The generateMatrix function can take 4 parameters:
=over 4
lib/Algorithm/RandomMatrixGeneration.pm view on Meta::CPAN
=item 2. Single dimensional array containing column marginals (Can be real valued or integers)
=item 3. Precision: For the integer valued marginal specifying "-". For real valued marginals specify the required precision for the generated matrix values. (Recommended Precision = 4)
=item 4. Seed: Seed for the random number generator (Default: None) (Optional parameter)
=back
=head1 OUTPUT
The generateMatrix function returns a two dimensional array containing the generated random matrix.
The generated matrix is stored in sparse format in this returned array. That is, only non-zero values
are stored in this matrix. Thus to access the values in the returned matrix one can use:
view all matches for this distribution
view release on metacpan or search on metacpan
RectanglesContainingDot_XS.xs view on Meta::CPAN
struct algorithm *
new(klass)
SV *klass
CODE:
RETVAL = allocate_algorithm(aTHX);
OUTPUT:
RETVAL
void
DESTROY(self)
struct algorithm *self
view all matches for this distribution