Go to the source code of this file.
#define BITSINLONG 32 |
** (c) Copyright Hewlett-Packard Company, 1988. ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** http://www.apache.org/licenses/LICENSE-2.0 ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License.
Definition at line 25 of file bitvec.h.
Referenced by ReadTempConfig().
#define copy_all_bits | ( | source, | |||
dest, | |||||
length | ) |
Value:
{\ register int index; /*temporary index*/\ \ for (index=0;index<length;index++)\ dest[index]=source[index]; /*copy all bits*/\ }
Definition at line 52 of file bitvec.h.
Referenced by MakeNewTemporaryConfig().
#define reset_bit | ( | array, | |||
bit | ) | (array[bit/BITSINLONG]&=~(1<<(bit&(BITSINLONG-1)))) |
#define set_all_bits | ( | array, | |||
length | ) |
Value:
{\ register int index; /*temporary index*/\ \ for (index=0;index<length;index++)\ array[index]= ~0; /*set all bits*/\ }
Definition at line 44 of file bitvec.h.
Referenced by compare_tess_blobs(), and InitAdaptiveClassifier().
#define SET_BIT | ( | array, | |||
bit | ) | (array[bit/BITSINLONG]|=1<<(bit&(BITSINLONG-1))) |
Definition at line 60 of file bitvec.h.
Referenced by ConvertConfig(), FillPPCircularBits(), FillPPLinearBits(), MakeNewAdaptedClass(), MakeNewTemporaryConfig(), MakeNewTempProtos(), and SplitProto().
#define test_bit | ( | array, | |||
bit | ) | (array[bit/BITSINLONG] & (1<<(bit&(BITSINLONG-1)))) |
Definition at line 64 of file bitvec.h.
Referenced by ClassConfigLength(), ConvertConfig(), MakeTempProtoPerm(), ReadAdaptedClass(), SplitProto(), WriteAdaptedClass(), and WriteOldConfigFile().
#define WordsInVectorOfSize | ( | NumBits | ) | (((NumBits) + BITSINLONG - 1) / BITSINLONG) |
Definition at line 66 of file bitvec.h.
Referenced by AddConfigToClass(), compare_tess_blobs(), config_mask_to_proto_mask(), ExpandBitVector(), InitAdaptiveClassifier(), MakeNewTemporaryConfig(), NewAdaptedClass(), NewBitVector(), NewTempConfig(), ReadAdaptedClass(), ReadConfigs(), SetUpForFloat2Int(), WriteAdaptedClass(), and WriteConfigs().
#define zero_all_bits | ( | array, | |||
length | ) |
Value:
{\ register int index; /*temporary index*/\ \ for (index=0;index<length;index++)\ array[index]=0; /*zero all bits*/\ }
Definition at line 36 of file bitvec.h.
Referenced by AddConfigToClass(), config_mask_to_proto_mask(), InitAdaptiveClassifier(), MakeNewTemporaryConfig(), NewAdaptedClass(), and NewTempConfig().
BIT_VECTOR ExpandBitVector | ( | BIT_VECTOR | Vector, | |
int | NewNumBits | |||
) |
Uses realloc to increase the size of the specified bit vector.
Vector | Bit vector to be expanded | |
NewNumBits | New size of bit vector |
Definition at line 48 of file bitvec.cpp.
References Erealloc(), and WordsInVectorOfSize.
Referenced by AddProtoToClass().
00048 { 00049 return ((BIT_VECTOR) Erealloc (Vector, 00050 sizeof (unsigned long) * 00051 WordsInVectorOfSize (NewNumBits))); 00052 00053 } /* ExpandBitVector */
void FreeBitVector | ( | BIT_VECTOR | BitVector | ) |
Frees a bit vector & decrements the global counter that keeps track of the number of bit vectors allocated.
BitVector | Bit vector to be freed |
Definition at line 69 of file bitvec.cpp.
References BitVectorCount, cprintf(), and memfree().
Referenced by compare_tess_blobs(), EndAdaptiveClassifier(), free_adapted_class(), FreeClassFields(), and FreeTempConfig().
00069 { 00070 if (BitVector) { 00071 memfree(BitVector); 00072 BitVectorCount--; 00073 } 00074 else { 00075 cprintf ("%6d BITVECTOR elements in use\n", BitVectorCount); 00076 } 00077 00078 } /* FreeBitVector */
int hamming_distance | ( | register unsigned long * | array1, | |
register unsigned long * | array2, | |||
register int | length | |||
) |
Computes the hamming distance between two bit strings.
array1 | First array to compare | |
array2 | Second array to compare | |
length | Length of arrays |
Definition at line 90 of file bitvec.cpp.
Referenced by delete_search().
00093 { 00094 register unsigned long diff; /*bit difference */ 00095 register int dist; /*total distance */ 00096 00097 dist = 0; 00098 for (; length > 0; length--) { 00099 diff = *array1++ ^ *array2++;/*different bits */ 00100 while (diff) { 00101 diff &= diff - 1; /*lose a bit */ 00102 dist++; 00103 } 00104 } 00105 return dist; /*total distance */ 00106 }
BIT_VECTOR NewBitVector | ( | int | NumBits | ) |
Allocate and return a new bit vector large enough to hold the specified number of bits.
NumBits | Number of bits in new bit vector |
Definition at line 120 of file bitvec.cpp.
References BitVectorCount, Emalloc(), and WordsInVectorOfSize.
Referenced by AddConfigToClass(), compare_tess_blobs(), InitAdaptiveClassifier(), NewAdaptedClass(), NewTempConfig(), ReadAdaptedClass(), ReadConfigs(), ReadTempConfig(), and SetUpForFloat2Int().
00120 { 00121 BitVectorCount++; 00122 return ((BIT_VECTOR) Emalloc (sizeof (unsigned long) * 00123 WordsInVectorOfSize (NumBits))); 00124 00125 } /* NewBitVector */