Vector(3pm) | User Contributed Perl Documentation | Vector(3pm) |

Version $version = Bit::Vector->Version(); Word_Bits $bits = Bit::Vector->Word_Bits(); # bits in a machine word Long_Bits $bits = Bit::Vector->Long_Bits(); # bits in an unsigned long new $vector = Bit::Vector->new($bits); # bit vector constructor @veclist = Bit::Vector->new($bits,$count); new_Hex $vector = Bit::Vector->new_Hex($bits,$string); new_Bin $vector = Bit::Vector->new_Bin($bits,$string); new_Dec $vector = Bit::Vector->new_Dec($bits,$string); new_Enum $vector = Bit::Vector->new_Enum($bits,$string); Concat_List $vector = Bit::Vector->Concat_List(@vectors);

new $vec2 = $vec1->new($bits); # alternative call of constructor @veclist = $vec->new($bits,$count); Shadow $vec2 = $vec1->Shadow(); # new vector, same size but empty Clone $vec2 = $vec1->Clone(); # new vector, exact duplicate Concat $vector = $vec1->Concat($vec2); Concat_List $vector = $vec1->Concat_List($vec2,$vec3,...); Size $bits = $vector->Size(); Resize $vector->Resize($bits); $vector->Resize($vector->Size()+5); $vector->Resize($vector->Size()-5); Copy $vec2->Copy($vec1); Empty $vector->Empty(); Fill $vector->Fill(); Flip $vector->Flip(); Primes $vector->Primes(); # Sieve of Erathostenes Reverse $vec2->Reverse($vec1); Interval_Empty $vector->Interval_Empty($min,$max); Interval_Fill $vector->Interval_Fill($min,$max); Interval_Flip $vector->Interval_Flip($min,$max); Interval_Reverse $vector->Interval_Reverse($min,$max); Interval_Scan_inc if (($min,$max) = $vector->Interval_Scan_inc($start)) Interval_Scan_dec if (($min,$max) = $vector->Interval_Scan_dec($start)) Interval_Copy $vec2->Interval_Copy($vec1,$offset2,$offset1,$length); Interval_Substitute $vec2->Interval_Substitute($vec1,$off2,$len2,$off1,$len1); is_empty if ($vector->is_empty()) is_full if ($vector->is_full()) equal if ($vec1->equal($vec2)) Lexicompare (unsigned) if ($vec1->Lexicompare($vec2) == 0) if ($vec1->Lexicompare($vec2) != 0) if ($vec1->Lexicompare($vec2) < 0) if ($vec1->Lexicompare($vec2) <= 0) if ($vec1->Lexicompare($vec2) > 0) if ($vec1->Lexicompare($vec2) >= 0) Compare (signed) if ($vec1->Compare($vec2) == 0) if ($vec1->Compare($vec2) != 0) if ($vec1->Compare($vec2) < 0) if ($vec1->Compare($vec2) <= 0) if ($vec1->Compare($vec2) > 0) if ($vec1->Compare($vec2) >= 0) to_Hex $string = $vector->to_Hex(); from_Hex $vector->from_Hex($string); to_Bin $string = $vector->to_Bin(); from_Bin $vector->from_Bin($string); to_Dec $string = $vector->to_Dec(); from_Dec $vector->from_Dec($string); to_Enum $string = $vector->to_Enum(); # e.g. "2,3,5-7,11,13-19" from_Enum $vector->from_Enum($string); Bit_Off $vector->Bit_Off($index); Bit_On $vector->Bit_On($index); bit_flip $bit = $vector->bit_flip($index); bit_test contains $bit = $vector->bit_test($index); $bit = $vector->contains($index); if ($vector->bit_test($index)) if ($vector->contains($index)) Bit_Copy $vector->Bit_Copy($index,$bit); LSB (least significant bit) $vector->LSB($bit); MSB (most significant bit) $vector->MSB($bit); lsb (least significant bit) $bit = $vector->lsb(); msb (most significant bit) $bit = $vector->msb(); rotate_left $carry = $vector->rotate_left(); rotate_right $carry = $vector->rotate_right(); shift_left $carry = $vector->shift_left($carry); shift_right $carry = $vector->shift_right($carry); Move_Left $vector->Move_Left($bits); # shift left "$bits" positions Move_Right $vector->Move_Right($bits); # shift right "$bits" positions Insert $vector->Insert($offset,$bits); Delete $vector->Delete($offset,$bits); increment $carry = $vector->increment(); decrement $carry = $vector->decrement(); inc $overflow = $vec2->inc($vec1); dec $overflow = $vec2->dec($vec1); add $carry = $vec3->add($vec1,$vec2,$carry); ($carry,$overflow) = $vec3->add($vec1,$vec2,$carry); subtract $carry = $vec3->subtract($vec1,$vec2,$carry); ($carry,$overflow) = $vec3->subtract($vec1,$vec2,$carry); Neg Negate $vec2->Neg($vec1); $vec2->Negate($vec1); Abs Absolute $vec2->Abs($vec1); $vec2->Absolute($vec1); Sign if ($vector->Sign() == 0) if ($vector->Sign() != 0) if ($vector->Sign() < 0) if ($vector->Sign() <= 0) if ($vector->Sign() > 0) if ($vector->Sign() >= 0) Multiply $vec3->Multiply($vec1,$vec2); Divide $quot->Divide($vec1,$vec2,$rest); GCD (Greatest Common Divisor) $vecgcd->GCD($veca,$vecb); $vecgcd->GCD($vecx,$vecy,$veca,$vecb); Power $vec3->Power($vec1,$vec2); Block_Store $vector->Block_Store($buffer); Block_Read $buffer = $vector->Block_Read(); Word_Size $size = $vector->Word_Size(); # number of words in "$vector" Word_Store $vector->Word_Store($offset,$word); Word_Read $word = $vector->Word_Read($offset); Word_List_Store $vector->Word_List_Store(@words); Word_List_Read @words = $vector->Word_List_Read(); Word_Insert $vector->Word_Insert($offset,$count); Word_Delete $vector->Word_Delete($offset,$count); Chunk_Store $vector->Chunk_Store($chunksize,$offset,$chunk); Chunk_Read $chunk = $vector->Chunk_Read($chunksize,$offset); Chunk_List_Store $vector->Chunk_List_Store($chunksize,@chunks); Chunk_List_Read @chunks = $vector->Chunk_List_Read($chunksize); Index_List_Remove $vector->Index_List_Remove(@indices); Index_List_Store $vector->Index_List_Store(@indices); Index_List_Read @indices = $vector->Index_List_Read(); Or Union $vec3->Or($vec1,$vec2); $set3->Union($set1,$set2); And Intersection $vec3->And($vec1,$vec2); $set3->Intersection($set1,$set2); AndNot Difference $vec3->AndNot($vec1,$vec2); $set3->Difference($set1,$set2); Xor ExclusiveOr $vec3->Xor($vec1,$vec2); $set3->ExclusiveOr($set1,$set2); Not Complement $vec2->Not($vec1); $set2->Complement($set1); subset if ($set1->subset($set2)) # true if $set1 is subset of $set2 Norm $norm = $set->Norm(); $norm = $set->Norm2(); $norm = $set->Norm3(); Min $min = $set->Min(); Max $max = $set->Max(); Multiplication $matrix3->Multiplication($rows3,$cols3, $matrix1,$rows1,$cols1, $matrix2,$rows2,$cols2); Product $matrix3->Product($rows3,$cols3, $matrix1,$rows1,$cols1, $matrix2,$rows2,$cols2); Closure $matrix->Closure($rows,$cols); Transpose $matrix2->Transpose($rows2,$cols2,$matrix1,$rows1,$cols1);

