/********************************bit_mask.c************************************ Author: Henry M. Tufo III e-mail: hmt@cs.brown.edu snail-mail: Division of Applied Mathematics Brown University Providence, RI 02912 Last Modification: 11.21.97 *********************************bit_mask.c***********************************/ #include <../src/ksp/pc/impls/tfs/tfs.h> /*********************************bit_mask.c***********************************/ PetscErrorCode PCTFS_bm_to_proc(char *ptr, PetscInt p_mask, PetscInt *msg_list) { PetscInt i, tmp; PetscFunctionBegin; if (msg_list) { /* low to high */ ptr+=(p_mask-1); for (i=p_mask-1;i>=0;i--) { tmp = BYTE*(p_mask-i-1); if (*ptr&BIT_0) { *msg_list = tmp; msg_list++; } if (*ptr&BIT_1) { *msg_list = tmp+1; msg_list++; } if (*ptr&BIT_2) { *msg_list = tmp+2; msg_list++; } if (*ptr&BIT_3) { *msg_list = tmp+3; msg_list++; } if (*ptr&BIT_4) { *msg_list = tmp+4; msg_list++; } if (*ptr&BIT_5) { *msg_list = tmp+5; msg_list++; } if (*ptr&BIT_6) { *msg_list = tmp+6; msg_list++; } if (*ptr&BIT_7) { *msg_list = tmp+7; msg_list++; } ptr--; } } PetscFunctionReturn(0); } /*********************************bit_mask.c***********************************/ PetscInt PCTFS_ct_bits(char *ptr, PetscInt n) { PetscInt i, tmp=0; for (i=0;i=0, denom=%D ! >0",numer,denom); /* if integer division remainder then increment */ rt_val = numer/denom; if (numer%denom) rt_val++; return(rt_val); } /*********************************bit_mask.c***********************************/ PetscInt PCTFS_len_bit_mask(PetscInt num_items) { PetscInt rt_val, tmp; if (num_items<0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Value Sent To PCTFS_len_bit_mask() Must be >= 0!"); /* mod BYTE ceiling function */ rt_val = num_items/BYTE; if (num_items%BYTE) rt_val++; /* make mults of sizeof int */ if ((tmp=rt_val%sizeof(PetscInt))) rt_val+=(sizeof(PetscInt)-tmp); return(rt_val); } /*********************************bit_mask.c***********************************/ PetscErrorCode PCTFS_set_bit_mask(PetscInt *bm, PetscInt len, PetscInt val) { PetscInt i, offset; char mask = 1; char *cptr; PetscFunctionBegin; if (PCTFS_len_bit_mask(val)>len) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"The Bit Mask Isn't That Large!"); cptr = (char*) bm; offset = len/sizeof(PetscInt); for (i=0; i