r3774 - in /packages/libmath-nocarry-perl: ./ branches/ branches/upstream/ branches/upstream/current/ branches/upstream/current/lib/ branches/upstream/current/t/ tags/

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


Author: gregoa-guest
Date: Thu Sep 14 22:13:43 2006
New Revision: 3774

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

Added:
    packages/libmath-nocarry-perl/
    packages/libmath-nocarry-perl/branches/
    packages/libmath-nocarry-perl/branches/upstream/
    packages/libmath-nocarry-perl/branches/upstream/current/
    packages/libmath-nocarry-perl/branches/upstream/current/Changes
    packages/libmath-nocarry-perl/branches/upstream/current/MANIFEST
    packages/libmath-nocarry-perl/branches/upstream/current/META.yml
    packages/libmath-nocarry-perl/branches/upstream/current/Makefile.PL
    packages/libmath-nocarry-perl/branches/upstream/current/README
    packages/libmath-nocarry-perl/branches/upstream/current/lib/
    packages/libmath-nocarry-perl/branches/upstream/current/lib/NoCarry.pm
    packages/libmath-nocarry-perl/branches/upstream/current/t/
    packages/libmath-nocarry-perl/branches/upstream/current/t/add.t
    packages/libmath-nocarry-perl/branches/upstream/current/t/load.t
    packages/libmath-nocarry-perl/branches/upstream/current/t/multiply.t
    packages/libmath-nocarry-perl/branches/upstream/current/t/pod.t
    packages/libmath-nocarry-perl/branches/upstream/current/t/pod_coverage.t
    packages/libmath-nocarry-perl/branches/upstream/current/t/prereq.t
    packages/libmath-nocarry-perl/branches/upstream/current/t/subtract.t
    packages/libmath-nocarry-perl/branches/upstream/current/t/test_manifest
    packages/libmath-nocarry-perl/tags/

Added: packages/libmath-nocarry-perl/branches/upstream/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-nocarry-perl/branches/upstream/current/Changes?rev=3774&op=file
==============================================================================
--- packages/libmath-nocarry-perl/branches/upstream/current/Changes (added)
+++ packages/libmath-nocarry-perl/branches/upstream/current/Changes Thu Sep 14 22:13:43 2006
@@ -1,0 +1,24 @@
+Revision history for Perl extension Math::NoCarry.
+
+1.09 - Thu May 18 17:15:39 2006
+	* Updates to distro and kwalitee. No need to upgrade.
+
+1.08 - Fri Mar 11 21:55:20 2005
+	* Updated docs for POD coverage tests
+	* No code changes, but the docs for subtract() are labelled
+	correctly now.
+
+1.07 - Wed Nov 17 16:03:55 2004
+* no changes
+
+1.07 - Fri Oct  8 15:56:57 2004
+* no feature changes: added strictures and removed unreachable statement
+
+1.06 - Wed Sep  8 03:43:12 2004
+* cleaned up the distro and the docs
+8 no code changes, no need to upgrade
+
+0.01  Tue Jun 25 03:10:43 2002
+	- original version; created by h2xs 1.21 with options
+		-AXn Math::NoCarry
+

Added: packages/libmath-nocarry-perl/branches/upstream/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-nocarry-perl/branches/upstream/current/MANIFEST?rev=3774&op=file
==============================================================================
--- packages/libmath-nocarry-perl/branches/upstream/current/MANIFEST (added)
+++ packages/libmath-nocarry-perl/branches/upstream/current/MANIFEST Thu Sep 14 22:13:43 2006
@@ -1,0 +1,14 @@
+Changes
+lib/NoCarry.pm
+Makefile.PL
+MANIFEST
+META.yml
+README
+t/add.t
+t/load.t
+t/multiply.t
+t/pod.t
+t/pod_coverage.t
+t/prereq.t
+t/subtract.t
+t/test_manifest

Added: packages/libmath-nocarry-perl/branches/upstream/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-nocarry-perl/branches/upstream/current/META.yml?rev=3774&op=file
==============================================================================
--- packages/libmath-nocarry-perl/branches/upstream/current/META.yml (added)
+++ packages/libmath-nocarry-perl/branches/upstream/current/META.yml Thu Sep 14 22:13:43 2006
@@ -1,0 +1,11 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
+name:         Math-NoCarry
+version:      1.09
+version_from: lib/NoCarry.pm
+installdirs:  site
+requires:
+    Test::More:                    0
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.30