- •
- Method naming conventions

- •
- Boolean values

- •
- Negative numbers
**UNSIGNED**(as opposed to the contents of the bit vectors themselves, which are usually considered to be**SIGNED**).

- •
- Bit order
**RIGHTMOST**bit is always the**LEAST SIGNIFICANT**one, and the**LEFTMOST**bit is always the**MOST SIGNIFICANT**bit.

- •
- "Word" related methods
**MACHINE-DEPENDENT**!**ABSOLUTELY CERTAIN**that portability of your code is not an issue!**IN A PORTABLE WAY**using the methods whose names begin with ""Chunk_"".

- •
- Chunk sizes
**NOT**allowed!).

- •
- Matching sizes

- •
- Index ranges

- •
- Object persistence
*Storable*(3) documentation for more details.

- •
- "$version = Bit::Vector->Version();"

- •
- "$bits = Bit::Vector->Word_Bits();"

- •
- "$bits = Bit::Vector->Long_Bits();"

- •
- "$vector = Bit::Vector->new($bits);"

- •
- "@veclist = Bit::Vector->new($bits,$count);"

- •
- "$vector =
Bit::Vector->new_Hex($bits,$string);"

- •
- "$vector =
Bit::Vector->new_Bin($bits,$string);"

- •
- "$vector =
Bit::Vector->new_Dec($bits,$string);"

