Algorithm-GoldenSection
view release on metacpan or search on metacpan
lib/Algorithm/GoldenSection.pm view on Meta::CPAN
Readonly::Scalar my $tolerancia => 3.0e-8; # tolerance
Readonly::Scalar my $C => (3-sqrt(5))/2;
Readonly::Scalar my $R => 1-$C;
#/ I had leaving things for operator precedence. you won´t see A+B*(C-D) whe you mean: A+( B*(C-D) ) - i.e. * binds more tightly that +
sub new {
my ( $class, $h_ref ) = @_;
croak qq{\nArguments must be passed as HASH reference.} if ( ( $h_ref ) && ( ref $h_ref ne q{HASH} ) );
my $self = {};
bless $self, $class;
$self->_check_options($h_ref);
return $self;
}
sub _check_options {
my ( $self, $h_ref ) = @_;
croak qq{\nOption \x27function\x27 is obrigatory and accepts a CODE reference}
if ( ( !exists $h_ref->{function} ) || ( ref $h_ref->{function} ne q{CODE} ) );
( run in 0.250 second using v1.01-cache-2.11-cpan-de7293f3b23 )