Skip to content

Commit fddef59

Browse files
author
Steffen Beyer
committedAug 22, 2009
Release 'Bit-Vector-7.0' of Bit::Vector
1 parent 8af9afb commit fddef59

23 files changed

+308
-309
lines changed
 

‎BitVector.c

+55-33
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ typedef enum
2121
ErrCode_Type, /* types word and size_t have incompatible sizes */
2222
ErrCode_Bits, /* bits of word and sizeof(word) are inconsistent */
2323
ErrCode_Word, /* size of word is less than 16 bits */
24-
ErrCode_Long, /* size of word is greater than size of long */
2524
ErrCode_Powr, /* number of bits of word is not a power of two */
2625
ErrCode_Loga, /* error in calculation of logarithm */
26+
ErrCode_Lpwr, /* number of bits of long is not a power of two */
27+
ErrCode_WgtL, /* size of word is greater than size of long */
2728

2829
ErrCode_Null, /* unable to allocate memory */
2930

@@ -44,7 +45,7 @@ typedef wordptr *listptr;
4445

4546
charptr BitVector_Error (ErrCode error); /* return string for err code */
4647

47-
ErrCode BitVector_Boot (void); /* 0 = ok, 1..16 = error */
48+
ErrCode BitVector_Boot (void); /* 0 = ok, 1..17 = error */
4849

