r3769 - in /packages/libmath-fibonacci-perl: ./ branches/ branches/upstream/ branches/upstream/current/ branches/upstream/current/lib/ branches/upstream/current/lib/Math/ branches/upstream/current/t/ tags/

gregoa-guest at users.alioth.debian.org gregoa-guest at users.alioth.debian.org
Thu Sep 14 22:09:14 UTC 2006


Author: gregoa-guest
Date: Thu Sep 14 22:09:13 2006
New Revision: 3769

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=3769
Log:
[svn-inject] Installing original source of libmath-fibonacci-perl

Added:
    packages/libmath-fibonacci-perl/
    packages/libmath-fibonacci-perl/branches/
    packages/libmath-fibonacci-perl/branches/upstream/
    packages/libmath-fibonacci-perl/branches/upstream/current/
    packages/libmath-fibonacci-perl/branches/upstream/current/ARTISTIC
    packages/libmath-fibonacci-perl/branches/upstream/current/Changes
    packages/libmath-fibonacci-perl/branches/upstream/current/MANIFEST
    packages/libmath-fibonacci-perl/branches/upstream/current/Makefile.PL
    packages/libmath-fibonacci-perl/branches/upstream/current/TODO
    packages/libmath-fibonacci-perl/branches/upstream/current/lib/
    packages/libmath-fibonacci-perl/branches/upstream/current/lib/Math/
    packages/libmath-fibonacci-perl/branches/upstream/current/lib/Math/Fibonacci.pm
    packages/libmath-fibonacci-perl/branches/upstream/current/t/
    packages/libmath-fibonacci-perl/branches/upstream/current/t/01-basic.t   (with props)
    packages/libmath-fibonacci-perl/branches/upstream/current/t/02-decompose.t   (with props)
    packages/libmath-fibonacci-perl/tags/

Added: packages/libmath-fibonacci-perl/branches/upstream/current/ARTISTIC
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-fibonacci-perl/branches/upstream/current/ARTISTIC?rev=3769&op=file
==============================================================================
--- packages/libmath-fibonacci-perl/branches/upstream/current/ARTISTIC (added)
+++ packages/libmath-fibonacci-perl/branches/upstream/current/ARTISTIC Thu Sep 14 22:09:13 2006
@@ -1,0 +1,117 @@
+
+
+                        The "Artistic License"
+
+                              Preamble
+
+The intent of this document is to state the conditions under which a
+Package may be copied, such that the Copyright Holder maintains some
+semblance of artistic control over the development of the package, while
+giving the users of the package the right to use and distribute the
+Package in a more-or-less customary fashion, plus the right to make
+reasonable modifications.
+
+Definitions:
+
+        "Package" refers to the collection of files distributed by the
+        Copyright Holder, and derivatives of that collection of files
+        created through textual modification.
+
+        "Standard Version" refers to such a Package if it has not been
+        modified, or has been modified in accordance with the wishes of
+        the Copyright Holder.
+
+        "Copyright Holder" is whoever is named in the copyright or
+        copyrights for the package.
+
+        "You" is you, if you're thinking about copying or distributing
+        this Package.
+
+        "Reasonable copying fee" is whatever you can justify on the basis
+        of media cost, duplication charges, time of people involved, and
+        so on. (You will not be required to justify it to the Copyright
+        Holder, but only to the computing community at large as a market
+        that must bear the fee.)
+
+        "Freely Available" means that no fee is charged for the item
+        itself, though there may be fees involved in handling the item. It
+        also means that recipients of the item may redistribute it under
+        the same conditions they received it.
+
+1. You may make and give away verbatim copies of the source form of the
+   Standard Version of this Package without restriction, provided that you
+   duplicate all of the original copyright notices and associated
+   disclaimers.
+
+2. You may apply bug fixes, portability fixes and other modifications
+   derived from the Public Domain or from the Copyright Holder. A Package
+   modified in such a way shall still be considered the Standard Version.
+
+3. You may otherwise modify your copy of this Package in any way, provided
+   that you insert a prominent notice in each changed file stating how and
+   when you changed that file, and provided that you do at least ONE of
+   the following:
+
+    a) place your modifications in the Public Domain or otherwise make
+       them Freely Available, such as by posting said modifications to
+       Usenet or an equivalent medium, or placing the modifications on a
+       major archive site such as ftp.uu.net, or by allowing the
+       Copyright Holder to include your modifications in the Standard
+       Version of the Package.
+
+    b) use the modified Package only within your corporation or
+       organization.
+
+    c) rename any non-standard executables so the names do not conflict
+       with standard executables, which must also be provided, and provide
+       a separate manual page for each non-standard executable that
+       clearly documents how it differs from the Standard Version.
+
+    d) make other distribution arrangements with the Copyright Holder.
+
+4. You may distribute the programs of this Package in object code or
+   executable form, provided that you do at least ONE of the following:
+
+    a) distribute a Standard Version of the executables and library files,
+       together with instructions (in the manual page or equivalent) on
+       where to get the Standard Version.
+
+    b) accompany the distribution with the machine-readable source of the
+       Package with your modifications.
+
+    c) accompany any non-standard executables with their corresponding
+       Standard Version executables, giving the non-standard executables
+       non-standard names, and clearly documenting the differences in
+       manual pages (or equivalent), together with instructions on where
+       to get the Standard Version.
+
+    d) make other distribution arrangements with the Copyright Holder.
+
+5. You may charge a reasonable copying fee for any distribution of this
+   Package. You may charge any fee you choose for support of this Package.
+   You may not charge a fee for this Package itself. However, you may
+   distribute this Package in aggregate with other (possibly commercial)
+   programs as part of a larger (possibly commercial) software
+   distribution provided that you do not advertise this Package as a
+   product of your own.
+
+6. The scripts and library files supplied as input to or produced as
+   output from the programs of this Package do not automatically fall
+   under the copyright of this Package, but belong to whomever
+   generated them, and may be sold commercially, and may be aggregated
+   with this Package.
+
+7. C or perl subroutines supplied by you and linked into this Package
+   shall not be considered part of this Package.
+
+8. The name of the Copyright Holder may not be used to endorse or promote
+   products derived from this software without specific prior written
+   permission.
+
+9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
+   WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+   MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+                                The End
+
+