- •
- "$vector =
Bit::Vector->new_Enum($bits,$string);"

- •
- "$vector =
Bit::Vector->Concat_List(@vectors);"
**RIGHTMOST**bit vector from the argument list will become the**LEAST**significant part of the resulting bit vector, and the**LEFTMOST**bit vector from the argument list will become the**MOST**significant part of the resulting bit vector.

- •
- "$vec2 = $vec1->new($bits);"
**ALL**class methods in this module can be called this way, even though this is probably considered to be "politically incorrect" by OO ("object-orientation") aficionados. ;-)

- •
- "$vec2 = $vec1->Shadow();"
**NEW**bit vector "$vec2" of the**SAME SIZE**as "$vec1" but which is**EMPTY**.

- •
- "$vec2 = $vec1->Clone();"
**NEW**bit vector "$vec2" of the**SAME SIZE**as "$vec1" which is an**EXACT COPY**of "$vec1".

- •
- "$vector = $vec1->Concat($vec2);"
**MOST**significant part of the resulting bit vector, and "$vec2" the**LEAST**significant part.

- •
- "$vector =
$vec1->Concat_List($vec2,$vec3,...);"

- •
- "$bits = $vector->Size();"

- •
- "$vector->Resize($bits);"
*Resize()*" will obediently attempt to create a bit vector of that size, probably resulting in an exception, as explained above.

- •
- "$vec2->Copy($vec1);"
**CREATE**any new bit vector object.

- •
- "$vector->Empty();"

- •
- "$vector->Fill();"

- •
- "$vector->Flip();"

- •
- "$vector->Primes();"

- •
- "$vec2->Reverse($vec1);"

- •
- "$vector->Interval_Empty($min,$max);"

- •
- "$vector->Interval_Fill($min,$max);"

- •
- "$vector->Interval_Flip($min,$max);"

- •
- "$vector->Interval_Reverse($min,$max);"

- •
- "if (($min,$max) =
$vector->Interval_Scan_inc($start))"
**NOT**altered. I.e., you have to set it to the desired value yourself prior to each call to ""Interval_Scan_inc()"" (see also the example given below).$start = 0; while (($start < $vector->Size()) && (($min,$max) = $vector->Interval_Scan_inc($start))) { $start = $max + 2; # do something with $min and $max }

- •
- "if (($min,$max) =
$vector->Interval_Scan_dec($start))"
**NOT**altered. I.e., you have to set it to the desired value yourself prior to each call to ""Interval_Scan_dec()"" (see also the example given below).$start = $vector->Size() - 1; while (($start >= 0) && (($min,$max) = $vector->Interval_Scan_dec($start))) { $start = $min - 2; # do something with $min and $max }

- •
- "$vec2->Interval_Copy($vec1,$offset2,$offset1,$length);"
**NOT**need to have the same (matching) size!

- •
- "$vec2->Interval_Substitute($vec1,$off2,$len2,$off1,$len1);"
**NOT**need to have the same (matching) size!**NOT**""$vec1->Size()-1"" and ""$vec2->Size()-1"", as they would be for any other method in this module, but that these offsets may actually point to one position**PAST THE END**of the corresponding bit vector.**APPEND**a given stretch of bits to the target bit vector instead of**REPLACING**something in it.**NOT**alter the intended result, even though this may seem counter-intuitive at first!)**SOURCE**bit vector (""$len1 == 0"") means that the indicated stretch of bits in the target bit vector (starting at position "$off2") is to be replaced by**NOTHING**, i.e., is to be**DELETED**.**TARGET**bit vector ("$len2 == 0") means that**NOTHING**is replaced, and that the stretch of bits from the source bit vector is simply**INSERTED**into the target bit vector at the indicated position ("$off2").**IMPLICITLY**and**AUTOMATICALLY**adapts the length of the resulting bit vector as needed, as given by$size = $vec2->Size(); # before $size += $len1 - $len2; # after

