Actual source code: btview.c

  1: #include <petscsys.h>

  3: /*@
  4:   PetscBTView - View the contents of a `PetscBT` (bit array) on a `PetscViewer`, one line per bit

  6:   Collective on `viewer`; No Fortran Support

  8:   Input Parameters:
  9: + m      - the number of bits in the array to print
 10: . bt     - the `PetscBT`
 11: - viewer - the `PetscViewer` to print to, or `NULL` to use `PETSC_VIEWER_STDOUT_SELF`

 13:   Level: developer

 15: .seealso: `PetscBT`, `PetscBTCreate()`, `PetscBTLookup()`, `PetscViewer`
 16: @*/
 17: PetscErrorCode PetscBTView(PetscCount m, const PetscBT bt, PetscViewer viewer)
 18: {
 19:   PetscFunctionBegin;
 20:   if (!viewer) PetscCall(PetscViewerASCIIGetStdout(PETSC_COMM_SELF, &viewer));
 21:   PetscCall(PetscViewerASCIIPushSynchronized(viewer));
 22:   for (PetscCount i = 0; i < m; ++i) PetscCall(PetscViewerASCIISynchronizedPrintf(viewer, "%" PetscCount_FMT " %hhu\n", i, PetscBTLookup(bt, i)));
 23:   PetscCall(PetscViewerFlush(viewer));
 24:   PetscCall(PetscViewerASCIIPopSynchronized(viewer));
 25:   PetscFunctionReturn(PETSC_SUCCESS);
 26: }