Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jonathan Leto
committed
Oct 3, 2008
1 parent
950f328
commit dc25479
Showing
3 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/perl -w | ||
|
||
use strict; | ||
use warnings; | ||
use Data::Dumper; | ||
use Math::GSL::Vector qw/:all/; | ||
use Math::GSL::RNG qw/:all/; | ||
use Storable; | ||
|
||
if ( -e 'data' ) { | ||
my $thawed = retrieve('data'); | ||
my $v = $thawed->{vector}; | ||
print "Thawed vector of length " . $v->length() . "\n"; | ||
print Dumper [ $v->as_list() ]; | ||
print join (" ", $v->as_list() ) . "\n"; | ||
} else { | ||
my %data; | ||
my $rng = Math::GSL::RNG->new; | ||
my @stuff = map { $rng->get } (1..10) ; | ||
my $vector = Math::GSL::Vector->new( \@stuff ); | ||
print "Serialized vector of length " . $vector->length() . "\n"; | ||
$data{vector} = $vector; | ||
store \%data, 'data'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/perl -w | ||
|
||
use strict; | ||
use warnings; | ||
use Math::GSL::Vector qw/:all/; | ||
use Benchmark; | ||
use Math::GSL::RNG qw/:all/; | ||
|
||
my $min; | ||
my $rng = Math::GSL::RNG->new; | ||
my $num = 1000000; | ||
my @stuff = map { $rng->get() } (1..$num); | ||
my $vector = Math::GSL::Vector->new([@stuff]); | ||
|
||
|
||
timethese(5000, { | ||
'perl array ' => sub { $min = min(@stuff) }, | ||
'Math::GSL vector ' => sub { $min = $vector->min() }, | ||
}); | ||
|
||
sub min | ||
{ | ||
$min = $_[0] < $min ? $_[0] : $min; | ||
} | ||
|
||
|