Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ WriteMakefile(
},
BUILD_REQUIRES => {
'Test::More' => 0,
'Moose' => 0,
'Moose::Role' => 0,
'MooseX::Traits' => 0,
'Moo' => 0,
'Moo::Role' => 0,
'MooX::Traits' => 0,
'Module::Runtime' => 0,
'Module::Pluggable' => 0,
'Carp' => 0,
Expand Down
11 changes: 6 additions & 5 deletions lib/Math/Function/Interpolator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@ use 5.006;
use strict;
use warnings FATAL => 'all';

use Moose;
with qw(MooseX::Traits);
use Moo;
with qw(MooX::Traits);

use Carp qw(confess);
use Scalar::Util qw(looks_like_number);
use Module::Runtime;
use Module::Pluggable
sub_name => 'interpolate_methods',
search_path => ['Math::Function::Interpolator'],
;
;

# Automatically load all interpolate methods
has 'interpolate_classes' => (
is => 'ro',
isa => 'Bool',
lazy => 1,
default => sub {
my ($self) = @_;
Expand All @@ -32,7 +31,9 @@ has 'interpolate_classes' => (

has points => (
is => 'ro',
isa => 'HashRef',
isa => sub {
die "Points $_[0] shold be hash" unless ref $_[0] eq 'HASH';
},
required => 1,
);

Expand Down
21 changes: 11 additions & 10 deletions lib/Math/Function/Interpolator/Cubic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use warnings FATAL => 'all';

our $VERSION = '0.01';

use Moose::Role;
use Moo::Role;

use Carp qw(confess);
use List::MoreUtils qw(pairwise indexes);
Expand All @@ -15,7 +15,10 @@ use Scalar::Util qw(looks_like_number);

has 'interpolate' => (
is => 'ro',
isa => 'Math::Function::Interpolator',
isa => sub {
die "Must be Interpolate class"
unless ref $_[0] eq 'Math::Function::Interpolator';
},
required => 1
);

Expand All @@ -26,14 +29,14 @@ has _sorted_Xs => (
);

sub _build__sorted_Xs {
my $self = shift;
my ($self) = @_;
return [ sort { $a <=> $b } keys %{ $self->interpolate->points } ];
}

has _spline_points => (
is => 'ro',
init_arg => undef,
lazy_build => 1,
lazy => 1,
builder => '_build__spline_points',
);

sub _build__spline_points {
Expand All @@ -44,11 +47,10 @@ sub _build__spline_points {
my @Ys = map { $points_ref->{$_} } @$Xs;

# First element is 0
# Second derivative of the Y's
# Second derivative of the Ys
my @y_2derivative = (0);

my @u = (0);
my $counter = @$Xs - 2;
my @u = (0);
my $counter = @$Xs - 2;

for my $i ( 1 .. $counter ) {
my $sig =
Expand Down Expand Up @@ -91,7 +93,6 @@ sub _extrapolate_spline {
}

# Returns the interpolated_y given point_x and a minimum of 5 data points

sub do_calculation {
my ( $self, $x ) = @_;

Expand Down
9 changes: 6 additions & 3 deletions lib/Math/Function/Interpolator/Linear.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ use warnings FATAL => 'all';

our $VERSION = '0.01';

use Moose::Role;

use Moo::Role;
use Carp qw(confess);
use Number::Closest::XS qw(find_closest_numbers_around);
use Scalar::Util qw(looks_like_number);

has 'interpolate' => (
is => 'ro',
isa => 'Math::Function::Interpolator',
isa => sub {
die "Must be Interpolate class"
unless ref $_[0] eq 'Math::Function::Interpolator';
},
required => 1
);

Expand Down
7 changes: 5 additions & 2 deletions lib/Math/Function/Interpolator/Quadratic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use warnings FATAL => 'all';

our $VERSION = '0.01';

use Moose::Role;
use Moo::Role;

use Carp qw(confess);
use List::MoreUtils qw(pairwise indexes);
Expand All @@ -19,7 +19,10 @@ use Try::Tiny;

has 'interpolate' => (
is => 'ro',
isa => 'Math::Function::Interpolator',
isa => sub {
die "Must be Interpolate class"
unless ref $_[0] eq 'Math::Function::Interpolator';
},
required => 1
);

Expand Down