Diab Jerius > Math-Rational-Approx-0.01 > Math::Rational::Approx::ContFrac

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

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.01   Source   Latest Release: Math-Rational-Approx-0.02

NAME ^

Math::Rational::Approx::ContFrac - Rational number approximation via continued fractions

SYNOPSIS ^

    use Math::Rational::Approx::ContFrac;

    $x = Math::Rational::Approx::ContFrac->new( x => 1.234871035, n => 10 );
    ( $n, $d ) = $x->approx;
    # continue for an additonal number of steps
    ( $n, $d ) = $x->approx( 3 );

DESCRIPTION ^

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

INTERFACE ^

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

Construct an object which will maintain state for the continued fraction. The following attributes are available:

x

The number to approximate. It must be positive.

n

The number of terms to generate. This may be augmented in calls to the approx method.

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

Calculate the continued fractions and return the associated nominator and denominator. If $n is not specified, the number of terms generated is that specified in the call to the constructor, plus any terms requested by additional calls to approx with $n specified.

$n specifies the number of additional terms to generate beyond what has already been requested.

x
  $x = $obj->x;

The original number to be approximated.

n
  $n = $obj->n;

The number of terms generated.

terms
  $arrayref = $obj->terms

Returns an arrayref of the current terms.

resid

The residual of the input number as a Math::BigFloat object. This is not the difference between the input number and the rational approximation.

DEPENDENCIES ^

Math::BigFloat, Moo, MooX::Types::MooseLike::Numeric, Params::Validate

INCOMPATIBILITIES ^

None reported.

BUGS AND LIMITATIONS ^

No bugs have been reported.

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

SEE ALSO ^

Math::BigFloat, Moo, MooX::Types::MooseLike, Params::Validate, 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: