| 1 |
===================================== |
|---|
| 2 |
Package "Bit::Vector" Version 6.3 |
|---|
| 3 |
===================================== |
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
This package is available for download either from my web site at |
|---|
| 7 |
|
|---|
| 8 |
http://www.engelschall.com/u/sb/download/ |
|---|
| 9 |
|
|---|
| 10 |
or from any CPAN (= "Comprehensive Perl Archive Network") mirror server: |
|---|
| 11 |
|
|---|
| 12 |
http://www.perl.com/CPAN/authors/id/S/ST/STBEY/ |
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
Abstract: |
|---|
| 16 |
--------- |
|---|
| 17 |
|
|---|
| 18 |
Bit::Vector is an efficient C library which allows you to handle |
|---|
| 19 |
bit vectors, sets (of integers), "big integer arithmetic" and |
|---|
| 20 |
boolean matrices, all of arbitrary sizes. |
|---|
| 21 |
|
|---|
| 22 |
The library is efficient (in terms of algorithmical complexity) |
|---|
| 23 |
and therefore fast (in terms of execution speed) for instance |
|---|
| 24 |
through the widespread use of divide-and-conquer algorithms. |
|---|
| 25 |
|
|---|
| 26 |
The package also includes an object-oriented Perl module for |
|---|
| 27 |
accessing the C library from Perl, and optionally features |
|---|
| 28 |
overloaded operators for maximum ease of use. |
|---|
| 29 |
|
|---|
| 30 |
The C library can nevertheless be used stand-alone, without Perl. |
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
What's new in version 6.3: |
|---|
| 34 |
-------------------------- |
|---|
| 35 |
|
|---|
| 36 |
+ Added "Create_List()" and "GCD2()" in "BitVector.c". |
|---|
| 37 |
+ "new()" now can optionally return a list of bit vectors. |
|---|
| 38 |
+ "GCD()" now can optionally return the two integer factors |
|---|
| 39 |
"x" and "y" for the linear combination of its input values |
|---|
| 40 |
"a" and "b" so that gcd(a,b) = x * a + y * b. |
|---|
| 41 |
+ Changed the test files "t/01________new.t" and "t/09_parameters.t" |
|---|
| 42 |
as well as the documentation accordingly. |
|---|
| 43 |
+ Added a new test file "t/17________gcd.t". |
|---|
| 44 |
+ Further simplified the error handlers in "Vector.xs", making the |
|---|
| 45 |
resulting object library file substantially smaller (about 20%!) |
|---|
| 46 |
and thus faster to load. |
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
Legal issues: |
|---|
| 50 |
------------- |
|---|
| 51 |
|
|---|
| 52 |
This package with all its parts is |
|---|
| 53 |
|
|---|
| 54 |
Copyright (c) 1995 - 2002 by Steffen Beyer. |
|---|
| 55 |
All rights reserved. |
|---|
| 56 |
|
|---|
| 57 |
This package is free software; you can use, modify and redistribute |
|---|
| 58 |
it under the same terms as Perl itself, i.e., under the terms of |
|---|
| 59 |
the "Artistic License" or the "GNU General Public License". |
|---|
| 60 |
|
|---|
| 61 |
The C library at the core of this Perl module can additionally |
|---|
| 62 |
be used, modified and redistributed under the terms of the |
|---|
| 63 |
"GNU Library General Public License". |
|---|
| 64 |
|
|---|
| 65 |
Please refer to the files "Artistic.txt", "GNU_GPL.txt" and |
|---|
| 66 |
"GNU_LGPL.txt" in this distribution, respectively, for details! |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
Prerequisites: |
|---|
| 70 |
-------------- |
|---|
| 71 |
|
|---|
| 72 |
Perl version 5.000 or higher, and an ANSI C compiler. (!) |
|---|
| 73 |
^^^^^^ |
|---|
| 74 |
If you compile under Windows, note that you will need |
|---|
| 75 |
exactly the same compiler your Perl itself was compiled |
|---|
| 76 |
with! (This is also true for Unix, but rarely a problem.) |
|---|
| 77 |
|
|---|
| 78 |
Moreover, you usually cannot build any modules under |
|---|
| 79 |
Windows 95/98, the Win 95/98 command shell doesn't |
|---|
| 80 |
grok the "&&" operator. You will need the Windows NT |
|---|
| 81 |
command shell ("cmd.exe") or the "4DOS" shell. |
|---|
| 82 |
|
|---|
| 83 |
Note that ActiveState provides precompiled binaries of |
|---|
| 84 |
this module for their Win32 port of Perl ("ActivePerl") |
|---|
| 85 |
on their web site, which you should be able to install |
|---|
| 86 |
simply by typing "ppm install Bit-Vector" in your MS-DOS |
|---|
| 87 |
command shell (but note the "-" instead of "::" in the |
|---|
| 88 |
package name!). This also works under Windows 95/98. |
|---|
| 89 |
|
|---|
| 90 |
If your firewall prevents "ppm" from downloading |
|---|
| 91 |
this package, you can also download it manually from |
|---|
| 92 |
http://www.activestate.com/ppmpackages/5.005/zips/ or |
|---|
| 93 |
http://www.activestate.com/ppmpackages/5.6/zips/. |
|---|
| 94 |
Follow the installation instructions included in |
|---|
| 95 |
the "zip" archive. |
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
Note to CPAN Testers: |
|---|
| 99 |
--------------------- |
|---|
| 100 |
|
|---|
| 101 |
After completion, version 6.3 of this module has already |
|---|
| 102 |
been tested successfully with the following configurations: |
|---|
| 103 |
|
|---|
| 104 |
Perl 5.005_03 - FreeBSD 4.1.1-RELEASE (with "dlopen() relative paths" patch) |
|---|
| 105 |
Perl 5.6.0 - FreeBSD 4.1.1-RELEASE |
|---|
| 106 |
Perl 5.6.1 - FreeBSD 4.1.1-RELEASE |
|---|
| 107 |
Perl 5.7.0 - FreeBSD 4.1.1-RELEASE |
|---|
| 108 |
Perl 5.7.1 - FreeBSD 4.1.1-RELEASE |
|---|
| 109 |
Perl 5.7.2 - FreeBSD 4.1.1-RELEASE |
|---|
| 110 |
Perl 5.8.0 - FreeBSD 4.1.1-RELEASE |
|---|
| 111 |
Perl 5.005_03 - FreeBSD 4.6-STABLE |
|---|
| 112 |
Perl 5.6.1 - FreeBSD 4.6-STABLE |
|---|
| 113 |
Perl 5.005_03 - Windows NT 4.0 & MS VC++ 6.0 (native Perl build) |
|---|
| 114 |
Perl 5.8.0 - Windows NT 4.0 & MS VC++ 6.0 (native Perl build) |
|---|
| 115 |
Perl 5.6.1 - Windows NT 4.0 & ActivePerl 5.6.1.633 (multi-thread) |
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
Installation: |
|---|
| 119 |
------------- |
|---|
| 120 |
|
|---|
| 121 |
Please see the file "INSTALL.txt" in this distribution for instructions |
|---|
| 122 |
on how to install this package. |
|---|
| 123 |
|
|---|
| 124 |
It is essential that you read this file since one of the special cases |
|---|
| 125 |
described in it might apply to you, especially if you are running Perl |
|---|
| 126 |
under Windows. |
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
Changes over previous versions: |
|---|
| 130 |
------------------------------- |
|---|
| 131 |
|
|---|
| 132 |
Please refer to the file "CHANGES.txt" in this distribution for a more |
|---|
| 133 |
detailed version history log. |
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
Documentation: |
|---|
| 137 |
-------------- |
|---|
| 138 |
|
|---|
| 139 |
The documentation of this package is included in POD format (= "Plain |
|---|
| 140 |
Old Documentation") in the files with the extension ".pod" in this |
|---|
| 141 |
distribution, the human-readable markup-language standard for Perl |
|---|
| 142 |
documentation. |
|---|
| 143 |
|
|---|
| 144 |
By building this package, this documentation will automatically be |
|---|
| 145 |
converted into man pages, which will automatically be installed in |
|---|
| 146 |
your Perl tree for further reference through the installation process, |
|---|
| 147 |
where they can be accessed by the commands "man Bit::Vector" (Unix) |
|---|
| 148 |
and "perldoc Bit::Vector" (Unix and Win32 alike), for example. |
|---|
| 149 |
|
|---|
| 150 |
Available man pages: |
|---|
| 151 |
|
|---|
| 152 |
Bit::Vector(3) |
|---|
| 153 |
Bit::Vector::Overload(3) |
|---|
| 154 |
Carp::Clan(3) |
|---|
| 155 |
|
|---|
| 156 |
If Perl is not available on your system, you can also read the ".pod" |
|---|
| 157 |
files |
|---|
| 158 |
|
|---|
| 159 |
./Vector.pod |
|---|
| 160 |
./lib/Bit/Vector/Overload.pod |
|---|
| 161 |
./lib/Carp/Clan.pod |
|---|
| 162 |
|
|---|
| 163 |
directly. |
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
What does it do: |
|---|
| 167 |
---------------- |
|---|
| 168 |
|
|---|
| 169 |
This module implements bit vectors of arbitrary size and provides efficient |
|---|
| 170 |
methods for handling them. |
|---|
| 171 |
|
|---|
| 172 |
This goes far beyond the built-in capabilities of Perl for handling bit |
|---|
| 173 |
vectors (compare with the method list below!). |
|---|
| 174 |
|
|---|
| 175 |
Moreover, the C core of this module can be used "stand-alone" in other |
|---|
| 176 |
C applications; Perl is not necessarily required. |
|---|
| 177 |
|
|---|
| 178 |
The module is intended to serve as a base class for other applications |
|---|
| 179 |
or application classes, such as implementing sets or performing big |
|---|
| 180 |
integer arithmetic. |
|---|
| 181 |
|
|---|
| 182 |
All methods are implemented in C internally for maximum performance. |
|---|
| 183 |
|
|---|
| 184 |
An add-on module (named "Bit::Vector::Overload") provides overloaded |
|---|
| 185 |
arithmetic and relational operators for maximum ease of use (Perl only). |
|---|
| 186 |
|
|---|
| 187 |
Note that there is (of course) a little speed penalty to pay for |
|---|
| 188 |
overloaded operators. If speed is crucial, use the "Bit::Vector" |
|---|
| 189 |
module alone! |
|---|
| 190 |
|
|---|
| 191 |
This module is useful for a large range of different tasks: |
|---|
| 192 |
|
|---|
| 193 |
- For example for implementing sets and performing set operations |
|---|
| 194 |
(like union, difference, intersection, complement, check for subset |
|---|
| 195 |
relationship etc.), |
|---|
| 196 |
|
|---|
| 197 |
- as a basis for many efficient algorithms, for instance the |
|---|
| 198 |
"Sieve of Erathostenes" (for calculating prime numbers), |
|---|
| 199 |
|
|---|
| 200 |
(The complexities of the methods in this module are usually either |
|---|
| 201 |
O(1) or O(n/b), where "b" is the number of bits in a machine word |
|---|
| 202 |
on your system.) |
|---|
| 203 |
|
|---|
| 204 |
- for shift registers of arbitrary length (for example for cyclic |
|---|
| 205 |
redundancy checksums), |
|---|
| 206 |
|
|---|
| 207 |
- to calculate "look-ahead", "first" and "follow" character sets |
|---|
| 208 |
for parsers and compiler-compilers, |
|---|
| 209 |
|
|---|
| 210 |
- for graph algorithms, |
|---|
| 211 |
|
|---|
| 212 |
- for efficient storage and retrieval of status information, |
|---|
| 213 |
|
|---|
| 214 |
- for performing text synthesis ruled by boolean expressions, |
|---|
| 215 |
|
|---|
| 216 |
- for "big integer" arithmetic with arbitrarily large integers, |
|---|
| 217 |
|
|---|
| 218 |
- for manipulations of chunks of bits of arbitrary size, |
|---|
| 219 |
|
|---|
| 220 |
- for bitwise processing of audio CD wave files, |
|---|
| 221 |
|
|---|
| 222 |
- to convert formats of data files, |
|---|
| 223 |
|
|---|
| 224 |
and more. |
|---|
| 225 |
|
|---|
| 226 |
(A number of example applications is available from my web site at |
|---|
| 227 |
http://www.engelschall.com/u/sb/download/.) |
|---|
| 228 |
|
|---|
| 229 |
A large number of import/export methods allow you to access individual |
|---|
| 230 |
bits, contiguous ranges of bits, machine words, arbitrary chunks of |
|---|
| 231 |
bits, lists (arrays) of chunks of bits or machine words and a whole |
|---|
| 232 |
bit vector at once (for instance for blockwrite/-read to and from |
|---|
| 233 |
a file). |
|---|
| 234 |
|
|---|
| 235 |
You can also import and export the contents of a bit vector in binary, |
|---|
| 236 |
hexadecimal and decimal representation as well as ".newsrc" style |
|---|
| 237 |
enumerations. |
|---|
| 238 |
|
|---|
| 239 |
Note that this module is specifically designed for efficiency, which is |
|---|
| 240 |
also the reason why its methods are implemented in C. |
|---|
| 241 |
|
|---|
| 242 |
To further increase execution speed, the module doesn't use bytes as its |
|---|
| 243 |
basic storage unit, but rather uses machine words, assuming that a machine |
|---|
| 244 |
word is the most efficiently handled size of all scalar types on all |
|---|
| 245 |
machines (that's what the ANSI C standard proposes and assumes anyway). |
|---|
| 246 |
|
|---|
| 247 |
In order to achieve this, it automatically determines the number of bits |
|---|
| 248 |
in a machine word on your system and then adjusts its internal configuration |
|---|
| 249 |
constants accordingly. |
|---|
| 250 |
|
|---|
| 251 |
The greater the size of this basic storage unit, the better the complexity |
|---|
| 252 |
(= execution speed) of the methods in this module, but also the greater the |
|---|
| 253 |
average waste of unused bits in the last word. |
|---|
| 254 |
|
|---|
| 255 |
The range of available methods is exceptionally large for this kind of library; |
|---|
| 256 |
in detail: |
|---|
| 257 |
|
|---|
| 258 |
Version() Word_Bits() Long_Bits() |
|---|
| 259 |
new() new_Hex() new_Bin() |
|---|
| 260 |
new_Dec() new_Enum() Shadow() |
|---|
| 261 |
Clone() Concat() Concat_List() |
|---|
| 262 |
Size() Resize() Copy() |
|---|
| 263 |
Empty() Fill() Flip() |
|---|
| 264 |
Primes() Reverse() Interval_Empty() |
|---|
| 265 |
Interval_Fill() Interval_Flip() Interval_Reverse() |
|---|
| 266 |
Interval_Scan_inc() Interval_Scan_dec() Interval_Copy() |
|---|
| 267 |
Interval_Substitute() is_empty() is_full() |
|---|
| 268 |
equal() Lexicompare() Compare() |
|---|
| 269 |
to_Hex() from_Hex() to_Bin() |
|---|
| 270 |
from_Bin() to_Dec() from_Dec() |
|---|
| 271 |
to_Enum() from_Enum() Bit_Off() |
|---|
| 272 |
Bit_On() bit_flip() bit_test() |
|---|
| 273 |
Bit_Copy() LSB() MSB() |
|---|
| 274 |
lsb() msb() rotate_left() |
|---|
| 275 |
rotate_right() shift_left() shift_right() |
|---|
| 276 |
Move_Left() Move_Right() Insert() |
|---|
| 277 |
Delete() increment() decrement() |
|---|
| 278 |
inc() dec() add() |
|---|
| 279 |
subtract() Negate() Absolute() |
|---|
| 280 |
Sign() Multiply() Divide() |
|---|
| 281 |
GCD() Power() Block_Store() |
|---|
| 282 |
Block_Read() Word_Size() Word_Store() |
|---|
| 283 |
Word_Read() Word_List_Store() Word_List_Read() |
|---|
| 284 |
Word_Insert() Word_Delete() Chunk_Store() |
|---|
| 285 |
Chunk_Read() Chunk_List_Store() Chunk_List_Read() |
|---|
| 286 |
Index_List_Remove() Index_List_Store() Index_List_Read() |
|---|
| 287 |
Union() Intersection() Difference() |
|---|
| 288 |
ExclusiveOr() Complement() subset() |
|---|
| 289 |
Norm() Min() Max() |
|---|
| 290 |
Multiplication() Product() Closure() |
|---|
| 291 |
Transpose() |
|---|
| 292 |
|
|---|
| 293 |
|
|---|
| 294 |
Note to C developers: |
|---|
| 295 |
--------------------- |
|---|
| 296 |
|
|---|
| 297 |
Note again that the C library at the core of this module can also be |
|---|
| 298 |
used stand-alone (i.e., it contains no inter-dependencies whatsoever |
|---|
| 299 |
with Perl). |
|---|
| 300 |
|
|---|
| 301 |
The library itself consists of three files: "BitVector.c", "BitVector.h" |
|---|
| 302 |
and "ToolBox.h". |
|---|
| 303 |
|
|---|
| 304 |
Just compile "BitVector.c" (which automatically includes "ToolBox.h") |
|---|
| 305 |
and link the resulting output file "BitVector.o" with your application, |
|---|
| 306 |
which in turn should include "ToolBox.h" and "BitVector.h" (in this order). |
|---|
| 307 |
|
|---|
| 308 |
|
|---|
| 309 |
Example applications: |
|---|
| 310 |
--------------------- |
|---|
| 311 |
|
|---|
| 312 |
See the module "Set::IntRange" for an easy-to-use module for sets |
|---|
| 313 |
of integers within arbitrary ranges. |
|---|
| 314 |
|
|---|
| 315 |
See the module "Math::MatrixBool" for an efficient implementation |
|---|
| 316 |
of boolean matrices and boolean matrix operations. |
|---|
| 317 |
|
|---|
| 318 |
(Both modules are also available from my web site at |
|---|
| 319 |
http://www.engelschall.com/u/sb/download/ or any CPAN server.) |
|---|
| 320 |
|
|---|
| 321 |
See the file "SetObject.pl" in the "examples" subdirectory of this |
|---|
| 322 |
distribution for a way to emulate the "Set::Object" module from CPAN |
|---|
| 323 |
using "Bit::Vector" - this is a way to perform set operations on sets |
|---|
| 324 |
of arbitrary objects (any Perl objects or Perl data structures you want!). |
|---|
| 325 |
|
|---|
| 326 |
An application relying crucially on this "Bit::Vector" module is "Slice", |
|---|
| 327 |
a tool for generating different document versions out of a single |
|---|
| 328 |
master file, ruled by boolean expressions ("include english version |
|---|
| 329 |
of text plus examples but not ..."). |
|---|
| 330 |
|
|---|
| 331 |
(See also http://www.engelschall.com/sw/slice/.) |
|---|
| 332 |
|
|---|
| 333 |
This tool is itself part of another tool, "Website META Language" ("WML"), |
|---|
| 334 |
which allows you to generate and maintain large web sites. |
|---|
| 335 |
|
|---|
| 336 |
Among many other features, it allows you to define your own HTML tags which |
|---|
| 337 |
will be expanded either at generation or at run time, depending on your |
|---|
| 338 |
choice. |
|---|
| 339 |
|
|---|
| 340 |
(See also http://www.engelschall.com/sw/wml/.) |
|---|
| 341 |
|
|---|
| 342 |
Both tools are written by Ralf S. Engelschall. |
|---|
| 343 |
|
|---|
| 344 |
|
|---|
| 345 |
Credits: |
|---|
| 346 |
-------- |
|---|
| 347 |
|
|---|
| 348 |
Please refer to the file "CREDITS.txt" in this distribution for a list |
|---|
| 349 |
of contributors. |
|---|
| 350 |
|
|---|
| 351 |
|
|---|
| 352 |
Author's note: |
|---|
| 353 |
-------------- |
|---|
| 354 |
|
|---|
| 355 |
If you have any questions, suggestions or need any assistance, please |
|---|
| 356 |
let me know! |
|---|
| 357 |
|
|---|
| 358 |
Please do send feedback, this is essential for improving this module |
|---|
| 359 |
according to your needs! |
|---|
| 360 |
|
|---|
| 361 |
I hope you will find this module useful. Enjoy! |
|---|
| 362 |
|
|---|
| 363 |
Yours, |
|---|
| 364 |
-- |
|---|
| 365 |
Steffen Beyer <sb@engelschall.com> http://www.engelschall.com/u/sb/ |
|---|
| 366 |
"There is enough for the need of everyone in this world, but not |
|---|
| 367 |
for the greed of everyone." - Mohandas Karamchand "Mahatma" Gandhi |
|---|