/usr/lib/petscdir/3.4.2/include/petscbt.h is in libpetsc3.4.2-dev 3.4.2.dfsg1-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | #if !defined(__PETSCBT_H)
#define __PETSCBT_H
#include <petscconf.h>
#include <petscviewer.h>
/*S
PetscBT - PETSc bitarrays
Level: advanced
PetscBTCreate(m,&bt) - creates a bit array with enough room to hold m values
PetscBTDestroy(&bt) - destroys the bit array
PetscBTMemzero(m,bt) - zeros the entire bit array (sets all values to false)
PetscBTSet(bt,index) - sets a particular entry as true
PetscBTClear(bt,index) - sets a particular entry as false
PetscBTLookup(bt,index) - returns the value
PetscBTLookupSet(bt,index) - returns the value and then sets it true
PetscBTLookupClear(bt,index) - returns the value and then sets it false
PetscBTLength(m) - returns number of bytes in array with m bits
PetscBTView(m,bt,viewer) - prints all the entries in a bit array
We do not currently check error flags on PetscBTSet(), PetscBTClear(), PetscBTLookup(),
PetcBTLookupSet(), PetscBTLength() cause error checking would cost hundreds more cycles then
the operation.
S*/
typedef char* PetscBT;
PETSC_STATIC_INLINE PetscInt PetscBTLength(PetscInt m)
{
return ((m)/PETSC_BITS_PER_BYTE+1);
}
PETSC_STATIC_INLINE PetscErrorCode PetscBTMemzero(PetscInt m,PetscBT array)
{
return PetscMemzero(array,sizeof(char)*((m)/PETSC_BITS_PER_BYTE+1));
}
PETSC_STATIC_INLINE PetscErrorCode PetscBTDestroy(PetscBT *array)
{
return PetscFree(*array);
}
PETSC_STATIC_INLINE char PetscBTLookup(PetscBT array,PetscInt index)
{
char BT_mask,BT_c;
PetscInt BT_idx;
return (BT_idx = (index)/PETSC_BITS_PER_BYTE,
BT_c = array[BT_idx],
BT_mask = (char)1 << ((index)%PETSC_BITS_PER_BYTE),
BT_c & BT_mask);
}
PETSC_STATIC_INLINE PetscErrorCode PetscBTView(PetscInt m,const PetscBT bt,PetscViewer viewer)
{
PetscInt i;
PetscErrorCode ierr;
ierr = PetscViewerASCIIGetStdout(PETSC_COMM_SELF,&viewer);CHKERRQ(ierr);
ierr = PetscViewerASCIISynchronizedAllow(viewer,PETSC_TRUE);CHKERRQ(ierr);
for (i=0; i<m; i++) {
ierr = PetscViewerASCIISynchronizedPrintf(viewer,"%D %d\n",i,PetscBTLookup(bt,i));CHKERRQ(ierr);
}
ierr = PetscViewerFlush(viewer);CHKERRQ(ierr);
ierr = PetscViewerASCIISynchronizedAllow(viewer,PETSC_FALSE);CHKERRQ(ierr);
return 0;
}
PETSC_STATIC_INLINE PetscErrorCode PetscBTCreate(PetscInt m,PetscBT *array)
{
return (PetscMalloc(((m)/PETSC_BITS_PER_BYTE+1)*sizeof(char),array) || PetscBTMemzero(m,*array));
}
PETSC_STATIC_INLINE char PetscBTLookupSet(PetscBT array,PetscInt index)
{
char BT_mask,BT_c;
PetscInt BT_idx;
return (BT_idx = (index)/PETSC_BITS_PER_BYTE,
BT_c = array[BT_idx],
BT_mask = (char)1 << ((index)%PETSC_BITS_PER_BYTE),
array[BT_idx] = BT_c | BT_mask,
BT_c & BT_mask);
}
PETSC_STATIC_INLINE PetscErrorCode PetscBTSet(PetscBT array,PetscInt index)
{
char BT_mask,BT_c;
PetscInt BT_idx;
BT_idx = (index)/PETSC_BITS_PER_BYTE;
BT_c = array[BT_idx];
BT_mask = (char)1 << ((index)%PETSC_BITS_PER_BYTE);
array[BT_idx] = BT_c | BT_mask;
return 0;
}
PETSC_STATIC_INLINE char PetscBTLookupClear(PetscBT array,PetscInt index)
{
char BT_mask,BT_c;
PetscInt BT_idx;
return (BT_idx = (index)/PETSC_BITS_PER_BYTE,
BT_c = array[BT_idx],
BT_mask = (char)1 << ((index)%PETSC_BITS_PER_BYTE),
array[BT_idx] = BT_c & (~BT_mask),
BT_c & BT_mask);
}
PETSC_STATIC_INLINE PetscErrorCode PetscBTClear(PetscBT array,PetscInt index)
{
char BT_mask,BT_c;
PetscInt BT_idx;
BT_idx = (index)/PETSC_BITS_PER_BYTE;
BT_c = array[BT_idx];
BT_mask = (char)1 << ((index)%PETSC_BITS_PER_BYTE);
array[BT_idx] = BT_c & (~BT_mask);
return 0;
}
#endif
|