Added: packages/libmath-fibonacci-perl/branches/upstream/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-fibonacci-perl/branches/upstream/current/Changes?rev=3769&op=file
==============================================================================
--- packages/libmath-fibonacci-perl/branches/upstream/current/Changes (added)
+++ packages/libmath-fibonacci-perl/branches/upstream/current/Changes Thu Sep 14 22:09:13 2006
@@ -1,0 +1,5 @@
+
+                       CHANGELOG for Math::Fibonacci
+           $Id: Changes,v 1.1.1.1 2001/04/28 19:17:52 vipul Exp $
+
+--------------------------------------------------------------------------

Added: packages/libmath-fibonacci-perl/branches/upstream/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-fibonacci-perl/branches/upstream/current/MANIFEST?rev=3769&op=file
==============================================================================
--- packages/libmath-fibonacci-perl/branches/upstream/current/MANIFEST (added)
+++ packages/libmath-fibonacci-perl/branches/upstream/current/MANIFEST Thu Sep 14 22:09:13 2006
@@ -1,0 +1,17 @@
+
+# Files in Math-Fibonacci bundle. 
+
+MANIFEST
+ARTISTIC
+TODO 
+Changes
+
+Makefile.PL
+
+lib/Math/Fibonacci.pm
+
+t/01-basic.t
+t/02-decompose.t
+
+# $Id: MANIFEST,v 1.2 2001/04/28 20:38:36 vipul Exp $ 
+

Added: packages/libmath-fibonacci-perl/branches/upstream/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-fibonacci-perl/branches/upstream/current/Makefile.PL?rev=3769&op=file
==============================================================================
--- packages/libmath-fibonacci-perl/branches/upstream/current/Makefile.PL (added)
+++ packages/libmath-fibonacci-perl/branches/upstream/current/Makefile.PL Thu Sep 14 22:09:13 2006
@@ -1,0 +1,19 @@
+#!/usr/bin/perl -sw
+##
+## Makefile.PL for Math::Fibonacci
+##
+## Copyright (c) 2001, Vipul Ved Prakash.  All rights reserved.
+## This code is free software; you can redistribute it and/or modify
+## it under the same terms as Perl itself.
+##
+## $Id: Makefile.PL,v 1.2 2001/04/28 20:36:55 vipul Exp $
+
+use ExtUtils::MakeMaker;
+WriteMakefile(
+    'NAME'         => 'Math::Fibonacci',
+    'AUTHOR'       => 'Vipul Ved Prakash <mail at vipul.net>',
+    'VERSION_FROM' => 'lib/Math/Fibonacci.pm',
+    'PREREQ_PM'    => { 
+                      } 
+);
+

