Diab Jerius > Math-Rational-Approx > Math::Rational::Approx::MaxD

Download:
Math-Rational-Approx-0.02.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.01   Source  

NAME ^

Math::Rational::Approx::MaxD - approximate a number with a rational number up to a given denominator

SYNOPSIS ^

    use Math::Rational::Approx::MaxD;

    # approximate up to denominator of 10
    $rat = Math::Rational::Approx::MaxD->new( x => $x, maxD => 10 );

    ($n, $d ) = $rat->approx;

    # approximate up to denominator of 20
    ($n, $d ) = $rat->approx( 20 );

DESCRIPTION ^

This module is an object oriented front end to the Math::Rational::Approx::maxd function

INTERFACE ^

new
    $obj = Math::Rational::Approx::MaxD->new( %attr );

Create a new object. The following attributes are available

x

The number to approximate.

maxD

The limiting maximum denominator to check;

bounds

Optional. A reference to a four element array containing the initial bounds on the region to search. It takes the form

  bounds => [ a, b, c, d ]

where the elements are all non-negative integers and the bounds are given by

  a/b < x < c/d

By default it searches from float(x) to float(x)+1.

approx
  ( $n, $d ) = $obj->approx;
  ( $n, $d ) = $obj->approx( $maxD );

Return the nominator and denominator for a given maximum value of the denominator. If $maxD is not specified it is that specified in the call to the constructor or in any subsequent call to approx. New values of $maxD less than one already specified are ignored.

bounds
  $bounds = $obj->bounds;

Return an arrayref which contains the current bounds on the search, in the same format as the bounds attribute passed to new.

x
  $x = $obj->x;

The original number to be approximated.

maxD

The current value of the maximum denominator.

DEPENDENCIES ^

Moo, MooX::Types::MooseLike, Params::Validate, Math::Rational::Approx.

INCOMPATIBILITIES ^

None reported.

BUGS AND LIMITATIONS ^

No bugs have been reported.

Please report any bugs or feature requests to bug-math-rational-approx@rt.cpan.org, or through the web interface at http://rt.cpan.org/Public/Dist/Display.html?Name=Math-Rational-Approx.

SEE ALSO ^

Math::Rational::Approx

AUTHOR ^

Diab Jerius <djerius@cpan.org>

LICENSE AND COPYRIGHT ^

Copyright (c) 2012 The Smithsonian Astrophysical Observatory

Math::Rational::Approx is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

syntax highlighting: