bool unit_cube(int n, bool expect) { bool ret = isCubes(n); bool r = ret == expect; if (!r) { printf("cube(%d) = %s !!!= %s\n", n, showBool(ret), showBool(expect)); } return r; }
/* Most efficient function ever */ char* showNBodyCtx(const NBodyCtx* ctx) { char* buf; char* potBuf; if (!ctx) return NULL; potBuf = showPotential(&ctx->pot); if (!potBuf) return NULL; if (0 > asprintf(&buf, "ctx = { \n" " eps2 = %f\n" " theta = %f\n" " timestep = %f\n" " timeEvolve = %f\n" " treeRSize = %f\n" " sunGCDist = %f\n" " criterion = %s\n" " useQuad = %s\n" " allowIncest = %s\n" " checkpointT = %d\n" " nStep = %u\n" " potentialType = %s\n" " pot = %s\n" "};\n", ctx->eps2, ctx->theta, ctx->timestep, ctx->timeEvolve, ctx->treeRSize, ctx->sunGCDist, showCriterionT(ctx->criterion), showBool(ctx->useQuad), showBool(ctx->allowIncest), (int) ctx->checkpointT, ctx->nStep, showExternalPotentialType(ctx->potentialType), potBuf )) { mw_fail("asprintf() failed\n"); } free(potBuf); return buf; }
char* showBody(const Body* p) { char* buf; char* vel; char* pos; if (!p) return NULL; vel = showVector(Vel(p)); pos = showVector(Pos(p)); if (0 > asprintf(&buf, "body { \n" " mass = %g\n" " position = %s\n" " velocity = %s\n" " ignore = %s\n" " };\n", Mass(p), pos, vel, showBool(ignoreBody(p)))) { mw_fail("asprintf() failed\n"); } free(vel); free(pos); return buf; }
char* showNBodyState(const NBodyState* st) { char* buf; char* treeBuf; treeBuf = showNBodyTree(&st->tree); if (0 > asprintf(&buf, "NBodyState %p = {\n" " tree = %s\n" " freeCell = %p\n" " lastCheckpoint = %d\n" " step = %u\n" " nbody = %u\n" " bodytab = %p\n" " acctab = %p\n" " treeIncest = %s\n" "};\n", st, treeBuf, st->freeCell, (int) st->lastCheckpoint, st->step, st->nbody, st->bodytab, st->acctab, showBool(st->treeIncest) )) { mw_fail("asprintf() failed\n"); } free(treeBuf); return buf; }