Added: packages/libmath-nocarry-perl/branches/upstream/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-nocarry-perl/branches/upstream/current/Makefile.PL?rev=3774&op=file
==============================================================================
--- packages/libmath-nocarry-perl/branches/upstream/current/Makefile.PL (added)
+++ packages/libmath-nocarry-perl/branches/upstream/current/Makefile.PL Thu Sep 14 22:13:43 2006
@@ -1,0 +1,21 @@
+# $Id: Makefile.PL,v 1.3 2006/05/18 22:14:56 comdog Exp $
+use ExtUtils::MakeMaker;
+
+eval "use Test::Manifest 1.14";
+
+WriteMakefile
+	(
+	'NAME'           => 'Math::NoCarry',
+	'VERSION_FROM'   => 'lib/NoCarry.pm',
+	'PM'             => {
+		'lib/NoCarry.pm'    => '$(INST_LIBDIR)/NoCarry.pm',
+		},
+	'PREREQ_PM' => {
+		'Test::More'       => '0',
+		},
+	'MAN3PODS'     => {
+		'lib/NoCarry.pm' => '$(INST_MAN3DIR)/Math::NoCarry.3',
+		},
+
+	clean => { FILES => 'Math-NoCarry-*' },
+	);

Added: packages/libmath-nocarry-perl/branches/upstream/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-nocarry-perl/branches/upstream/current/README?rev=3774&op=file
==============================================================================
--- packages/libmath-nocarry-perl/branches/upstream/current/README (added)
+++ packages/libmath-nocarry-perl/branches/upstream/current/README Thu Sep 14 22:13:43 2006
@@ -1,0 +1,27 @@
+$Id: README,v 1.1 2004/09/08 08:30:21 comdog Exp $
+
+You can install this using in the usual Perl fashion
+
+	perl Makefile.PL
+	make
+	make test
+	make install
+	
+The documentation is in the module file.  Once you install
+the file, you can read it with perldoc.
+
+	perldoc Math::NoCarry
+	
+If you want to read it before you install it, you can use
+perldoc directly on the module file.
+
+	perldoc  lib/NoCarry.pm
+	
+This module is also in CVS on SourceForge
+
+	http://sourceforge.net/projects/brian-d-foy/
+
+
+Enjoy, 
+
+brian d foy, bdfoy at cpan.org

