|
From: <kin...@us...> - 2024-07-16 22:15:27
|
Revision: 7210
http://sourceforge.net/p/teem/code/7210
Author: kindlmann
Date: 2024-07-16 22:15:26 +0000 (Tue, 16 Jul 2024)
Log Message:
-----------
tweaks to new flexiblity in loi==hii, and in its testing
Modified Paths:
--------------
teem/trunk/src/limn/splineFit.c
teem/trunk/src/limn/test/00-data.sh
teem/trunk/src/limn/test/01-test-tvt.sh
Modified: teem/trunk/src/limn/splineFit.c
===================================================================
--- teem/trunk/src/limn/splineFit.c 2024-07-16 20:26:18 UTC (rev 7209)
+++ teem/trunk/src/limn/splineFit.c 2024-07-16 22:15:26 UTC (rev 7210)
@@ -650,8 +650,8 @@
/* idxLift: error-checked index lifting (from "actual" to "lifted" indices, explained
above) for limnCbfTVT and maybe others. If no error, *loiP will be same as given gloi,
-but in loops *vviP and *hiiP may be lifted (relative to gvvi and ghii), and outside loops
-*hiiP may be changed to #points-1.
+but in loops *vviP and/or *hiiP may be lifted (relative to gvvi and ghii), and outside
+loops *hiiP may be changed to #points-1.
That sounds like nothing fancy, but this is messy because of the flexibility in how we
handle points: might not be a loop or might not, and, consideration of vertices should
@@ -665,7 +665,7 @@
static const char me[] = "idxLift";
uint pnum = lpnt->num, loi, hii, vvi;
- *loiP = *hiiP = *vviP = UINT_MAX; /* initialize to bogus indices */
+ *loiP = *hiiP = *vviP = UINT_MAX; /* ini tialize to bogus indices */
if (!(pnum < (1U << 29))) {
/* UB = undefined behavior */
biffAddf(LIMN, "%s: # points %u seems too big (to stay well clear of UB)", me, pnum);
@@ -682,8 +682,8 @@
hii = ghii;
vvi = gvvi;
if (lpnt->isLoop) {
- if (!(gloi < ghii)) hii += pnum;
- /* now loi < hii */
+ if (!(gloi <= ghii)) hii += pnum;
+ /* now loi <= hii ; loi==hii possible for any valid index */
if (gvvi < gloi) vvi += pnum;
/* now loi <= vvi */
} else {
@@ -698,7 +698,7 @@
/* else gloi==ghii==0 */
hii = pnum - 1;
/* now loi < hii */
- /* because of uint type 0 == loi <= vvi */
+ /* because of uint type, 0 == loi <= vvi */
} else { /* gloi != ghii */
if (!(gloi < ghii)) {
biffAddf(LIMN, "%s: in non-loop, need loi (%u) < hii (%u)", me, gloi, ghii);
@@ -713,18 +713,21 @@
/* now loi <= vii */
}
}
- /* now, in any case: must have loi < hii and loi <= vvi */
+ /* now, in any case: must have loi <= hii (and loi==hii only possible in loop)
+ and loi <= vvi */
if (verbose) {
printf("%s: given loi,hii,vvi %u %u %u --> lifted %u %u %u\n", me, gloi, ghii, gvvi,
loi, hii, vvi);
}
- /* make sure that vvi is below upper bound hii */
- if (!(vvi <= hii)) {
- biffAddf(LIMN, "%s: vvi %u->%u not in [%u,%u]->[%u,%u] span", me, gvvi, vvi, /* */
- gloi, ghii, loi, hii);
- return 1;
+ if (loi < hii) {
+ /* if have consequential bounds, check that vvi is in closed-interval [loi,hii];
+ (the test w.r.t. loi is actually redundant with above, but here for clarity) */
+ if (!(loi <= vvi && vvi <= hii)) {
+ biffAddf(LIMN, "%s: vvi %u->%u not in [%u,%u]->[%u,%u] span", me, gvvi, vvi, /* */
+ gloi, ghii, loi, hii);
+ return 1;
+ }
}
- /* now, in any case: loi <= vvi <= hii */
/* all's well, set output values */
*loiP = loi;
@@ -866,7 +869,7 @@
: sui;
const double *xy = PPlowerI(lpnt, sbi); /* coords at sbi */
ELL_2V_SCALE_INCR(posC, vw, xy);
- if (fctx->verbose > 1) {
+ if (fctx->verbose > 2) {
printf("%s: ci=%d (in [%d,%d]) idx %d --[%d,%d]--> %d; v,t w %g,%g on "
"xy=(%g,%g)\n",
me, ci, -lim, lim, sui, slo, shi, sbi, vw, tw, xy[0], xy[1]);
@@ -874,13 +877,13 @@
}
if (ci < 0) {
ELL_2V_SCALE_INCR(posM, tw, xy);
- if (fctx->verbose > 1) {
+ if (fctx->verbose > 2) {
printf("%s: ---> posM=(%g,%g)\n", me, posM[0], posM[1]);
}
}
if (ci > 0) {
ELL_2V_SCALE_INCR(posP, tw, xy);
- if (fctx->verbose > 1) {
+ if (fctx->verbose > 2) {
printf("%s: ---> posP=(%g,%g)\n", me, posP[0], posP[1]);
}
}
@@ -1430,7 +1433,7 @@
ELL_2V_COPY(vttv[3], vv3);
if (givenP) *givenP = AIR_TRUE;
} else {
- double v0c[2], t1c[2], t2c[2], v3c[3]; /* locally computed info */
+ double v0c[2], t1c[2], t2c[2], v3c[3]; /* to store locally computed info */
if (vv0 || tt1 || tt2 || vv3) {
biffAddf(LIMN,
"%s: should either give all vv0,tt1,tt2,vv3 or none (not %p,%p,%p,%p)",
@@ -1438,14 +1441,14 @@
(const void *)vv3);
return 1;
}
- if (loi == hii && hii != 0) {
+ /* if (loi == hii && hii != 0) { (no longer true)
biffAddf(LIMN, "%s: can only handle loi=hii=%u if both 0", me, hii);
return 1;
- }
- if (loi == hii) { /* and hence both 0, due to above */
- /* e.g., we're doing the first fit on of a circular (corner-less) path */
+ } */
+ if (loi == hii) {
+ /* e.g., we're doing the first fit on a circular path with 0 or 1 corners */
if (!lpnt->isLoop) {
- biffAddf(LIMN, "%s: can handle loi=hii=0 only with point loop", me);
+ biffAddf(LIMN, "%s: can handle loi=hii only with point loop", me);
return 1;
}
if (limnCbfTVT(t2c, v0c, t1c, /* */
@@ -1456,7 +1459,7 @@
}
ELL_2V_COPY(v3c, v0c);
} else {
- /* do not have geometry info; must find it all */
+ /* loi < hii */
if (limnCbfTVT(NULL, v0c, t1c, /* */
fctx, lpnt, loi, hii, loi, /* */
AIR_TRUE /* yes oneSided */)
Modified: teem/trunk/src/limn/test/00-data.sh
===================================================================
--- teem/trunk/src/limn/test/00-data.sh 2024-07-16 20:26:18 UTC (rev 7209)
+++ teem/trunk/src/limn/test/00-data.sh 2024-07-16 22:15:26 UTC (rev 7210)
@@ -32,7 +32,7 @@
# https://devmanual.gentoo.org/tools-reference/bash/
unset UNRRDU_QUIET_QUIT
-N=50
+N=24
echo 0 1 |
unu reshape -s 2 |
Modified: teem/trunk/src/limn/test/01-test-tvt.sh
===================================================================
--- teem/trunk/src/limn/test/01-test-tvt.sh 2024-07-16 20:26:18 UTC (rev 7209)
+++ teem/trunk/src/limn/test/01-test-tvt.sh 2024-07-16 22:15:26 UTC (rev 7210)
@@ -40,24 +40,60 @@
RTOUT=out-lt.txt
BIN=670
-rm -f $VVOUT; touch $VVOUT; junk $VVOUT
-rm -f $LTOUT; touch $LTOUT; junk $LTOUT
-rm -f $RTOUT; touch $RTOUT; junk $RTOUT
+EPS=0.2
+SCL=1.1
+VERB=2
+# initialize outputs to be non-empty but also non-consequential
+rm -f $VVOUT; echo "nan nan" > $VVOUT; junk $VVOUT
+rm -f $LTOUT; echo "nan nan" > $LTOUT; junk $LTOUT
+rm -f $RTOUT; echo "nan nan" > $RTOUT; junk $RTOUT
+echo "for I in seq 0 $((N-1)) ..."
for I in $(seq 0 $((N-1))); do
- # 16-fold (!) TEST:
- # 8: without -loop, versus with -loop
- # 4: LO=HI=0 (or LO=HI=5 in loop), versus some interval around I
- # 2: oneside (4th arg to -tvt) 0 versus 1
- # 1: -scl 0 versus >0
- LO=0 # $((I-4))
- HI=0 # $((I+4))
- CMD="./lpu cbfit -i $IN -tvt $LO $HI $I 0 -scl 0 -eps 1 -v 0"
- echo $CMD
+ ## 16-fold, and then some (!) TEST:
+ ## 8: without -loop, versus with -loop
+ ## 4: LO=HI=0 (or LO=HI=5 in loop), versus some interval around I (centered or not)
+ ## 2: -scl 0 versus >0
+ ## 1: oneside (4th arg to -tvt) 0 versus 1
+ CMD="./lpu cbfit -i $IN -tvt 0 0 $I 0 -scl 0 -eps $EPS -v $VERB" # 0
+ # CMD="./lpu cbfit -i $IN -tvt 0 0 $I 1 -scl 0 -eps $EPS -v $VERB" # 1
+ # CMD="./lpu cbfit -i $IN -tvt 0 0 $I 0 -scl $SCL -eps $EPS -v $VERB" # 2
+ # CMD="./lpu cbfit -i $IN -tvt 0 0 $I 1 -scl $SCL -eps $EPS -v $VERB" # 3
+ # CMD="./lpu cbfit -i $IN -tvt $((I-4)) $((I+4)) $I 0 -scl 0 -eps $EPS -v $VERB" # 4
+ # CMD="./lpu cbfit -i $IN -tvt $((I-1)) $((I+7)) $I 0 -scl 0 -eps $EPS -v $VERB" # 4.5
+ # CMD="./lpu cbfit -i $IN -tvt $((I-4)) $((I+4)) $I 1 -scl 0 -eps $EPS -v $VERB" # 5
+ # CMD="./lpu cbfit -i $IN -tvt $((I-1)) $((I+7)) $I 1 -scl 0 -eps $EPS -v $VERB" # 5.5
+ # CMD="./lpu cbfit -i $IN -tvt $((I-4)) $((I+4)) $I 0 -scl $SCL -eps $EPS -v $VERB" # 6
+ # CMD="./lpu cbfit -i $IN -tvt $((I-1)) $((I+7)) $I 0 -scl $SCL -eps $EPS -v $VERB" # 6.5
+ # CMD="./lpu cbfit -i $IN -tvt $((I-4)) $((I+4)) $I 1 -scl $SCL -eps $EPS -v $VERB" # 7
+ # CMD="./lpu cbfit -i $IN -tvt $((I-1)) $((I+7)) $I 1 -scl $SCL -eps $EPS -v $VERB" # 7.5
+ # CMD="./lpu cbfit -i $IN -loop -tvt 0 0 $I 0 -scl 0 -eps $EPS -v $VERB" # 8
+ # CMD="./lpu cbfit -i $IN -loop -tvt 4 4 $I 0 -scl 0 -eps $EPS -v $VERB" # 8.5
+ # CMD="./lpu cbfit -i $IN -loop -tvt 0 0 $I 1 -scl 0 -eps $EPS -v $VERB" # 9
+ # CMD="./lpu cbfit -i $IN -loop -tvt 4 4 $I 1 -scl 0 -eps $EPS -v $VERB" # 9.5
+ # CMD="./lpu cbfit -i $IN -loop -tvt 0 0 $I 0 -scl $SCL -eps $EPS -v $VERB" # 10
+ # CMD="./lpu cbfit -i $IN -loop -tvt 4 4 $I 0 -scl $SCL -eps $EPS -v $VERB" # 10.5
+ # CMD="./lpu cbfit -i $IN -loop -tvt 0 0 $I 1 -scl $SCL -eps $EPS -v $VERB" # 11
+ # CMD="./lpu cbfit -i $IN -loop -tvt 4 4 $I 1 -scl $SCL -eps $EPS -v $VERB" # 11.5
+ # CMD="./lpu cbfit -i $IN -loop -tvt $((I-4)) $((I+4)) $I 0 -scl 0 -eps $EPS -v $VERB" # 12
+ # CMD="./lpu cbfit -i $IN -loop -tvt $((I-1)) $((I+7)) $I 0 -scl 0 -eps $EPS -v $VERB" # 12.5
+ # CMD="./lpu cbfit -i $IN -loop -tvt $((I-4)) $((I+4)) $I 1 -scl 0 -eps $EPS -v $VERB" # 13
+ # CMD="./lpu cbfit -i $IN -loop -tvt $((I-1)) $((I+7)) $I 1 -scl 0 -eps $EPS -v $VERB" # 13.5
+ # CMD="./lpu cbfit -i $IN -loop -tvt $((I-4)) $((I+4)) $I 0 -scl $SCL -eps $EPS -v $VERB" # 14
+ # CMD="./lpu cbfit -i $IN -loop -tvt $((I-1)) $((I+7)) $I 0 -scl $SCL -eps $EPS -v $VERB" # 14.5
+ # CMD="./lpu cbfit -i $IN -loop -tvt $((I-4)) $((I+4)) $I 1 -scl $SCL -eps $EPS -v $VERB" # 15
+ # CMD="./lpu cbfit -i $IN -loop -tvt $((I-1)) $((I+7)) $I 1 -scl $SCL -eps $EPS -v $VERB" # 15.5
+ echo "$I/$N: $CMD"
rm -f log.txt
+ set +o errexit
(eval $CMD 2>&1) > log.txt
- grep "lt =" log.txt | cut -d' ' -f 3,4 >> $LTOUT
- grep "vv =" log.txt | cut -d' ' -f 3,4 >> $VVOUT
- grep "rt =" log.txt | cut -d' ' -f 3,4 >> $RTOUT
+ RET=$?
+ set -o errexit
+ if [ 0 -eq $RET ]; then
+ grep "^limnCbfTVT" log.txt ||:
+ grep "lt =" log.txt | cut -d' ' -f 3,4 >> $LTOUT
+ grep "vv =" log.txt | cut -d' ' -f 3,4 >> $VVOUT
+ grep "rt =" log.txt | cut -d' ' -f 3,4 >> $RTOUT
+ fi
done
rm -f log.txt
@@ -68,7 +104,7 @@
unu jhisto -i $VVOUT $MMB | unu quantize -b 8 -max 1 -o vv.png
junk vv.png
-TSCL=0.02
+TSCL=0.08
unu 2op x $LTOUT $TSCL | unu 2op + - $VVOUT | unu jhisto $MMB | unu quantize -b 8 -max 1 -o lt.png
unu 2op x $RTOUT $TSCL | unu 2op + - $VVOUT | unu jhisto $MMB | unu quantize -b 8 -max 1 -o rt.png
junk {l,r}t.png
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|