Added: packages/libmath-fibonacci-perl/branches/upstream/current/TODO
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-fibonacci-perl/branches/upstream/current/TODO?rev=3769&op=file
==============================================================================
--- packages/libmath-fibonacci-perl/branches/upstream/current/TODO (added)
+++ packages/libmath-fibonacci-perl/branches/upstream/current/TODO Thu Sep 14 22:09:13 2006
@@ -1,0 +1,21 @@
+
+
+                         TODO for Math::Fibonacci
+            $Id: TODO,v 1.1.1.1 2001/04/28 19:17:52 vipul Exp $
+
+-------------------------------------------------------------------------------
+P No Task                                              Status
+- -- ------------------------------------------------  ------------------------
+
+*  1 Should be able to decompose Math::Pari integers
+*  2 Should return Math::Pari integers if the return 
+     value is too big to fit in a perl int.
+
+-------------------------------------------------------------------------------
+
+LEGEND
+ - Date in the Status field indicates the task was completed on that date.
+ - `*' in P field distinguishes pending tasks.
+ - `+' before the task description indicates a sub-task.
+
+

Added: packages/libmath-fibonacci-perl/branches/upstream/current/lib/Math/Fibonacci.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-fibonacci-perl/branches/upstream/current/lib/Math/Fibonacci.pm?rev=3769&op=file
==============================================================================
--- packages/libmath-fibonacci-perl/branches/upstream/current/lib/Math/Fibonacci.pm (added)
+++ packages/libmath-fibonacci-perl/branches/upstream/current/lib/Math/Fibonacci.pm Thu Sep 14 22:09:13 2006
@@ -1,0 +1,135 @@
+#!/usr/bin/perl
+#
+# Computes the Fibonacci sequence using the fast algorithm:  F(n) ~ g^n/sqrt(5),
+# where g is the golden ratio and ~ stands for "take the nearest integer."
+#
+# Copyright (c) 1999-2000, Vipul Ved Prakash <mail at vipul.net>
+# This code is free software distributed under the same license as Perl itself.
+# $Id: Fibonacci.pm,v 1.5 2001/04/28 20:41:15 vipul Exp $
+
+package Math::Fibonacci;
+use strict;
+use vars qw($VERSION @ISA @EXPORT_OK);
+use POSIX qw(log10 ceil floor); 
+require Exporter;
+ at ISA = qw(Exporter);
+( $VERSION )  = '$Revision: 1.5 $' =~ /\s(\d+\.\d+)\s/; 
+
+ at EXPORT_OK = qw(term series decompose isfibonacci);
+
+sub g ()     { "1.61803398874989" }  # golden ratio
+
+sub term     { nearestint ((g ** shift) / sqrt(5)) } # nth term of the seq
+
+sub series   { return map(term($_), 1..shift) } # n terms of the seq
+
+
+sub decompose {                      # decomposes any integer into the sum of
+                                     # members of the fibonacci sequence.
+    my ($int) = @_;
+    my $sum = decomp ($int);
+    return @$sum;
+
+}
+
+sub decomp { 
+    my ($a, $sum) = @_; 
+    my $n = nearestint ((log10($a) + log10(sqrt(5)))/log10(g));
+    my $fibn = term($n);
+       if ( $fibn == $a ) { push @$sum, $a; return $sum } 
+    elsif ( $fibn < $a  ) { push @$sum, $fibn; decomp( $a-$fibn, $sum ) }
+    elsif ( $a < $fibn  ) { my $fibn1 = term($n-1); push @$sum, $fibn1; 
+                            decomp( $a - $fibn1, $sum ) }
+};
+
+
+sub isfibonacci { 
+    
+    my $a = shift;
+    my $n = nearestint ((log10($a) + log10(sqrt(5)))/log10(g));
+    return $a == term($n) ? $n : 0;
+
+}
+
+sub nearestint {
+    my $v = shift;
+    my $f = floor($v); my $c = ceil($v);
+    ($v-$f) < ($c-$v) ? $f : $c;
+}
+
+
+# routines to implement term and series with the familiar additive algorithm.
+
+sub a_term     { return $_[0] < 3 ? 1 : a_term($_[0]-1) + a_term ($_[0]-2) }
+
+sub a_series   {
+    my @series = map(a_term($_), 1..shift);
+    \@series;
+}
+
+
+1;
+
+
+=head1 NAME
+
+Math::Fibonacci - Fibonacci numbers.
+
+=head1 VERSION
+
+    $Revision: 1.5 $
+
+=head1 SYNOPSIS
+
+    use Math::Fibonacci qw(term series decompose);
+
+    my $term = term ( 42 );
+    my @series = series ( 42 );
+    my @sum = decompose ( 65535 );
+
+=head1 DESCRIPTION
+
+This module provides a few functions related to Fibonacci numbers.
+
+=head1 EXPORTS ON REQUEST
+
+term(), series() decompose(), isfibonacci()
+
+=head1 FUNCTIONS
+
+=over 4
+
+=item B<term($n)> 
+
+Returns the $n-th term of the Fibonacci sequence. The term is computed
+using the fast algorithm: C<F(n) ~ g^n/sqrt(5)>, where g is the golden
+ratio and ~ means "take the nearest integer".
+
+=item B<series($n)> 
+
+Computes and returns the first $n Fibonacci numbers.
+
+=item B<decompose($int)> 
+
+Decomposes $int into the sum of Fibonacci numbers. Returns the list of
+Fibonacci numbers.  
+
+=item B<isfibonacci($int)>
+
+Returns the sequence number of $int if it is a Fibonacci number or a
+non-true value if it is not.
+
+=head1 AUTHOR
+
+Vipul Ved Prakash, E<lt>mail at vipul.netE<gt>
+
+=head1 LICENSE 
+
+Copyright (c) 1999-2001, Vipul Ved Prakash.  
+
+This code is free software; you can redistribute it and/or modify it under
+the ARTISTIC license (a copy is included in the distribution) or under the
+same terms as Perl itself.
+
+=cut
+