Added: packages/libmath-nocarry-perl/branches/upstream/current/lib/NoCarry.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-nocarry-perl/branches/upstream/current/lib/NoCarry.pm?rev=3774&op=file
==============================================================================
--- packages/libmath-nocarry-perl/branches/upstream/current/lib/NoCarry.pm (added)
+++ packages/libmath-nocarry-perl/branches/upstream/current/lib/NoCarry.pm Thu Sep 14 22:13:43 2006
@@ -1,0 +1,229 @@
+# $Id: NoCarry.pm,v 1.9 2006/05/18 22:14:56 comdog Exp $
+package Math::NoCarry;
+use strict;
+
+use base qw(Exporter);
+
+use vars qw($VERSION);
+$VERSION = sprintf "%d.%02d", q$Revision: 1.9 $ =~ m/ (\d+) \. (\d+) /xg;
+
+=head1 NAME
+
+Math::NoCarry - Perl extension for no carry arithmetic
+
+=head1 SYNOPSIS
+
+	use Math::NoCarry;
+
+	my $sum        = Math::NoCarry::add( 123, 456 );
+
+	my $difference = Math::NoCarry::subtract( 123, 456 );
+
+	my $product    = Math::NoCarry::multiply( 123, 456 );
+
+=head1 DESCRIPTION
+
+No carry arithmetic doesn't allow you to carry digits to the
+next column.  For example, if you add 8 and 4, you normally
+expect the answer to be 12, but that 1 digit is a carry.
+In no carry arithmetic you can't do that, so the sum of
+8 and 4 is just 2.  In effect, this is addition modulo 10
+in each column. I discard all of the carry digits in
+this example:
+
+	  1234
+	+ 5678
+	------
+	  6802
+
+For multiplication, the result of pair-wise multiplication
+of digits is the modulo 10 value of their normal, everyday
+multiplication.
+
+        123
+      x 456
+      -----
+          8   6 x 3
+         2    6 x 2
+        6     6 x 1
+
+         5    5 x 3
+        0     5 x 2
+       5      5 x 1
+
+        2     4 x 3
+       8      4 x 2
+    + 4       4 x 1
+    -------
+      43878
+
+Since multiplication and subtraction are actually types of
+additions, you can multiply and subtract like this as well.
+
+No carry arithmetic is both associative and commutative.
+
+=head2 Functions
+
+This module does not export any functions.
+
+=over 4
+
+=item multiply( A, B )
+
+Returns the no carry product of A and B.
+
+Return A if it is the only argument ( A x 1 );
+
+=cut
+
+sub multiply
+	{
+	return $_[0] if $#_ < 1;
+
+	@_ = map { $_ += 0 } @_;
+
+	my $sign = ($_[0] > 0 and $_[1] < 0 ) ||
+		($_[1] > 0 and $_[0] < 0 );
+
+	my @p0 = reverse split //, abs $_[0];
+	my @p1 = reverse split //, abs $_[1];
+
+	my @m;
+
+	foreach my $i ( 0 .. $#p0 )
+		{
+		foreach my $j ( 0 .. $#p1 )
+			{
+			push @m, ( ( $p1[$j] * $p0[$i] ) % 10 ) * ( 10**($i+$j) );
+			}
+		}
+
+	while( @m > 1 )
+		{
+		unshift @m, Math::NoCarry::add( shift @m, shift @m );
+		}
+
+	$m[0] *= -1 if $sign;
+
+	return $m[0];
+	}
+
+=item add( A, B )
+
+Returns the no carry sum of the positive numbers A and B.
+
+Returns A if it is the only argument ( A + 0 )
+
+Returns false if either number is negative.
+
+=cut
+
+sub add
+	{
+	return $_[0] if $#_ < 1;
+
+	@_ = map { local $^W; $_ += 0 } @_;
+
+	return unless( $_[0] >= 0 and $_[1] >= 0 );
+
+	my @addends = map scalar reverse, @_;
+
+	my $string = '';
+
+	my $max = length $addends[0];
+	$max = length $addends[1] if length $addends[1] > $max;
+
+	for( my $i = 0; $i < $max ; $i++ )
+		{
+		my @digits = map { local $^W = 0; substr( $_, $i, 1) or 0 } @addends;
+
+		my $sum = ( $digits[0] + $digits[1] ) % 10;
+
+		$string .= $sum;
+		}
+
+	$string =~ s/0*$//;
+
+	$string = scalar reverse $string;
+
+	return $string;
+	}
+
+=item subtract( A, B )
+
+Returns the no carry difference of the postive numbers A and B.
+
+Returns A if it is the only argument ( A - 0 )
+
+Returns false if either number is negative.
+
+=cut
+
+sub subtract
+	{
+	return $_[0] if $#_ < 1;
+
+	return unless( $_[0] >= 0 and $_[1] >= 0);
+
+	my @addends = map scalar reverse, @_;
+
+	my $string = '';
+
+	my $max = length $addends[0];
+	$max = length $addends[1] if length $addends[1] > $max;
+
+	for( my $i = 0; $i < $max ; $i++ )
+		{
+		my @digits = map { substr $_, $i, 1 } @addends;
+
+		$digits[0] += 10 if $digits[0] < $digits[1];
+
+		my $sum = ( $digits[0] - $digits[1] ) % 10;
+
+		$string .= $sum;
+		}
+
+	return scalar reverse $string;
+	}
+
+1;
+
+__END__
+
+=back
+
+=head1 BUGS
+
+* none reported yet :)
+
+=head1 TO DO
+
+* this could be a full object package with overloaded
++, *, and - operators
+
+* it would be nice if i could give the functions more than
+two arguments.
+
+* addition and subtraction don't do negative numbers.
+
+=head1 SOURCE AVAILABILITY
+
+This source is part of a SourceForge project which always has the
+latest sources in CVS, as well as all of the previous releases.
+
+	http://sourceforge.net/projects/brian-d-foy/
+
+If, for some reason, I disappear from the world, one of the other
+members of the project can shepherd this module appropriately.
+
+=head1 AUTHOR
+
+brian d foy, C<< <bdfoy at cpan.org> >>
+
+=head1 COPYRIGHT
+
+Copyright 2002-2006, brian d foy, All Rights Reserved.
+
+You may redistribute this under the same terms as Perl itself.
+
+=cut

Added: packages/libmath-nocarry-perl/branches/upstream/current/t/add.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-nocarry-perl/branches/upstream/current/t/add.t?rev=3774&op=file
==============================================================================
--- packages/libmath-nocarry-perl/branches/upstream/current/t/add.t (added)
+++ packages/libmath-nocarry-perl/branches/upstream/current/t/add.t Thu Sep 14 22:13:43 2006
@@ -1,0 +1,1 @@
+BEGIN { print "1..4\n"; }

END { print "not ok\n" unless $loaded }

use Math::NoCarry;

$loaded = 1;

print "ok\n";

my @triads = (
	[qw(123 456 579)],
	[qw(890 135 925)],
	[qw(456 879 225)],
	);

eval {	
	foreach my $triad ( @triads )
		{
		my( $n, $m, $expected ) = @$triad;
		
		my $sum1 = Math::NoCarry::add( $n, $m );
		my $sum2 = Math::NoCarry::add( $m, $n );
		
		die "Different results for different orders!\n" .
			"[$n + $m] gave [$sum1]\n[$m + $n] gave [$sum2]\n"
			if $sum1 != $sum2;
		
		die "[$n + $m] gave [$sum1], but I expected [$expected]\n"
			unless $sum1 == $expected;
		}
	};
print STDERR $@ if $@;
print $@ ? 'not ' : '', "ok\n";
	
eval {	
	foreach my $triad ( @triads )
		{
		foreach my $n ( @$triad )
			{
			my $sum = Math::NoCarry::add( $n );
			
			die "[$n] gave [$sum], but I expected [$n]\n"
				unless $sum == $n;
			}
		}
	};
print STDERR $@ if $@;
print $@ ? 'not ' : '', "ok\n";

eval {	
	my $sum = Math::NoCarry::add();
			
	die "[NULL] gave [$sum], but I expected [FALSE]\n"
				if $sum;
	};
print STDERR $@ if $@;
print $@ ? 'not ' : '', "ok\n";


Added: packages/libmath-nocarry-perl/branches/upstream/current/t/load.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-nocarry-perl/branches/upstream/current/t/load.t?rev=3774&op=file
==============================================================================
--- packages/libmath-nocarry-perl/branches/upstream/current/t/load.t (added)
+++ packages/libmath-nocarry-perl/branches/upstream/current/t/load.t Thu Sep 14 22:13:43 2006
@@ -1,0 +1,11 @@
+# $Id: load.t,v 1.1 2004/09/08 08:30:22 comdog Exp $
+BEGIN {
+	@classes = qw(Math::NoCarry);
+	}
+
+use Test::More tests => scalar @classes;
+
+foreach my $class ( @classes )
+	{
+	print "bail out! $class did not compile\n" unless use_ok( $class );
+	}

Added: packages/libmath-nocarry-perl/branches/upstream/current/t/multiply.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-nocarry-perl/branches/upstream/current/t/multiply.t?rev=3774&op=file
==============================================================================
--- packages/libmath-nocarry-perl/branches/upstream/current/t/multiply.t (added)
+++ packages/libmath-nocarry-perl/branches/upstream/current/t/multiply.t Thu Sep 14 22:13:43 2006
@@ -1,0 +1,1 @@
+BEGIN { print "1..4\n"; }

END { print "not ok\n" unless $loaded }

use Math::NoCarry;

$loaded = 1;

print "ok\n";

my @triads = (
	[qw( 123  456  43878)],
	[qw(-123 -456  43878)],
	[qw(-123  456 -43878)],
	[qw( 123 -456 -43878)],
	
	[qw(456 123 43878)],
	[qw(456 879 28974)],
	[qw(879 456 28974)],

	[qw(  890 135  83750)],
	[qw( 135  890  83750)],
	[qw(-135  890 -83750)],
	[qw( 135 -890 -83750)],
	[qw(-135 -890  83750)],

	[qw(500 321 50500)],
	[qw(321 500 50500)],
	);

eval {	
	foreach my $triad ( @triads )
		{
		my( $n, $m, $expected ) = @$triad;
		
		my $product = Math::NoCarry::multiply( $n, $m );
				
		die "[$n x $m] gave [$product], but I expected [$expected]\n"
			unless $product == $expected;
		}
	};
print STDERR $@ if $@;
print $@ ? 'not ' : '', "ok\n";

eval {	
	foreach my $triad ( @triads )
		{
		foreach my $n ( @$triad )
			{
			my $product = Math::NoCarry::multiply( $n );
			
			die "[$n] gave [$product], but I expected [$n]\n"
				unless $product == $n;
			}
		}
	};
print STDERR $@ if $@;
print $@ ? 'not ' : '', "ok\n";

eval {	
	my $product = Math::NoCarry::multiply();
			
	die "[NULL] gave [$product], but I expected [FALSE]\n"
				if $product;
	};
print STDERR $@ if $@;
print $@ ? 'not ' : '', "ok\n";


Added: packages/libmath-nocarry-perl/branches/upstream/current/t/pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-nocarry-perl/branches/upstream/current/t/pod.t?rev=3774&op=file
==============================================================================
--- packages/libmath-nocarry-perl/branches/upstream/current/t/pod.t (added)
+++ packages/libmath-nocarry-perl/branches/upstream/current/t/pod.t Thu Sep 14 22:13:43 2006
@@ -1,0 +1,5 @@
+# $Id: pod.t,v 1.1 2004/09/08 08:30:22 comdog Exp $
+use Test::More;
+eval "use Test::Pod 1.00";
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
+all_pod_files_ok();

Added: packages/libmath-nocarry-perl/branches/upstream/current/t/pod_coverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-nocarry-perl/branches/upstream/current/t/pod_coverage.t?rev=3774&op=file
==============================================================================
--- packages/libmath-nocarry-perl/branches/upstream/current/t/pod_coverage.t (added)
+++ packages/libmath-nocarry-perl/branches/upstream/current/t/pod_coverage.t Thu Sep 14 22:13:43 2006
@@ -1,0 +1,15 @@
+# $Id: pod_coverage.t,v 1.1 2005/03/12 03:53:50 comdog Exp $
+
+use Test::More;
+eval "use Test::Pod::Coverage";
+
+if( $@ )
+	{
+	plan skip_all => "Test::Pod::Coverage required for testing POD";
+	}
+else
+	{
+	plan tests => 1;
+
+	pod_coverage_ok( "Math::NoCarry" );      
+	}

Added: packages/libmath-nocarry-perl/branches/upstream/current/t/prereq.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-nocarry-perl/branches/upstream/current/t/prereq.t?rev=3774&op=file
==============================================================================
--- packages/libmath-nocarry-perl/branches/upstream/current/t/prereq.t (added)
+++ packages/libmath-nocarry-perl/branches/upstream/current/t/prereq.t Thu Sep 14 22:13:43 2006
@@ -1,0 +1,5 @@
+# $Id: prereq.t,v 1.1 2004/09/08 08:30:22 comdog Exp $
+use Test::More;
+eval "use Test::Prereq";
+plan skip_all => "Test::Prereq required to test dependencies" if $@;
+prereq_ok();

Added: packages/libmath-nocarry-perl/branches/upstream/current/t/subtract.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-nocarry-perl/branches/upstream/current/t/subtract.t?rev=3774&op=file
==============================================================================
--- packages/libmath-nocarry-perl/branches/upstream/current/t/subtract.t (added)
+++ packages/libmath-nocarry-perl/branches/upstream/current/t/subtract.t Thu Sep 14 22:13:43 2006
@@ -1,0 +1,59 @@
+# $Id: subtract.t,v 1.1 2004/09/08 08:30:22 comdog Exp $
+
+BEGIN { print "1..4\n"; }
+
+END { print "not ok\n" unless $loaded }
+
+use Math::NoCarry;
+
+$loaded = 1;
+
+print "ok\n";
+
+my @triads = (
+	[qw(123 456 579)],
+	[qw(890 135 925)],
+	[qw(456 879 225)],
+	);
+
+eval {	
+	foreach my $triad ( @triads )
+		{
+		my( $expected, $m, $n ) = @$triad;
+		
+		my $diff1 = Math::NoCarry::subtract( $n, $m );
+		my $diff2 = Math::NoCarry::subtract( $n, $expected );
+				
+		die "[$n - $m] gave [$diff], but I expected [$expected]\n"
+			unless $diff1 == $expected;
+		die "[$n - $expected] gave [$diff], but I expected [$m]\n"
+			unless $diff2 == $m;
+		}
+	};
+print STDERR $@ if $@;
+print $@ ? 'not ' : '', "ok\n";
+	
+eval {	
+	foreach my $triad ( @triads )
+		{
+		foreach my $n ( @$triad )
+			{
+			my $diff = Math::NoCarry::subtract( $n );
+			
+			die "[$n] gave [$diff], but I expected [$n]\n"
+				unless $diff == $n;
+			}
+		}
+	};
+print STDERR $@ if $@;
+print $@ ? 'not ' : '', "ok\n";
+
+eval {	
+	my $diff = Math::NoCarry::subtract();
+			
+	die "[NULL] gave [$diff], but I expected [FALSE]\n"
+				if $diff;
+	};
+print STDERR $@ if $@;
+print $@ ? 'not ' : '', "ok\n";
+

Added: packages/libmath-nocarry-perl/branches/upstream/current/t/test_manifest
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmath-nocarry-perl/branches/upstream/current/t/test_manifest?rev=3774&op=file
==============================================================================
--- packages/libmath-nocarry-perl/branches/upstream/current/t/test_manifest (added)
+++ packages/libmath-nocarry-perl/branches/upstream/current/t/test_manifest Thu Sep 14 22:13:43 2006
@@ -1,0 +1,8 @@
+# $Id: test_manifest,v 1.2 2005/03/12 03:53:57 comdog Exp $
+load.t
+pod.t
+pod_coverage.t
+prereq.t
+add.t
+multiply.t
+subtract.t




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