Math-Interpolator

 view release on metacpan or  search on metacpan

t/edge.t  view on Meta::CPAN

use warnings;
use strict;

use Test::More tests => 3 + 3*8;

BEGIN { use_ok "Math::Interpolator::Linear"; }
BEGIN { use_ok "Math::Interpolator::Knot"; }
BEGIN { use_ok "Math::Interpolator::Source"; }

sub pt(@) { Math::Interpolator::Knot->new(@_) }
sub proto(@) { Math::Interpolator::Source->new(@_) }

my $a5_called = 0;
sub a5() {
	$a5_called++;
	return [ pt(4, 6), pt(6, 7) ];
}

my $ipl;

$ipl = Math::Interpolator::Linear->new(pt(0, 1), pt(1, 0), pt(3, 5),
					proto(\&a5, 5));
is $a5_called, 0;
is $ipl->y(3.5), 5.5;

t/fraction.t  view on Meta::CPAN

use warnings;
use strict;

use Test::More tests => 11;

BEGIN { use_ok "Math::Interpolator::Linear"; }

BEGIN { use_ok "Math::Interpolator::Knot"; }

sub pt(@) { Math::Interpolator::Knot->new(@_) }

my $ipl = Math::Interpolator::Linear->new(pt(0.3, 5), pt(0.4, 6), pt(0.6, 5),
		pt(0.9, 5.75));

eval { $ipl->y(0.25); };
like $@, qr/\Adata does not extend to x=0\.25 /;

is $ipl->y(0.3), 5;
is $ipl->y(0.325), 5.25;
is $ipl->y(0.4), 6;

t/null.t  view on Meta::CPAN

use warnings;
use strict;

use Test::More tests => 12;

BEGIN { use_ok "Math::Interpolator::Linear"; }
BEGIN { use_ok "Math::Interpolator::Knot"; }
BEGIN { use_ok "Math::Interpolator::Source"; }

sub pt(@) { Math::Interpolator::Knot->new(@_) }
sub proto(@) { Math::Interpolator::Source->new(@_) }

my $a5_called = 0;
sub a5() {
	$a5_called++;
	return [];
}

my $ipl = Math::Interpolator::Linear->new(pt(0, 1), pt(1, 0), pt(3, 5),
		proto(\&a5, 5), pt(9, 8));

is $ipl->y(0.25), 0.75;
is $ipl->y(2), 2.5;
is $a5_called, 0;

t/ppro.t  view on Meta::CPAN

use warnings;
use strict;

use Test::More tests => 17;

BEGIN { use_ok "Math::Interpolator::Linear"; }
BEGIN { use_ok "Math::Interpolator::Knot"; }
BEGIN { use_ok "Math::Interpolator::Source"; }

sub pt(@) { Math::Interpolator::Knot->new(@_) }
sub proto(@) { Math::Interpolator::Source->new(@_) }

my $a6_called = 0;
sub a6() {
	$a6_called++;
	return [ pt(4, 6), pt(6, 7) ];
}

my $a5_called = 0;
sub a5() {
	$a5_called++;
	return [ pt(1, 0), pt(3, 5), proto(\&a6, 6), pt(9, 7.75) ];
}

my $ipl = Math::Interpolator::Linear->new(pt(0, 1), proto(\&a5, 5), pt(10, 8));

is $a5_called, 0;
is $a6_called, 0;
is $ipl->y(0.25), 0.75;
is $a5_called, 1;

t/proto.t  view on Meta::CPAN

use warnings;
use strict;

use Test::More tests => 12;

BEGIN { use_ok "Math::Interpolator::Linear"; }
BEGIN { use_ok "Math::Interpolator::Knot"; }
BEGIN { use_ok "Math::Interpolator::Source"; }

sub pt(@) { Math::Interpolator::Knot->new(@_) }
sub proto(@) { Math::Interpolator::Source->new(@_) }

my $a5_called = 0;
sub a5() {
	$a5_called++;
	return [ pt(4, 6), pt(6, 7) ];
}

my $ipl = Math::Interpolator::Linear->new(pt(0, 1), pt(1, 0), pt(3, 5),
		proto(\&a5, 5), pt(9, 7.75));

is $ipl->y(0.25), 0.75;
is $ipl->y(2), 2.5;
is $a5_called, 0;

t/robust.t  view on Meta::CPAN

use warnings;
use strict;

use Test::More tests => 74;

BEGIN { use_ok "Math::Interpolator::Robust"; }

BEGIN { use_ok "Math::Interpolator::Knot"; }

sub pt(@) { Math::Interpolator::Knot->new(@_) }

my $ipl = Math::Interpolator::Robust->new(
		pt(0, 1), pt(3, 5), pt(4, 6), pt(6, 5),
		pt(9, 5.75), pt(10, 10), pt(12, 12));

eval { $ipl->y(2.5); };
like $@, qr/\Adata does not extend to x=2\.5 /;

eval { $ipl->y(10.5); };
like $@, qr/\Adata does not extend to x=10\.5 /;

t/simple.t  view on Meta::CPAN

use warnings;
use strict;

use Test::More tests => 11;

BEGIN { use_ok "Math::Interpolator::Linear"; }

BEGIN { use_ok "Math::Interpolator::Knot"; }

sub pt(@) { Math::Interpolator::Knot->new(@_) }

my $ipl = Math::Interpolator::Linear->new(pt(3, 5), pt(4, 6), pt(6, 5),
		pt(9, 5.75));

eval { $ipl->y(2.5); };
like $@, qr/\Adata does not extend to x=2\.5 /;

is $ipl->y(3), 5;
is $ipl->y(3.25), 5.25;
is $ipl->y(4), 6;

t/xy.t  view on Meta::CPAN

use warnings;
use strict;

use Test::More tests => 20;

BEGIN { use_ok "Math::Interpolator::Linear"; }

BEGIN { use_ok "Math::Interpolator::Knot"; }

sub pt(@) { Math::Interpolator::Knot->new(@_) }

my $ipl = Math::Interpolator::Linear->new(pt(3, 5), pt(4, 6), pt(6, 7),
			pt(9, 7.75));

eval { $ipl->y(2.5); };
like $@, qr/\Adata does not extend to x=2\.5 /;

eval { $ipl->y(9.5); };
like $@, qr/\Adata does not extend to x=9\.5 /;



( run in 3.321 seconds using v1.01-cache-2.11-cpan-524268b4103 )