Skip to content

Commit

Permalink
Add some random scripts found on an old server
Browse files Browse the repository at this point in the history
  • Loading branch information
leto committed May 23, 2011
1 parent 222e944 commit f1fdfed
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
28 changes: 28 additions & 0 deletions misc/bench.pl
@@ -0,0 +1,28 @@
#!/usr/bin/perl -w

use Math::MatrixReal;
use Benchmark;
do 'funcs.pl';
my $matrix1 = Math::MatrixReal->new_random(10);
my $matrix2 = $matrix1->new_random(5);

my @matrices = map { Math::MatrixReal->new_random($_) } qw(5 10 15 20);

my $iter = 1000;

for my $matrix ( @matrices ) {
my ($r,$c) = $matrix->dim;
print "Benchmarking $r x $c matrix\n";

timethese($iter,
{
'matrix_squared ' => sub { $matrix ** 2 },
'matrix_times_itself' => sub { $matrix * $matrix },
'det ' => sub { $matrix->det },
'det_LR ' => sub { $matrix->decompose_LR->det_LR },
'inverse ' => sub { $matrix->inverse() },
'to_negative_one ' => sub { $matrix ** -1 },
'invert_LR ' => sub { $matrix->decompose_LR->invert_LR },
});

}
29 changes: 29 additions & 0 deletions misc/log_stuff.c
@@ -0,0 +1,29 @@
#include <math.h>
#include <stdio.h>
#include <errno.h>

/* Ref. a.o. http://www.ansic.net/showlog.php?id=31&res=log%20function */

int
main(int argc, char **argv)
{
double a, b;

a = INFINITY;
b = log(a);
printf("log(%3f)\t\t= %5f errno=%2d (expected: inf / %d)\n", a, b, errno, 0);

a = -INFINITY;
b = log(a);
printf("log(%3f)\t\t= %5f errno=%2d (expected: nan / %d)\n", a, b, errno, EDOM);

a = -1;
b = log(a);
printf("log(%3f)\t\t= %5f errno=%2d (expected: nan / %d)\n", a, b, errno, EDOM);

a = NAN;
b = log(a);
printf("log(%3f)\t\t= %5f errno=%2d (expected: nan / %d)\n", a, b, errno, EDOM);

return 0;
}
13 changes: 13 additions & 0 deletions misc/push_gsl_docs
@@ -0,0 +1,13 @@
#!/usr/bin/perl5.10.0 -w

use strict;
use warnings;
use 5.010;

my $pod_dir = q{blib/libhtml/site/lib};
my $html_dir = q{/export/domains/leto.net/htdocs/code/Math-GSL/htmldocs};
my $host = shift || q{leto.net};
my $cmd = qq[./Build html && scp -prv $pod_dir/* ${host}:$html_dir];

say " Running => $cmd" && qx{ $cmd };
say "!!!";

0 comments on commit f1fdfed

Please sign in to comment.