|
From: <kin...@us...> - 2023-07-15 21:57:29
|
Revision: 7115
http://sourceforge.net/p/teem/code/7115
Author: kindlmann
Date: 2023-07-15 21:57:26 +0000 (Sat, 15 Jul 2023)
Log Message:
-----------
using new AIR_SIZE_T (and some overdue clang-format)
Modified Paths:
--------------
teem/trunk/src/nrrd/apply1D.c
teem/trunk/src/nrrd/cc.c
teem/trunk/src/nrrd/ccmethods.c
teem/trunk/src/nrrd/deringNrrd.c
teem/trunk/src/nrrd/encodingGzip.c
teem/trunk/src/nrrd/formatPNM.c
teem/trunk/src/nrrd/formatVTK.c
teem/trunk/src/nrrd/histogram.c
teem/trunk/src/nrrd/map.c
teem/trunk/src/nrrd/methodsNrrd.c
teem/trunk/src/nrrd/resampleContext.c
teem/trunk/src/nrrd/subset.c
teem/trunk/src/nrrd/test/ax.c
teem/trunk/src/nrrd/test/genvol.c
teem/trunk/src/nrrd/test/histrad.c
teem/trunk/src/nrrd/test/phrnd.c
teem/trunk/src/nrrd/test/quadvol.c
teem/trunk/src/nrrd/test/texp.c
teem/trunk/src/nrrd/test/trand.c
Modified: teem/trunk/src/nrrd/apply1D.c
===================================================================
--- teem/trunk/src/nrrd/apply1D.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/apply1D.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -830,8 +830,7 @@
airSprintSize_t(stmp, aclLen));
return 1;
}
- if (nrrdMaybeAlloc_va(nacl, nrrdTypeUShort, 2, AIR_CAST(size_t, 2),
- AIR_CAST(size_t, aclLen))) {
+ if (nrrdMaybeAlloc_va(nacl, nrrdTypeUShort, 2, AIR_SIZE_T(2), AIR_SIZE_T(aclLen))) {
biffAddf(NRRD, "%s: ", me);
return 1;
}
Modified: teem/trunk/src/nrrd/cc.c
===================================================================
--- teem/trunk/src/nrrd/cc.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/cc.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -374,7 +374,7 @@
if (!(*nvalP)) {
*nvalP = nrrdNew();
}
- if (nrrdMaybeAlloc_va(*nvalP, nin->type, 1, AIR_CAST(size_t, numsettleid))) {
+ if (nrrdMaybeAlloc_va(*nvalP, nin->type, 1, AIR_SIZE_T(numsettleid))) {
biffAddf(NRRD, "%s: couldn't allocate output value list", me);
airMopError(mop);
return 1;
@@ -561,8 +561,8 @@
return 1;
}
maxid = nrrdCCMax(nin);
- if (nrrdMaybeAlloc_va(nout, nrrdTypeUChar, 2, AIR_CAST(size_t, maxid + 1),
- AIR_CAST(size_t, maxid + 1))) {
+ if (nrrdMaybeAlloc_va(nout, nrrdTypeUChar, 2, AIR_SIZE_T(maxid + 1),
+ AIR_SIZE_T(maxid + 1))) {
biffAddf(NRRD, "%s: trouble allocating output", me);
return 1;
}
@@ -858,7 +858,7 @@
if (!(*nvalP)) {
*nvalP = nrrdNew();
}
- if (nrrdMaybeAlloc_va(*nvalP, nin->type, 1, AIR_CAST(size_t, numid))) {
+ if (nrrdMaybeAlloc_va(*nvalP, nin->type, 1, AIR_SIZE_T(numid))) {
biffAddf(NRRD, "%s: couldn't allocate output value list", me);
airMopError(mop);
return 1;
Modified: teem/trunk/src/nrrd/ccmethods.c
===================================================================
--- teem/trunk/src/nrrd/ccmethods.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/ccmethods.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -64,7 +64,7 @@
return 1;
}
maxid = nrrdCCMax(nin);
- if (nrrdMaybeAlloc_va(nout, nrrdTypeUInt, 1, AIR_CAST(size_t, maxid + 1))) {
+ if (nrrdMaybeAlloc_va(nout, nrrdTypeUInt, 1, AIR_SIZE_T(maxid + 1))) {
biffAddf(NRRD, "%s: can't allocate output", me);
return 1;
}
Modified: teem/trunk/src/nrrd/deringNrrd.c
===================================================================
--- teem/trunk/src/nrrd/deringNrrd.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/deringNrrd.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -381,11 +381,10 @@
for (pi = 0; pi < PTXF_NUM; pi++) {
if (drc->verticalSeam && (CROP == pi || CBLR == pi)) {
E = nrrdMaybeAlloc_va(dbg->nptxf[pi], nrrdTypeDouble, 3, dbg->radNum,
- AIR_CAST(size_t, drc->thetaNum / 2 - 1),
- AIR_CAST(size_t, 2));
+ AIR_SIZE_T(drc->thetaNum / 2 - 1), AIR_SIZE_T(2));
} else {
E = nrrdMaybeAlloc_va(dbg->nptxf[pi], nrrdTypeDouble, 2, dbg->radNum,
- AIR_CAST(size_t, drc->thetaNum));
+ AIR_SIZE_T(drc->thetaNum));
}
if (E) {
biffAddf(NRRD, "%s: polar transform allocation problem", me);
@@ -655,7 +654,7 @@
airMopAdd(mop, ntmp[1], (airMopper)nrrdNuke, airMopAlways);
if (nrrdReshape_va(ntmp[0], dbg->nptxf[RING], 2,
(dbg->nptxf[RING]->axis[0].size * dbg->nptxf[RING]->axis[1].size),
- AIR_CAST(size_t, 1))
+ AIR_SIZE_T(1))
|| nrrdProject(ntmp[1], ntmp[0], 0, nrrdMeasureL2, nrrdTypeDouble)) {
biffAddf(NRRD, "%s: trouble", me);
airMopError(mop);
Modified: teem/trunk/src/nrrd/encodingGzip.c
===================================================================
--- teem/trunk/src/nrrd/encodingGzip.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/encodingGzip.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -127,10 +127,10 @@
}
/* backwards is (positive) number of bytes AFTER data that we ignore */
backwards = -nio->byteSkip - 1;
- if (sizeRed < sizeData + AIR_CAST(size_t, backwards)) {
+ if (sizeRed < sizeData + AIR_SIZE_T(backwards)) {
char stmp[2][AIR_STRLEN_SMALL + 1];
biffAddf(NRRD, "%s: expected %s bytes but received only %s", me,
- airSprintSize_t(stmp[0], sizeData + AIR_CAST(size_t, backwards)),
+ airSprintSize_t(stmp[0], sizeData + AIR_SIZE_T(backwards)),
airSprintSize_t(stmp[1], sizeRed));
return 1;
}
Modified: teem/trunk/src/nrrd/formatPNM.c
===================================================================
--- teem/trunk/src/nrrd/formatPNM.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/formatPNM.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -163,8 +163,8 @@
goto plain;
}
/* else this PNM comment is trying to tell us something */
- nio->pos = AIR_CAST(int, strlen(NRRD_PNM_COMMENT));
- nio->pos += AIR_CAST(int, strspn(nio->line + nio->pos, _nrrdFieldSep));
+ nio->pos = AIR_INT(strlen(NRRD_PNM_COMMENT));
+ nio->pos += AIR_INT(strspn(nio->line + nio->pos, _nrrdFieldSep));
ret = _nrrdReadNrrdParseField(nio, AIR_FALSE);
if (!ret) {
if (1 <= nrrdStateVerboseIO) {
@@ -249,11 +249,10 @@
/* we know what we need in order to set nrrd fields and read data */
if (color) {
- nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSize, AIR_CAST(size_t, 3), AIR_CAST(size_t, sx),
- AIR_CAST(size_t, sy));
+ nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSize, AIR_SIZE_T(3), AIR_SIZE_T(sx),
+ AIR_SIZE_T(sy));
} else {
- nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSize, AIR_CAST(size_t, sx),
- AIR_CAST(size_t, sy));
+ nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSize, AIR_SIZE_T(sx), AIR_SIZE_T(sy));
}
if (!nio->skipData) {
if (_nrrdCalloc(nrrd, nio, file)) {
Modified: teem/trunk/src/nrrd/formatVTK.c
===================================================================
--- teem/trunk/src/nrrd/formatVTK.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/formatVTK.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -220,21 +220,21 @@
return 1;
}
nrrd->dim = 3;
- nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSize, AIR_CAST(size_t, sx),
- AIR_CAST(size_t, sy), AIR_CAST(size_t, sz));
+ nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSize, AIR_SIZE_T(sx), AIR_SIZE_T(sy),
+ AIR_SIZE_T(sz));
nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSpacing, xs, ys, zs);
nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoMin, xm, ym, zm);
} else if (!strncmp("VECTORS", three[0], strlen("VECTORS"))) {
nrrd->dim = 4;
- nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSize, AIR_CAST(size_t, 3), AIR_CAST(size_t, sx),
- AIR_CAST(size_t, sy), AIR_CAST(size_t, sz));
+ nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSize, AIR_SIZE_T(3), AIR_SIZE_T(sx),
+ AIR_SIZE_T(sy), AIR_SIZE_T(sz));
nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSpacing, AIR_NAN, xs, ys, zs);
nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoMin, AIR_NAN, xm, ym, zm);
nrrd->axis[0].kind = nrrdKind3Vector;
} else if (!strncmp("TENSORS", three[0], strlen("TENSORS"))) {
nrrd->dim = 4;
- nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSize, AIR_CAST(size_t, 9), AIR_CAST(size_t, sx),
- AIR_CAST(size_t, sy), AIR_CAST(size_t, sz));
+ nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSize, AIR_SIZE_T(9), AIR_SIZE_T(sx),
+ AIR_SIZE_T(sy), AIR_SIZE_T(sz));
nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSpacing, AIR_NAN, xs, ys, zs);
nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoMin, AIR_NAN, xm, ym, zm);
nrrd->axis[0].kind = nrrdKind3DMatrix;
Modified: teem/trunk/src/nrrd/histogram.c
===================================================================
--- teem/trunk/src/nrrd/histogram.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/histogram.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -293,7 +293,7 @@
if (!E) E |= nrrdCommentAdd(nout, cmt);
sprintf(cmt, "max hits: %g, in bin %s, around value %g\n", maxhits,
airSprintSize_t(stmp, maxhitidx),
- nrrdAxisInfoPos(nout, 0, AIR_CAST(double, maxhitidx)));
+ nrrdAxisInfoPos(nout, 0, AIR_DOUBLE(maxhitidx)));
if (!E) E |= nrrdCommentAdd(nout, cmt);
if (!E) E |= nrrdContentSet_va(nout, func, nin, "%s", airSprintSize_t(stmp, sy));
if (E) {
@@ -600,9 +600,8 @@
break;
}
}
- coord[ai] = AIR_CAST(size_t,
- airIndexClampULL(range[ai]->min, val, range[ai]->max,
- bins[ai]));
+ coord[ai] = AIR_SIZE_T(airIndexClampULL(range[ai]->min, val, range[ai]->max,
+ bins[ai]));
}
if (skip) {
continue;
Modified: teem/trunk/src/nrrd/map.c
===================================================================
--- teem/trunk/src/nrrd/map.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/map.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -663,7 +663,7 @@
/* for "smart" mode, we have to some extra work while creating the
histogram to look for bins incessantly hit with the exact same
value */
- if (nrrdMaybeAlloc_va(nhist = nrrdNew(), nrrdTypeUInt, 1, AIR_CAST(size_t, bins))) {
+ if (nrrdMaybeAlloc_va(nhist = nrrdNew(), nrrdTypeUInt, 1, AIR_SIZE_T(bins))) {
biffAddf(NRRD, "%s: failed to allocate histogram", me);
airMopError(mop);
return 1;
@@ -722,8 +722,7 @@
/* printf("%s: disrespecting bin %d\n", me, steady[1+2*bii]); */
}
}
- if (nrrdMaybeAlloc_va(nmap = nrrdNew(), nrrdTypeDouble, 1,
- AIR_CAST(size_t, bins + 1))) {
+ if (nrrdMaybeAlloc_va(nmap = nrrdNew(), nrrdTypeDouble, 1, AIR_SIZE_T(bins + 1))) {
biffAddf(NRRD, "%s: failed to create map nrrd", me);
airMopError(mop);
return 1;
Modified: teem/trunk/src/nrrd/methodsNrrd.c
===================================================================
--- teem/trunk/src/nrrd/methodsNrrd.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/methodsNrrd.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -1381,7 +1381,7 @@
static const char me[] = "nrrdPPM";
char stmp[2][AIR_STRLEN_SMALL + 1];
- if (nrrdMaybeAlloc_va(ppm, nrrdTypeUChar, 3, AIR_CAST(size_t, 3), sx, sy)) {
+ if (nrrdMaybeAlloc_va(ppm, nrrdTypeUChar, 3, AIR_SIZE_T(3), sx, sy)) {
biffAddf(NRRD, "%s: couldn't allocate %s x %s 24-bit image", me,
airSprintSize_t(stmp[0], sx), airSprintSize_t(stmp[1], sy));
return 1;
Modified: teem/trunk/src/nrrd/resampleContext.c
===================================================================
--- teem/trunk/src/nrrd/resampleContext.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/resampleContext.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -119,7 +119,7 @@
axis->axIdx = axIdx; /* never changes */
axis->passIdx = AIR_UINT(-1);
for (axJdx = 0; axJdx < NRRD_DIM_MAX; axJdx++) {
- axis->sizePerm[axJdx] = AIR_CAST(size_t, -1);
+ axis->sizePerm[axJdx] = AIR_SIZE_T(-1);
axis->axisPerm[axJdx] = AIR_UINT(-1);
}
axis->ratio = AIR_NAN;
@@ -598,7 +598,7 @@
nrrdEmpty(axis->nline);
} else {
if (nrrdMaybeAlloc_va(axis->nline, nrrdResample_nt, 1,
- AIR_CAST(size_t, 1 + axis->sizeIn))) {
+ AIR_SIZE_T(1 + axis->sizeIn))) {
biffAddf(NRRD, "%s: couldn't allocate scanline buffer", me);
return 1;
}
@@ -662,10 +662,10 @@
/* some kernels can report zero support when they're basically
delta functions */
dotLen = AIR_MAX(2, dotLen);
- if (nrrdMaybeAlloc_va(axis->nweight, nrrdResample_nt, 2, AIR_CAST(size_t, dotLen),
- AIR_CAST(size_t, axis->samples))
- || nrrdMaybeAlloc_va(axis->nindex, nrrdTypeInt, 2, AIR_CAST(size_t, dotLen),
- AIR_CAST(size_t, axis->samples))) {
+ if (nrrdMaybeAlloc_va(axis->nweight, nrrdResample_nt, 2, AIR_SIZE_T(dotLen),
+ AIR_SIZE_T(axis->samples))
+ || nrrdMaybeAlloc_va(axis->nindex, nrrdTypeInt, 2, AIR_SIZE_T(dotLen),
+ AIR_SIZE_T(axis->samples))) {
biffAddf(NRRD, "%s: trouble allocating index and weighting vectors", me);
return 1;
}
Modified: teem/trunk/src/nrrd/subset.c
===================================================================
--- teem/trunk/src/nrrd/subset.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/subset.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -778,7 +778,7 @@
*/
/* adjust based on offset */
if (offset > 0) {
- if (min[axi] < AIR_CAST(size_t, offset)) {
+ if (min[axi] < AIR_SIZE_T(offset)) {
/* desired outwards offset is more than cropping set */
min[axi] = 0;
} else {
Modified: teem/trunk/src/nrrd/test/ax.c
===================================================================
--- teem/trunk/src/nrrd/test/ax.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/test/ax.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -19,11 +19,11 @@
Fifth Floor, Boston, MA 02110-1301 USA
*/
-
#include <stdlib.h>
#include "../nrrd.h"
-float frand(float min, float max) {
+float
+frand(float min, float max) {
return AIR_FLOAT(min + airDrandMT() * (max - min));
}
@@ -35,9 +35,7 @@
AIR_UNUSED(argc);
AIR_UNUSED(argv);
- if (nrrdAlloc_va(nrrd=nrrdNew(), nrrdTypeFloat, 2,
- AIR_CAST(size_t, 4),
- AIR_CAST(size_t, 4))) {
+ if (nrrdAlloc_va(nrrd = nrrdNew(), nrrdTypeFloat, 2, AIR_SIZE_T(4), AIR_SIZE_T(4))) {
printf("trouble:\n%s\n", biffGet(NRRD));
exit(1);
}
@@ -48,62 +46,59 @@
idx = 0;
printf("\n");
pos = nrrdAxisInfoPos(nrrd, 0, idx);
- printf("pos(0, %g) == %g --> %g\n",
- idx, pos, nrrdAxisInfoIdx(nrrd, 0, pos));
+ printf("pos(0, %g) == %g --> %g\n", idx, pos, nrrdAxisInfoIdx(nrrd, 0, pos));
pos = nrrdAxisInfoPos(nrrd, 1, idx);
- printf("pos(1, %g) == %g --> %g\n",
- idx, pos, nrrdAxisInfoIdx(nrrd, 1, pos));
+ printf("pos(1, %g) == %g --> %g\n", idx, pos, nrrdAxisInfoIdx(nrrd, 1, pos));
idx = 1;
printf("\n");
pos = nrrdAxisInfoPos(nrrd, 0, idx);
- printf("pos(0, %g) == %g --> %g\n",
- idx, pos, nrrdAxisInfoIdx(nrrd, 0, pos));
+ printf("pos(0, %g) == %g --> %g\n", idx, pos, nrrdAxisInfoIdx(nrrd, 0, pos));
pos = nrrdAxisInfoPos(nrrd, 1, idx);
- printf("pos(1, %g) == %g --> %g\n",
- idx, pos, nrrdAxisInfoIdx(nrrd, 1, pos));
+ printf("pos(1, %g) == %g --> %g\n", idx, pos, nrrdAxisInfoIdx(nrrd, 1, pos));
idx = 2;
printf("\n");
pos = nrrdAxisInfoPos(nrrd, 0, idx);
- printf("pos(0, %g) == %g --> %g\n",
- idx, pos, nrrdAxisInfoIdx(nrrd, 0, pos));
+ printf("pos(0, %g) == %g --> %g\n", idx, pos, nrrdAxisInfoIdx(nrrd, 0, pos));
pos = nrrdAxisInfoPos(nrrd, 1, idx);
- printf("pos(1, %g) == %g --> %g\n",
- idx, pos, nrrdAxisInfoIdx(nrrd, 1, pos));
+ printf("pos(1, %g) == %g --> %g\n", idx, pos, nrrdAxisInfoIdx(nrrd, 1, pos));
- idx = 0; idx2 = 0;
+ idx = 0;
+ idx2 = 0;
printf("\n");
nrrdAxisInfoPosRange(&lo, &hi, nrrd, 0, idx, idx2);
nrrdAxisInfoIdxRange(&idx3, &idx4, nrrd, 0, lo, hi);
- printf("range(0, %g -- %g) == (%g -- %g) --> (%g -- %g)\n",
- idx, idx2, lo, hi, idx3, idx4);
+ printf("range(0, %g -- %g) == (%g -- %g) --> (%g -- %g)\n", idx, idx2, lo, hi, idx3,
+ idx4);
nrrdAxisInfoPosRange(&lo, &hi, nrrd, 1, idx, idx2);
nrrdAxisInfoIdxRange(&idx3, &idx4, nrrd, 1, lo, hi);
- printf("range(1, %g -- %g) == (%g -- %g) --> (%g -- %g)\n",
- idx, idx2, lo, hi, idx3, idx4);
+ printf("range(1, %g -- %g) == (%g -- %g) --> (%g -- %g)\n", idx, idx2, lo, hi, idx3,
+ idx4);
- idx = 0; idx2 = 1;
+ idx = 0;
+ idx2 = 1;
printf("\n");
nrrdAxisInfoPosRange(&lo, &hi, nrrd, 0, idx, idx2);
nrrdAxisInfoIdxRange(&idx3, &idx4, nrrd, 0, lo, hi);
- printf("range(0, %g -- %g) == (%g -- %g) --> (%g -- %g)\n",
- idx, idx2, lo, hi, idx3, idx4);
+ printf("range(0, %g -- %g) == (%g -- %g) --> (%g -- %g)\n", idx, idx2, lo, hi, idx3,
+ idx4);
nrrdAxisInfoPosRange(&lo, &hi, nrrd, 1, idx, idx2);
nrrdAxisInfoIdxRange(&idx3, &idx4, nrrd, 1, lo, hi);
- printf("range(1, %g -- %g) == (%g -- %g) --> (%g -- %g)\n",
- idx, idx2, lo, hi, idx3, idx4);
+ printf("range(1, %g -- %g) == (%g -- %g) --> (%g -- %g)\n", idx, idx2, lo, hi, idx3,
+ idx4);
- idx = 1; idx2 = 0;
+ idx = 1;
+ idx2 = 0;
printf("\n");
nrrdAxisInfoPosRange(&lo, &hi, nrrd, 0, idx, idx2);
nrrdAxisInfoIdxRange(&idx3, &idx4, nrrd, 0, lo, hi);
- printf("range(0, %g -- %g) == (%g -- %g) --> (%g -- %g)\n",
- idx, idx2, lo, hi, idx3, idx4);
+ printf("range(0, %g -- %g) == (%g -- %g) --> (%g -- %g)\n", idx, idx2, lo, hi, idx3,
+ idx4);
nrrdAxisInfoPosRange(&lo, &hi, nrrd, 1, idx, idx2);
nrrdAxisInfoIdxRange(&idx3, &idx4, nrrd, 1, lo, hi);
- printf("range(1, %g -- %g) == (%g -- %g) --> (%g -- %g)\n",
- idx, idx2, lo, hi, idx3, idx4);
+ printf("range(1, %g -- %g) == (%g -- %g) --> (%g -- %g)\n", idx, idx2, lo, hi, idx3,
+ idx4);
nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoMin, 12.0, 12.0);
nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoMax, 10.0, 10.0);
@@ -112,62 +107,59 @@
idx = 0;
printf("\n");
pos = nrrdAxisInfoPos(nrrd, 0, idx);
- printf("pos(0, %g) == %g --> %g\n",
- idx, pos, nrrdAxisInfoIdx(nrrd, 0, pos));
+ printf("pos(0, %g) == %g --> %g\n", idx, pos, nrrdAxisInfoIdx(nrrd, 0, pos));
pos = nrrdAxisInfoPos(nrrd, 1, idx);
- printf("pos(1, %g) == %g --> %g\n",
- idx, pos, nrrdAxisInfoIdx(nrrd, 1, pos));
+ printf("pos(1, %g) == %g --> %g\n", idx, pos, nrrdAxisInfoIdx(nrrd, 1, pos));
idx = 1;
printf("\n");
pos = nrrdAxisInfoPos(nrrd, 0, idx);
- printf("pos(0, %g) == %g --> %g\n",
- idx, pos, nrrdAxisInfoIdx(nrrd, 0, pos));
+ printf("pos(0, %g) == %g --> %g\n", idx, pos, nrrdAxisInfoIdx(nrrd, 0, pos));
pos = nrrdAxisInfoPos(nrrd, 1, idx);
- printf("pos(1, %g) == %g --> %g\n",
- idx, pos, nrrdAxisInfoIdx(nrrd, 1, pos));
+ printf("pos(1, %g) == %g --> %g\n", idx, pos, nrrdAxisInfoIdx(nrrd, 1, pos));
idx = 2;
printf("\n");
pos = nrrdAxisInfoPos(nrrd, 0, idx);
- printf("pos(0, %g) == %g --> %g\n",
- idx, pos, nrrdAxisInfoIdx(nrrd, 0, pos));
+ printf("pos(0, %g) == %g --> %g\n", idx, pos, nrrdAxisInfoIdx(nrrd, 0, pos));
pos = nrrdAxisInfoPos(nrrd, 1, idx);
- printf("pos(1, %g) == %g --> %g\n",
- idx, pos, nrrdAxisInfoIdx(nrrd, 1, pos));
+ printf("pos(1, %g) == %g --> %g\n", idx, pos, nrrdAxisInfoIdx(nrrd, 1, pos));
- idx = 0; idx2 = 0;
+ idx = 0;
+ idx2 = 0;
printf("\n");
nrrdAxisInfoPosRange(&lo, &hi, nrrd, 0, idx, idx2);
nrrdAxisInfoIdxRange(&idx3, &idx4, nrrd, 0, lo, hi);
- printf("range(0, %g -- %g) == (%g -- %g) --> (%g -- %g)\n",
- idx, idx2, lo, hi, idx3, idx4);
+ printf("range(0, %g -- %g) == (%g -- %g) --> (%g -- %g)\n", idx, idx2, lo, hi, idx3,
+ idx4);
nrrdAxisInfoPosRange(&lo, &hi, nrrd, 1, idx, idx2);
nrrdAxisInfoIdxRange(&idx3, &idx4, nrrd, 1, lo, hi);
- printf("range(1, %g -- %g) == (%g -- %g) --> (%g -- %g)\n",
- idx, idx2, lo, hi, idx3, idx4);
+ printf("range(1, %g -- %g) == (%g -- %g) --> (%g -- %g)\n", idx, idx2, lo, hi, idx3,
+ idx4);
- idx = 0; idx2 = 2;
+ idx = 0;
+ idx2 = 2;
printf("\n");
nrrdAxisInfoPosRange(&lo, &hi, nrrd, 0, idx, idx2);
nrrdAxisInfoIdxRange(&idx3, &idx4, nrrd, 0, lo, hi);
- printf("range(0, %g -- %g) == (%g -- %g) --> (%g -- %g)\n",
- idx, idx2, lo, hi, idx3, idx4);
+ printf("range(0, %g -- %g) == (%g -- %g) --> (%g -- %g)\n", idx, idx2, lo, hi, idx3,
+ idx4);
nrrdAxisInfoPosRange(&lo, &hi, nrrd, 1, idx, idx2);
nrrdAxisInfoIdxRange(&idx3, &idx4, nrrd, 1, lo, hi);
- printf("range(1, %g -- %g) == (%g -- %g) --> (%g -- %g)\n",
- idx, idx2, lo, hi, idx3, idx4);
+ printf("range(1, %g -- %g) == (%g -- %g) --> (%g -- %g)\n", idx, idx2, lo, hi, idx3,
+ idx4);
- idx = 2; idx2 = 0;
+ idx = 2;
+ idx2 = 0;
printf("\n");
nrrdAxisInfoPosRange(&lo, &hi, nrrd, 0, idx, idx2);
nrrdAxisInfoIdxRange(&idx3, &idx4, nrrd, 0, lo, hi);
- printf("range(0, %g -- %g) == (%g -- %g) --> (%g -- %g)\n",
- idx, idx2, lo, hi, idx3, idx4);
+ printf("range(0, %g -- %g) == (%g -- %g) --> (%g -- %g)\n", idx, idx2, lo, hi, idx3,
+ idx4);
nrrdAxisInfoPosRange(&lo, &hi, nrrd, 1, idx, idx2);
nrrdAxisInfoIdxRange(&idx3, &idx4, nrrd, 1, lo, hi);
- printf("range(1, %g -- %g) == (%g -- %g) --> (%g -- %g)\n",
- idx, idx2, lo, hi, idx3, idx4);
+ printf("range(1, %g -- %g) == (%g -- %g) --> (%g -- %g)\n", idx, idx2, lo, hi, idx3,
+ idx4);
nrrd->axis[0].center = nrrdCenterCell;
nrrd->axis[0].size = 4;
@@ -183,22 +175,27 @@
printf("pos3, pos4 = %g, %g\n", pos3, pos4);
exit(1);
-
/* and now for random-ness */
airSrandMT((int)airTime());
nrrd->axis[0].center = nrrdCenterNode;
nrrd->axis[0].center = nrrdCenterCell;
- for (i=0; i<=1000000; i++) {
+ for (i = 0; i <= 1000000; i++) {
nrrd->axis[0].min = frand(-3.0, 3.0);
nrrd->axis[0].max = frand(-3.0, 3.0);
idx = frand(-3.0, 3.0);
pos = nrrdAxisInfoPos(nrrd, 0, idx);
diff = idx - nrrdAxisInfoIdx(nrrd, 0, pos);
- if (AIR_ABS(diff) > 0.00000001) { printf("PANIC 0\n"); exit(2); }
+ if (AIR_ABS(diff) > 0.00000001) {
+ printf("PANIC 0\n");
+ exit(2);
+ }
pos = frand(-3.0, 3.0);
idx = nrrdAxisInfoIdx(nrrd, 0, pos);
diff = pos - nrrdAxisInfoPos(nrrd, 0, idx);
- if (AIR_ABS(diff) > 0.00000001) { printf("PANIC 1\n"); exit(2); }
+ if (AIR_ABS(diff) > 0.00000001) {
+ printf("PANIC 1\n");
+ exit(2);
+ }
nrrd->axis[0].min = (int)frand(-3.0, 3.0);
nrrd->axis[0].max = (int)frand(-3.0, 3.0);
@@ -207,7 +204,10 @@
nrrdAxisInfoPosRange(&pos, &pos2, nrrd, 0, idx, idx2);
nrrdAxisInfoIdxRange(&idx3, &idx4, nrrd, 0, pos, pos2);
diff = AIR_ABS(idx - idx3) + AIR_ABS(idx2 - idx4);
- if (AIR_ABS(diff) > 0.00000001) { printf("PANIC 2\n"); exit(2); }
+ if (AIR_ABS(diff) > 0.00000001) {
+ printf("PANIC 2\n");
+ exit(2);
+ }
pos = (int)frand(-3.0, 3.0);
pos2 = (int)frand(-3.0, 3.0);
nrrdAxisInfoIdxRange(&idx, &idx2, nrrd, 0, pos, pos2);
@@ -218,7 +218,8 @@
printf("pos, pos2 = %g, %g\n", pos, pos2);
printf("idx, idx2 = %g, %g\n", idx, idx2);
printf("pos3, pos4 = %g, %g\n", pos3, pos4);
- printf("PANIC (%d) 3 %g\n", (int)nrrd->axis[0].size, diff); exit(2);
+ printf("PANIC (%d) 3 %g\n", (int)nrrd->axis[0].size, diff);
+ exit(2);
}
}
Modified: teem/trunk/src/nrrd/test/genvol.c
===================================================================
--- teem/trunk/src/nrrd/test/genvol.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/test/genvol.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -27,37 +27,33 @@
double
rho(double r) {
- return cos(2*AIR_PI*6.0*cos(AIR_PI*r/2));
+ return cos(2 * AIR_PI * 6.0 * cos(AIR_PI * r / 2));
}
double
genvolFunc(double x, double y, double z) {
- double mask, phi, R2, R3, Rbig, Rlit, sig0=0.17, sig1=0.04, a, b, w, ret;
+ double mask, phi, R2, R3, Rbig, Rlit, sig0 = 0.17, sig1 = 0.04, a, b, w, ret;
/* three bladed thing */
- R3 = sqrt(x*x + y*y + z*z);
- mask = AIR_AFFINE(-1.0, erf((R3 - 0.75)*15), 1.0, 1.0, 0.0);
- R2 = sqrt(x*x + y*y);
- phi = atan2(y+0.001,x+0.001) + z*1.2;
- w = pow((1+cos(3*phi))/2, R2*R2*90);
- ret = w*mask;
+ R3 = sqrt(x * x + y * y + z * z);
+ mask = AIR_AFFINE(-1.0, erf((R3 - 0.75) * 15), 1.0, 1.0, 0.0);
+ R2 = sqrt(x * x + y * y);
+ phi = atan2(y + 0.001, x + 0.001) + z * 1.2;
+ w = pow((1 + cos(3 * phi)) / 2, R2 * R2 * 90);
+ ret = w * mask;
if (0) {
/* ridge surface is a Mobius aka Moebius strip */
- Rbig = sqrt(x*x + y*y);
- Rlit = sqrt(z*z + (Rbig-0.5)*(Rbig-0.5));
- phi = atan2(Rbig-0.5, z) - atan2(x, y)/2;
- a = Rlit*cos(phi);
- b = Rlit*sin(phi);
+ Rbig = sqrt(x * x + y * y);
+ Rlit = sqrt(z * z + (Rbig - 0.5) * (Rbig - 0.5));
+ phi = atan2(Rbig - 0.5, z) - atan2(x, y) / 2;
+ a = Rlit * cos(phi);
+ b = Rlit * sin(phi);
/*
ret = airGaussian(a, 0, sig0)*airGaussian(b, 0, sig1);
*/
- a = (a > sig0
- ? a - sig0
- : (a < -sig0
- ? a + sig0
- : 0));
- ret = airGaussian(a, 0, sig1)*airGaussian(b, 0, sig1);
+ a = (a > sig0 ? a - sig0 : (a < -sig0 ? a + sig0 : 0));
+ ret = airGaussian(a, 0, sig1) * airGaussian(b, 0, sig1);
}
return ret;
@@ -116,37 +112,36 @@
"upper bounding corner of volume");
hestOptAdd(&hopt, "o", "filename", airTypeString, 1, 1, &out, "-",
"file to write output nrrd to");
- hestParseOrDie(hopt, argc-1, argv+1, hparm,
- me, genvolInfo, AIR_TRUE, AIR_TRUE, AIR_TRUE);
+ hestParseOrDie(hopt, argc - 1, argv + 1, hparm, me, genvolInfo, AIR_TRUE, AIR_TRUE,
+ AIR_TRUE);
airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);
nout = nrrdNew();
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
- if (nrrdAlloc_va(nout, nrrdTypeDouble, 3,
- AIR_CAST(size_t, size[0]),
- AIR_CAST(size_t, size[1]),
- AIR_CAST(size_t, size[2]))) {
+ if (nrrdAlloc_va(nout, nrrdTypeDouble, 3, AIR_SIZE_T(size[0]), AIR_SIZE_T(size[1]),
+ AIR_SIZE_T(size[2]))) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: problem allocating volume:\n%s\n", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
data = (double *)nout->data;
- for (zi=0; zi<size[2]; zi++) {
- z = AIR_AFFINE(0, zi, size[2]-1, min[2], max[2]);
- for (yi=0; yi<size[1]; yi++) {
- y = AIR_AFFINE(0, yi, size[1]-1, min[1], max[1]);
- for (xi=0; xi<size[0]; xi++) {
- x = AIR_AFFINE(0, xi, size[0]-1, min[0], max[0]);
- *data = genvolFunc(x,y,z);
+ for (zi = 0; zi < size[2]; zi++) {
+ z = AIR_AFFINE(0, zi, size[2] - 1, min[2], max[2]);
+ for (yi = 0; yi < size[1]; yi++) {
+ y = AIR_AFFINE(0, yi, size[1] - 1, min[1], max[1]);
+ for (xi = 0; xi < size[0]; xi++) {
+ x = AIR_AFFINE(0, xi, size[0] - 1, min[0], max[0]);
+ *data = genvolFunc(x, y, z);
data += 1;
}
}
}
- nrrdAxisInfoSet_va(nout, nrrdAxisInfoCenter,
- nrrdCenterNode, nrrdCenterNode, nrrdCenterNode);
+ nrrdAxisInfoSet_va(nout, nrrdAxisInfoCenter, nrrdCenterNode, nrrdCenterNode,
+ nrrdCenterNode);
#if 0
nrrdAxisInfoSet_va(nout, nrrdAxisInfoMin, min[0], min[1], min[2]);
nrrdAxisInfoSet_va(nout, nrrdAxisInfoMax, max[0], max[1], max[2]);
@@ -155,8 +150,7 @@
nrrdAxisInfoSpacingSet(nout, 2);
#else
/* impatient, not using API, bad! */
-#define ELL_3V_SET(v, a, b, c) \
- ((v)[0] = (a), (v)[1] = (b), (v)[2] = (c))
+# define ELL_3V_SET(v, a, b, c) ((v)[0] = (a), (v)[1] = (b), (v)[2] = (c))
nout->space = nrrdSpaceLeftPosteriorSuperior;
nout->spaceDim = 3;
ELL_3V_SET(nout->spaceOrigin, 0, 0, 0);
@@ -168,7 +162,8 @@
if (nrrdSave(out, nout, NULL)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: problem saving output:\n%s\n", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
airMopOkay(mop);
Modified: teem/trunk/src/nrrd/test/histrad.c
===================================================================
--- teem/trunk/src/nrrd/test/histrad.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/test/histrad.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -43,8 +43,8 @@
hparm = hestParmNew();
hopt = NULL;
airMopAdd(mop, hparm, (airMopper)hestParmFree, airMopAlways);
- hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, NULL,
- "input image", NULL, NULL, nrrdHestNrrd);
+ hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, NULL, "input image", NULL,
+ NULL, nrrdHestNrrd);
hestOptAdd(&hopt, "b", "rbins hbins", airTypeInt, 2, 2, bins, NULL,
"# of histogram bins: radial and value");
hestOptAdd(&hopt, "min", "value", airTypeDouble, 1, 1, &vmin, "nan",
@@ -59,14 +59,15 @@
"The center point around which to build radial histogram");
hestOptAdd(&hopt, "o", "filename", airTypeString, 1, 1, &outS, "-",
"file to write histogram to");
- hestParseOrDie(hopt, argc-1, argv+1, hparm,
- me, histradInfo, AIR_TRUE, AIR_TRUE, AIR_TRUE);
+ hestParseOrDie(hopt, argc - 1, argv + 1, hparm, me, histradInfo, AIR_TRUE, AIR_TRUE,
+ AIR_TRUE);
airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);
if (2 != nin->dim) {
fprintf(stderr, "%s: need 2-D input (not %d-D)\n", me, nin->dim);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
rbins = bins[0];
@@ -73,15 +74,15 @@
hbins = bins[1];
nhist = nrrdNew();
airMopAdd(mop, nhist, (airMopper)nrrdNuke, airMopAlways);
- if (nrrdMaybeAlloc_va(nhist, nrrdTypeDouble, 2,
- AIR_CAST(size_t, rbins),
- AIR_CAST(size_t, hbins))) {
+ if (nrrdMaybeAlloc_va(nhist, nrrdTypeDouble, 2, AIR_SIZE_T(rbins),
+ AIR_SIZE_T(hbins))) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: couldn't allocate histogram:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
- if (!( AIR_EXISTS(vmin) && AIR_EXISTS(vmax) )) {
+ if (!(AIR_EXISTS(vmin) && AIR_EXISTS(vmax))) {
range = nrrdRangeNewSet(nin, nrrdStateBlind8BitRange);
airMopAdd(mop, range, (airMopper)nrrdRangeNix, airMopAlways);
vmin = AIR_EXISTS(vmin) ? vmin : range->min;
@@ -88,7 +89,7 @@
vmax = AIR_EXISTS(vmax) ? vmax : range->max;
}
-#define DIST(x0, y0, x1, y1) (sqrt((x0-x1)*(x0-x1) + (y0-y1)*(y0-y1)))
+#define DIST(x0, y0, x1, y1) (sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1)))
sx = AIR_INT(nin->axis[0].size); /* HEY unsigned? */
sy = AIR_INT(nin->axis[1].size);
@@ -95,26 +96,26 @@
if (!AIR_EXISTS(rmax)) {
rmax = 0;
rmax = AIR_MAX(rmax, DIST(cent[0], cent[1], 0, 0));
- rmax = AIR_MAX(rmax, DIST(cent[0], cent[1], sx-1, 0));
- rmax = AIR_MAX(rmax, DIST(cent[0], cent[1], 0, sy-1));
- rmax = AIR_MAX(rmax, DIST(cent[0], cent[1], sx-1, sy-1));
+ rmax = AIR_MAX(rmax, DIST(cent[0], cent[1], sx - 1, 0));
+ rmax = AIR_MAX(rmax, DIST(cent[0], cent[1], 0, sy - 1));
+ rmax = AIR_MAX(rmax, DIST(cent[0], cent[1], sx - 1, sy - 1));
}
lup = nrrdDLookup[nin->type];
- hist = (double*)(nhist->data);
- for (xi=0; xi<sx; xi++) {
- for (yi=0; yi<sy; yi++) {
+ hist = (double *)(nhist->data);
+ for (xi = 0; xi < sx; xi++) {
+ for (yi = 0; yi < sy; yi++) {
rad = DIST(cent[0], cent[1], xi, yi);
if (!AIR_IN_OP(0, rad, rmax)) {
continue;
}
- val = lup(nin->data, xi + sx*yi);
+ val = lup(nin->data, xi + sx * yi);
if (!AIR_IN_OP(vmin, val, vmax)) {
continue;
}
ridx = airIndex(0, rad, rmax, rbins);
hidx = airIndex(vmin, val, vmax, hbins);
- hist[ridx + rbins*hidx] += 1;
+ hist[ridx + rbins * hidx] += 1;
}
}
@@ -125,7 +126,8 @@
if (nrrdSave(outS, nhist, NULL)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: couldn't save output:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
airMopOkay(mop);
Modified: teem/trunk/src/nrrd/test/phrnd.c
===================================================================
--- teem/trunk/src/nrrd/test/phrnd.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/test/phrnd.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -21,8 +21,8 @@
#include "../nrrd.h"
-#define NRRDNEW(X) \
- (X) = nrrdNew(); \
+#define NRRDNEW(X) \
+ (X) = nrrdNew(); \
airMopAdd(mop, (X), (airMopper)nrrdNuke, airMopAlways)
const char *phrndInfo = ("randomizes phase of a real-valued array "
@@ -38,21 +38,21 @@
int rigor;
char *err, *outS, *imagOutS, *wispath, *seedS;
Nrrd *ntmp, *ntmp2, /* tmp */
- *njarg[2], /* arguments to join */
- *nrin, /* given real-valued input */
- *nrdin, /* given real-valued input, as double */
- *ncin, /* (padded) complex-valued input */
- *ncfin, /* complex-valued transform of input */
- *nR, /* real part of something */
- *nI, /* imag part of something */
- *nP, /* phase */
- *nM, /* mag */
- *nlut, /* phase look-up table */
- *ncfout, /* complex-valued transform of output */
- *ncdout, /* double complex-valued output */
- *ncout, /* complex-valued output, as input type */
- *niout, /* imaginary output */
- *nrout; /* real output */
+ *njarg[2], /* arguments to join */
+ *nrin, /* given real-valued input */
+ *nrdin, /* given real-valued input, as double */
+ *ncin, /* (padded) complex-valued input */
+ *ncfin, /* complex-valued transform of input */
+ *nR, /* real part of something */
+ *nI, /* imag part of something */
+ *nP, /* phase */
+ *nM, /* mag */
+ *nlut, /* phase look-up table */
+ *ncfout, /* complex-valued transform of output */
+ *ncdout, /* double complex-valued output */
+ *ncout, /* complex-valued output, as input type */
+ *niout, /* imaginary output */
+ *nrout; /* real output */
double howrand, *lut, *P;
unsigned int len, axi, seed;
size_t II, NN, minInset[NRRD_DIM_MAX];
@@ -65,8 +65,8 @@
hparm = hestParmNew();
hopt = NULL;
airMopAdd(mop, hparm, (airMopper)hestParmFree, airMopAlways);
- hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nrin, NULL,
- "input array", NULL, NULL, nrrdHestNrrd);
+ hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nrin, NULL, "input array", NULL,
+ NULL, nrrdHestNrrd);
hestOptAdd(&hopt, "n", "len", airTypeUInt, 1, 1, &len, "65536",
"length (must be EVEN) of phase look-up table, used "
"enable being dumb (rather than clever) in asserting "
@@ -99,8 +99,8 @@
"permit confirming that it doesn't carry significant info");
hestOptAdd(&hopt, "o", "filename", airTypeString, 1, 1, &outS, NULL,
"file to write output nrrd to");
- hestParseOrDie(hopt, argc-1, argv+1, hparm,
- me, phrndInfo, AIR_TRUE, AIR_TRUE, AIR_TRUE);
+ hestParseOrDie(hopt, argc - 1, argv + 1, hparm, me, phrndInfo, AIR_TRUE, AIR_TRUE,
+ AIR_TRUE);
airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);
@@ -121,7 +121,7 @@
/* got no request for specific seed */
airSrandMT(AIR_UINT(airTime()));
}
- for (axi=0; axi<NRRD_DIM_MAX; axi++) {
+ for (axi = 0; axi < NRRD_DIM_MAX; axi++) {
minInset[axi] = 0;
}
/* pointless to set content */
@@ -130,15 +130,14 @@
/* ============== pad real input nrin to complex-valued input ncin */
minPad[0] = 0;
maxPad[0] = 1;
- for (axi=0; axi<nrin->dim; axi++) {
- minPad[axi+1] = 0;
- maxPad[axi+1] = AIR_CAST(ptrdiff_t, nrin->axis[axi].size-1);
+ for (axi = 0; axi < nrin->dim; axi++) {
+ minPad[axi + 1] = 0;
+ maxPad[axi + 1] = AIR_CAST(ptrdiff_t, nrin->axis[axi].size - 1);
}
NRRDNEW(nrdin);
NRRDNEW(ntmp);
NRRDNEW(ncin);
- if (nrrdConvert(nrdin, nrin, nrrdTypeDouble)
- || nrrdAxesInsert(ntmp, nrdin, 0)
+ if (nrrdConvert(nrdin, nrin, nrrdTypeDouble) || nrrdAxesInsert(ntmp, nrdin, 0)
|| nrrdPad_nva(ncin, ntmp, minPad, maxPad, nrrdBoundaryPad, 0.0)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: error creating complex input:\n%s", me, err);
@@ -158,14 +157,16 @@
}
fclose(fwise);
} else {
- fprintf(stderr, "%s: (\"%s\" couldn't be opened, will try to save "
- "wisdom afterwards)", me, wispath);
+ fprintf(stderr,
+ "%s: (\"%s\" couldn't be opened, will try to save "
+ "wisdom afterwards)",
+ me, wispath);
}
}
/* ============== transform input to phase and magnitude */
- for (axi=0; axi<nrin->dim; axi++) {
- axes[axi] = axi+1;
+ for (axi = 0; axi < nrin->dim; axi++) {
+ axes[axi] = axi + 1;
}
NRRDNEW(ncfin);
NRRDNEW(nR);
@@ -173,8 +174,7 @@
NRRDNEW(nP);
NRRDNEW(nM);
if (nrrdFFT(ncfin, ncin, axes, nrin->dim, +1, AIR_TRUE, rigor)
- || nrrdSlice(nR, ncfin, 0, 0)
- || nrrdSlice(nI, ncfin, 0, 1)
+ || nrrdSlice(nR, ncfin, 0, 0) || nrrdSlice(nI, ncfin, 0, 1)
|| nrrdArithBinaryOp(nP, nrrdBinaryOpAtan2, nI, nR)
|| nrrdProject(nM, ncfin, 0, nrrdMeasureL2, nrrdTypeDefault)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
@@ -185,7 +185,7 @@
/* ============== randomize phase */
NRRDNEW(nlut);
- if (nrrdMaybeAlloc_va(nlut, nrrdTypeDouble, 1, AIR_CAST(size_t, len))) {
+ if (nrrdMaybeAlloc_va(nlut, nrrdTypeDouble, 1, AIR_SIZE_T(len))) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: error making lut:\n%s", me, err);
airMopError(mop);
@@ -192,17 +192,17 @@
return 1;
}
lut = AIR_CAST(double *, nlut->data);
- for (II=0; II<len; II++) {
+ for (II = 0; II < len; II++) {
/* random phase */
- if (II < len/2) {
+ if (II < len / 2) {
lut[II] = AIR_AFFINE(0, airDrandMT(), 1, -AIR_PI, AIR_PI);
} else {
- lut[II] = -lut[len-1-II];
+ lut[II] = -lut[len - 1 - II];
}
}
NN = nrrdElementNumber(nP);
P = AIR_CAST(double *, nP->data);
- for (II=0; II<NN; II++) {
+ for (II = 0; II < NN; II++) {
/* pp is the original input phase */
double pp = P[II];
/* pi is the index for the input phase */
@@ -225,10 +225,9 @@
|| nrrdArithBinaryOp(nR, nrrdBinaryOpMultiply, nR, nM)
|| nrrdArithUnaryOp(nI, nrrdUnaryOpSin, nP)
|| nrrdArithBinaryOp(nI, nrrdBinaryOpMultiply, nI, nM)
- || nrrdJoin(ncfout, AIR_CAST(const Nrrd*const*, njarg), 2, 0, AIR_TRUE)
+ || nrrdJoin(ncfout, AIR_CAST(const Nrrd *const *, njarg), 2, 0, AIR_TRUE)
|| nrrdFFT(ncdout, ncfout, axes, nrin->dim, -1, AIR_TRUE, rigor)
- || nrrdConvert(ntmp, ncdout, nrin->type)
- || nrrdConvert(ntmp2, ncin, nrin->type)
+ || nrrdConvert(ntmp, ncdout, nrin->type) || nrrdConvert(ntmp2, ncin, nrin->type)
|| nrrdInset(ncout, ntmp2, ntmp, minInset)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: error creating output\n%s", me, err);
@@ -254,8 +253,8 @@
/* ============== DONE. saving things to save */
if (airStrlen(wispath) && nrrdFFTWEnabled) {
if (!(fwise = fopen(wispath, "w"))) {
- fprintf(stderr, "%s: couldn't open %s for writing: %s\n",
- me, wispath, strerror(errno));
+ fprintf(stderr, "%s: couldn't open %s for writing: %s\n", me, wispath,
+ strerror(errno));
airMopError(mop);
return 1;
}
@@ -269,22 +268,19 @@
}
if (airStrlen(imagOutS)) {
NRRDNEW(niout);
- if (nrrdSlice(niout, ncout, 0, 1)
- || nrrdSave(imagOutS, niout, NULL)) {
+ if (nrrdSlice(niout, ncout, 0, 1) || nrrdSave(imagOutS, niout, NULL)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
- fprintf(stderr, "%s: error slicing/saving imaginary output:\n%s",
- me, err);
+ fprintf(stderr, "%s: error slicing/saving imaginary output:\n%s", me, err);
airMopError(mop);
return 1;
}
}
NRRDNEW(nrout);
- if (nrrdSlice(nrout, ncout, 0, 0)
- || nrrdSave(outS, nrout, NULL)) {
+ if (nrrdSlice(nrout, ncout, 0, 0) || nrrdSave(outS, nrout, NULL)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
- fprintf(stderr, "%s: problem slicing/saving real output:\n%s\n",
- me, err);
- airMopError(mop); return 1;
+ fprintf(stderr, "%s: problem slicing/saving real output:\n%s\n", me, err);
+ airMopError(mop);
+ return 1;
}
airMopOkay(mop);
Modified: teem/trunk/src/nrrd/test/quadvol.c
===================================================================
--- teem/trunk/src/nrrd/test/quadvol.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/test/quadvol.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -28,7 +28,7 @@
float
quadFunc(float x, float y, float z, float A, float B, float off) {
- return A*x*x + B*y*y - z + off;
+ return A * x * x + B * y * y - z + off;
}
int
@@ -59,30 +59,29 @@
"vertical offset");
hestOptAdd(&hopt, "o", "filename", airTypeString, 1, 1, &out, "-",
"file to write output nrrd to");
- hestParseOrDie(hopt, argc-1, argv+1, hparm,
- me, quadInfo, AIR_TRUE, AIR_TRUE, AIR_TRUE);
+ hestParseOrDie(hopt, argc - 1, argv + 1, hparm, me, quadInfo, AIR_TRUE, AIR_TRUE,
+ AIR_TRUE);
airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);
nout = nrrdNew();
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
- if (nrrdAlloc_va(nout, nrrdTypeFloat, 3,
- AIR_CAST(size_t, size[0]),
- AIR_CAST(size_t, size[1]),
- AIR_CAST(size_t, size[2]))) {
+ if (nrrdAlloc_va(nout, nrrdTypeFloat, 3, AIR_SIZE_T(size[0]), AIR_SIZE_T(size[1]),
+ AIR_SIZE_T(size[2]))) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: problem allocating volume:\n%s\n", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
data = (float *)nout->data;
- for (zi=0; zi<size[2]; zi++) {
- z = AIR_FLOAT(AIR_AFFINE(0, zi, size[2]-1, min[2], max[2]));
- for (yi=0; yi<size[1]; yi++) {
- y = AIR_FLOAT(AIR_AFFINE(0, yi, size[1]-1, min[1], max[1]));
- for (xi=0; xi<size[0]; xi++) {
- x = AIR_FLOAT(AIR_AFFINE(0, xi, size[0]-1, min[0], max[0]));
- *data = quadFunc(x,y,z, AB[0], AB[1], off);
+ for (zi = 0; zi < size[2]; zi++) {
+ z = AIR_FLOAT(AIR_AFFINE(0, zi, size[2] - 1, min[2], max[2]));
+ for (yi = 0; yi < size[1]; yi++) {
+ y = AIR_FLOAT(AIR_AFFINE(0, yi, size[1] - 1, min[1], max[1]));
+ for (xi = 0; xi < size[0]; xi++) {
+ x = AIR_FLOAT(AIR_AFFINE(0, xi, size[0] - 1, min[0], max[0]));
+ *data = quadFunc(x, y, z, AB[0], AB[1], off);
data += 1;
}
}
@@ -96,7 +95,8 @@
if (nrrdSave(out, nout, NULL)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: problem saving output:\n%s\n", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
airMopOkay(mop);
Modified: teem/trunk/src/nrrd/test/texp.c
===================================================================
--- teem/trunk/src/nrrd/test/texp.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/test/texp.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -19,13 +19,12 @@
Fifth Floor, Boston, MA 02110-1301 USA
*/
-
#include <teem/air.h>
#include <teem/biff.h>
#include "../nrrd.h"
void
-usage(char *me) { /* 0 1 2 3 4 (5) */
+usage(char *me) { /* 0 1 2 3 4 (5) */
fprintf(stderr, "usage: %s <min> <N> <max> <fileOut>\n", me);
exit(1);
}
@@ -41,45 +40,40 @@
if (5 != argc) {
usage(me);
}
- if (3 != (sscanf(argv[2], "%u", &NN)
- + sscanf(argv[1], "%lf", &min)
- + sscanf(argv[3], "%lf", &max))) {
- fprintf(stderr, "%s: couldn't parse %s %s %s double uint double",
- me, argv[1], argv[2], argv[3]);
+ if (3
+ != (sscanf(argv[2], "%u", &NN) + sscanf(argv[1], "%lf", &min)
+ + sscanf(argv[3], "%lf", &max))) {
+ fprintf(stderr, "%s: couldn't parse %s %s %s double uint double", me, argv[1],
+ argv[2], argv[3]);
usage(me);
}
nout = nrrdNew();
- if (nrrdAlloc_va(nout, nrrdTypeDouble, 2,
- AIR_CAST(size_t, 5),
- AIR_CAST(size_t, NN))) {
- fprintf(stderr, "%s: trouble allocating:\n%s", me,
- biffGetDone(NRRD));
+ if (nrrdAlloc_va(nout, nrrdTypeDouble, 2, AIR_SIZE_T(5), AIR_SIZE_T(NN))) {
+ fprintf(stderr, "%s: trouble allocating:\n%s", me, biffGetDone(NRRD));
exit(1);
}
out = AIR_CAST(double *, nout->data);
- for (ii=0; ii<NN; ii++) {
+ for (ii = 0; ii < NN; ii++) {
double xx, rr, ff, gg;
- xx = AIR_AFFINE(0, ii, NN-1, min, max);
+ xx = AIR_AFFINE(0, ii, NN - 1, min, max);
rr = exp(xx);
ff = airFastExp(xx);
gg = airExp(xx);
- if (rr < 0 || ff < 0 || gg < 0
- || !AIR_EXISTS(rr) || !AIR_EXISTS(ff) || !AIR_EXISTS(gg)) {
- fprintf(stderr, "%s: problem: %f -> real %f, approx %f %f\n",
- me, xx, rr, ff, gg);
+ if (rr < 0 || ff < 0 || gg < 0 || !AIR_EXISTS(rr) || !AIR_EXISTS(ff)
+ || !AIR_EXISTS(gg)) {
+ fprintf(stderr, "%s: problem: %f -> real %f, approx %f %f\n", me, xx, rr, ff, gg);
exit(1);
}
out[0] = rr;
out[1] = ff;
- out[2] = (ff-rr)/rr;
+ out[2] = (ff - rr) / rr;
out[3] = gg;
- out[4] = (gg-rr)/rr;
+ out[4] = (gg - rr) / rr;
out += 5;
}
if (nrrdSave(argv[4], nout, NULL)) {
- fprintf(stderr, "%s: trouble saving:\n%s", me,
- biffGetDone(NRRD));
+ fprintf(stderr, "%s: trouble saving:\n%s", me, biffGetDone(NRRD));
exit(1);
}
exit(0);
Modified: teem/trunk/src/nrrd/test/trand.c
===================================================================
--- teem/trunk/src/nrrd/test/trand.c 2023-07-15 21:56:46 UTC (rev 7114)
+++ teem/trunk/src/nrrd/test/trand.c 2023-07-15 21:57:26 UTC (rev 7115)
@@ -32,17 +32,16 @@
AIR_UNUSED(argc);
AIR_UNUSED(argv);
- nrrdAlloc_va(nval=nrrdNew(), nrrdTypeDouble, 1,
- AIR_CAST(size_t, BINS*BINS));
+ nrrdAlloc_va(nval = nrrdNew(), nrrdTypeDouble, 1, AIR_SIZE_T(BINS * BINS));
val = (double *)nval->data;
airSrandMT((int)airTime());
- for (i=0; i<BINS*BINS; i++) {
+ for (i = 0; i < BINS * BINS; i++) {
val[i] = airDrandMT();
}
- nrrdHisto(nhist=nrrdNew(), nval, NULL, NULL, BINS, nrrdTypeInt);
- nrrdHistoDraw(npgm=nrrdNew(), nhist, HGHT, AIR_FALSE, 0.0);
+ nrrdHisto(nhist = nrrdNew(), nval, NULL, NULL, BINS, nrrdTypeInt);
+ nrrdHistoDraw(npgm = nrrdNew(), nhist, HGHT, AIR_FALSE, 0.0);
nrrdSave("hist.pgm", npgm, NULL);
nrrdNuke(nval);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|