xref: /petsc/include/petscbt.h (revision 19fee000dbee7edc54005b99cf44305ad2fe3fbf)
1*19fee000SSatish Balay /*
2*19fee000SSatish Balay       BT_LOOKUP - Expexts a charecter array -'array' as input, and
3*19fee000SSatish Balay       treats it as  an array of bits. It Checks if a given bit location
4*19fee000SSatish Balay       ( specified by 'index') is marked, and later marks that location.
5*19fee000SSatish Balay 
6*19fee000SSatish Balay       Input:
7*19fee000SSatish Balay       array  - an array of char. Initially all bits are to be set to zero
8*19fee000SSatish Balay                by using PetscMemzero().
9*19fee000SSatish Balay       index  - specifies the index of the required bit in the bit array.
10*19fee000SSatish Balay 
11*19fee000SSatish Balay       Output:
12*19fee000SSatish Balay       return val - 0 if the bit is not found,
13*19fee000SSatish Balay                  - nonzero if found.
14*19fee000SSatish Balay 
15*19fee000SSatish Balay       Usage :
16*19fee000SSatish Balay       BT_LOOKUP(char * array,  int index) ;
17*19fee000SSatish Balay 
18*19fee000SSatish Balay       Summary:
19*19fee000SSatish Balay           The bit operations are euivalent to:
20*19fee000SSatish Balay               1: retval = array[idx];
21*19fee000SSatish Balay               2: array[index] = 1;
22*19fee000SSatish Balay               3: return retval;
23*19fee000SSatish Balay */
24*19fee000SSatish Balay 
25*19fee000SSatish Balay static char _mask, _BT_c;
26*19fee000SSatish Balay static int  _BT_idx;
27*19fee000SSatish Balay #define BT_LOOKUP( array,  index) (_BT_idx         = index/8, \
28*19fee000SSatish Balay                                    _BT_c           = array[_BT_idx], \
29*19fee000SSatish Balay                                    _BT_idx         = index/8, \
30*19fee000SSatish Balay                                    _mask           = (char)1 << (index%8), \
31*19fee000SSatish Balay                                    array[_BT_idx]  = _BT_c|_mask, \
32*19fee000SSatish Balay                                    _BT_c & _mask )
33*19fee000SSatish Balay 
34*19fee000SSatish Balay 
35