- •
- "if ($vector->is_empty())"
**ALL**of its bits are cleared (in the "off" state).

- •
- "if ($vector->is_full())"
**ALL**of its bits are set (in the "on" state).

- •
- "if ($vec1->equal($vec2))"

- •
- "$cmp = $vec1->Lexicompare($vec2);"
**UNSIGNED**numbers in binary representation.

- •
- "$cmp = $vec1->Compare($vec2);"
**SIGNED**numbers in binary representation.

- •
- "$string = $vector->to_Hex();"
**LEAST**significant hexadecimal digit is located at the**RIGHT**end of the resulting string, and the**MOST**significant digit at the**LEFT**end.

- •
- "$vector->from_Hex($string);"

- •
- "$string = $vector->to_Bin();"
$vector = Bit::Vector->new(8); $vector->Primes(); $string = $vector->to_Bin(); print "'$string'\n";

'10101100'

**LEAST**significant bit is located at the**RIGHT**end of the resulting string, and the**MOST**significant bit at the**LEFT**end.

- •
- "$vector->from_Bin($string);"
**LEAST**significant bit is located at the**RIGHT**end of the binary string, and the**MOST**significant bit at the**LEFT**end. Therefore, the string is actually read in from right to left while the bit vector is filled accordingly, one bit at a time, starting with the least significant bit and going upward to the most significant bit.