Added: packages/libmath-fibonacci-perl/branches/upstream/current/t/01-basic.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-fibonacci-perl/branches/upstream/current/t/01-basic.t?rev=3769&op=file
==============================================================================
--- packages/libmath-fibonacci-perl/branches/upstream/current/t/01-basic.t (added)
+++ packages/libmath-fibonacci-perl/branches/upstream/current/t/01-basic.t Thu Sep 14 22:09:13 2006
@@ -1,0 +1,31 @@
+#!/usr/bin/perl -sw
+##
+## 01-basic.t
+##
+## Copyright (c) 2001, Vipul Ved Prakash.  All rights reserved.
+## This code is free software; you can redistribute it and/or modify
+## it under the same terms as Perl itself.
+##
+## $Id: 01-basic.t,v 1.1.1.1 2001/04/28 19:17:52 vipul Exp $
+
+use Test; 
+use lib '../lib';
+use Math::Fibonacci qw(term series decompose isfibonacci);
+
+BEGIN { plan tests => 10 };
+
+ok(term(2),1);
+ok(term(10),55);
+ok(term(42),267914296);
+ok(term(31),1346269);
+
+ok("@{[series(20)]}", "1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765");
+
+ok(isfibonacci(3),4);
+ok(isfibonacci(233),13);
+ok(isfibonacci(267914296),42);
+ok(isfibonacci(15),0);
+ok(isfibonacci(65535),0);
+
+# my @y = decompose (4200);
+# print "@y\n";

Propchange: packages/libmath-fibonacci-perl/branches/upstream/current/t/01-basic.t
------------------------------------------------------------------------------
    svn:executable = 

Added: packages/libmath-fibonacci-perl/branches/upstream/current/t/02-decompose.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-fibonacci-perl/branches/upstream/current/t/02-decompose.t?rev=3769&op=file
==============================================================================
--- packages/libmath-fibonacci-perl/branches/upstream/current/t/02-decompose.t (added)
+++ packages/libmath-fibonacci-perl/branches/upstream/current/t/02-decompose.t Thu Sep 14 22:09:13 2006
@@ -1,0 +1,20 @@
+#!/usr/bin/perl -sw
+##
+## 01-basic.t
+##
+## Copyright (c) 2001, Vipul Ved Prakash.  All rights reserved.
+## This code is free software; you can redistribute it and/or modify
+## it under the same terms as Perl itself.
+##
+## $Id: 02-decompose.t,v 1.1.1.1 2001/04/28 19:17:52 vipul Exp $
+
+use Test; 
+use lib '../lib';
+use Math::Fibonacci qw(decompose isfibonacci);
+
+BEGIN { plan tests => 9 };
+
+my @d = decompose (9372883);
+for (@d) { 
+    ok(isfibonacci($_));
+};

Propchange: packages/libmath-fibonacci-perl/branches/upstream/current/t/02-decompose.t
------------------------------------------------------------------------------
    svn:executable = 




More information about the Pkg-perl-cvs-commits mailing list