4950
N_word BitVector_Size (N_int bits); /* bit vector size (# of words) */
5051
N_word BitVector_Mask (N_int bits); /* bit vector mask (unused bits) */
@@ -254,9 +255,10 @@ void Matrix_Transpose (wordptr X, N_int rowsX, N_int colsX,
254255
#define ERRCODE_TYPE "sizeof(word) > sizeof(size_t)"
255256
#define ERRCODE_BITS "bits(word) != sizeof(word)*8"
256257
#define ERRCODE_WORD "bits(word) < 16"
257-
#define ERRCODE_LONG "bits(word) > bits(long)"
258-
#define ERRCODE_POWR "bits(word) != 2^x"
258+
#define ERRCODE_POWR "bits(word) is not a power of two"
259259
#define ERRCODE_LOGA "bits(word) != 2^ld(bits(word))"
260+
#define ERRCODE_LPWR "bits(long) is not a power of two"
261+
#define ERRCODE_WGTL "bits(word) > bits(long)"
260262
#define ERRCODE_NULL "unable to allocate memory"
261263
#define ERRCODE_INDX "index out of range"
262264
#define ERRCODE_ORDR "minimum > maximum index"
@@ -512,9 +514,10 @@ charptr BitVector_Error(ErrCode error)
512514
case ErrCode_Type: return( (charptr) ERRCODE_TYPE ); break;
513515
case ErrCode_Bits: return( (charptr) ERRCODE_BITS ); break;
514516
case ErrCode_Word: return( (charptr) ERRCODE_WORD ); break;
515-
case ErrCode_Long: return( (charptr) ERRCODE_LONG ); break;
516517
case ErrCode_Powr: return( (charptr) ERRCODE_POWR ); break;
517518
case ErrCode_Loga: return( (charptr) ERRCODE_LOGA ); break;
519+
case ErrCode_Lpwr: return( (charptr) ERRCODE_LPWR ); break;
520+
case ErrCode_WgtL: return( (charptr) ERRCODE_WGTL ); break;
518521
case ErrCode_Null: return( (charptr) ERRCODE_NULL ); break;
519522
case ErrCode_Indx: return( (charptr) ERRCODE_INDX ); break;
520523
case ErrCode_Ordr: return( (charptr) ERRCODE_ORDR ); break;
@@ -542,53 +545,67 @@ charptr BitVector_Error(ErrCode error)
542545

543546
ErrCode BitVector_Boot(void)
544547
{
545-
N_long longsample = 1L;
546-
N_word sample = LSB;
547-
N_word lsb;
548+
N_word sample;
549+
N_long longsample;
548550

549551
if (sizeof(N_word) > sizeof(size_t)) return(ErrCode_Type);
550552

551-
BITS = 1;
552-
while (sample <<= 1) BITS++; /* determine # of bits in a machine word */
553+
BITS = 0;
554+
sample = ~0;
555+
while (sample) /* determine # of bits in a machine word */
556+
{
557+
sample &= sample - 1;
558+
BITS++;
559+
}
553560

554561
if (BITS != (sizeof(N_word) << 3)) return(ErrCode_Bits);
555562

556563
if (BITS < 16) return(ErrCode_Word);
557564

558-
LONGBITS = 1;
559-
while (longsample <<= 1) LONGBITS++; /* = # of bits in an unsigned long */
560-
561-
if (BITS > LONGBITS) return(ErrCode_Long);
565+
LONGBITS = 0;
566+
longsample = ~0L;
567+
while (longsample) /* determine # of bits in an unsigned long */
568+
{
569+
longsample &= longsample - 1L;
570+
LONGBITS++;
571+
}
562572

563573
LOGBITS = 0;
564-
sample = BITS;
565-
lsb = (sample AND LSB);
566-
while ((sample >>= 1) and (not lsb))
574+
sample = MODMASK = BITS - 1;
575+
if (sample AND BITS) return(ErrCode_Powr); /* # not a power of 2! */
576+
while (sample)
567577
{
578+
sample &= sample - 1;
568579
LOGBITS++;
569-
lsb = (sample AND LSB);
570580
}
581+
if (BITS != (LSB << LOGBITS)) return(ErrCode_Loga); /* ld(bits) wrong! */
571582

572-
if (sample) return(ErrCode_Powr); /* # of bits is not a power of 2! */
583+
/*
584+
* MacOS X (PERL_DARWIN) is known to give LONGBITS == 33
585+
* when counting bits using shift-left or shift-right!
586+
*
587+
*/
573588

574-
if (BITS != (LSB << LOGBITS)) return(ErrCode_Loga);
589+
longsample = LONGBITS - 1;
590+
if ((longsample AND LONGBITS) or (LONGBITS != (sizeof(N_long) << 3)))
591+
{
592+
LONGBITS = (sizeof(N_long) << 3);
593+
longsample = LONGBITS - 1;
594+
if (longsample AND LONGBITS) return(ErrCode_Lpwr);
595+
}
575596

576-
MODMASK = BITS - 1;
577-
FACTOR = LOGBITS - 3; /* ld(BITS / 8) = ld(BITS) - ld(8) = ld(BITS) - 3 */
578-
MSB = (LSB << MODMASK);
597+
if (BITS > LONGBITS) return(ErrCode_WgtL);
579598

580599
if (BITS > MASKTABSIZE) return(ErrCode_Oops);
581600

582601
for ( sample = 0; sample < BITS; sample++ )
583602
{
584603
BITMASKTAB[sample] = (LSB << sample);
585604
}
586-
/*
587-
for ( sample = BITS; sample < MASKTABSIZE; sample++ )
588-
{
589-
BITMASKTAB[sample] = 0;
590-
}
591-
*/
605+
606+
FACTOR = LOGBITS - 3; /* ld(BITS / 8) = ld(BITS) - ld(8) = ld(BITS) - 3 */
607+
608+
MSB = (LSB << MODMASK);
592609

593610
LOG10 = (N_word) (MODMASK * 0.30103); /* = (BITS - 1) * ( ln 2 / ln 10 ) */
594611
EXP10 = power10(LOG10);
@@ -616,7 +633,7 @@ N_word BitVector_Mask(N_int bits) /* bit vector mask (unused bits) */
616633

617634
charptr BitVector_Version(void)
618635
{
619-
return((charptr)"6.9");
636+
return((charptr)"7.0");
620637
}
621638

622639
N_int BitVector_Word_Bits(void)
@@ -3081,20 +3098,24 @@ ErrCode BitVector_GCD2(wordptr U, wordptr V, wordptr W, wordptr X, wordptr Y)
30813098
{
30823099
return(ErrCode_Same);
30833100
}
3101+
if ((bits == 0) or (size == 0))
3102+
{
3103+
return(ErrCode_Ok);
3104+
}
30843105
if (BitVector_is_empty(X))
30853106
{
30863107
if (U != Y) BitVector_Copy(U,Y);
30873108
BitVector_Empty(V);
30883109
BitVector_Empty(W);
3089-
*W = 1;
3110+
if (size_(W)) *W = 1;
30903111
return(ErrCode_Ok);
30913112
}
30923113
if (BitVector_is_empty(Y))
30933114
{
30943115
if (U != X) BitVector_Copy(U,X);
30953116
BitVector_Empty(V);
30963117
BitVector_Empty(W);
3097-
*V = 1;
3118+
if (size_(V)) *V = 1;
30983119
return(ErrCode_Ok);
30993120
}
31003121
if ((L = BitVector_Create_List(bits,false,11)) == NULL)
@@ -3821,11 +3842,12 @@ void Matrix_Transpose(wordptr X, N_int rowsX, N_int colsX,
38213842
}
38223843

38233844
/*****************************************************************************/
3824-
/* VERSION: 6.9 */
3845+
/* VERSION: 7.0 */
38253846
/*****************************************************************************/
38263847
/* VERSION HISTORY: */
38273848
/*****************************************************************************/
38283849
/* */
3850+
/* Version 7.0 22.08.09 Fixed bugs in "GCD2()" and "Boot()". */
38293851
/* Version 6.9 12.08.09 Removed an obsolete warning (memory leak). */
38303852
/* Version 6.8 10.08.09 Fixed hard-coded table size MASKTABSIZE. */
38313853
/* Version 6.7 08.08.09 No changes. */

‎BitVector.h

+8-5
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ typedef enum
2525
ErrCode_Type, /* types word and size_t have incompatible sizes */
2626
ErrCode_Bits, /* bits of word and sizeof(word) are inconsistent */
2727
ErrCode_Word, /* size of word is less than 16 bits */
28-
ErrCode_Long, /* size of word is greater than size of long */
2928
ErrCode_Powr, /* number of bits of word is not a power of two */
3029
ErrCode_Loga, /* error in calculation of logarithm */
30+
ErrCode_Lpwr, /* number of bits of long is not a power of two */
31+
ErrCode_WgtL, /* size of word is greater than size of long */
3132

3233
ErrCode_Null, /* unable to allocate memory */
3334

@@ -48,7 +49,7 @@ typedef wordptr *listptr;
4849

4950
charptr BitVector_Error (ErrCode error); /* return string for err code */
5051

51-
ErrCode BitVector_Boot (void); /* 0 = ok, 1..16 = error */
52+
ErrCode BitVector_Boot (void); /* 0 = ok, 1..17 = error */
5253

5354
N_word BitVector_Size (N_int bits); /* bit vector size (# of words) */
5455
N_word BitVector_Mask (N_int bits); /* bit vector mask (unused bits) */
@@ -258,9 +259,10 @@ void Matrix_Transpose (wordptr X, N_int rowsX, N_int colsX,
258259
#define ERRCODE_TYPE "sizeof(word) > sizeof(size_t)"
259260
#define ERRCODE_BITS "bits(word) != sizeof(word)*8"
260261
#define ERRCODE_WORD "bits(word) < 16"
261-
#define ERRCODE_LONG "bits(word) > bits(long)"
262-
#define ERRCODE_POWR "bits(word) != 2^x"
262+
#define ERRCODE_POWR "bits(word) is not a power of two"
263263
#define ERRCODE_LOGA "bits(word) != 2^ld(bits(word))"
264+
#define ERRCODE_LPWR "bits(long) is not a power of two"
265+
#define ERRCODE_WGTL "bits(word) > bits(long)"
264266
#define ERRCODE_NULL "unable to allocate memory"
265267
#define ERRCODE_INDX "index out of range"
266268
#define ERRCODE_ORDR "minimum > maximum index"
@@ -315,11 +317,12 @@ extern const N_int BitVector_BYTENORM[256];
315317
/*****************************************************************************/
316318

317319
/*****************************************************************************/
318-
/* VERSION: 6.9 */
320+
/* VERSION: 7.0 */
319321
/*****************************************************************************/
320322
/* VERSION HISTORY: */
321323
/*****************************************************************************/
322324
/* */
325+
/* Version 7.0 22.08.09 Fixed bugs in "GCD2()" and "Boot()". */
323326
/* Version 6.9 12.08.09 Removed an obsolete warning (memory leak). */
324327
/* Version 6.8 10.08.09 Fixed hard-coded table size MASKTABSIZE. */
325328
/* Version 6.7 08.08.09 No changes. */

‎CHANGES.txt

+24-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
=====================================
2-
Package "Bit::Vector" Version 6.9
2+
Package "Bit::Vector" Version 7.0
33
=====================================
44

55

@@ -10,29 +10,44 @@
1010
Version history:
1111
----------------
1212

13+
Version 7.0 22.08.2009
14+
15+
+ Fixed a bug in "GCD2()" in "BitVector.c" with null-size vectors
16+
+ Added more test cases for "GCD()" in "t/17_________gcd.t"
17+
+ Almost completely rewrote "BitVector_Boot()" in "BitVector.c"
18+
in order to fix the problem that it calculated an unsigned
19+
long to have 33 bits under MacOS X (Darwin), leading to
20+
failing tests in "t/28___chunklist.t"
21+
+ BEWARE that the type "ErrCode", which is part of the inter-
22+
face of the C library "BitVector.c", has been changed!
23+
+ Added more tests and a debugging aid to "t/28___chunklist.t"
24+
+ Removed the two example files showing how to freeze/thaw
25+
"Bit::Vector" objects using "Data::Dumper", because after
26+
closer inspection this proved to be a can of worms
27+
1328
Version 6.9 12.08.2009
1429

15-
+ Replaced Storable::freeze by Storable::nfreeze
16-
+ Added more test cases for Storable
30+
+ Replaced "Storable::freeze()" by "Storable::nfreeze()"
31+
+ Added more test cases for "Storable"
1732
+ Added two example files showing how to freeze/thaw
18-
using Data::Dumper
33+
using "Data::Dumper"
1934

2035
Version 6.8 10.08.2009
2136

22-
+ Fixed the bug of Storable not reconstructing nested data
37+
+ Fixed the bug of "Storable" not reconstructing nested data
2338
structures properly which contain several references to
24-
the same Bit::Vector object
25-
+ Fixed hard-coded table size MASKTABSIZE in BitVector.c
39+
the same "Bit::Vector" object
40+
+ Fixed hard-coded table size "MASKTABSIZE" in "BitVector.c"
2641
+ Small cosmetic fixes to the documentation
2742

2843
Version 6.7 08.08.2009
2944

30-
+ Replaced STORABLE_thaw by STORABLE_attach
45+
+ Replaced "STORABLE_thaw()" by "STORABLE_attach()"
3146

3247
Version 6.6 27.07.2009
3348

3449
+ Made the module thread-safe and MacOS X compatible
35-
+ Prevented BitVector_Boot() in BitVector.c to leak
50+
+ Prevented "BitVector_Boot()" in "BitVector.c" to leak
3651
memory when called repeatedly
3752

3853
Version 6.5 27.07.2009

‎CREDITS.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
=====================================
2-
Package "Bit::Vector" Version 6.9
2+
Package "Bit::Vector" Version 7.0
33
=====================================
44

55

@@ -210,4 +210,8 @@ memory if called more than once, because of the dynamic allocation of
210210
the BITMASKTAB. This has been fixed in version 6.6 and improved in
211211
version 6.8.
212212

213+
Thanks a lot to Christopher Jones <c.jones@ucl.ac.uk> for notifying me
214+
about the failing tests in "t/28___chunklist.t" under MacOs X / Darwin
215+
and for running some test scripts on his machine for me.
216+
213217

‎INSTALL.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
=====================================
2-
Package "Bit::Vector" Version 6.9
2+
Package "Bit::Vector" Version 7.0
33
=====================================
44

55

@@ -23,7 +23,7 @@ Perl version 5.000 or higher, and an ANSI C compiler. (!)
2323
^^^^^^
2424
Module "Carp::Clan" version 5.3 or higher.
2525

26-
Optionally, module "Storable" version 2.20 or newer.
26+
Optionally, module "Storable" version 2.21 or newer.
2727

2828
Note that in order to compile Perl modules which contain
2929
C (and/or XS) code (such as this one), you always HAVE
@@ -79,7 +79,7 @@ Edit the file "Makefile.PL" and change the line
7979

8080
'VERSION_FROM' => 'Vector.pm',
8181
to
82-
'VERSION' => '6.9',
82+
'VERSION' => '7.0',
8383

8484
Then edit the file "Vector.pm" and change the line
8585

@@ -89,7 +89,7 @@ to
8989

9090
Also edit the file "t/00____version.t" and change the line
9191

92-
use Bit::Vector 6.9;
92+
use Bit::Vector 7.0;
9393

9494
to
9595

@@ -133,7 +133,7 @@ Detailed installation guide:
133133
----------------------------
134134

135135
1) Change directory to the directory that has been created by unpacking this
136-
package ("cd Bit-Vector-6.9").
136+
package ("cd Bit-Vector-7.0").
137137

138138
2) Type "perl Makefile.PL" (or whatever the name and path of your Perl 5
139139
binary is).
@@ -220,7 +220,7 @@ Detailed installation guide:
220220
t/50_freeze_thaw.t .. ok
221221
t/51_file_nstore.t .. ok
222222
All tests successful.
223-
Files=23, Tests=90856, 15 wallclock secs (13.40 usr 0.30 sys + 2.83 cusr 0.57 csys = 17.10 CPU)
223+
Files=23, Tests=91963, 16 wallclock secs (13.63 usr 0.23 sys + 2.91 cusr 0.56 csys = 17.34 CPU)
224224
Result: PASS
225225

226226
(Note that the exact number of tests will depend on the number of bits

‎MANIFEST

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ ToolBox.h
1313
Vector.pm
1414
Vector.pod
1515
Vector.xs
16-
examples/DataDumperFreeze.pl
17-
examples/DataDumperFreezeOO.pl
1816
examples/SetObject.pl
1917
examples/benchmk1.pl
2018
examples/benchmk2.pl

‎META.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
--- #YAML:1.0
22
name: Bit-Vector
3-
version: 6.9
3+
version: 7.0
44
abstract: ~
55
license: ~
66
author: ~
77
generated_by: ExtUtils::MakeMaker version 6.42
88
distribution_type: module
99
requires:
1010
Carp::Clan: 5.3
11-
Storable: 2.2
11+
Storable: 2.21
1212
meta-spec:
1313
url: http://module-build.sourceforge.net/META-spec-v1.3.html
1414
version: 1.3

‎Makefile.PL

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ WriteMakefile(
2222
'PREREQ_PM' =>
2323
{
2424
'Carp::Clan' => 5.3,
25-
'Storable' => 2.20
25+
'Storable' => 2.21
2626
},
2727
'OBJECT' => '$(O_FILES)',
2828
# ($] >= 5.005 ?

‎README.txt

+16-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
=====================================
2-
Package "Bit::Vector" Version 6.9
2+
Package "Bit::Vector" Version 7.0
33
=====================================
44

55

@@ -30,13 +30,21 @@ overloaded operators for maximum ease of use.
3030
The C library can nevertheless be used stand-alone, without Perl.
3131

3232

33-
What's new in version 6.9:
33+
What's new in version 7.0:
3434
--------------------------
3535

36-
+ Replaced Storable::freeze by Storable::nfreeze
37-
+ Added more test cases for Storable
38-
+ Added two example files showing how to freeze/thaw
39-
using Data::Dumper
36+
+ Fixed a bug in "GCD2()" in "BitVector.c" with null-size vectors
37+
+ Added more test cases for "GCD()" in "t/17_________gcd.t"
38+
+ Almost completely rewrote "BitVector_Boot()" in "BitVector.c"
39+
in order to fix the problem that it calculated an unsigned
40+
long to have 33 bits under MacOS X (Darwin), leading to
41+
failing tests in "t/28___chunklist.t"
42+
+ BEWARE that the type "ErrCode", which is part of the inter-
43+
face of the C library "BitVector.c", has been changed!
44+
+ Added more tests and a debugging aid to "t/28___chunklist.t"
45+
+ Removed the two example files showing how to freeze/thaw
46+
"Bit::Vector" objects using "Data::Dumper", because after
47+
closer inspection this proved to be a can of worms
4048

4149

4250
What's new since version 6.5:
@@ -80,7 +88,7 @@ Perl version 5.000 or higher, and an ANSI C compiler. (!)
8088
^^^^^^
8189
Module "Carp::Clan" version 5.3 or higher.
8290

83-
Optionally, module "Storable" version 2.20 or newer.
91+
Optionally, module "Storable" version 2.21 or newer.
8492

8593
Note that in order to compile Perl modules which contain
8694
C (and/or XS) code (such as this one), you always HAVE
@@ -132,7 +140,7 @@ the "zip" archive.
132140
Note to CPAN Testers:
133141
---------------------
134142

135-
After completion, version 6.9 of this module has already
143+
After completion, version 7.0 of this module has already
136144
been tested successfully with the following configurations:
137145

138146
Perl 5.005_03 - Windows XP SP3 & MS VC++ 6.0 (native Perl build)
@@ -351,22 +359,6 @@ of boolean matrices and boolean matrix operations.
351359
(Both modules are also available from my web site at
352360
http://www.engelschall.com/u/sb/download/ or any CPAN server.)
353361

354-
See the two files "DataDumperFreeze.pl" and "DataDumperFreezeOO.pl"
355-
in the "examples" subdirectory of this distribution for an example
356-
of how to freeze and thaw "Bit::Vector" objects using "Data::Dumper".
357-
358-
On my machines, however, these examples do only work with older
359-
versions of "Data::Dumper", e.g. version 2.121. The current version
360-
1.125 does not work (this latter version doesn't even compile on my
361-
Windows XP machine with a native build of Perl 5.8.0 and Microsoft
362-
Visual C++ compiler 6.0).
363-
364-
You will probably find "Storable" to be much easier to use and to be
365-
more efficient, anyway. The advantage of "Data::Dumper" is that its
366-
output is human-readable, which may be an advantage while debugging.
367-
However, whereas "Storable" is supported out-of-the-box, "Data::Dumper"
368-
requires some extra handling in your code.
369-
370362
See the file "SetObject.pl" in the "examples" subdirectory of this
371363
distribution for a way to emulate the "Set::Object" module from CPAN
372364
using "Bit::Vector" - this is a way to perform set operations on sets

‎Vector.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require DynaLoader;
2323

2424
@EXPORT_OK = qw();
2525

26-
$VERSION = '6.9';
26+
$VERSION = '7.0';
2727

2828
bootstrap Bit::Vector $VERSION;
2929

@@ -37,7 +37,7 @@ sub STORABLE_thaw
3737
{
3838
my($self, $clone, $string) = @_;
3939
my($size,$buffer) = @{ Storable::thaw($string) };
40-
$self->Unfake($size); # Undocumented new feature (slightly dangerous!) - for use by Storable only!
40+
$self->Unfake($size); # Undocumented feature, only for use by "Storable"!
4141
$self->Block_Store($buffer);
4242
}
4343

‎Vector.pod

+1-1
Original file line numberDiff line numberDiff line change
@@ -3148,7 +3148,7 @@ Graph::Kruskal(3).
31483148

31493149
=head1 VERSION
31503150

3151-
This man page documents "Bit::Vector" version 6.9.
3151+
This man page documents "Bit::Vector" version 7.0.
31523152

31533153
=head1 AUTHOR
31543154

‎examples/DataDumperFreeze.pl

-64
This file was deleted.

‎examples/DataDumperFreezeOO.pl

-66
This file was deleted.

‎lib/Bit/Vector/Overload.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require Exporter;
2424

2525
@EXPORT_OK = qw();
2626

27-
$VERSION = '6.9';
27+
$VERSION = '7.0';
2828

2929
package Bit::Vector;
3030

‎lib/Bit/Vector/Overload.pod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ Bit::Vector(3), Bit::Vector::String(3).
13271327

13281328
=head1 VERSION
13291329

1330-
This man page documents "Bit::Vector::Overload" version 6.9.
1330+
This man page documents "Bit::Vector::Overload" version 7.0.
13311331

13321332
=head1 AUTHOR
13331333

‎lib/Bit/Vector/String.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require Exporter;
2424

2525
@EXPORT_OK = qw();
2626

27-
$VERSION = '6.9';
27+
$VERSION = '7.0';
2828

2929
package Bit::Vector;
3030

‎lib/Bit/Vector/String.pod

+1-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ Bit::Vector(3), Bit::Vector::Overload(3).
363363

364364
=head1 VERSION
365365

366-
This man page documents "Bit::Vector::String" version 6.9.
366+
This man page documents "Bit::Vector::String" version 7.0.
367367

368368
=head1 AUTHOR
369369

‎t/00_____version.t

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ $n++;
2828

2929
require Bit::Vector;
3030

31-
if ($Bit::Vector::VERSION eq "6.9")
31+
if ($Bit::Vector::VERSION eq "7.0")
3232
{print "ok $n\n";} else {print "not ok $n\n";}
3333
$n++;
3434

35-
if (Bit::Vector::Version() eq "6.9")
35+
if (Bit::Vector::Version() eq "7.0")
3636
{print "ok $n\n";} else {print "not ok $n\n";}
3737
$n++;
3838
if (Bit::Vector::Word_Bits() >= 32)
@@ -42,7 +42,7 @@ if (Bit::Vector::Long_Bits() >= 32)
4242
{print "ok $n\n";} else {print "not ok $n\n";}
4343
$n++;
4444

45-
if (Bit::Vector->Version() eq "6.9")
45+
if (Bit::Vector->Version() eq "7.0")
4646
{print "ok $n\n";} else {print "not ok $n\n";}
4747
$n++;
4848
if (Bit::Vector->Word_Bits() >= 32)
@@ -71,7 +71,7 @@ $n++;
7171

7272
require Bit::Vector::Overload;
7373

74-
if ($Bit::Vector::Overload::VERSION eq "6.9")
74+
if ($Bit::Vector::Overload::VERSION eq "7.0")
7575
{print "ok $n\n";} else {print "not ok $n\n";}
7676
$n++;
7777

@@ -81,7 +81,7 @@ $n++;
8181

8282
require Bit::Vector::String;
8383

84-
if ($Bit::Vector::String::VERSION eq "6.9")
84+
if ($Bit::Vector::String::VERSION eq "7.0")
8585
{print "ok $n\n";} else {print "not ok $n\n";}
8686
$n++;
8787

‎t/17_________gcd.t

+119-43
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use strict;
44

55
use Bit::Vector;
66

7-
print "1..162\n";
7+
print "1..693\n";
88

99
my $n = 1;
1010

@@ -34,26 +34,35 @@ sub gcd($$$$$)
3434

3535
$i = 0;
3636

37-
while ($t[$i+1][0])
37+
if ($t[$i][0])
3838
{
39-
$a = $t[$i][0];
40-
$b = $t[$i+1][0];
41-
$q = int( $a / $b );
42-
$r = $a - $q * $b;
43-
$t[$i+2][0] = $r;
44-
$t[$i+2][1] = $t[$i][1] - $t[$i+1][1] * $q;
45-
$t[$i+2][2] = $t[$i][2] - $t[$i+1][2] * $q;
46-
$t[$i+1][3] = $q;
47-
# printf("[ %6d, %6d, %6d, %6d ]\n", @{$t[$i+1]});
48-
$i++;
39+
while ($t[$i+1][0])
40+
{
41+
$a = $t[$i][0];
42+
$b = $t[$i+1][0];
43+
$q = int( $a / $b );
44+
$r = $a - $q * $b;
45+
$t[$i+2][0] = $r;
46+
$t[$i+2][1] = $t[$i][1] - $t[$i+1][1] * $q;
47+
$t[$i+2][2] = $t[$i][2] - $t[$i+1][2] * $q;
48+
$t[$i+1][3] = $q;
49+
# printf("[ %6d, %6d, %6d, %6d ]\n", @{$t[$i+1]});
50+
$i++;
51+
}
52+
}
53+
else
54+
{
55+
$t[$i][0] = $t[$i+1][0];
56+
$t[$i][1] = 0;
57+
$t[$i][2] = 1;
4958
}
5059

5160
# printf("[ %6d, %6d, %6d, %6d ]\n", @{$t[$i+1]});
5261

5362
# print "\nGCD1( $t[0][0], $t[1][0] ) = ", $t[$i][0], "\n";
5463

5564
if ($t[$i][0] == $c)
56-
{print "ok $n\n";} else {print "not ok $n\n";}
65+
{print "ok $n\n";} else {print "not ok $n\n";warn "#1: $t[$i][0] != $c\n";} # 1
5766
$n++;
5867

5968
$z->GCD($x,$y);
@@ -65,7 +74,7 @@ sub gcd($$$$$)
6574
# printf("GCD2( %s, %s ) = %s\n", $xx, $yy, $zz);
6675

6776
if ($zz == $c)
68-
{print "ok $n\n";} else {print "not ok $n\n";}
77+
{print "ok $n\n";} else {print "not ok $n\n";warn "#2: $zz != $c\n";} # 2
6978
$n++;
7079

7180
$z->GCD($v,$w,$x,$y);
@@ -80,7 +89,7 @@ sub gcd($$$$$)
8089
# printf("GCD3( %s, %s ) = %s\n", $xx, $yy, $zz);
8190

8291
if ($zz == $c)
83-
{print "ok $n\n";} else {print "not ok $n\n";}
92+
{print "ok $n\n";} else {print "not ok $n\n";warn "#3: $zz != $c\n";} # 3
8493
$n++;
8594

8695
$v->Multiply($v,$x);
@@ -96,54 +105,121 @@ sub gcd($$$$$)
96105
# $t[$i][2] * $t[1][0]);
97106

98107
if (($t[$i][1] * $t[0][0] + $t[$i][2] * $t[1][0]) == $c)
99-
{print "ok $n\n";} else {print "not ok $n\n";}
108+
{print "ok $n\n";} else {print "not ok $n\n";warn "#4: $t[$i][1] * $t[0][0] + $t[$i][2] * $t[1][0] != $c\n";} # 4
100109
$n++;
101110

102111
if ($t[$i][1] == $d)
103-
{print "ok $n\n";} else {print "not ok $n\n";}
112+
{print "ok $n\n";} else {print "not ok $n\n";warn "#5: $t[$i][1] != $d\n";} # 5
104113
$n++;
105114

106115
if ($t[$i][2] == $e)
107-
{print "ok $n\n";} else {print "not ok $n\n";}
116+
{print "ok $n\n";} else {print "not ok $n\n";warn "#6: $t[$i][2] != $e\n";} # 6
108117
$n++;
109118

110119
# printf("%s * %s + %s * %s = %s\n\n", $vv, $xx, $ww, $yy, $uu);
111120

112121
if ($uu == $c)
113-
{print "ok $n\n";} else {print "not ok $n\n";}
122+
{print "ok $n\n";} else {print "not ok $n\n";warn "#7: $uu != $c\n";} # 7
114123
$n++;
115124

116125
if ($vv == $d)
117-
{print "ok $n\n";} else {print "not ok $n\n";}
126+
{print "ok $n\n";} else {print "not ok $n\n";warn "#8: $vv != $d\n";} # 8
118127
$n++;
119128

120129
if ($ww == $e)
121-
{print "ok $n\n";} else {print "not ok $n\n";}
130+
{print "ok $n\n";} else {print "not ok $n\n";warn "#9: $ww != $e\n";} # 9
122131
$n++;
123132
}
124133

125-
gcd( 2322, 0, 2322, 1, 0 );
126-
gcd( 0, 654, 654, 0, 1 );
127-
128-
gcd( 2322, 654, 6, 20, -71 );
129-
gcd( 2322, -654, 6, 20, 71 );
130-
gcd( -2322, 654, -6, 20, 71 );
131-
gcd( -2322, -654, -6, 20, -71 );
132-
133-
gcd( 654, 2322, 6, -71, 20 );
134-
gcd( 654, -2322, -6, 71, 20 );
135-
gcd( -654, 2322, 6, 71, 20 );
136-
gcd( -654, -2322, -6, -71, 20 );
137-
138-
gcd( 12345, 54321, 3, 3617, -822 );
139-
gcd( 12345, -54321, 3, 3617, 822 );
140-
gcd( -12345, 54321, -3, 3617, 822 );
141-
gcd( -12345, -54321, -3, 3617, -822 );
142-
143-
gcd( 54321, 12345, 3, -822, 3617 );
144-
gcd( 54321, -12345, -3, 822, 3617 );
145-
gcd( -54321, 12345, 3, 822, 3617 );
146-
gcd( -54321, -12345, -3, -822, 3617 );
134+
gcd( 0, 0, 0, 0, 1 );
135+
136+
gcd( 0, 1, 1, 0, 1 );
137+
gcd( 1, 0, 1, 1, 0 );
138+
gcd( 0, -1, -1, 0, 1 );
139+
gcd( -1, 0, -1, 1, 0 );
140+
141+
gcd( 0, 2, 2, 0, 1 );
142+
gcd( 2, 0, 2, 1, 0 );
143+
gcd( 0, -2, -2, 0, 1 );
144+
gcd( -2, 0, -2, 1, 0 );
145+
146+
gcd( 0, 3, 3, 0, 1 );
147+
gcd( 3, 0, 3, 1, 0 );
148+
gcd( 0, -3, -3, 0, 1 );
149+
gcd( -3, 0, -3, 1, 0 );
150+
151+
gcd( 1, 1, 1, 0, 1 );
152+
gcd( 1, -1, -1, 0, 1 );
153+
gcd( -1, 1, 1, 0, 1 );
154+
gcd( -1, -1, -1, 0, 1 );
155+
156+
gcd( 1, 2, 1, 1, 0 );
157+
gcd( 2, 1, 1, 0, 1 );
158+
gcd( -1, 2, -1, 1, 0 );
159+
gcd( 2, -1, -1, 0, 1 );
160+
gcd( 1, -2, 1, 1, 0 );
161+
gcd( -2, 1, 1, 0, 1 );
162+
gcd( -1, -2, -1, 1, 0 );
163+
gcd( -2, -1, -1, 0, 1 );
164+
165+
gcd( 2, 3, 1, -1, 1 );
166+
gcd( 3, 2, 1, 1, -1 );
167+
gcd( -2, 3, 1, 1, 1 );
168+
gcd( 3, -2, 1, 1, 1 );
169+
gcd( 2, -3, -1, 1, 1 );
170+
gcd( -3, 2, -1, 1, 1 );
171+
gcd( -2, -3, -1, -1, 1 );
172+
gcd( -3, -2, -1, 1, -1 );
173+
174+
gcd( 3, 5, 1, 2, -1 );
175+
gcd( 5, 3, 1, -1, 2 );
176+
gcd( -3, 5, -1, 2, 1 );
177+
gcd( 5, -3, -1, 1, 2 );
178+
gcd( 3, -5, 1, 2, 1 );
179+
gcd( -5, 3, 1, 1, 2 );
180+
gcd( -3, -5, -1, 2, -1 );
181+
gcd( -5, -3, -1, -1, 2 );
182+
183+
gcd( 5, 7, 1, 3, -2 );
184+
gcd( 7, 5, 1, -2, 3 );
185+
gcd( -5, 7, -1, 3, 2 );
186+
gcd( 7, -5, -1, 2, 3 );
187+
gcd( 5, -7, 1, 3, 2 );
188+
gcd( -7, 5, 1, 2, 3 );
189+
gcd( -5, -7, -1, 3, -2 );
190+
gcd( -7, -5, -1, -2, 3 );
191+
192+
gcd( 6, 30, 6, 1, 0 );
193+
gcd( 30, 6, 6, 0, 1 );
194+
gcd( -6, 30, -6, 1, 0 );
195+
gcd( 30, -6, -6, 0, 1 );
196+
gcd( 6, -30, 6, 1, 0 );
197+
gcd( -30, 6, 6, 0, 1 );
198+
gcd( -6, -30, -6, 1, 0 );
199+
gcd( -30, -6, -6, 0, 1 );
200+
201+
gcd( 2322, 0, 2322, 1, 0 );
202+
gcd( 0, 654, 654, 0, 1 );
203+
gcd( -2322, 0, -2322, 1, 0 );
204+
gcd( 0, -654, -654, 0, 1 );
205+
206+
gcd( 2322, 654, 6, 20, -71 );
207+
gcd( 2322, -654, 6, 20, 71 );
208+
gcd( -2322, 654, -6, 20, 71 );
209+
gcd( -2322, -654, -6, 20, -71 );
210+
gcd( 654, 2322, 6, -71, 20 );
211+
gcd( 654, -2322, -6, 71, 20 );
212+
gcd( -654, 2322, 6, 71, 20 );
213+
gcd( -654, -2322, -6, -71, 20 );
214+
215+
gcd( 12345, 54321, 3, 3617, -822 );
216+
gcd( 12345, -54321, 3, 3617, 822 );
217+
gcd( -12345, 54321, -3, 3617, 822 );
218+
gcd( -12345, -54321, -3, 3617, -822 );
219+
gcd( 54321, 12345, 3, -822, 3617 );
220+
gcd( 54321, -12345, -3, 822, 3617 );
221+
gcd( -54321, 12345, 3, 822, 3617 );
222+
gcd( -54321, -12345, -3, -822, 3617 );
147223

148224
__END__
149225

‎t/28___chunklist.t

+55-36
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!perl -w
22

33
use strict;
4-
no strict "vars";
54

65
use Bit::Vector;
76

@@ -12,53 +11,73 @@ use Bit::Vector;
1211
# $vector->Chunk_List_Store($bits,@values);
1312
# ======================================================================
1413

15-
$limit = 1000;
14+
my $limit = 1013; # Prime number in order to avoid trivial cases
1615

17-
$longbits = Bit::Vector::Long_Bits();
16+
my $longbits = Bit::Vector::Long_Bits();
1817

19-
print "1..", 3*$longbits, "\n";
18+
print "1..", 12*$longbits, "\n";
2019

21-
$set = Bit::Vector->new($limit+1);
22-
$tst = $set->Shadow();
20+
my($set,$tst,$bits,$ok,$i,$offset);
21+
my(@primes,@chunks);
2322

24-
$set->Fill();
25-
$set->Bit_Off(0);
26-
$set->Bit_Off(1);
27-
for ( $j = 4; $j <= $limit; $j += 2 ) { $set->Bit_Off($j); }
28-
for ( $i = 3; ($j = $i * $i) <= $limit; $i += 2 )
23+
my(@vec) = Bit::Vector->new($limit,5);
24+
25+
$vec[0]->Primes(); # Make sure all chunks here are unique, i.e., mutually different (as far as possible)
26+
$vec[3]->Fill();
27+
$tst = $vec[4];
28+
29+
my $k = 0;
30+
while ($k < $limit)
2931
{
30-
for ( ; $j <= $limit; $j += $i ) { $set->Bit_Off($j); }
32+
$vec[1]->Bit_On($k++);
33+
$vec[2]->Bit_On($k++) if ($k < $limit);
3134
}
3235

33-
$n = 1;
34-
35-
for ( $bits = 1; $bits <= $longbits; $bits++ )
36+
my $n = 1;
37+
for ( $k = 0; $k < 4; $k++ )
3638
{
37-
undef @primes;
38-
$tst->Empty();
39-
@primes = $set->Chunk_List_Read($bits);
40-
$tst->Chunk_List_Store($bits,@primes);
41-
if ($set->equal($tst))
42-
{print "ok $n\n";} else {print "not ok $n\n";}
43-
$n++;
44-
undef @chunks;
45-
$tst->Empty();
46-
$ok = 1;
47-
for ( $i = 0, $offset = 0; $offset <= $limit; $i++, $offset += $bits )
39+
$set = $vec[$k];
40+
for ( $bits = 1; $bits <= $longbits; $bits++ )
4841
{
49-
$chunks[$i] = $set->Chunk_Read($bits,$offset);
50-
if ($primes[$i] != $chunks[$i]) { $ok = 0; }
42+
undef @primes;
43+
$tst->Empty();
44+
@primes = $set->Chunk_List_Read($bits);
45+
$tst->Chunk_List_Store($bits,@primes);
46+
if ($set->equal($tst))
47+
{print "ok $n\n";} else {print "not ok $n\n";print "k = $k\nvect. bits: $limit bits\nchunk size: $bits bits\nset=".$set->to_Hex()."\ntst=".$tst->to_Hex()."\n";$tst->Xor($tst,$set);print "xor=".$tst->to_Hex()."\n";Dump(\@primes,'primes',$bits);}
48+
$n++;
49+
undef @chunks;
50+
$tst->Empty();
51+
$ok = 1;
52+
for ( $i = 0, $offset = 0; $offset < $limit; $i++, $offset += $bits )
53+
{
54+
$chunks[$i] = $set->Chunk_Read($bits,$offset);
55+
if ($primes[$i] != $chunks[$i]) { $ok = 0; }
56+
}
57+
if ($ok)
58+
{print "ok $n\n";} else {print "not ok $n\n";}
59+
$n++;
60+
for ( $i = 0; $i <= $#chunks; $i++ )
61+
{
62+
$tst->Chunk_Store($bits,$i*$bits,$chunks[$i]);
63+
}
64+
if ($set->equal($tst))
65+
{print "ok $n\n";} else {print "not ok $n\n";print "k = $k\nvect. bits: $limit bits\nchunk size: $bits bits\nset=".$set->to_Hex()."\ntst=".$tst->to_Hex()."\n";$tst->Xor($tst,$set);print "xor=".$tst->to_Hex()."\n";Dump(\@chunks,'chunks',$bits);}
66+
$n++;
5167
}
52-
if ($ok)
53-
{print "ok $n\n";} else {print "not ok $n\n";}
54-
$n++;
55-
for ( $i = 0; $i <= $#chunks; $i++ )
68+
}
69+
70+
sub Dump
71+
{
72+
my($list,$name,$size) = @_;
73+
my($i,$len);
74+
my($sum) = 0;
75+
$len = $size >> 2; $len++ if ($size & 0x03);
76+
for ( $i = 0; $i < @{$list}; $i++ )
5677
{
57-
$tst->Chunk_Store($bits,$i*$bits,$chunks[$i]);
78+
$sum += $bits;
79+
printf('$' . $name . "[%02d] = '%0${len}X'; # %d\n", $i, $list->[$i], $sum);
5880
}
59-
if ($set->equal($tst))
60-
{print "ok $n\n";} else {print "not ok $n\n";}
61-
$n++;
6281
}
6382

6483
__END__

‎t/50_freeze_thaw.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ eval
1212
*dclone = \&Storable::dclone;
1313
};
1414

15-
if ($@ or $Storable::VERSION < 2.2)
15+
if ($@ or $Storable::VERSION < 2.21)
1616
{
17-
print "1..0 # skip module Storable 2.20 or newer not found\n";
17+
print "1..0 # skip module Storable 2.21 or newer not found (we have $Storable::VERSION)\n";
1818
exit 0;
1919
}
2020

‎t/51_file_nstore.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ eval
1616
*retrieve = \&Storable::retrieve;
1717
};
1818

19-
if ($@ or $Storable::VERSION < 2.2)
19+
if ($@ or $Storable::VERSION < 2.21)
2020
{
21-
print "1..0 # skip module Storable 2.20 or newer not found\n";
21+
print "1..0 # skip module Storable 2.21 or newer not found (we have $Storable::VERSION)\n";
2222
exit 0;
2323
}
2424

‎typemap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
###############################################################################
33
## ##
4-
## Typemap for module "Bit::Vector" version 6.9. ##
4+
## Typemap for module "Bit::Vector" version 7.0. ##
55
## ##
66
## Copyright (c) 1995 - 2009 by Steffen Beyer. ##
77
## All rights reserved. ##

0 commit comments

Comments
 (0)
Please sign in to comment.