- •
- "$string = $vector->to_Dec();"
**SIGNED**(and to contain a number in two's complement binary representation).**NEGATIVE**.

- •
- "$vector->from_Dec($string);"
*to_Dec()*" (e.g. "-1", in our example), because numbers with the most significant bit set are considered to be negative in two's complement binary representation.eval { $vector->from_Dec("1152921504606846976"); }; if ($@) { # an error occurred }

if ($@ =~ /item is not a string/) if ($@ =~ /input string syntax error/) if ($@ =~ /numeric overflow error/) if ($@ =~ /unable to allocate memory/)

- •
- "$string = $vector->to_Enum();"
$vector = Bit::Vector->new(20); $vector->Bit_On(2); $vector->Bit_On(3); $vector->Bit_On(11); $vector->Interval_Fill(5,7); $vector->Interval_Fill(13,19); print "'", $vector->to_Enum(), "'\n";

'2,3,5-7,11,13-19'

Bit::Vector->Configuration("out=enum"); $vector = Bit::Vector->new(20); $vector->Index_List_Store(2,3,5,6,7,11,13,14,15,16,17,18,19); print "'$vector'\n";

- •
- "$vector->from_Enum($string);"
eval { $vector->from_Enum("2,3,5-7,11,13-19"); }; if ($@) { # an error occurred }

if ($@ =~ /item is not a string/) if ($@ =~ /input string syntax error/) if ($@ =~ /index out of range/) if ($@ =~ /minimum > maximum index/)

eval { $vector->from_Enum("11,5-7,3,13-19,2"); };

- •
- "$vector->Bit_Off($index);"

- •
- "$vector->Bit_On($index);"

- •
- "$vector->bit_flip($index)"
**NEW**state of the bit in question, i.e., it returns "0" if the bit is cleared or "1" if the bit is set (**AFTER**flipping it).

- •
- "if ($vector->bit_test($index))"

- •
- "$vector->Bit_Copy($index,$bit);"

- •
- "$vector->LSB($bit);"

- •
- "$vector->MSB($bit);"

- •
- "$bit = $vector->lsb();"

- •
- "$bit = $vector->msb();"

- •
- "$carry_out = $vector->rotate_left();"
carry MSB vector: LSB out: +---+ +---+---+---+--- ---+---+---+---+ | | <---+--- | | | | ... | | | | <---+ +---+ | +---+---+---+--- ---+---+---+---+ | | | +------------------------------------------------+

- •
- "$carry_out = $vector->rotate_right();"
MSB vector: LSB carry out: +---+---+---+--- ---+---+---+---+ +---+ +---> | | | | ... | | | | ---+---> | | | +---+---+---+--- ---+---+---+---+ | +---+ | | +------------------------------------------------+

- •
- "$carry_out = $vector->shift_left($carry_in);"
carry MSB vector: LSB carry out: in: +---+ +---+---+---+--- ---+---+---+---+ +---+ | | <--- | | | | ... | | | | <--- | | +---+ +---+---+---+--- ---+---+---+---+ +---+

- •
- "$carry_out =
$vector->shift_right($carry_in);"
carry MSB vector: LSB carry in: out: +---+ +---+---+---+--- ---+---+---+---+ +---+ | | ---> | | | | ... | | | | ---> | | +---+ +---+---+---+--- ---+---+---+---+ +---+

- •
- "$vector->Move_Left($bits);"
**WITHOUT WARNING**if "$bits" is greater than or equal to the size of the given bit vector!for ( $i = 0; $i < $bits; $i++ ) { $vector->shift_left(0); }

- •
- "$vector->Move_Right($bits);"
**WITHOUT WARNING**if "$bits" is greater than or equal to the size of the given bit vector!for ( $i = 0; $i < $bits; $i++ ) { $vector->shift_right(0); }

- •
- "$vector->Insert($offset,$bits);"
**NOT**increase the size of the given bit vector, i.e., the bit vector is**NOT**extended at its upper end to "rescue" the "$bits" uppermost (most significant) bits - instead, these bits are lost forever.**EXPLICITLY**and**BEFORE**you perform the "Insert" operation, with a statement such as the following:$vector->Resize($vector->Size() + $bits);

- •
- "$vector->Delete($offset,$bits);"
**NOT**decrease the size of the given bit vector, i.e., the bit vector is**NOT**clipped at its upper end to "get rid of" the vacant "$bits" uppermost bits.**EXPLICITLY**and**AFTER**the "Delete" operation, with a couple of statements such as these:$size = $vector->Size(); if ($bits > $size) { $bits = $size; } $vector->Resize($size - $bits);

- •
- "$carry = $vector->increment();"
before: 2 ^ (b-1) - 1 (= "0111...1111") after: 2 ^ (b-1) (= "1000...0000")

- •
- "$carry = $vector->decrement();"
before: 2 ^ (b-1) (= "1000...0000") after: 2 ^ (b-1) - 1 (= "0111...1111")

- •
- "$overflow = $vec2->inc($vec1);"
*add()*" below for a more in-depth explanation of what "overflow" means).

- •
- "$overflow = $vec2->dec($vec1);"
*subtract()*" below for a more in-depth explanation of what "overflow" means).

- •
- "$carry = $vec3->add($vec1,$vec2,$carry);"

$vec3 = $vec1 + $vec2 + $carry# initialize for ( $i = 0; $i < $n; $i++ ) { $a[$i] = Bit::Vector->new($bits); $b[$i] = Bit::Vector->new($bits); $c[$i] = Bit::Vector->new($bits); } # fill @a and @b # $a[ 0 ] is low order part, # $a[$n-1] is high order part, # and same for @b # add $carry = 0; for ( $i = 0; $i < $n; $i++ ) { $carry = $c[$i]->add($a[$i],$b[$i],$carry); }

**SIGNED**.

- •
- "$carry =
$vec3->subtract($vec1,$vec2,$carry);"

$vec3 = $vec1 - $vec2 - $carry# initialize for ( $i = 0; $i < $n; $i++ ) { $a[$i] = Bit::Vector->new($bits); $b[$i] = Bit::Vector->new($bits); $c[$i] = Bit::Vector->new($bits); } # fill @a and @b # $a[ 0 ] is low order part, # $a[$n-1] is high order part, # and same for @b # subtract $carry = 0; for ( $i = 0; $i < $n; $i++ ) { $carry = $c[$i]->subtract($a[$i],$b[$i],$carry); }

**SIGNED**.

- •
- "$vec2->Neg($vec1);"

- •
- "$vec2->Abs($vec1);"

- •
- "$sign = $vector->Sign();"

- •
- "$vec3->Multiply($vec1,$vec2);"
**SIGNED**.$msb1 = $vec1->msb(); $msb2 = $vec2->msb(); $vec1->Resize($vec1->Size()+1); $vec2->Resize($vec2->Size()+1); $vec3->Resize($vec3->Size()+1); $vec1->MSB($msb1); $vec2->MSB($msb2); $vec3->Multiply($vec1,$vec2);

- •
- "$quot->Divide($vec1,$vec2,$rest);"

$quot = $vec1 / $vec2; # div

$rest = $vec1 % $vec2; # mod**DISTINCT**bit vectors, or a fatal "result vector(s) must be distinct" error will occur.**SIGNED**.$msb1 = $vec1->msb(); $msb2 = $vec2->msb(); $vec1->Resize($vec1->Size()+1); $vec2->Resize($vec2->Size()+1); $quot->Resize($quot->Size()+1); $rest->Resize($rest->Size()+1); $vec1->MSB($msb1); $vec2->MSB($msb2); $quot->Divide($vec1,$vec2,$rest);

- •
- "$vecgcd->GCD($veca,$vecb);"
int GCD(int a, int b) { int t; while (b != 0) { t = a % b; /* = remainder of (a div b) */ a = b; b = t; } return(a); }

- •
- "$vecgcd->GCD($vecx,$vecy,$veca,$vecb);"
a = 2322 b = 654 GCD( 2322, 654 ) == 6 x = 20 y = -71 20 * 2322 - 71 * 654 == 6

- •
- "$vec3->Power($vec1,$vec2);"
$vec1 * $vec1 * $vec1 * $vec1 * $vec1 * $vec1 * $vec1 * $vec1 * $vec1 * $vec1 * $vec1 * $vec1 * $vec1

$power[0] = $vec1; $power[1] = $vec1 * $vec1; $power[2] = $power[1] * $power[1]; $power[3] = $power[2] * $power[2]; etc.

$result = 1; $result *= $power[0] if ($vec2 & 1); $result *= $power[1] if ($vec2 & 2); $result *= $power[2] if ($vec2 & 4); $result *= $power[3] if ($vec2 & 8); etc.

- •
- "$vector->Block_Store($buffer);"
**MUST**be a string (**NO**automatic conversion from numeric to string is provided here as would normally in Perl!) containing the bit vector in "low order byte first" order.

- •
- "$buffer = $vector->Block_Read();"

- •
- "$size = $vector->Word_Size();"
**MACHINE-DEPENDENT**!**DO NOT USE**these methods unless you are absolutely certain that portability of your code is not an issue!

- •
- "$vector->Word_Store($offset,$word);"

- •
- "$word = $vector->Word_Read($offset);"

- •
- "$vector->Word_List_Store(@words);"
**LEFTMOST**value in the list ("$words[0]") is stored in the**LEAST**significant word of the internal array of words (the one with offset "0"), the next value from the list ("$words[1]") is stored in the word with offset "1", and so on, as intuitively expected.

- •
- "@words = $vector->Word_List_Read();"
**LEFTMOST**value in the returned list ("$words[0]") is the**LEAST**significant word from the given bit vector, and the**RIGHTMOST**value in the returned list ("$words[$#words]") is the**MOST**significant word of the given bit vector.

- •
- "$vector->Word_Insert($offset,$count);"
**NOT**increase the size of the given bit vector, i.e., the bit vector is**NOT**extended at its upper end to "rescue" the "$count" uppermost (most significant) words - instead, these words are lost forever.**EXPLICITLY**and**BEFORE**you perform the "Insert" operation, with a statement such as the following:$vector->Resize($vector->Size() + $count * Bit::Vector->Word_Bits());

- •
- "$vector->Word_Delete($offset,$count);"
**NOT**decrease the size of the given bit vector, i.e., the bit vector is**NOT**clipped at its upper end to "get rid of" the vacant "$count" uppermost words.**EXPLICITLY**and**AFTER**the "Delete" operation, with a couple of statements such as these:$bits = $vector->Size(); $count *= Bit::Vector->Word_Bits(); if ($count > $bits) { $count = $bits; } $vector->Resize($bits - $count);

- •
- "$vector->Chunk_Store($chunksize,$offset,$chunk);"

- •
- "$chunk =
$vector->Chunk_Read($chunksize,$offset);"

- •
- "$vector->Chunk_List_Store($chunksize,@chunks);"
$vector->Chunk_List_Store(3, split(//, reverse $string));

if ($string =~ /^[0-7]+$/) { # okay, go ahead with conversion as shown above } else { # error, string contains other than octal characters }

$pattern = 0xDEADBEEF; $length = 32; # = length of $pattern in bits $size = $vector->Size(); $factor = int($size / $length); if ($size % $length) { $factor++; } $vector->Chunk_List_Store($length, ($pattern) x $factor);

- •
- "@chunks =
$vector->Chunk_List_Read($chunksize);"
**BEWARE**that for large bit vectors and/or small values of "$chunksize", the number of returned list elements can be extremely large!**BE CAREFUL!**$string = reverse join('', $vector->Chunk_List_Read(3));

- •
- "$vector->Index_List_Remove(@indices);"
foreach $index (@indices) { $vector->Bit_Off($index); }

**NOT**clear the given bit vector before processing its list of arguments.

- •
- "$vector->Index_List_Store(@indices);"
foreach $index (@indices) { $vector->Bit_On($index); }

**NOT**clear the given bit vector before processing its list of arguments.

- •
- "@indices = $vector->Index_List_Read();"
**BEWARE**that for large bit vectors, this can result in a literally overwhelming number of list elements!**BE CAREFUL!**You could run out of memory or slow down your application considerably!$limit = 1000; # or whatever $vector = Bit::Vector->new($limit+1); $vector->Primes(); @primes = $vector->Index_List_Read();

- •
- "$vec3->Or($vec1,$vec2);"

- •
- "$vec3->And($vec1,$vec2);"

- •
- "$vec3->AndNot($vec1,$vec2);"

- •
- "$vec3->Xor($vec1,$vec2);"

- •
- "$vec2->Not($vec1);"

- •
- "if ($set1->subset($set2))"

- •
- "$norm = $set->Norm();"

- •
- "$norm = $set->Norm2();"

- •
- "$norm = $set->Norm3();"

- •
- "$min = $set->Min();"

- •
- "$max = $set->Max();"

- •
- "$m3->Multiplication($r3,$c3,$m1,$r1,$c1,$m2,$r2,$c2);"
rows3 == rows1 cols3 == cols2 cols1 == rows2

*Math::MatrixBool*(3) for details.

- •
- "$m3->Product($r3,$c3,$m1,$r1,$c1,$m2,$r2,$c2);"
rows3 == rows1 cols3 == cols2 cols1 == rows2

*Math::MatrixBool*(3) for details.

- •
- "$matrix->Closure($rows,$cols);"
*Math::Kleene*(3) for a brief introduction into the theory behind Kleene's algorithm.)**EDGE**exists between any two vertices of the graph or not, whereas the reflexive transitive closure answers the question whether a**PATH**(a series of adjacent edges) exists between any two vertices of the graph!*Math::MatrixBool*(3) for details.

- •
- "$matrix2->Transpose($rows2,$cols2,$matrix1,$rows1,$cols1);"
rows2 == cols1 cols2 == rows1

*Math::MatrixBool*(3) for details.

Steffen Beyer mailto:STBEY@cpan.org http://www.engelschall.com/u/sb/download/

2017-07-22 | perl v5.26.0 |