Diff of the two buildlogs: -- --- b1/build.log 2024-06-15 23:18:13.615061745 +0000 +++ b2/build.log 2024-06-15 23:21:34.814500540 +0000 @@ -1,6 +1,6 @@ I: pbuilder: network access will be disabled during build -I: Current time: Sat Jun 15 11:12:55 -12 2024 -I: pbuilder-time-stamp: 1718493175 +I: Current time: Sat Jul 19 19:41:13 +14 2025 +I: pbuilder-time-stamp: 1752903673 I: Building the build Environment I: extracting base tarball [/var/cache/pbuilder/unstable-reproducible-base.tgz] I: copying local configuration @@ -37,54 +37,86 @@ dpkg-source: info: applying octave9.patch I: Not using root during the build. I: Installing the build-deps -I: user script /srv/workspace/pbuilder/23568/tmp/hooks/D02_print_environment starting +I: user script /srv/workspace/pbuilder/2523/tmp/hooks/D01_modify_environment starting +debug: Running on ionos6-i386. +I: Changing host+domainname to test build reproducibility +I: Adding a custom variable just for the fun of it... +I: Changing /bin/sh to bash +'/bin/sh' -> '/bin/bash' +lrwxrwxrwx 1 root root 9 Jul 19 05:41 /bin/sh -> /bin/bash +I: Setting pbuilder2's login shell to /bin/bash +I: Setting pbuilder2's GECOS to second user,second room,second work-phone,second home-phone,second other +I: user script /srv/workspace/pbuilder/2523/tmp/hooks/D01_modify_environment finished +I: user script /srv/workspace/pbuilder/2523/tmp/hooks/D02_print_environment starting I: set - BUILDDIR='/build/reproducible-path' - BUILDUSERGECOS='first user,first room,first work-phone,first home-phone,first other' - BUILDUSERNAME='pbuilder1' - BUILD_ARCH='i386' - DEBIAN_FRONTEND='noninteractive' - DEB_BUILD_OPTIONS='buildinfo=+all reproducible=+all parallel=11 ' - DISTRIBUTION='unstable' - HOME='/root' - HOST_ARCH='i386' + BASH=/bin/sh + BASHOPTS=checkwinsize:cmdhist:complete_fullquote:extquote:force_fignore:globasciiranges:globskipdots:hostcomplete:interactive_comments:patsub_replacement:progcomp:promptvars:sourcepath + BASH_ALIASES=() + BASH_ARGC=() + BASH_ARGV=() + BASH_CMDS=() + BASH_LINENO=([0]="12" [1]="0") + BASH_LOADABLES_PATH=/usr/local/lib/bash:/usr/lib/bash:/opt/local/lib/bash:/usr/pkg/lib/bash:/opt/pkg/lib/bash:. + BASH_SOURCE=([0]="/tmp/hooks/D02_print_environment" [1]="/tmp/hooks/D02_print_environment") + BASH_VERSINFO=([0]="5" [1]="2" [2]="21" [3]="1" [4]="release" [5]="i686-pc-linux-gnu") + BASH_VERSION='5.2.21(1)-release' + BUILDDIR=/build/reproducible-path + BUILDUSERGECOS='second user,second room,second work-phone,second home-phone,second other' + BUILDUSERNAME=pbuilder2 + BUILD_ARCH=i386 + DEBIAN_FRONTEND=noninteractive + DEB_BUILD_OPTIONS='buildinfo=+all reproducible=+all parallel=21 ' + DIRSTACK=() + DISTRIBUTION=unstable + EUID=0 + FUNCNAME=([0]="Echo" [1]="main") + GROUPS=() + HOME=/root + HOSTNAME=i-capture-the-hostname + HOSTTYPE=i686 + HOST_ARCH=i386 IFS=' ' - INVOCATION_ID='aecbd721f2864cdc85a5fbb37c714782' - LANG='C' - LANGUAGE='en_US:en' - LC_ALL='C' - LD_LIBRARY_PATH='/usr/lib/libeatmydata' - LD_PRELOAD='libeatmydata.so' - MAIL='/var/mail/root' - OPTIND='1' - PATH='/usr/sbin:/usr/bin:/sbin:/bin:/usr/games' - PBCURRENTCOMMANDLINEOPERATION='build' - PBUILDER_OPERATION='build' - PBUILDER_PKGDATADIR='/usr/share/pbuilder' - PBUILDER_PKGLIBDIR='/usr/lib/pbuilder' - PBUILDER_SYSCONFDIR='/etc' - PPID='23568' - PS1='# ' - PS2='> ' + INVOCATION_ID=bff8bb0c5ccd4245a831731732dd6c17 + LANG=C + LANGUAGE=de_CH:de + LC_ALL=C + LD_LIBRARY_PATH=/usr/lib/libeatmydata + LD_PRELOAD=libeatmydata.so + MACHTYPE=i686-pc-linux-gnu + MAIL=/var/mail/root + OPTERR=1 + OPTIND=1 + OSTYPE=linux-gnu + PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/i/capture/the/path + PBCURRENTCOMMANDLINEOPERATION=build + PBUILDER_OPERATION=build + PBUILDER_PKGDATADIR=/usr/share/pbuilder + PBUILDER_PKGLIBDIR=/usr/lib/pbuilder + PBUILDER_SYSCONFDIR=/etc + PIPESTATUS=([0]="0") + POSIXLY_CORRECT=y + PPID=2523 PS4='+ ' - PWD='/' - SHELL='/bin/bash' - SHLVL='2' - SUDO_COMMAND='/usr/bin/timeout -k 18.1h 18h /usr/bin/ionice -c 3 /usr/bin/nice /usr/sbin/pbuilder --build --configfile /srv/reproducible-results/rbuild-debian/r-b-build.Tz6FumWf/pbuilderrc_sTpr --distribution unstable --hookdir /etc/pbuilder/first-build-hooks --debbuildopts -b --basetgz /var/cache/pbuilder/unstable-reproducible-base.tgz --buildresult /srv/reproducible-results/rbuild-debian/r-b-build.Tz6FumWf/b1 --logfile b1/build.log octave-level-set_0.3.1~git.2019.04.13-7.dsc' - SUDO_GID='112' - SUDO_UID='107' - SUDO_USER='jenkins' - TERM='unknown' - TZ='/usr/share/zoneinfo/Etc/GMT+12' - USER='root' - _='/usr/bin/systemd-run' - http_proxy='http://46.16.76.132:3128' + PWD=/ + SHELL=/bin/bash + SHELLOPTS=braceexpand:errexit:hashall:interactive-comments:posix + SHLVL=3 + SUDO_COMMAND='/usr/bin/timeout -k 24.1h 24h /usr/bin/ionice -c 3 /usr/bin/nice -n 11 /usr/bin/unshare --uts -- /usr/sbin/pbuilder --build --configfile /srv/reproducible-results/rbuild-debian/r-b-build.Tz6FumWf/pbuilderrc_TKfc --distribution unstable --hookdir /etc/pbuilder/rebuild-hooks --debbuildopts -b --basetgz /var/cache/pbuilder/unstable-reproducible-base.tgz --buildresult /srv/reproducible-results/rbuild-debian/r-b-build.Tz6FumWf/b2 --logfile b2/build.log octave-level-set_0.3.1~git.2019.04.13-7.dsc' + SUDO_GID=112 + SUDO_UID=107 + SUDO_USER=jenkins + TERM=unknown + TZ=/usr/share/zoneinfo/Etc/GMT-14 + UID=0 + USER=root + _='I: set' + http_proxy=http://213.165.73.152:3128 I: uname -a - Linux ionos12-i386 6.1.0-21-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.90-1 (2024-05-03) x86_64 GNU/Linux + Linux i-capture-the-hostname 6.1.0-21-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.90-1 (2024-05-03) x86_64 GNU/Linux I: ls -l /bin - lrwxrwxrwx 1 root root 7 Jun 5 22:35 /bin -> usr/bin -I: user script /srv/workspace/pbuilder/23568/tmp/hooks/D02_print_environment finished + lrwxrwxrwx 1 root root 7 Jun 5 2024 /bin -> usr/bin +I: user script /srv/workspace/pbuilder/2523/tmp/hooks/D02_print_environment finished -> Attempting to satisfy build-dependencies -> Creating pbuilder-satisfydepends-dummy package Package: pbuilder-satisfydepends-dummy @@ -647,7 +679,7 @@ Get: 517 http://deb.debian.org/debian unstable/main i386 dh-octave all 1.8.0 [22.7 kB] Get: 518 http://deb.debian.org/debian unstable/main i386 octave-struct i386 1.0.18-3+b2 [37.6 kB] Get: 519 http://deb.debian.org/debian unstable/main i386 octave-parallel i386 4.0.2-1+b1 [217 kB] -Fetched 212 MB in 4s (60.1 MB/s) +Fetched 212 MB in 4s (55.3 MB/s) debconf: delaying package configuration, since apt-utils is not installed Selecting previously unselected package autoconf-archive. (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 19640 files and directories currently installed.) @@ -2780,7 +2812,11 @@ Building tag database... -> Finished parsing the build-deps I: Building the package -I: Running cd /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/ && env PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" HOME="/nonexistent/first-build" dpkg-buildpackage -us -uc -b && env PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" HOME="/nonexistent/first-build" dpkg-genchanges -S > ../octave-level-set_0.3.1~git.2019.04.13-7_source.changes +I: user script /srv/workspace/pbuilder/2523/tmp/hooks/A99_set_merged_usr starting +Not re-configuring usrmerge for unstable +I: user script /srv/workspace/pbuilder/2523/tmp/hooks/A99_set_merged_usr finished +hostname: Name or service not known +I: Running cd /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/ && env PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/i/capture/the/path" HOME="/nonexistent/second-build" dpkg-buildpackage -us -uc -b && env PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/i/capture/the/path" HOME="/nonexistent/second-build" dpkg-genchanges -S > ../octave-level-set_0.3.1~git.2019.04.13-7_source.changes dpkg-buildpackage: info: source package octave-level-set dpkg-buildpackage: info: source version 0.3.1~git.2019.04.13-7 dpkg-buildpackage: info: source distribution unstable @@ -2838,14 +2874,14 @@ CXXFLAGS="-g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security" /usr/bin/mkoctfile --verbose nbFromGeom.cpp FastMarching.o Utils.o -o __levelset_nbFromGeom.oct CXXFLAGS="-g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security" /usr/bin/mkoctfile --verbose internal_mesh.cpp FastMarching.o Utils.o -o __levelset_internal_mesh.oct CXXFLAGS="-g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security" /usr/bin/mkoctfile --verbose upwindGrad.cpp FastMarching.o Utils.o -o __levelset_upwindGrad.oct -g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security internal_fastmarching.cpp -o /tmp/oct-doWjOe.o -g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security internal_init_narrowband.cpp -o /tmp/oct-3Uuhrw.o -g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security geomElements.cpp -o /tmp/oct-OAYKZj.o -g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security geomBoundary.cpp -o /tmp/oct-q88Nzd.o -g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security geomGamma.cpp -o /tmp/oct-NWxR4j.o -g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security nbFromGeom.cpp -o /tmp/oct-xXKplA.o -g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security upwindGrad.cpp -o /tmp/oct-ae7o7v.o -g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security internal_mesh.cpp -o /tmp/oct-Gx1eHQ.o +g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security internal_fastmarching.cpp -o /tmp/oct-stzsm6.o +g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security internal_init_narrowband.cpp -o /tmp/oct-CxOYqI.o +g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security geomElements.cpp -o /tmp/oct-iOTV3z.o +g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security geomBoundary.cpp -o /tmp/oct-hLTEtc.o +g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security geomGamma.cpp -o /tmp/oct-4s8Eji.o +g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security nbFromGeom.cpp -o /tmp/oct-nYYt4u.o +g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security internal_mesh.cpp -o /tmp/oct-zPL2bm.o +g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security upwindGrad.cpp -o /tmp/oct-QJh1i5.o In file included from /usr/include/i386-linux-gnu/c++/13/bits/c++allocator.h:33, from /usr/include/c++/13/bits/allocator.h:46, from /usr/include/c++/13/string:43, @@ -2901,18 +2937,18 @@ /usr/include/c++/13/bits/new_allocator.h:151:55: note: returned from 'void* operator new(std::size_t)' 151 | return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp))); | ^ -g++ -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -o __levelset_internal_init_narrowband.oct FastMarching.o Utils.o /tmp/oct-3Uuhrw.o -shared -Wl,-Bsymbolic -Wl,-z,relro -flto=auto -ffat-lto-objects -Wl,-z,relro -g++ -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -o __levelset_geomElements.oct FastMarching.o Utils.o /tmp/oct-OAYKZj.o -shared -Wl,-Bsymbolic -Wl,-z,relro -flto=auto -ffat-lto-objects -Wl,-z,relro -g++ -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -o __levelset_upwindGrad.oct FastMarching.o Utils.o /tmp/oct-ae7o7v.o -shared -Wl,-Bsymbolic -Wl,-z,relro -flto=auto -ffat-lto-objects -Wl,-z,relro -g++ -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -o __levelset_nbFromGeom.oct FastMarching.o Utils.o /tmp/oct-xXKplA.o -shared -Wl,-Bsymbolic -Wl,-z,relro -flto=auto -ffat-lto-objects -Wl,-z,relro -g++ -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -o __levelset_internal_fastmarching.oct FastMarching.o Utils.o /tmp/oct-doWjOe.o -shared -Wl,-Bsymbolic -Wl,-z,relro -flto=auto -ffat-lto-objects -Wl,-z,relro -g++ -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -o __levelset_geomBoundary.oct FastMarching.o Utils.o /tmp/oct-q88Nzd.o -shared -Wl,-Bsymbolic -Wl,-z,relro -flto=auto -ffat-lto-objects -Wl,-z,relro -g++ -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -o __levelset_internal_mesh.oct FastMarching.o Utils.o /tmp/oct-Gx1eHQ.o -shared -Wl,-Bsymbolic -Wl,-z,relro -flto=auto -ffat-lto-objects -Wl,-z,relro -g++ -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -o __levelset_geomGamma.oct FastMarching.o Utils.o /tmp/oct-NWxR4j.o -shared -Wl,-Bsymbolic -Wl,-z,relro -flto=auto -ffat-lto-objects -Wl,-z,relro +g++ -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -o __levelset_internal_init_narrowband.oct FastMarching.o Utils.o /tmp/oct-CxOYqI.o -shared -Wl,-Bsymbolic -Wl,-z,relro -flto=auto -ffat-lto-objects -Wl,-z,relro +g++ -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -o __levelset_upwindGrad.oct FastMarching.o Utils.o /tmp/oct-QJh1i5.o -shared -Wl,-Bsymbolic -Wl,-z,relro -flto=auto -ffat-lto-objects -Wl,-z,relro +g++ -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -o __levelset_internal_fastmarching.oct FastMarching.o Utils.o /tmp/oct-stzsm6.o -shared -Wl,-Bsymbolic -Wl,-z,relro -flto=auto -ffat-lto-objects -Wl,-z,relro +g++ -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -o __levelset_geomElements.oct FastMarching.o Utils.o /tmp/oct-iOTV3z.o -shared -Wl,-Bsymbolic -Wl,-z,relro -flto=auto -ffat-lto-objects -Wl,-z,relro +g++ -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -o __levelset_nbFromGeom.oct FastMarching.o Utils.o /tmp/oct-nYYt4u.o -shared -Wl,-Bsymbolic -Wl,-z,relro -flto=auto -ffat-lto-objects -Wl,-z,relro +g++ -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -o __levelset_geomBoundary.oct FastMarching.o Utils.o /tmp/oct-hLTEtc.o -shared -Wl,-Bsymbolic -Wl,-z,relro -flto=auto -ffat-lto-objects -Wl,-z,relro +g++ -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -o __levelset_geomGamma.oct FastMarching.o Utils.o /tmp/oct-4s8Eji.o -shared -Wl,-Bsymbolic -Wl,-z,relro -flto=auto -ffat-lto-objects -Wl,-z,relro +g++ -I/usr/include/octave-9.1.0/octave/.. -I/usr/include/octave-9.1.0/octave -pthread -fopenmp -mieee-fp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13=. -fstack-protector-strong -Wformat -Werror=format-security -o __levelset_internal_mesh.oct FastMarching.o Utils.o /tmp/oct-zPL2bm.o -shared -Wl,-Bsymbolic -Wl,-z,relro -flto=auto -ffat-lto-objects -Wl,-z,relro make[1]: Leaving directory '/build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/src' copyfile /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/./src/__levelset_geomBoundary.oct /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/./src/__levelset_geomElements.oct /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/./src/__levelset_geomGamma.oct /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/./src/__levelset_internal_fastmarching.oct /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/./src/__levelset_internal_init_narrowband.oct /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/./src/__levelset_internal_mesh.oct /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/./src/__levelset_nbFromGeom.oct /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/./src/__levelset_upwindGrad.oct /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/./inst/i686-pc-linux-gnu-api-v59 -octave-help-b3iPWA:150: missing @table argument -octave-help-b3iPWA:150: missing @table argument +octave-help-fCs0dv:150: missing @table argument +octave-help-fCs0dv:150: missing @table argument warning: doc_cache_create: unusable help text found in file 'ls_sign_colourmap' warning: called from doc_cache_create>handle_function at line 98 column 5 @@ -2925,10 +2961,10 @@ pkg at line 619 column 9 /usr/share/dh-octave/install-pkg.m at line 38 column 1 -octave-help-f8cuft:145: @code expected braces -octave-help-f8cuft:149: @code expected braces -octave-help-f8cuft:145: @code expected braces -octave-help-f8cuft:149: @code expected braces +octave-help-rPPpxb:145: @code expected braces +octave-help-rPPpxb:149: @code expected braces +octave-help-rPPpxb:145: @code expected braces +octave-help-rPPpxb:149: @code expected braces warning: doc_cache_create: unusable help text found in file 'so_example_problem' warning: called from doc_cache_create>handle_function at line 98 column 5 @@ -2946,374 +2982,326 @@ Checking package... Run the unit tests... Checking m files ... -[inst/fastmarching.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/fastmarching.m +[inst/upwind_gradient_norm.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/upwind_gradient_norm.m ***** error - fastmarching () -***** error - fastmarching (1, 2, 3, 4) + upwind_gradient_norm () +***** error + upwind_gradient_norm (1, 2, 3, 4) ***** error - [a, b] = fastmarching (1, 2) -***** error - fastmarching ([1, 2], [1; 2]) -***** error - fastmarching ([1, 2], [1; 2], [1, 2]) -***** error - fastmarching ([NA, 1], [0, 5]); + upwind_gradient_norm ([1, 1], [2, 2], [3, 3]) +***** error + upwind_gradient_norm ([1, 1], [2, 2, 2]) +***** error + upwind_gradient_norm ([1, 1], [2, 2, 2], 5) ***** test - n = 600; - x = linspace (0, 1, n); - h = x(2) - x(1); - [XX, YY] = meshgrid (x, x); - u0 = NA (n, n); - u0(2 : end - 1, 2 : end - 1) = Inf; - u0(1, 1) = 0; - f = 1 + YY; - u = fastmarching (u0, h * f); + phi = [0, 2, 3]; + fPos = ones (size (phi)); - % Length of vertical side: integrate (1 + y, y, 0, x) - vertLength = @(x) x/2 .* (x + 2); + % Propagate the original phi to the right. This should result + % in the *backward* difference to be used in the middle. + g = upwind_gradient_norm (phi); + assert (g(2), 2); + gp = upwind_gradient_norm (phi, fPos); + assert (gp, g); + gp = upwind_gradient_norm (phi, 0.5); + assert (gp, 2 * g); + gp = upwind_gradient_norm (phi, fPos, 0.5); + assert (gp, 2 * g); - % Speed difference at top and bottom, gives where the - % paths will meet on the bottom side. - % solve (x * fBot = fTop + (1 - x) * fBot, x) - fTop = mean (f(1, :)); - fBot = mean (f(end, :)); - xMeet = (fTop + fBot) / 2 / fBot; - botRow = vertLength (1) + fBot * x; - where = (x > xMeet); - botRow(where) = vertLength (1) + 1 + fBot * (1 - x(where)); + % Propagate to the left for the reverse effect. + g = upwind_gradient_norm (phi, -fPos); + assert (g(2), 1); - assert (u(1, :), x, sqrt (eps)); - assert (u(:, 1), vertLength (x'), 1e-3); - assert (u(:, end), 1 + vertLength (x'), 1e-3); - assert (u(end, :), botRow, 1e-3); + % Propagate -phi, which again turns everything around. + g = upwind_gradient_norm (-phi, fPos); + assert (g(2), 1); + g = upwind_gradient_norm (-phi, -fPos); + assert (g(2), 2); ***** test - n = 1100; - x = linspace (0, 1, n); + n = 50; + x = linspace (-1, 1, n); h = x(2) - x(1); + [XX, YY, ZZ] = ndgrid (x, x, x); - obst1 = round (0.5 / h); - obst2 = round (0.75 / h); - s1 = round (0.2 / h); - s1val = 1; - s2 = round (0.9 / h); - s2val = -1; - - u0 = NA (n, 1); - u0([obst1, obst2]) = Inf; - u0([s1, s2]) = [s1val, s2val]; - f = ones (size (u0)); - g0 = NA (size (u0)); - g0([s1, s2]) = [s1val, s2val]; - - [u, g] = fastmarching (u0, g0, f * h); - - gDesired = NA (size (u0)); - gDesired(1 : obst1 - 1) = s1val; - gDesired(obst2 + 1 : end) = s2val; - assert (g, gDesired, sqrt (eps)); - - uDesired = NA (size (u0)); - uDesired([obst1, obst2]) = Inf; - uDesired(1 : obst1 - 1) = s1val + abs (s1 * h - x(1 : obst1 - 1)); - uDesired(obst2 + 1 : end) = s2val + abs (s2 * h - x(obst2 + 1 : end)); - assert (u, uDesired, 1e-3); -***** test - assert (fastmarching ([], []), []); + phi = XX.^2 + YY.^2 + ZZ.^2; + g = upwind_gradient_norm (phi, h); + + r = sqrt (phi); + assert (g, 2 * r, 0.1); +7 tests, 7 passed, 0 known failure, 0 skipped +[inst/ls_time_step.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_time_step.m +***** error + ls_time_step (1, 2) +***** error + ls_time_step (1, 2, 3, 4, 5, 6) +***** error + ls_time_step (1, 2, 3, 4, [5, 5]) +***** error + ls_time_step ([1; 1], [2, 2], [3, 3, 3]) +***** error + ls_time_step ([1, 1], 1, [2, 2], [3, 3, 3]) +***** error + ls_time_step (ones (2, 2), 1, 1) ***** test - n = 42; - r = 1; - R = 2; - x = linspace (-R, R, n); + n = 100; + x = linspace (0, 1, n); h = x(2) - x(1); - [XX, YY, ZZ] = ndgrid (x); - RR = sqrt (XX.^2 + YY.^2 + ZZ.^2); - PPhi = NA (size (XX)); - for i = 1 : numel (PPhi) - pt = [XX(i), YY(i), ZZ(i)]; - PPhi(i) = acos (dot (pt, [0, 0, 1]) / norm (pt)); - endfor + phi0 = sin (x); + fPos = ones (size (phi0)); - initial = (RR < r); - u0 = NA (size (XX)); - u0(initial) = 0; - g0 = NA (size (XX)); - g0(initial) = PPhi(initial); - f = ones (size (u0)); - [u, g] = fastmarching (u0, g0, h * f); + % Single time step, moving exactly one grid step. + phit = ls_time_step (1, phi0, fPos); + assert (phit(2 : end), phi0(1 : end - 1)); - assert (u(~initial), RR(~initial) - r, 1e-1); - assert (g(~initial), PPhi(~initial), 2e-1); -***** function [dx, dy] = gradient (fcn, h) - ext = NA (size (fcn) + 2); - ext(2 : end - 1, 2 : end - 1) = fcn; - ext(:, 1) = 2 * ext(:, 2) - ext(:, 3); - ext(:, end) = 2 * ext(:, end - 1) - ext(:, end - 2); - ext(1, :) = 2 * ext(2, :) - ext(3, :); - ext(end, :) = 2 * ext(end - 1, :) - ext(end - 2, :); - dx = (ext(2 : end - 1, 3 : end) - ext(2 : end - 1, 1 : end - 2)) / (2 * h); - dy = (ext(3 : end, 2 : end - 1) - ext(1 : end - 2, 2 : end - 1)) / (2 * h); + % t = 1 should correspond to the previous result, and t = 2 + % shifts one more time step. However, due to boundary effects, + % we have to exclude some elements in the comparisons. + phitArr = ls_time_step ([1, 2], 0.5, phi0, fPos); + assert (size (phitArr), [2, 1]); + assert (phitArr{1}(3 : end), phit(3 : end), 1e-4); + assert (phitArr{2}(5 : end), phi0(3 : end - 2), 1e-4); + + % Try out movement in the other direction. + phit = ls_time_step (0.5, 0.1, phi0, -fPos, 0.5); + assert (phit(1 : end - 4), phi0(2 : end - 3), 1e-4); +***** function compareFastMarching (t, phi0, F, h, tol) + phit = ls_time_step (t, phi0, F, h); + d = ls_solve_stationary (phi0, F, h); + phit_fm = ls_extract_solution (t, d, phi0, F); + + sd1 = ls_signed_distance (phit, h); + sd2 = ls_signed_distance (phit_fm, h); + assert (sd1, sd2, tol); ***** endfunction ***** test - n = 1000; - x = linspace (-2, 2, n); + warning ("off", "level-set:fast-marching:too-far-alive"); + + n = 100; + x = linspace (-5, 5, n); h = x(2) - x(1); [XX, YY] = meshgrid (x, x); - phi0 = 2 * XX.^2 + 0.4 * YY.^2 - 1; - initial = (phi0 < 0); - %contour (XX, YY, phi0, [0, 0], "r"); - - f = ones (size (XX)); - u0 = NA (size (XX)); - u0(initial) = 0; - g0 = NA (size (XX)); - g0(initial) = sin (atan2 (YY(initial), XX(initial))); - - [u, g] = fastmarching (u0, g0, h * f); + phi0 = ls_genbasic (XX, YY, "sphere", [0, 0], [3, 1.5]); + F = ones (size (phi0)); + compareFastMarching (0.5, phi0, F, h, h / 2); + compareFastMarching (1.5, phi0, F, h, h / 2); - [dxu, dyu] = gradient (u, h); - [dxg, dyg] = gradient (g, h); + phi0 = ls_genbasic (XX, YY, "box", [-3, -3], [3, 3]); + F = YY / 5; + compareFastMarching (1, phi0, F, h, h); - % We only verify the mean error here, since there tend - % to be lower-dimensional lines on which the error is - % large while it is very low otherwise. - err = abs (dxu .* dxg + dyu .* dyg); - assert (mean (err(initial)), 0, 1e-3); -***** test - u0 = [1.257221, NA, NA; Inf, 0.275128, 0.433001]; - f = [NA, 0.85714, 0.66667; NA, NA, NA]; - u = fastmarching (u0, f); -warning: increased distance in fast marching 1.121446 to 1.131670 -warning: called from - fastmarching at line 110 column 19 - __test__ at line 5 column 5 - test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 14 column 31 + F = ones (size (phi0)); + compareFastMarching (1, phi0, F, h, h / 2); + phi0 = ls_genbasic (XX, YY, "sphere", [0, 0], 3); + F = sin (XX .* YY); + compareFastMarching (1, phi0, F, h, h); ***** test - u0 = [0, NA; Inf, 2]; - f = ones (size (u0)); - u = fastmarching (u0, f); - assert (u(1, 2), 1, sqrt (eps)); -warning: found too far alive point in fast marching, d = -8.000000 -warning: called from - fastmarching at line 110 column 19 - __test__ at line 5 column 5 - test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 14 column 31 - -warning: found too far alive point in fast marching, d = -8.000000 -warning: called from - fastmarching at line 110 column 19 - __test__ at line 5 column 5 - test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 14 column 31 + warning ("off", "level-set:fast-marching:increased-distance"); -***** test - u0 = [0, NA, NA, NA, 0.1; ... - Inf, Inf, Inf, Inf, Inf; ... - 0.1, NA, NA, NA, 0]; - f = ones (size (u0)); - u = fastmarching (u0, f); + n = 50; + x = linspace (-5, 5, n); + h = x(2) - x(1); + [XX, YY, ZZ] = ndgrid (x, x, x); - uExpected = [0, 1, 2, 1.1, 0.1; ... - Inf, Inf, Inf, Inf, Inf; ... - 0.1, 1.1, 2, 1, 0]; - assert (u, uExpected, sqrt (eps)); -***** xtest - ns = [101, 201, 501, 1001, 2001]; - realNs = NA (size (ns)); - times = NA (size (ns)); - for i = 1 : length (ns) - nMid = (ns(i) + 1) / 2; - assert (nMid, round (nMid)); - u0 = NA (ns(i), ns(i)); - u0(nMid, nMid) = 0; - f = ones (size (u0)); - realNs(i) = numel (u0); + phi0 = ls_genbasic (XX, YY, ZZ, "sphere", [0, 0, 0], 3); + F = ones (size (phi0)); + compareFastMarching (1, phi0, F, h, h / 2); + compareFastMarching (1, phi0, -F, h, h / 2); +***** demo + n = 500; + x = linspace (-5, 5, n); + h = x(2) - x(1); + [XX, YY] = meshgrid (x, x); - old = cputime (); - u = fastmarching (u0, f); - new = cputime (); - times(i) = new - old; + F = sin (XX .* YY); + phi0 = ls_genbasic (XX, YY, "sphere", [0, 0], 3); + phit = ls_time_step ([0.5, 1], phi0, F, h); - printf ("n = %4d: t = %6.3f s\n", ns(i), times(i)); - endfor + figure (); + hold ("on"); + imagesc (x, x, F); + axis ("equal"); + set (gca (), "ydir", "normal"); + ls_sign_colourmap (); + contour (XX, YY, phi0, [0, 0], "k", "LineWidth", 2); + contour (XX, YY, phit{1}, [0, 0], "k", "LineWidth", 2); + contour (XX, YY, phit{2}, [0, 0], "k", "LineWidth", 2); + hold ("off"); +9 tests, 9 passed, 0 known failure, 0 skipped +[inst/ls_normalise.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_normalise.m +***** error + ls_normalise () +***** error + ls_normalise (1, 2, 3, 4) +***** test + h = 0.1; + zeroTol = 0.2; + phi = ones (4, 4); + phiEx = phi; + phi(2 : 3, 2 : 3) = [-eps, -0; 0, eps]; + phiEx(2 : 3, 2 : 3) = [-zeroTol*h, -zeroTol*h; zeroTol*h, zeroTol*h]; + phin = ls_normalise (phi, h, zeroTol); + if (exist ("signbit") == 5) + assert (phin, phiEx); + else + warning ("'signbit' function not available, skipping test."); + endif +3 tests, 3 passed, 0 known failure, 0 skipped +[inst/ls_sign_colourmap.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_sign_colourmap.m +***** shared colours + colours = [1, 1, 1; 0, 0, 0; 1, 1, 1; 0, 0, 0]; +***** error + ls_sign_colourmap (1, 2); +***** error + ls_sign_colourmap (1); +***** error + cmap = ls_sign_colourmap (); +***** error + ls_sign_colourmap ("foo"); +***** test + figure (); + ls_sign_colourmap (); + ls_sign_colourmap ("highlight"); + ls_sign_colourmap (colours); + close (); +warning: using the gnuplot graphics toolkit is discouraged - nLogN = realNs .* log (realNs); - p = polyfit (log (realNs), log (times), 1); - pLogN = polyfit (log(nLogN), log (times), 1); - printf ("Exponents:\n O(n): %4.2f\n O(n log n): %4.2f\n", ... - p(1), pLogN(1)); - assert (p(1), 1, 1e-1); - assert (pLogN(1), 1, 1e-1); -n = 101: t = 0.039 s -n = 201: t = 0.161 s -n = 501: t = 1.048 s -n = 1001: t = 4.421 s -n = 2001: t = 18.803 s -Exponents: - O(n): 1.03 - O(n log n): 0.95 +The gnuplot graphics toolkit is not actively maintained and has a number +of limitations that are unlikely to be fixed. Communication with gnuplot +uses a one-directional pipe and limited information is passed back to the +Octave interpreter so most changes made interactively in the plot window +will not be reflected in the graphics properties managed by Octave. For +example, if the plot window is closed with a mouse click, Octave will not +be notified and will not update its internal list of open figure windows. +The qt toolkit is recommended instead. +***** error + ls_sign_colourmap (1, 2, 3); +***** error + ls_sign_colourmap ([1, 2, 3]); +***** error + ls_sign_colourmap ([1, 2], 1); +***** error + ls_sign_colourmap ([1, 2], "foo"); ***** test - T = 1.6; - timeSteps = 10000; - L = 2; - gridSteps = 10000; - eps = 1e-4; - floorValue = -1/2; - tol = 7e-2; - - t = linspace (0, T, timeSteps); - dt = t(2) - t(1); - x = linspace (-L/2, L/2, gridSteps); - h = x(2) - x(1); - - F = sqrt (abs (x)); - phi0 = NA (size (x)); - phi0(1 : end/4) = floorValue; - phi0(3*end/4 : end) = floorValue; - phi0 = fastmarching (phi0, h ./ F); - - % Plot the speed field and initial data. - %{ + cmap = ls_sign_colourmap ([1, 2]); + cmap = ls_sign_colourmap ([1; 2], "highlight"); + cmap = ls_sign_colourmap ([1; 2], colours); +***** demo + n = 100; + x = linspace (-2, 2, n); + y = linspace (-1, 3, n); + [XX, YY] = meshgrid (x, y); + phi = ls_genbasic (XX, YY, "sphere", [0, 1], 1); + figure (); - plot (x, F, "r", x, phi0, "k"); - legend ("F", "\\phi_0"); - title ("Speed Field and Initial Data"); - ax = [-L/2, L/2, -1, 1]; - axis (ax); - %} - - % Create the Laplacian as matrix. We assume homogeneous Neumann boundary - % conditions so that the initial data can be chosen as we like. - Delta = spdiags (repmat ([1, -2, 1], gridSteps, 1), [-1, 0, 1], ... - gridSteps, gridSteps); - Delta(1, 1) += Delta(1, 2); - Delta(end, end) += Delta(end - 1, end); - Delta /= h^2; - - % Perform the calculation. The Laplacian is done implicitly, the - % non-linear term explicitly: - % - % phi+ - phi0 = dt (eps Delta phi+ - F |grad phi0|) - % => (I - dt eps Delta) phi+ = phi0 - F |grad phi0| - - %figure (); - phi = phi0'; - M = eye (gridSteps) - dt * eps * Delta; - for tInd = 2 : timeSteps - - % Calculate derivatives as symmetric differences, and zero on the - % boundary. Since the data is flat there, this is correct. - d = NA (size (phi)); - low = 1 : gridSteps - 2; - mid = 2 : gridSteps - 1; - high = 3 : gridSteps; - d(mid) = (phi(high) - phi(low)) / (2 * h); - d([1, end]) = 0; - gradNorm = abs (d); - - % Do the solve. - phi = M \ (phi - dt * F' .* gradNorm); - phiEx = max (phi0 - t(tInd), floorValue); - assert (phi, phiEx', tol); - - % Show solution as animation in real time. - %{ - if (mod (tInd, 100) == 0) - plot (x, phi, "r", x, phiEx, "k"); - legend ("Approximate", "Exact"); - axis (ax); - title (sprintf ("t = %.2f", t(tInd))); - drawnow (); - %pause (0.1); - endif - %} - endfor + imagesc (x, y, phi); + set (gca (), "ydir", "normal"); + ls_sign_colourmap (); + colorbar (); + title ("Type 'sign'"); ***** demo n = 100; - x = linspace (-1, 1, n); + x = linspace (-2, 2, n); h = x(2) - x(1); [XX, YY] = meshgrid (x, x); - u0 = NA (size (XX)); - u0(sqrt (XX.^2 + YY.^2) < 0.5) = Inf; - u0(end, :) = 0; - f = 3 + XX; - g0 = NA (size (XX)); - g0(end, :) = x; - - [u, g] = fastmarching (u0, g0, h * f); + phi = ls_genbasic (XX, YY, "sphere", [0, 0], 1); + d = ls_signed_distance (phi, h); + F = YY .* exp (-10 * d.^2); figure (); - subplot (2, 2, 1); - imagesc (f); - colorbar (); - title ("Speed Field"); - subplot (2, 2, 2); - imagesc (u0); - colorbar (); - title ("Initial Distances"); - subplot (2, 2, 3); - imagesc (u); - colorbar (); - title ("Distance u"); - subplot (2, 2, 4); - imagesc (g); + hold ("on"); + imagesc (x, x, F); + set (gca (), "ydir", "normal"); + ls_sign_colourmap ("highlight"); colorbar (); - title ("Extended Function g"); -***** demo - pkgs = pkg ("list"); - file = false; - for i = 1 : length (pkgs) - if (strcmp (pkgs{i}.name, "level-set")) - file = fullfile (pkgs{i}.dir, "maze.png"); - endif - endfor - if (!file) - error ("could not locate example image file"); - endif - img = double (imread (file)) / 255; + contour (XX, YY, phi, [0, 0], "k", "LineWidth", 2); + hold ("off"); + title ("Type 'highlight'"); +10 tests, 10 passed, 0 known failure, 0 skipped +[inst/ls_disjoint.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_disjoint.m +***** error + ls_disjoint () +***** error + ls_disjoint (1, -2, [1, 2]) +***** test + assert (ls_disjoint ([-1, 0, 1], [0, 0, 0], [1, 0, -1])); + assert (~ls_disjoint ([Inf, -Inf, 1], [-1, -1, 1])); + assert (~ls_disjoint ([-1, -1, 1], [0, 0, 0], [1, -1, -1])); +***** test + n = 50; + x = linspace (-10, 10, n); + [XX, YY] = meshgrid (x, x); - % Red is the start area, white (not black) the accessible domain. - start = (img(:, :, 1) > img(:, :, 2) + img(:, :, 3)); - domain = (img(:, :, 2) + img(:, :, 3) > 1.0) | start; + phi1 = (XX - 2).^2 + (YY - 2).^2 - 2^2; + phi2 = (XX + 2).^2 + (YY + 2).^2 - 2^2; + phi3 = XX.^2 + YY.^2 - 2^2; - u0 = NA (size (domain)); - u0(start) = 0; - u0(~domain) = Inf; - f = ones (size (u0)); + assert (ls_disjoint (phi1, phi2)); + assert (~ls_disjoint (phi1, phi3)); + assert (~ls_disjoint (phi2, phi3)); + assert (~ls_disjoint (phi1, phi2, phi3)); +4 tests, 4 passed, 0 known failure, 0 skipped +[inst/ls_intersect.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_intersect.m +***** error + ls_intersect () +***** error + ls_intersect (1, -2, [1, 2]) +***** test + n = 50; + x = linspace (-10, 10, n); + [XX, YY] = meshgrid (x, x); - u = fastmarching (u0, f); - u = u / max (u(isfinite (u))); + phi1 = (XX - 2).^2 + (YY - 2).^2 - 2^2; + phi2 = (XX + 2).^2 + (YY + 2).^2 - 2^2; + phi3 = XX.^2 + YY.^2 - 2^2; + + assert (ls_isempty (ls_intersect (phi1, phi2))); + assert (ls_intersect (phi3), phi3); + + phi = ls_intersect (phi1, phi3); + assert (~ls_isempty (phi)); + assert (ls_issubset (phi, phi1) && ls_issubset (phi, phi3)); + + phi = ls_intersect (phi2, phi3); + assert (~ls_isempty (phi)); + assert (ls_issubset (phi, phi2) && ls_issubset (phi, phi3)); +***** demo + n = 100; + x = linspace (-7, 7, n); + [XX, YY] = meshgrid (x, x); + + phi1 = (XX - 2 * cos (7/6 * pi)).^2 + (YY - 2 * sin (7/6 * pi)).^2 - 3^2; + phi2 = (XX - 2 * cos (11/6 * pi)).^2 + (YY - 2 * sin (11/6 * pi)).^2 - 3^2; + phi3 = XX.^2 + (YY - 2).^2 - 3^2; + phi = ls_intersect (phi1, phi2, phi3); - % Format result as image. - walls = isinf (u); - notReached = isna (u); - ur = u; - ug = u; - ub = u; - ur(notReached) = 1; - ug(notReached) = 0; - ub(notReached) = 0; - ur(walls) = 0; - ug(walls) = 0; - ub(walls) = 1; - ur(start) = 1; - ug(start) = 1; - ub(start) = 0; - u = NA (size (u, 1), size (u, 2), 3); - u(:, :, 1) = ur; - u(:, :, 2) = ug; - u(:, :, 3) = ub; figure (); - imshow (u); - title ("Solved Maze. Blue: Walls, Red: Unreachable, Yellow: Start."); -16 tests, 16 passed, 0 known failure, 0 skipped + subplot (1, 2, 1); + hold ("on"); + contour (XX, YY, phi1, [0, 0], "k"); + contour (XX, YY, phi2, [0, 0], "k"); + contour (XX, YY, phi3, [0, 0], "k"); + hold ("off"); + axis ("equal"); + + subplot (1, 2, 2); + hold ("on"); + imagesc (x, x, phi); + set (gca (), "ydir", "normal"); + ls_sign_colourmap (); + contour (XX, YY, phi, [0, 0], "k"); + hold ("off"); + axis ("equal"); +3 tests, 3 passed, 0 known failure, 0 skipped [inst/ls_build_mesh.m] >>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_build_mesh.m ***** error @@ -3420,406 +3408,32 @@ axis ("equal"); axis ("square"); 4 tests, 4 passed, 0 known failure, 0 skipped -[inst/ls_setdiff.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_setdiff.m +[inst/ls_nb_from_geom.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_nb_from_geom.m ***** error - ls_setdiff (1) -***** error - ls_setdiff (1, 2, 3) -***** error - ls_setdiff (1, [1, 2]) -***** test - assert (ls_equal (ls_setdiff ([-1, -1, 1], [1, -1, -1]), [-1, 1, 1])); - n = 50; - x = linspace (-10, 10, n); - h = x(2) - x(1); - [XX, YY] = meshgrid (x, x); - - phi1 = XX.^2 + YY.^2 - 8^2; - phi2 = XX.^2 + YY.^2 - 5^2; - - phi = ls_setdiff (phi1, phi2); - assert (ls_issubset (phi, phi1)); - assert (ls_disjoint (phi, phi2)); - - phi = ls_setdiff (phi2, phi1); - assert (ls_isempty (phi)); -***** demo - n = 100; - x = linspace (-7, 7, n); - [XX, YY] = meshgrid (x, x); - - phi1 = (XX - 2).^2 + YY.^2 - 3^2; - phi2 = (XX + 2).^2 + YY.^2 - 3^2; - phi = ls_setdiff (phi1, phi2); - - figure (); - subplot (1, 2, 1); - hold ("on"); - contour (XX, YY, phi1, [0, 0], "k"); - contour (XX, YY, phi2, [0, 0], "k"); - hold ("off"); - axis ("equal"); - - subplot (1, 2, 2); - hold ("on"); - imagesc (x, x, phi); - set (gca (), "ydir", "normal"); - ls_sign_colourmap (); - contour (XX, YY, phi, [0, 0], "k"); - hold ("off"); - axis ("equal"); -***** demo - n = 100; - x = linspace (-7, 7, n); - [XX, YY] = meshgrid (x, x); - - phi1 = XX.^2 + YY.^2 - 6^2; - phi2 = XX.^2 + YY.^2 - 3^2; - phi = ls_setdiff (phi1, phi2); - - figure (); - subplot (1, 2, 1); - hold ("on"); - contour (XX, YY, phi1, [0, 0], "k"); - contour (XX, YY, phi2, [0, 0], "k"); - hold ("off"); - axis ("equal"); - - subplot (1, 2, 2); - hold ("on"); - imagesc (x, x, phi); - set (gca (), "ydir", "normal"); - ls_sign_colourmap (); - contour (XX, YY, phi, [0, 0], "k"); - hold ("off"); - axis ("equal"); -4 tests, 4 passed, 0 known failure, 0 skipped -[inst/ls_solve_stationary.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_solve_stationary.m + ls_nb_from_geom (1) +***** error + ls_nb_from_geom (1, 2, 3, 4) ***** error - ls_solve_stationary (1) -***** error - ls_solve_stationary (1, 2, 3, 4, 5) -***** error - ls_solve_stationary ([1, 2], [3; 4]); -***** error - ls_solve_stationary ([1, 2], [1, 2], :, [3; 4]); -***** test - assert (ls_solve_stationary ([], []), []); -***** function checkOutput (phi, f, d) - assert (all (isna (d(f == 0)))); - where = (f ~= 0); - assert (all (isfinite (d(where)) | isinf (d(where)))); - assert (sign (d(where)), sign (phi(where))); -***** endfunction -***** test - phis = ls_get_tests (); - for i = 1 : length (phis) - f = ones (size (phis{i})); - for j = -1 : 1 - phi = ls_normalise (phis{i}); - d = ls_solve_stationary (phi, j * f); - checkOutput (phi, j * f, d); - endfor - endfor -***** test - n = 101; - x = linspace (-10, 10, n); - h = x(2) - x(1); - [XX, YY] = meshgrid (x, x); - - r1 = (XX - 5).^2 + YY.^2; - r2 = (XX + 5).^2 + YY.^2; - - phi = ls_union (r1 - 2^2, r2 - 2^2); - f1 = max (r1 - 3^2, 1^2 - r1); - f2 = max (r2 - 3^2, 1^2 - r2); - f = min (f1, f2) .* sign (XX); - assert (~all (f(:) ~= 0)); - - d = ls_solve_stationary (phi, f, h); - - checkOutput (phi, f, d); - where = (f ~= 0); - assert (any (isinf (d(where)))); - - %{ - contour (phi, [0, 0]); - colorbar (); - figure (); - imagesc (f); - colorbar (); - figure (); - imagesc (d); - colorbar (); - %} -***** test - phi = [3, 1, -1, 1, 3]; - f = ones (size (phi)); - dists1 = ls_solve_stationary (phi, f); - dists2 = ls_solve_stationary (phi, f, :, [NA, NA, -0.1, NA, NA]); - - assert (dists1, [1.5, 0.5, -0.5, 0.5, 1.5], sqrt (eps)); - assert (dists2, [1.9, 0.9, -0.1, 0.9, 1.9]); -***** demo - n = 100; - x = linspace (-10, 10, n); - h = x(2) - x(1); - [XX, YY] = meshgrid (x, x); - - phi0 = YY - XX + 15; - f = sign (XX) + 2; - - d = ls_solve_stationary (phi0, f, h); - figure (); - contour (XX, YY, d); - line ([0, 0], [-10, 10]); - title ("Refraction"); -***** demo - n = 101; - x = linspace (-10, 10, n); + [a, b] = ls_nb_from_geom (1, 2); +***** error + ls_nb_from_geom (1, 2, rand (2, 2)); +***** error + x = linspace (-10, 10, 10); h = x(2) - x(1); [XX, YY] = meshgrid (x, x); - - phi0 = XX + 9; - f = ones (size (phi0)); - f(XX == 0 & abs (YY) > 2) = 0; - - d = ls_solve_stationary (phi0, f, h); - figure (); - contour (XX, YY, d); - line ([0, 0], [-10, -2]); - line ([0, 0], [2, 10]); - title ("Diffraction"); -8 tests, 8 passed, 0 known failure, 0 skipped -[inst/ls_signed_distance.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_signed_distance.m -***** error - ls_signed_distance () -***** error - ls_signed_distance (1, 2, 3) -***** test - assert (ls_signed_distance ([]), []); -***** test - n = 10; - x = linspace (-2, 2, n); - h = x(2) - x(1); - phi = abs (x) - 1; - - d = ls_signed_distance (phi, h); - assert (d, phi, sqrt (eps)); -***** test - n = 50; - x = linspace (-2, 2, n); - h = x(2) - x(1); - [XX, YY, ZZ] = ndgrid (x); - RRsq = XX.^2 + YY.^2 + ZZ.^2; - phi = RRsq - 1; - - d = ls_signed_distance (phi, h); - assert (d, sqrt (RRsq) - 1, h); -***** test - phi = [5e-6, 1.7e-154, -1.3e-2]; - for h = [0.02, 0.01, 0.005] - d = ls_signed_distance (phi, h); - assert (all (isfinite (d))); - assert (d(2), 0); - endfor -***** test - phis = ls_get_tests (); - for i = 1 : length (phis) - phi = ls_normalise (phis{i}); - d = ls_signed_distance (phi); - assert (ls_equal (d, phi)); - endfor -***** test - if (exist ("signbit") == 5) - phi = [-0, 0]; - d = ls_signed_distance (phi); - assert (ls_equal (phi, d)); - else - warning ("'signbit' function not available, skipping test."); - endif -***** demo - n = 100; - x = linspace (-10, 10, n); + phi = ls_genbasic (XX, YY, "sphere", [0, 0], 5); + phi = ls_normalise (phi, h); + geom = ls_find_geometry (phi, h); + ls_nb_from_geom (geom, phi); +***** error + x = linspace (-10, 10, 10); h = x(2) - x(1); [XX, YY] = meshgrid (x, x); - - phi0 = atan (ls_union ((XX.^2 + (YY - 5).^2) - 20, ... - (XX.^2 + (YY + 5).^2) - 20)); - %phi0 = XX.^2 / 1.3^2 + YY.^2 - 1; - d = ls_signed_distance (phi0, h); - - figure (); - subplot (1, 2, 1); - contour (XX, YY, phi0); - title ("Initial"); - colorbar (); - axis ("equal"); - - subplot (1, 2, 2); - contour (XX, YY, d); - title ("Signed Distance"); - colorbar (); - axis ("equal"); -8 tests, 8 passed, 0 known failure, 0 skipped -[inst/so_save_descent.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/so_save_descent.m -***** error - so_save_descent (1, 2); -***** error - so_save_descent (1, 2, 3, 4); -***** error - so_save_descent (1, 2, 3); -***** error - so_save_descent (struct (), 2, struct ()); -***** error - so_save_descent ([2, 3], 2, struct ()); -***** error <'fsave' is not available> - pkg unload -nodeps parallel; - so_save_descent ("foo", 2, struct ()); -***** test - pkg load parallel; - so_save_descent ("foo", 2, struct ()); - so_save_descent (5, 2, struct ()); -7 tests, 7 passed, 0 known failure, 0 skipped -[inst/ls_find_geometry.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_find_geometry.m -***** error - ls_find_geometry () -***** error - ls_find_geometry (1, 2, 3, 4) -***** error - ls_find_geometry (resize (zeros (8, 1), [2, 2, 2])) -***** error - ls_find_geometry ([1, -1, 1]) -***** error - ls_find_geometry ([0, 1; -1, -1]) -***** error - ls_find_geometry ([-1, NA; -1, -1]) -***** function verifyGeometry (phi, geom) - sz = size (phi); - nNode = prod (sz); - L = sz(1); - M = sz(2); - nElem = (L - 1) * (M - 1); - assert (geom.dim, sz); - - % Basic properties of the elem field. - assert (geom.elem.n, nElem); - assert (size (geom.elem.nodelist), [nElem, 4]); - assert (all (geom.elem.type(geom.elem.index.inner) == -1)); - assert (all ((geom.elem.type(geom.elem.index.bdry) == 0))); - assert (all ((geom.elem.type(geom.elem.index.outer) == 1))); - % Order of the nodes in nodelist. - assert (geom.elem.nodelist(1, :), [L+2, 2, 1, L+1]); - % Correct classification of inner/outer/bdry elements. - assert (all (phi(geom.elem.nodelist(geom.elem.index.inner, :))(:) < 0)); - assert (all (phi(geom.elem.nodelist(geom.elem.index.outer, :))(:) > 0)); - bdryPhis = phi(geom.elem.nodelist(geom.elem.index.bdry, :)); - bdryPhis = sort (bdryPhis, 2); - assert (all (bdryPhis(:, 1) < 0) && all (bdryPhis(:, end) > 0)); - - % Each boundary element should have two or four intersected edges. - % Also verify that the start/endEdge fields of the internal information - % match up to the points in question. - for i = 1 : geom.bdryel.n - empty = length (find (isna (geom.bdryel.edges(i, :)))); - assert (empty == 2 || empty == 0); - for j = 1 : length (geom.internal.bdryelSegments{i}) - s = geom.internal.bdryelSegments{i}{j}; - assert (geom.bdryel.edges(i, s.startEdge) == s.startPt); - assert (geom.bdryel.edges(i, s.endEdge) == s.endPt); - endfor - endfor - - % Run through gamma components and verify that geom.ispts.onedge matches. - for i = 1 : geom.gamma.n - c = geom.gamma.ispts{i}; - c(end + 1) = c(1); - for j = 1 : length (c) - 1 - cur = c(j); - next = c(j + 1); - bdryel = geom.ispts.onedge(cur, 1, 1); - assert (geom.ispts.onedge(next, 2, 1), bdryel); - assert (geom.bdryel.edges(bdryel, geom.ispts.onedge(cur, 1, 2)), cur); - assert (geom.bdryel.edges(bdryel, geom.ispts.onedge(next, 2, 2)), next); - - edgeForward = geom.ispts.onedge(cur, 1, 3); - assert (geom.bedges.ispts(edgeForward, 1), cur); - assert (geom.bedges.ispts(edgeForward, 2), next); - - assert (geom.ispts.gammachain(cur, 1), next); - assert (geom.ispts.gammachain(next, 2), cur); - endfor - endfor - - % Verify that the ordering of points in bedges matches the onedge - % information about start / end points in each boundary element. - for i = 1 : geom.bedges.n - assert (geom.ispts.onedge(geom.bedges.ispts(i, 1), 1, 1), ... - geom.ispts.onedge(geom.bedges.ispts(i, 2), 2, 1)); - assert (geom.ispts.onedge(geom.bedges.ispts(i, 1), 1, 3), i); - assert (geom.ispts.onedge(geom.bedges.ispts(i, 2), 2, 3), i); - endfor -***** endfunction -***** test - phis = ls_get_tests (); - hs = [0.1, 0.5, 1, 1.5]; - for i = 1 : length (phis) - for h = hs - for s = [-1, 1] - cur = phis{i} * s; - phi = ls_normalise (cur, h); - geom = ls_find_geometry (phi, h); - verifyGeometry (phi, geom); - endfor - endfor - endfor -***** test - phi = ones (4, 4); - phi(2 : 3, 2 : 3) = [Inf, -1; -Inf, 2]; - g = ls_find_geometry (phi, 0.1, 0.01); - - ind = find (g.elem.index.bdry == 5); - assert (size (ind), [1, 1]); - edges = g.bdryel.edges(ind, :); - assert (all (~isna (edges))); - - assert (g.ispts.inout(edges, :), [7, 11; 7, 6; 10, 6; 10, 11]); - assert (g.ispts.frac(edges), [0.99; 0.5; 0.01; 1/3], sqrt (eps)); - assert (g.ispts.incoord(edges, :), ... - [0.099, 0; 0, -0.05; -0.001, 0; 0, 1/30], sqrt (eps)); -***** error - phi = [-1, -1; 1, 1]; - ls_find_geometry (phi); -***** test - phi = ones (3, 3); - phi(2, 2) = -1; - geom = ls_find_geometry (phi); - - % Permute the component array such that it starts with the north point - % and then compare coordinates. Note that the "north" point is "south" - % in matrix interpretation and thus has "outindex" of 6. - assert (geom.gamma.n, 1); - c = geom.gamma.ispts{1}'; - while (geom.ispts.inout(c(1), 2) != 6) - c = [c(2 : end), c(1)]; - endwhile - assert (geom.ispts.incoord(c, :), ... - [0, 1/2; -1/2, 0; 0, -1/2; 1/2, 0], sqrt (eps)); -***** function checkBoundaryDirection (pts, dir) - pts(end + 1, :) = pts(1, :); - for i = 1 : length (pts) - 1 - a = [pts(i, :), 0]; - b = [pts(i + 1, :), 0]; - z = cross (a, b); - assert (z(1 : 2), [0, 0]); - assert (sign (z(3)), dir); - endfor -***** endfunction + phi = ls_genbasic (XX, YY, "sphere", [0, 0], 5); + phi = ls_normalise (phi, h); + geom = ls_find_geometry (phi, h); + ls_nb_from_geom (geom, phi, [1, 2, 3]); ***** test n = 50; x = linspace (-10, 10, n); @@ -3827,343 +3441,48 @@ [XX, YY] = meshgrid (x, x); phi = ls_setdiff (ls_genbasic (XX, YY, "sphere", [0, 0], 8), ... - ls_genbasic (XX, YY, "sphere", [0, 0], 4)); + ls_genbasic (XX, YY, "sphere", [1, 1], 5)); phi = ls_normalise (phi, h); geom = ls_find_geometry (phi, h); geom = ls_absolute_geom (geom, XX, YY); - assert (geom.gamma.n, 2); - len1 = length (geom.gamma.ispts{1}); - len2 = length (geom.gamma.ispts{2}); - if (len1 < len2) - outer = geom.gamma.ispts{2}; - inner = geom.gamma.ispts{1}; - else - assert (len1 > len2); - outer = geom.gamma.ispts{1}; - inner = geom.gamma.ispts{2}; - endif - - checkBoundaryDirection (geom.ispts.coord(outer, :), 1); - checkBoundaryDirection (geom.ispts.coord(inner, :), -1); -***** test - phi = ones (4, 4); - phi(2, 2) = -1; - phi(3, 3) = -1; - - geom = ls_find_geometry (phi); - assert (geom.gamma.n, 2); - geom = ls_find_geometry (-phi); - assert (geom.gamma.n, 1); + dOld = ls_init_narrowband (phi, h); + dNew = ls_nb_from_geom (geom, phi); - % Now also try with other "kind" of narrow pair. - phi = phi(:, end : -1 : 1); - geom = ls_find_geometry (phi); - assert (geom.gamma.n, 2); - geom = ls_find_geometry (-phi); - assert (geom.gamma.n, 1); + where = (!isna (dOld)); + assert (all (!isna (dNew(where)))); + assert (dNew(where), dOld(where), h / 4); ***** demo - n = 15; + n = 50; x = linspace (-10, 10, n); h = x(2) - x(1); [XX, YY] = meshgrid (x, x); - r1 = sqrt (2) * 2.9; - r2 = 3; - phi = ls_union (ls_genbasic (XX, YY, "sphere", [-3, -3], r1), ... - ls_genbasic (XX, YY, "sphere", [3, 3], r1), ... - ls_genbasic (XX, YY, "sphere", [-5, 5], r2), ... - ls_genbasic (XX, YY, "sphere", [5, -5], r2)); - + phi = ls_genbasic (XX, YY, "sphere", [0, 0], 3); phi = ls_normalise (phi, h); - g = ls_find_geometry (phi, h, 0.2); - g = ls_absolute_geom (g, XX, YY); - - figure (); - hold ("on"); - - for i = 1 : size (g.elem.nodelist, 1) - nodes = g.elem.nodelist(i, :); - switch (g.elem.type(i)) - case -1 - colour = [0.5, 0.5, 1]; - case 0 - colour = [1, 0.5, 0.5]; - case 1 - colour = [0.8, 0.8, 0.8]; - endswitch - patch (XX(nodes), YY(nodes), colour); - endfor + geom = ls_find_geometry (phi, h); + geom = ls_absolute_geom (geom, XX, YY); - plot (g.ispts.coord(:, 1), g.ispts.coord(:, 2), "k.", "MarkerSize", 8); - for i = 1 : g.gamma.n - pts = g.gamma.ispts{i}; - pts(end + 1) = pts(1); - plot (g.ispts.coord(pts, 1), g.ispts.coord(pts, 2), "k-", "LineWidth", 2); + g0 = NA (1, geom.bedges.n); + for i = 1 : geom.bedges.n + a = geom.ispts.coord(geom.bedges.ispts(i, 1), :); + b = geom.ispts.coord(geom.bedges.ispts(i, 2), :); + m = (a + b) / 2; + angle = abs (atan2 (m(2), m(1))); + g0(i) = min (angle, 2 * pi - angle); endfor - contour (XX, YY, phi, [0, 0], "g"); - - axis ([min(x), max(x), min(x), max(x)]); - axis ("equal"); - grid ("on"); - set (gca (), "xtick", x, "ytick", x, "xticklabel", "", "yticklabel", ""); - hold ("off"); -12 tests, 12 passed, 0 known failure, 0 skipped -[inst/ls_hausdorff_dist.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_hausdorff_dist.m -***** error - ls_hausdorff_dist (1) -***** error - ls_hausdorff_dist (1, 2, 3, 4) -***** error - ls_hausdorff_dist (1, 2, [3, 3]) -***** error - ls_hausdorff_dist (1, 2, "foo") -***** test - n = 50; - x = linspace (-5, 5, n); - h = x(2) - x(1); - [XX, YY] = meshgrid (x, x); - - phi1 = ls_genbasic (XX, YY, "sphere", [3, 0], 1); - phi2 = ls_genbasic (XX, YY, "sphere", [-2, 0], 2); - assert (ls_hausdorff_dist (phi1, phi2, h), 6, h); - - % Make sure that phi isn't a signed-distance fcn already. - % ls_genbasic should return the same, but make it explicit. - rSq = XX.^2 + YY.^2; - d = ls_hausdorff_dist (rSq - 4^2, rSq - 2^2, h); - assert (d, 2, h); - dWrong = ls_hausdorff_dist (rSq - 4^2, rSq - 2^2, "sd"); - assert (abs (d - dWrong) > 10 * h); - dRight = ls_hausdorff_dist (sqrt (rSq) - 4, sqrt (rSq) - 2, "sd"); - assert (dRight, d, h); -***** test - n = 200; - x = linspace (-5, 5, n); - h = x(2) - x(1); - [XX, YY] = meshgrid (x, x); - - phiA = ls_genbasic (XX, YY, "sphere", [0, 0], 4); - phiInner = ls_genbasic (XX, YY, "sphere", [0, 0], 2); - phiB = ls_setdiff (phiA, phiInner); - - d1 = ls_hausdorff_dist (phiA, phiB, h); - d2 = ls_hausdorff_dist (phiB, phiA, h); - assert (d1, d2); - assert (d1, 2, 2 * h); - dc = ls_hausdorff_dist (ls_complement (phiA), ... - ls_complement (phiB), h); - assert (dc, 4, 2 * h); - - sdA = ls_signed_distance (phiA, h); - sdB = ls_signed_distance (phiB, h); - sdDiff = norm (sdA(:) - sdB(:), inf); - assert (abs (sdDiff - d1) > 10 * h); -6 tests, 6 passed, 0 known failure, 0 skipped -[inst/ls_setxor.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_setxor.m -***** error - ls_setxor (1) -***** error - ls_setxor (1, 2, 3) -***** error - ls_setxor (1, [1, 2]) -***** test - assert (ls_equal (ls_setxor ([-1, -1, Inf], [1, -1, -Inf]), [-1, 1, -1])); - n = 50; - x = linspace (-10, 10, n); - h = x(2) - x(1); - [XX, YY] = meshgrid (x, x); - - phi1 = XX.^2 + YY.^2 - 8^2; - phi2 = XX.^2 + YY.^2 - 5^2; - - assert (ls_equal (ls_setdiff (phi1, phi2), ls_setxor (phi1, phi2))); -***** demo - n = 100; - x = linspace (-7, 7, n); - [XX, YY] = meshgrid (x, x); - - phi1 = (XX - 2).^2 + YY.^2 - 3^2; - phi2 = (XX + 2).^2 + YY.^2 - 3^2; - phi = ls_setxor (phi1, phi2); + [d, g] = ls_nb_from_geom (geom, phi, g0); + [d, g] = fastmarching (d, g, h * ones (size (phi))); figure (); - subplot (1, 2, 1); hold ("on"); - contour (XX, YY, phi1, [0, 0], "k"); - contour (XX, YY, phi2, [0, 0], "k"); - hold ("off"); - axis ("equal"); - - subplot (1, 2, 2); - hold ("on"); - imagesc (x, x, phi); + imagesc (x, x, g); set (gca (), "ydir", "normal"); - ls_sign_colourmap (); contour (XX, YY, phi, [0, 0], "k"); hold ("off"); - axis ("equal"); -4 tests, 4 passed, 0 known failure, 0 skipped -[inst/ls_init_narrowband.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_init_narrowband.m -***** error - ls_init_narrowband () -***** error - ls_init_narrowband (1, 2, 3) -***** test - assert (ls_init_narrowband ([]), []); -***** test - n = 10; - x = linspace (-2, 2, n); - h = x(2) - x(1); - phi = abs (x) - 1; - - d = ls_init_narrowband (phi, h); - where = ~isna (d); - assert (d(where), phi(where), sqrt (eps)); -***** test - n = 50; - x = linspace (-2, 2, n); - h = x(2) - x(1); - [XX, YY, ZZ] = ndgrid (x); - RRsq = XX.^2 + YY.^2 + ZZ.^2; - phi = RRsq - 1; - - d = ls_init_narrowband (phi, h); - where = ~isna (d); - assert (d(where), sqrt (RRsq(where)) - 1, h / 3); -***** test - tol = sqrt (eps); - assert (ls_init_narrowband ([Inf, -Inf, Inf]), [0.5, -0.5, 0.5], tol); - assert (ls_init_narrowband ([Inf, -1, Inf]), [1, 0, 1], tol); - %assert (ls_init_narrowband ([1, -Inf, 1]), [0, 1, 0], tol); -***** function dh = distToSegment (x, a, b) - dir = b - a; - dir /= norm (dir); - proj = dot (x - a, dir); - if (proj < 0) - dh = norm (x - a); - elseif (proj > 1) - dh = norm (x - b); - else - dh = norm (x - (a + proj * dir)); - endif -***** endfunction -***** function dh = distToLine (x, c) - assert (c(1, 1), 0); - dh = Inf; - for i = 2 : size (c, 2) - 1 - dh = min (dh, distToSegment (x, c(:, i), c(:, i + 1))); - endfor -***** endfunction -***** function dh = distOfContoursAsym (c1, c2) - dh = 0; - for i = 2 : size (c1, 2) - dh = max (dh, distToLine (c1(:, i), c2)); - endfor -***** endfunction -***** function dh = distOfContours (c1, c2) - dh = max (distOfContoursAsym (c1, c2), distOfContoursAsym (c2, c1)); -***** endfunction -***** test - phis = ls_get_tests (); - printf ("Comparing contours for %d cases...\n", length (phis)); - for i = 1 : length (phis) - d = ls_init_narrowband (phis{i}); - c1 = contourc (d, [0, 0]); - if (size (c1, 2) > 0) - c2 = contourc (phis{i}, [0, 0]); - dh = distOfContours (c1, c2); - printf ("i = %d: dist = %f\n", i, dh); - if (isfinite (dh)) - assert (dh, 0, 1e-1); - endif - endif - endfor -Comparing contours for 6 cases... -i = 1: dist = 0.060660 -i = 2: dist = Inf -i = 4: dist = 0.039039 -i = 5: dist = 0.085786 -i = 6: dist = 0.085786 + colorbar (); 7 tests, 7 passed, 0 known failure, 0 skipped -[inst/so_example_problem.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/so_example_problem.m -***** shared basicData - basicData = struct (); - basicData.p = so_init_params (true); - basicData.p.vol = 4; - basicData.p.weight = 10; - - n = 50; - x = linspace (-4, 5, n); - h = x(2) - x(1); - basicData.g = struct ("x", x, "h", h); -***** error - so_example_problem (); -***** error - so_example_problem (1, 2); -***** error - so_example_problem (1); -***** test - data = so_example_problem (basicData); - phi = ls_genbasic (data.g.x, "box", -2.5, 1.3); - - [a, b] = data.util.bounds (phi, data); - assert (a, -2.5, sqrt (eps)); - assert (b, 1.3, sqrt (eps)); -***** test - data = so_example_problem (basicData); - - phi = ls_genbasic (data.g.x, "box", -2, 2); - s0 = data.cb.update_state (phi, data); - - phi = ls_genbasic (data.g.x, "box", -3, 3); - s1 = data.cb.update_state (phi, data); - - phi = ls_genbasic (data.g.x, "box", -1, 1); - s2 = data.cb.update_state (phi, data); - - phi = ls_genbasic (data.g.x, "box", -1, 3); - s3 = data.cb.update_state (phi, data); - - phi = ls_genbasic (data.g.x, "box", -3, 1); - s4 = data.cb.update_state (phi, data); - - assert (all ([s0.cost, s1.cost, s2.cost, s3.cost, s4.cost] >= 0)); - assert (s0.cost, 0, 1e-1); - assert (s1.cost > s3.cost); - assert (s1.cost > s4.cost); - assert (s2.cost > s3.cost); - assert (s2.cost > s4.cost); - assert (s3.cost > s0.cost); - assert (s4.cost > s0.cost); -***** function testDeriv (a, b, data) - phi = ls_genbasic (data.g.x, "box", a, b); - data.s = data.cb.update_state (phi, data); - [f, dJ] = data.cb.get_direction (data); - assert (dJ < 0); - - dt = 5e-3; - dists = ls_solve_stationary (phi, f, data.g.h); - phip = ls_extract_solution (dt, dists, phi, f); - sp = data.cb.update_state (phip, data); - - assert (sp.cost < data.s.cost); - relErr = abs (sp.cost - (data.s.cost + dt * dJ)) / data.s.cost; - assert (relErr < 0.1); -***** endfunction -***** test - data = so_example_problem (basicData); - - testDeriv (-1, 1, data); - testDeriv (-3, 3, data); - testDeriv (-1, 3, data); - testDeriv (-3, 1, data); -6 tests, 6 passed, 0 known failure, 0 skipped [inst/ls_enforce_speed.m] >>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_enforce_speed.m ***** error @@ -4230,176 +3549,36 @@ F = ls_enforce_speed (F, "contain", XX.^2 + YY.^2 < 5^2); ls_animate_evolution (phi, F, h, times, 0.05); 6 tests, 6 passed, 0 known failure, 0 skipped -[inst/ls_distance_fcn.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_distance_fcn.m +[inst/ls_inside.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_inside.m ***** error - ls_distance_fcn () -***** error - ls_distance_fcn (1, 2, 3) -***** test - assert (ls_distance_fcn ([]), []); -***** test - n = 10; - x = linspace (-2, 2, n); - h = x(2) - x(1); - phi = abs (x) - 1; - - d = ls_distance_fcn (phi, h); - assert (d, max (phi, 0), sqrt (eps)); + ls_inside () +***** error + ls_inside (1, 2) ***** test - n = 50; - x = linspace (-2, 2, n); - h = x(2) - x(1); - [XX, YY, ZZ] = ndgrid (x); - RRsq = XX.^2 + YY.^2 + ZZ.^2; - phi = RRsq - 1; - - d = ls_distance_fcn (phi, h); - assert (d, max (sqrt (RRsq) - 1, 0), h); -***** xtest - n = 500; - x = linspace (-10, 10, n); - h = x(2) - x(1); - - [XX, YY] = meshgrid (x, x); - phi = ls_genbasic (XX, YY, "sphere", [0, 0], 8); - - id = tic (); - d = ls_distance_fcn (phi, h); - time1 = toc (id); - - id = tic (); - sd = ls_signed_distance (phi, h); - time2 = toc (id); - - assert (d, max (sd, 0), sqrt (eps)); - printf ("ls_distance_fcn faster than ls_signed_distance by %.1f%%\n", ... - 100 * ((time2 - time1) / time2)); - assert (time1 < time2); -ls_distance_fcn faster than ls_signed_distance by 19.8% + assert (ls_inside ([1, 0, -1, 0, 1]), [false, false, true, false, false]); ***** test - phis = ls_get_tests (); - for i = 1 : length (phis) - phi = ls_normalise (phis{i}); - d = ls_distance_fcn (phi); - sd = ls_signed_distance (phi); - assert (d, max (sd, 0), sqrt (eps)); - endfor -***** demo - n = 100; - x = linspace (-10, 10, n); - h = x(2) - x(1); - [XX, YY] = meshgrid (x, x); - - phi = ls_genbasic (XX, YY, "sphere", [0, 0], [8, 5]); - d = ls_distance_fcn (phi, h); - - figure (); - mesh (XX, YY, d); - view ([45, 45]); -7 tests, 7 passed, 0 known failure, 0 skipped -[inst/so_step_armijo.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/so_step_armijo.m -***** function s = updateState (phi, data) - inside = ls_inside (phi); - vol = data.g.h * length (find (inside)); - cost = 1 / vol; - - % Throw if the volume is too large. This is used - % to check the error handling code. - if (vol > 15) - error ("volume too large"); + if (exist ("signbit") == 5) + assert (ls_inside ([-0, 0]), [true, false]); + else + warning ("'signbit' function not available, skipping test."); endif - - s = struct ("phi", phi, "cost", cost); -***** endfunction -***** shared n, phi, baseData, d, f, dJ - n = 100; - x = linspace (-10, 10, n); - h = x(2) - x(1); - a = 0; - b = 5; - phi = ls_genbasic (x, "box", a, b); - - baseData = struct (); - baseData.p = so_init_params (false); - baseData.g = struct ("x", x, "h", h); - baseData.cb = struct ("update_state", @updateState); - baseData.s = updateState (phi, baseData); - baseData.s.phi = phi; - - f = ones (size (phi)); - d = ls_solve_stationary (phi, f, h); - - curVol = b - a; - dJ = -2 / curVol^2; -***** error - so_step_armijo (1, 2, 3, 4) -***** error - so_step_armijo (1, 2, 3, 4, 5, 6) -***** error - so_step_armijo ([1, 1], 2, 3, 4, struct ()) -***** error - so_step_armijo (1, 2, 3, [4, 4], struct ()) +4 tests, 4 passed, 0 known failure, 0 skipped +[inst/ls_absolute_geom.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_absolute_geom.m ***** error - so_step_armijo (1, 2, 3, 4, 5) -***** error - so_step_armijo (1, d, f, 4, baseData) -***** error - so_step_armijo (1, 2, f, dJ, baseData) -***** error - so_step_armijo (1, 2, 3, dJ, baseData) -***** error - data = baseData; - data.p.lineSearch.relaxation = 0; - so_step_armijo (1, d, f, dJ, data); -***** error - data = baseData; - data.p.lineSearch.relaxation = 1; - so_step_armijo (1, d, f, dJ, data); -***** error - data = baseData; - data.p.lineSearch.backtrack = 0; - so_step_armijo (1, d, f, dJ, data); -***** error - data = baseData; - data.p.lineSearch.backtrack = 1; - so_step_armijo (1, d, f, dJ, data); -***** error - data = baseData; - data.p.lineSearch.initial = 1; - so_step_armijo (1, d, f, dJ, data); -***** error - data = baseData; - data.p.lineSearch.minStep = -1; - so_step_armijo (1, d, f, dJ, data); -***** test - data = baseData; - data.p.lineSearch.minStep = 0; - so_step_armijo (1, d, f, dJ, data); -***** test - data = baseData; - data.p.verbose = true; - data.p.lineSearch.relaxation = 0.9; - [~, t] = so_step_armijo (1, d, f, dJ, data); - assert (t < 0.5); -Armijo step 2.000000: cost = 0.110000 -Armijo step 1.600000: cost = 0.120732 -Armijo step 1.280000: cost = 0.133784 -Armijo step 1.024000: cost = 0.141429 -Armijo step 0.819200: cost = 0.150000 -Armijo step 0.655360: cost = 0.159677 -Armijo step 0.524288: cost = 0.165000 -Armijo step 0.419430: cost = 0.170690 -Armijo step 0.335544: cost = 0.176786 -Armijo step 0.268435: cost = 0.183333 -Armijo step 0.214748: cost = 0.183333 -Armijo step 0.171799: cost = 0.183333 -***** test - so_step_armijo (2, d, f, dJ, baseData); -***** error - so_step_armijo (3, d, f, dJ, baseData); -18 tests, 18 passed, 0 known failure, 0 skipped + ls_absolute_geom (1, 2); +***** error + ls_absolute_geom (1, 2, 3, 4); +***** error + x = [-1, 1]; + [XX, YY, ZZ] = ndgrid (x); + ls_absolute_geom (struct (), XX, YY); +***** error + ls_absolute_geom (struct (), [-1, 0, 1], [0, 0, 0]); +***** error + ls_absolute_geom (struct (), zeros (3, 2), zeros (2, 2)); +5 tests, 5 passed, 0 known failure, 0 skipped [inst/ls_genbasic.m] >>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_genbasic.m ***** shared x, y, XX, YY, XXX, YYY, ZZZ @@ -4516,99 +3695,6 @@ hold ("off"); axis ("equal"); 23 tests, 23 passed, 0 known failure, 0 skipped -[inst/ls_equal.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_equal.m -***** error - ls_equal (1) -***** error - ls_equal (1, 2, 3) -***** error - ls_equal (1, [1, 2]) -***** test - assert (ls_equal ([Inf, 0, -2, -Inf, eps], ... - [1, 0, -Inf, -eps, 1])); - assert (ls_equal ([1, 0; -1, 0], [Inf, 0; -5, 0])); - assert (!ls_equal ([1, -1; 0, 0], [1, 0; 0, 0])); -***** test - if (exist ("signbit") == 5) - assert (ls_equal ([0, -0], [1, -1])); - else - warning ("'signbit' function not available, skipping test."); - endif -5 tests, 5 passed, 0 known failure, 0 skipped -[inst/ls_sign_colourmap.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_sign_colourmap.m -***** shared colours - colours = [1, 1, 1; 0, 0, 0; 1, 1, 1; 0, 0, 0]; -***** error - ls_sign_colourmap (1, 2); -***** error - ls_sign_colourmap (1); -***** error - cmap = ls_sign_colourmap (); -***** error - ls_sign_colourmap ("foo"); -***** test - figure (); - ls_sign_colourmap (); - ls_sign_colourmap ("highlight"); - ls_sign_colourmap (colours); - close (); -warning: using the gnuplot graphics toolkit is discouraged - -The gnuplot graphics toolkit is not actively maintained and has a number -of limitations that are unlikely to be fixed. Communication with gnuplot -uses a one-directional pipe and limited information is passed back to the -Octave interpreter so most changes made interactively in the plot window -will not be reflected in the graphics properties managed by Octave. For -example, if the plot window is closed with a mouse click, Octave will not -be notified and will not update its internal list of open figure windows. -The qt toolkit is recommended instead. -***** error - ls_sign_colourmap (1, 2, 3); -***** error - ls_sign_colourmap ([1, 2, 3]); -***** error - ls_sign_colourmap ([1, 2], 1); -***** error - ls_sign_colourmap ([1, 2], "foo"); -***** test - cmap = ls_sign_colourmap ([1, 2]); - cmap = ls_sign_colourmap ([1; 2], "highlight"); - cmap = ls_sign_colourmap ([1; 2], colours); -***** demo - n = 100; - x = linspace (-2, 2, n); - y = linspace (-1, 3, n); - [XX, YY] = meshgrid (x, y); - phi = ls_genbasic (XX, YY, "sphere", [0, 1], 1); - - figure (); - imagesc (x, y, phi); - set (gca (), "ydir", "normal"); - ls_sign_colourmap (); - colorbar (); - title ("Type 'sign'"); -***** demo - n = 100; - x = linspace (-2, 2, n); - h = x(2) - x(1); - [XX, YY] = meshgrid (x, x); - - phi = ls_genbasic (XX, YY, "sphere", [0, 0], 1); - d = ls_signed_distance (phi, h); - F = YY .* exp (-10 * d.^2); - - figure (); - hold ("on"); - imagesc (x, x, F); - set (gca (), "ydir", "normal"); - ls_sign_colourmap ("highlight"); - colorbar (); - contour (XX, YY, phi, [0, 0], "k", "LineWidth", 2); - hold ("off"); - title ("Type 'highlight'"); -10 tests, 10 passed, 0 known failure, 0 skipped [inst/so_replay_descent.m] >>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/so_replay_descent.m ***** error @@ -4838,148 +3924,383 @@ printf ("Final cost: %.6d\n", s.cost); warning: test: file /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/so_replay_descent.m leaked file descriptors 12 tests, 8 passed, 4 known failures, 0 skipped -[inst/ls_complement.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_complement.m +[inst/so_save_descent.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/so_save_descent.m ***** error - ls_complement () -***** error - ls_complement (1, 2) + so_save_descent (1, 2); +***** error + so_save_descent (1, 2, 3, 4); +***** error + so_save_descent (1, 2, 3); +***** error + so_save_descent (struct (), 2, struct ()); +***** error + so_save_descent ([2, 3], 2, struct ()); +***** error <'fsave' is not available> + pkg unload -nodeps parallel; + so_save_descent ("foo", 2, struct ()); +***** test + pkg load parallel; + so_save_descent ("foo", 2, struct ()); + so_save_descent (5, 2, struct ()); +7 tests, 7 passed, 0 known failure, 0 skipped +[inst/ls_union.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_union.m +***** error + ls_union () +***** error + ls_union (1, -2, [1, 2]) ***** test n = 50; x = linspace (-10, 10, n); - h = x(2) - x(1); [XX, YY] = meshgrid (x, x); - phi1 = (XX - 2).^2 + (YY - 2).^2 - 2^2; - phi2 = (XX + 2).^2 + (YY + 2).^2 - 2^2; + phi1 = (XX - 3).^2 + (YY - 3).^2 - 2^2; + phi2 = (XX + 3).^2 + (YY + 3).^2 - 2^2; + phi3 = XX.^2 + YY.^2 - 2^2; - assert (ls_disjoint (phi1, ls_complement (phi1))); - assert (ls_disjoint (phi2, ls_complement (phi2))); + phi = ls_union (phi1, phi2, phi3); + assert (ls_issubset (phi1, phi)); + assert (ls_issubset (phi2, phi)); + assert (ls_issubset (phi3, phi)); - assert (~ls_disjoint (phi1, ls_complement (phi2))); - assert (~ls_disjoint (phi2, ls_complement (phi1))); + assert (ls_union (phi3), phi3); +***** demo + n = 100; + x = linspace (-7, 7, n); + [XX, YY] = meshgrid (x, x); - sd1 = ls_signed_distance (ls_complement (phi1), h); - sd2 = ls_complement (ls_signed_distance (phi1, h)); - assert (sd1, sd2, sqrt (eps)); + phi1 = (XX - 2 * cos (7/6 * pi)).^2 + (YY - 2 * sin (7/6 * pi)).^2 - 3^2; + phi2 = (XX - 2 * cos (11/6 * pi)).^2 + (YY - 2 * sin (11/6 * pi)).^2 - 3^2; + phi3 = XX.^2 + (YY - 2).^2 - 3^2; + phi = ls_union (phi1, phi2, phi3); + + figure (); + subplot (1, 2, 1); + hold ("on"); + contour (XX, YY, phi1, [0, 0], "k"); + contour (XX, YY, phi2, [0, 0], "k"); + contour (XX, YY, phi3, [0, 0], "k"); + hold ("off"); + axis ("equal"); + + subplot (1, 2, 2); + hold ("on"); + imagesc (x, x, phi); + set (gca (), "ydir", "normal"); + ls_sign_colourmap (); + contour (XX, YY, phi, [0, 0], "k"); + hold ("off"); + axis ("equal"); 3 tests, 3 passed, 0 known failure, 0 skipped -[inst/ls_inside.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_inside.m +[inst/so_step_armijo.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/so_step_armijo.m +***** function s = updateState (phi, data) + inside = ls_inside (phi); + vol = data.g.h * length (find (inside)); + cost = 1 / vol; + + % Throw if the volume is too large. This is used + % to check the error handling code. + if (vol > 15) + error ("volume too large"); + endif + + s = struct ("phi", phi, "cost", cost); +***** endfunction +***** shared n, phi, baseData, d, f, dJ + n = 100; + x = linspace (-10, 10, n); + h = x(2) - x(1); + a = 0; + b = 5; + phi = ls_genbasic (x, "box", a, b); + + baseData = struct (); + baseData.p = so_init_params (false); + baseData.g = struct ("x", x, "h", h); + baseData.cb = struct ("update_state", @updateState); + baseData.s = updateState (phi, baseData); + baseData.s.phi = phi; + + f = ones (size (phi)); + d = ls_solve_stationary (phi, f, h); + + curVol = b - a; + dJ = -2 / curVol^2; ***** error - ls_inside () -***** error - ls_inside (1, 2) + so_step_armijo (1, 2, 3, 4) +***** error + so_step_armijo (1, 2, 3, 4, 5, 6) +***** error + so_step_armijo ([1, 1], 2, 3, 4, struct ()) +***** error + so_step_armijo (1, 2, 3, [4, 4], struct ()) +***** error + so_step_armijo (1, 2, 3, 4, 5) +***** error + so_step_armijo (1, d, f, 4, baseData) +***** error + so_step_armijo (1, 2, f, dJ, baseData) +***** error + so_step_armijo (1, 2, 3, dJ, baseData) +***** error + data = baseData; + data.p.lineSearch.relaxation = 0; + so_step_armijo (1, d, f, dJ, data); +***** error + data = baseData; + data.p.lineSearch.relaxation = 1; + so_step_armijo (1, d, f, dJ, data); +***** error + data = baseData; + data.p.lineSearch.backtrack = 0; + so_step_armijo (1, d, f, dJ, data); +***** error + data = baseData; + data.p.lineSearch.backtrack = 1; + so_step_armijo (1, d, f, dJ, data); +***** error + data = baseData; + data.p.lineSearch.initial = 1; + so_step_armijo (1, d, f, dJ, data); +***** error + data = baseData; + data.p.lineSearch.minStep = -1; + so_step_armijo (1, d, f, dJ, data); ***** test - assert (ls_inside ([1, 0, -1, 0, 1]), [false, false, true, false, false]); + data = baseData; + data.p.lineSearch.minStep = 0; + so_step_armijo (1, d, f, dJ, data); ***** test - if (exist ("signbit") == 5) - assert (ls_inside ([-0, 0]), [true, false]); - else - warning ("'signbit' function not available, skipping test."); - endif -4 tests, 4 passed, 0 known failure, 0 skipped -[inst/ls_time_step.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_time_step.m + data = baseData; + data.p.verbose = true; + data.p.lineSearch.relaxation = 0.9; + [~, t] = so_step_armijo (1, d, f, dJ, data); + assert (t < 0.5); +Armijo step 2.000000: cost = 0.110000 +Armijo step 1.600000: cost = 0.120732 +Armijo step 1.280000: cost = 0.133784 +Armijo step 1.024000: cost = 0.141429 +Armijo step 0.819200: cost = 0.150000 +Armijo step 0.655360: cost = 0.159677 +Armijo step 0.524288: cost = 0.165000 +Armijo step 0.419430: cost = 0.170690 +Armijo step 0.335544: cost = 0.176786 +Armijo step 0.268435: cost = 0.183333 +Armijo step 0.214748: cost = 0.183333 +Armijo step 0.171799: cost = 0.183333 +***** test + so_step_armijo (2, d, f, dJ, baseData); +***** error + so_step_armijo (3, d, f, dJ, baseData); +18 tests, 18 passed, 0 known failure, 0 skipped +[inst/so_init_params.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/so_init_params.m ***** error - ls_time_step (1, 2) -***** error - ls_time_step (1, 2, 3, 4, 5, 6) + so_init_params () +***** error + so_init_params (true, 1, 2) +***** error + so_init_params (true, 0); +***** error + so_init_params (true, 1.5); +***** test + p = so_init_params (true); +***** error <'pararrayfun' is not available> + pkg unload -nodeps parallel; + p = so_init_params (true, 2); +***** test + pkg load parallel; + p = so_init_params (true, 2); +7 tests, 7 passed, 0 known failure, 0 skipped +[inst/ls_setxor.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_setxor.m ***** error - ls_time_step (1, 2, 3, 4, [5, 5]) -***** error - ls_time_step ([1; 1], [2, 2], [3, 3, 3]) -***** error - ls_time_step ([1, 1], 1, [2, 2], [3, 3, 3]) -***** error - ls_time_step (ones (2, 2), 1, 1) + ls_setxor (1) +***** error + ls_setxor (1, 2, 3) +***** error + ls_setxor (1, [1, 2]) ***** test - n = 100; - x = linspace (0, 1, n); + assert (ls_equal (ls_setxor ([-1, -1, Inf], [1, -1, -Inf]), [-1, 1, -1])); + n = 50; + x = linspace (-10, 10, n); h = x(2) - x(1); + [XX, YY] = meshgrid (x, x); - phi0 = sin (x); - fPos = ones (size (phi0)); + phi1 = XX.^2 + YY.^2 - 8^2; + phi2 = XX.^2 + YY.^2 - 5^2; - % Single time step, moving exactly one grid step. - phit = ls_time_step (1, phi0, fPos); - assert (phit(2 : end), phi0(1 : end - 1)); + assert (ls_equal (ls_setdiff (phi1, phi2), ls_setxor (phi1, phi2))); +***** demo + n = 100; + x = linspace (-7, 7, n); + [XX, YY] = meshgrid (x, x); - % t = 1 should correspond to the previous result, and t = 2 - % shifts one more time step. However, due to boundary effects, - % we have to exclude some elements in the comparisons. - phitArr = ls_time_step ([1, 2], 0.5, phi0, fPos); - assert (size (phitArr), [2, 1]); - assert (phitArr{1}(3 : end), phit(3 : end), 1e-4); - assert (phitArr{2}(5 : end), phi0(3 : end - 2), 1e-4); + phi1 = (XX - 2).^2 + YY.^2 - 3^2; + phi2 = (XX + 2).^2 + YY.^2 - 3^2; + phi = ls_setxor (phi1, phi2); - % Try out movement in the other direction. - phit = ls_time_step (0.5, 0.1, phi0, -fPos, 0.5); - assert (phit(1 : end - 4), phi0(2 : end - 3), 1e-4); -***** function compareFastMarching (t, phi0, F, h, tol) - phit = ls_time_step (t, phi0, F, h); - d = ls_solve_stationary (phi0, F, h); - phit_fm = ls_extract_solution (t, d, phi0, F); + figure (); + subplot (1, 2, 1); + hold ("on"); + contour (XX, YY, phi1, [0, 0], "k"); + contour (XX, YY, phi2, [0, 0], "k"); + hold ("off"); + axis ("equal"); - sd1 = ls_signed_distance (phit, h); - sd2 = ls_signed_distance (phit_fm, h); - assert (sd1, sd2, tol); -***** endfunction + subplot (1, 2, 2); + hold ("on"); + imagesc (x, x, phi); + set (gca (), "ydir", "normal"); + ls_sign_colourmap (); + contour (XX, YY, phi, [0, 0], "k"); + hold ("off"); + axis ("equal"); +4 tests, 4 passed, 0 known failure, 0 skipped +[inst/ls_distance_fcn.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_distance_fcn.m +***** error + ls_distance_fcn () +***** error + ls_distance_fcn (1, 2, 3) ***** test - warning ("off", "level-set:fast-marching:too-far-alive"); - - n = 100; - x = linspace (-5, 5, n); + assert (ls_distance_fcn ([]), []); +***** test + n = 10; + x = linspace (-2, 2, n); h = x(2) - x(1); - [XX, YY] = meshgrid (x, x); + phi = abs (x) - 1; - phi0 = ls_genbasic (XX, YY, "sphere", [0, 0], [3, 1.5]); - F = ones (size (phi0)); - compareFastMarching (0.5, phi0, F, h, h / 2); - compareFastMarching (1.5, phi0, F, h, h / 2); + d = ls_distance_fcn (phi, h); + assert (d, max (phi, 0), sqrt (eps)); +***** test + n = 50; + x = linspace (-2, 2, n); + h = x(2) - x(1); + [XX, YY, ZZ] = ndgrid (x); + RRsq = XX.^2 + YY.^2 + ZZ.^2; + phi = RRsq - 1; - phi0 = ls_genbasic (XX, YY, "box", [-3, -3], [3, 3]); - F = YY / 5; - compareFastMarching (1, phi0, F, h, h); + d = ls_distance_fcn (phi, h); + assert (d, max (sqrt (RRsq) - 1, 0), h); +***** xtest + n = 500; + x = linspace (-10, 10, n); + h = x(2) - x(1); - F = ones (size (phi0)); - compareFastMarching (1, phi0, F, h, h / 2); + [XX, YY] = meshgrid (x, x); + phi = ls_genbasic (XX, YY, "sphere", [0, 0], 8); - phi0 = ls_genbasic (XX, YY, "sphere", [0, 0], 3); - F = sin (XX .* YY); - compareFastMarching (1, phi0, F, h, h); -***** test - warning ("off", "level-set:fast-marching:increased-distance"); + id = tic (); + d = ls_distance_fcn (phi, h); + time1 = toc (id); - n = 50; - x = linspace (-5, 5, n); - h = x(2) - x(1); - [XX, YY, ZZ] = ndgrid (x, x, x); + id = tic (); + sd = ls_signed_distance (phi, h); + time2 = toc (id); - phi0 = ls_genbasic (XX, YY, ZZ, "sphere", [0, 0, 0], 3); - F = ones (size (phi0)); - compareFastMarching (1, phi0, F, h, h / 2); - compareFastMarching (1, phi0, -F, h, h / 2); + assert (d, max (sd, 0), sqrt (eps)); + printf ("ls_distance_fcn faster than ls_signed_distance by %.1f%%\n", ... + 100 * ((time2 - time1) / time2)); + assert (time1 < time2); +ls_distance_fcn faster than ls_signed_distance by 30.3% +***** test + phis = ls_get_tests (); + for i = 1 : length (phis) + phi = ls_normalise (phis{i}); + d = ls_distance_fcn (phi); + sd = ls_signed_distance (phi); + assert (d, max (sd, 0), sqrt (eps)); + endfor ***** demo - n = 500; - x = linspace (-5, 5, n); + n = 100; + x = linspace (-10, 10, n); h = x(2) - x(1); [XX, YY] = meshgrid (x, x); - F = sin (XX .* YY); - phi0 = ls_genbasic (XX, YY, "sphere", [0, 0], 3); - phit = ls_time_step ([0.5, 1], phi0, F, h); + phi = ls_genbasic (XX, YY, "sphere", [0, 0], [8, 5]); + d = ls_distance_fcn (phi, h); figure (); - hold ("on"); - imagesc (x, x, F); - axis ("equal"); - set (gca (), "ydir", "normal"); - ls_sign_colourmap (); - contour (XX, YY, phi0, [0, 0], "k", "LineWidth", 2); - contour (XX, YY, phit{1}, [0, 0], "k", "LineWidth", 2); - contour (XX, YY, phit{2}, [0, 0], "k", "LineWidth", 2); - hold ("off"); -9 tests, 9 passed, 0 known failure, 0 skipped + mesh (XX, YY, d); + view ([45, 45]); +7 tests, 7 passed, 0 known failure, 0 skipped +[inst/so_example_problem.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/so_example_problem.m +***** shared basicData + basicData = struct (); + basicData.p = so_init_params (true); + basicData.p.vol = 4; + basicData.p.weight = 10; + + n = 50; + x = linspace (-4, 5, n); + h = x(2) - x(1); + basicData.g = struct ("x", x, "h", h); +***** error + so_example_problem (); +***** error + so_example_problem (1, 2); +***** error + so_example_problem (1); +***** test + data = so_example_problem (basicData); + phi = ls_genbasic (data.g.x, "box", -2.5, 1.3); + + [a, b] = data.util.bounds (phi, data); + assert (a, -2.5, sqrt (eps)); + assert (b, 1.3, sqrt (eps)); +***** test + data = so_example_problem (basicData); + + phi = ls_genbasic (data.g.x, "box", -2, 2); + s0 = data.cb.update_state (phi, data); + + phi = ls_genbasic (data.g.x, "box", -3, 3); + s1 = data.cb.update_state (phi, data); + + phi = ls_genbasic (data.g.x, "box", -1, 1); + s2 = data.cb.update_state (phi, data); + + phi = ls_genbasic (data.g.x, "box", -1, 3); + s3 = data.cb.update_state (phi, data); + + phi = ls_genbasic (data.g.x, "box", -3, 1); + s4 = data.cb.update_state (phi, data); + + assert (all ([s0.cost, s1.cost, s2.cost, s3.cost, s4.cost] >= 0)); + assert (s0.cost, 0, 1e-1); + assert (s1.cost > s3.cost); + assert (s1.cost > s4.cost); + assert (s2.cost > s3.cost); + assert (s2.cost > s4.cost); + assert (s3.cost > s0.cost); + assert (s4.cost > s0.cost); +***** function testDeriv (a, b, data) + phi = ls_genbasic (data.g.x, "box", a, b); + data.s = data.cb.update_state (phi, data); + [f, dJ] = data.cb.get_direction (data); + assert (dJ < 0); + + dt = 5e-3; + dists = ls_solve_stationary (phi, f, data.g.h); + phip = ls_extract_solution (dt, dists, phi, f); + sp = data.cb.update_state (phip, data); + + assert (sp.cost < data.s.cost); + relErr = abs (sp.cost - (data.s.cost + dt * dJ)) / data.s.cost; + assert (relErr < 0.1); +***** endfunction +***** test + data = so_example_problem (basicData); + + testDeriv (-1, 1, data); + testDeriv (-3, 3, data); + testDeriv (-1, 3, data); + testDeriv (-3, 1, data); +6 tests, 6 passed, 0 known failure, 0 skipped [inst/so_explore_descent.m] >>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/so_explore_descent.m ***** error @@ -5028,250 +4349,201 @@ so_explore_descent (f, init); fclose (f); 5 tests, 5 passed, 0 known failure, 0 skipped -[inst/ls_normalise.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_normalise.m +[inst/ls_equal.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_equal.m ***** error - ls_normalise () -***** error - ls_normalise (1, 2, 3, 4) + ls_equal (1) +***** error + ls_equal (1, 2, 3) +***** error + ls_equal (1, [1, 2]) +***** test + assert (ls_equal ([Inf, 0, -2, -Inf, eps], ... + [1, 0, -Inf, -eps, 1])); + assert (ls_equal ([1, 0; -1, 0], [Inf, 0; -5, 0])); + assert (!ls_equal ([1, -1; 0, 0], [1, 0; 0, 0])); ***** test - h = 0.1; - zeroTol = 0.2; - phi = ones (4, 4); - phiEx = phi; - phi(2 : 3, 2 : 3) = [-eps, -0; 0, eps]; - phiEx(2 : 3, 2 : 3) = [-zeroTol*h, -zeroTol*h; zeroTol*h, zeroTol*h]; - phin = ls_normalise (phi, h, zeroTol); if (exist ("signbit") == 5) - assert (phin, phiEx); + assert (ls_equal ([0, -0], [1, -1])); else warning ("'signbit' function not available, skipping test."); endif -3 tests, 3 passed, 0 known failure, 0 skipped -[inst/so_init_params.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/so_init_params.m -***** error - so_init_params () -***** error - so_init_params (true, 1, 2) -***** error - so_init_params (true, 0); -***** error - so_init_params (true, 1.5); -***** test - p = so_init_params (true); -***** error <'pararrayfun' is not available> - pkg unload -nodeps parallel; - p = so_init_params (true, 2); -***** test - pkg load parallel; - p = so_init_params (true, 2); -7 tests, 7 passed, 0 known failure, 0 skipped -[inst/ls_check.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_check.m +5 tests, 5 passed, 0 known failure, 0 skipped +[inst/ls_complement.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_complement.m ***** error - ls_check (1, 2) -***** error - ls_check (1, 2, 3, 4) -***** error - ls_check (1, "inside", [1, 2]); -***** error - ls_check (1, "foo", true); -***** error - ls_check (1, NA, false); + ls_complement () +***** error + ls_complement (1, 2) ***** test - n = 100; + n = 50; x = linspace (-10, 10, n); + h = x(2) - x(1); [XX, YY] = meshgrid (x, x); - circ2 = (XX.^2 + YY.^2 < 2^2); - circ8 = (XX.^2 + YY.^2 < 8^2); - phi = (XX.^2 + YY.^2 - 5^2); + phi1 = (XX - 2).^2 + (YY - 2).^2 - 2^2; + phi2 = (XX + 2).^2 + (YY + 2).^2 - 2^2; - assert (ls_check (phi, "inside", circ8)); - assert (ls_check (phi, "contain", circ2)); - assert (ls_check (phi, "outside", ~circ8)); + assert (ls_disjoint (phi1, ls_complement (phi1))); + assert (ls_disjoint (phi2, ls_complement (phi2))); - assert (~ls_check (phi, "inside", circ2)); - assert (~ls_check (phi, "contain", circ8)); - assert (~ls_check (phi, "outside", circ8)); -6 tests, 6 passed, 0 known failure, 0 skipped -[inst/upwind_gradient_norm.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/upwind_gradient_norm.m -***** error - upwind_gradient_norm () -***** error - upwind_gradient_norm (1, 2, 3, 4) + assert (~ls_disjoint (phi1, ls_complement (phi2))); + assert (~ls_disjoint (phi2, ls_complement (phi1))); + + sd1 = ls_signed_distance (ls_complement (phi1), h); + sd2 = ls_complement (ls_signed_distance (phi1, h)); + assert (sd1, sd2, sqrt (eps)); +3 tests, 3 passed, 0 known failure, 0 skipped +[inst/ls_hausdorff_dist.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_hausdorff_dist.m ***** error - upwind_gradient_norm ([1, 1], [2, 2], [3, 3]) -***** error - upwind_gradient_norm ([1, 1], [2, 2, 2]) -***** error - upwind_gradient_norm ([1, 1], [2, 2, 2], 5) + ls_hausdorff_dist (1) +***** error + ls_hausdorff_dist (1, 2, 3, 4) +***** error + ls_hausdorff_dist (1, 2, [3, 3]) +***** error + ls_hausdorff_dist (1, 2, "foo") ***** test - phi = [0, 2, 3]; - fPos = ones (size (phi)); - - % Propagate the original phi to the right. This should result - % in the *backward* difference to be used in the middle. - g = upwind_gradient_norm (phi); - assert (g(2), 2); - gp = upwind_gradient_norm (phi, fPos); - assert (gp, g); - gp = upwind_gradient_norm (phi, 0.5); - assert (gp, 2 * g); - gp = upwind_gradient_norm (phi, fPos, 0.5); - assert (gp, 2 * g); + n = 50; + x = linspace (-5, 5, n); + h = x(2) - x(1); + [XX, YY] = meshgrid (x, x); - % Propagate to the left for the reverse effect. - g = upwind_gradient_norm (phi, -fPos); - assert (g(2), 1); + phi1 = ls_genbasic (XX, YY, "sphere", [3, 0], 1); + phi2 = ls_genbasic (XX, YY, "sphere", [-2, 0], 2); + assert (ls_hausdorff_dist (phi1, phi2, h), 6, h); - % Propagate -phi, which again turns everything around. - g = upwind_gradient_norm (-phi, fPos); - assert (g(2), 1); - g = upwind_gradient_norm (-phi, -fPos); - assert (g(2), 2); + % Make sure that phi isn't a signed-distance fcn already. + % ls_genbasic should return the same, but make it explicit. + rSq = XX.^2 + YY.^2; + d = ls_hausdorff_dist (rSq - 4^2, rSq - 2^2, h); + assert (d, 2, h); + dWrong = ls_hausdorff_dist (rSq - 4^2, rSq - 2^2, "sd"); + assert (abs (d - dWrong) > 10 * h); + dRight = ls_hausdorff_dist (sqrt (rSq) - 4, sqrt (rSq) - 2, "sd"); + assert (dRight, d, h); ***** test - n = 50; - x = linspace (-1, 1, n); + n = 200; + x = linspace (-5, 5, n); h = x(2) - x(1); - [XX, YY, ZZ] = ndgrid (x, x, x); + [XX, YY] = meshgrid (x, x); - phi = XX.^2 + YY.^2 + ZZ.^2; - g = upwind_gradient_norm (phi, h); - - r = sqrt (phi); - assert (g, 2 * r, 0.1); -7 tests, 7 passed, 0 known failure, 0 skipped -[inst/ls_enforce.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_enforce.m + phiA = ls_genbasic (XX, YY, "sphere", [0, 0], 4); + phiInner = ls_genbasic (XX, YY, "sphere", [0, 0], 2); + phiB = ls_setdiff (phiA, phiInner); + + d1 = ls_hausdorff_dist (phiA, phiB, h); + d2 = ls_hausdorff_dist (phiB, phiA, h); + assert (d1, d2); + assert (d1, 2, 2 * h); + dc = ls_hausdorff_dist (ls_complement (phiA), ... + ls_complement (phiB), h); + assert (dc, 4, 2 * h); + + sdA = ls_signed_distance (phiA, h); + sdB = ls_signed_distance (phiB, h); + sdDiff = norm (sdA(:) - sdB(:), inf); + assert (abs (sdDiff - d1) > 10 * h); +6 tests, 6 passed, 0 known failure, 0 skipped +[inst/ls_solve_stationary.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_solve_stationary.m ***** error - ls_enforce (1, 2) -***** error - ls_enforce (1, 2, 3, 4) -***** error - ls_enforce (1, "inside", [1, 2]); -***** error - ls_enforce (1, "foo", true); -***** error - ls_enforce (1, NA, false); + ls_solve_stationary (1) +***** error + ls_solve_stationary (1, 2, 3, 4, 5) +***** error + ls_solve_stationary ([1, 2], [3; 4]); +***** error + ls_solve_stationary ([1, 2], [1, 2], :, [3; 4]); ***** test - n = 100; + assert (ls_solve_stationary ([], []), []); +***** function checkOutput (phi, f, d) + assert (all (isna (d(f == 0)))); + where = (f ~= 0); + assert (all (isfinite (d(where)) | isinf (d(where)))); + assert (sign (d(where)), sign (phi(where))); +***** endfunction +***** test + phis = ls_get_tests (); + for i = 1 : length (phis) + f = ones (size (phis{i})); + for j = -1 : 1 + phi = ls_normalise (phis{i}); + d = ls_solve_stationary (phi, j * f); + checkOutput (phi, j * f, d); + endfor + endfor +***** test + n = 101; x = linspace (-10, 10, n); + h = x(2) - x(1); [XX, YY] = meshgrid (x, x); - circ2 = (XX.^2 + YY.^2 < 2^2); - circ8 = (XX.^2 + YY.^2 < 8^2); - phi = (XX.^2 + YY.^2 - 5^2); + r1 = (XX - 5).^2 + YY.^2; + r2 = (XX + 5).^2 + YY.^2; - phi2 = ls_enforce (phi, "inside", circ8); - assert (ls_equal (phi2, phi)); - phi2 = ls_enforce (phi, "inside", circ2); - assert (ls_check (phi2, "inside", circ2)); + phi = ls_union (r1 - 2^2, r2 - 2^2); + f1 = max (r1 - 3^2, 1^2 - r1); + f2 = max (r2 - 3^2, 1^2 - r2); + f = min (f1, f2) .* sign (XX); + assert (~all (f(:) ~= 0)); - phi2 = ls_enforce (phi, "contain", circ2); - assert (ls_equal (phi2, phi)); - phi2 = ls_enforce (phi, "contain", circ8); - assert (ls_check (phi2, "contain", circ8)); + d = ls_solve_stationary (phi, f, h); - phi2 = ls_enforce (phi, "outside", ~circ8); - assert (ls_equal (phi2, phi)); - phi2 = ls_enforce (phi, "outside", ~circ2); - ls_check (phi2, "outside", ~circ2); - phi2 = ls_enforce (phi, "outside", circ2); - ls_check (phi2, "outside", circ2); -6 tests, 6 passed, 0 known failure, 0 skipped -[inst/so_run_descent.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/so_run_descent.m -***** shared data, phi0 - data = struct (); - data.p = so_init_params (false); - data.p.vol = 10; - data.p.weight = 50; + checkOutput (phi, f, d); + where = (f ~= 0); + assert (any (isinf (d(where)))); + %{ + contour (phi, [0, 0]); + colorbar (); + figure (); + imagesc (f); + colorbar (); + figure (); + imagesc (d); + colorbar (); + %} +***** test + phi = [3, 1, -1, 1, 3]; + f = ones (size (phi)); + dists1 = ls_solve_stationary (phi, f); + dists2 = ls_solve_stationary (phi, f, :, [NA, NA, -0.1, NA, NA]); + + assert (dists1, [1.5, 0.5, -0.5, 0.5, 1.5], sqrt (eps)); + assert (dists2, [1.9, 0.9, -0.1, 0.9, 1.9]); +***** demo n = 100; x = linspace (-10, 10, n); h = x(2) - x(1); - data.g = struct ("x", x, "h", h); - - data = so_example_problem (data); - data.handler = struct (); - - phi0 = ls_genbasic (data.g.x, "box", -3, 5); -***** error - so_run_descent (1, 2); -***** error - so_run_descent (1, 2, 3, 4); -***** error - so_run_descent (0, phi0, data); -***** error - so_run_descent (1.5, phi0, data); -***** error - so_run_descent ([2, 3], phi0, data); -***** error - d = data; - d.p.descent.initialStep = 0; - so_run_descent (1, phi0, d); -***** test - nSteps = 12; + [XX, YY] = meshgrid (x, x); - [s, descentLog] = so_run_descent (nSteps, phi0, data); - assert (s.cost, 0, 1e-3); - assert (length (descentLog.costs), nSteps + 1); - assert (descentLog.costs(end), s.cost); - %semilogy (descentLog.costs, "o"); -***** test - tol = 5e-2; - nSteps = 100; - d = data; - d.cb.check_stop = @(data) (data.cost < tol); + phi0 = YY - XX + 15; + f = sign (XX) + 2; - [s, descentLog] = so_run_descent (nSteps, phi0, d); - assert (s.cost < tol); - printf ("Steps needed: %d\n", descentLog.steps); - assert (descentLog.steps < nSteps); -Steps needed: 8 + d = ls_solve_stationary (phi0, f, h); + figure (); + contour (XX, YY, d); + line ([0, 0], [-10, 10]); + title ("Refraction"); ***** demo - data = struct (); - data.p = so_init_params (true); - data.p.vol = 10; - data.p.weight = 50; - - n = 100; + n = 101; x = linspace (-10, 10, n); h = x(2) - x(1); - data.g = struct ("x", x, "h", h); - - % Look at so_example_problem to see how the callbacks - % and the plotting handler is defined. - data = so_example_problem (data); + [XX, YY] = meshgrid (x, x); - phi0 = ls_genbasic (data.g.x, "box", -3, 7); - [s, descentLog] = so_run_descent (5, phi0, data); + phi0 = XX + 9; + f = ones (size (phi0)); + f(XX == 0 & abs (YY) > 2) = 0; + d = ls_solve_stationary (phi0, f, h); figure (); - semilogy (0 : descentLog.steps, descentLog.costs, "o"); - title ("Cost Descrease"); - - printf ("\nFinal interval: [%.6d, %.6d]\n", s.a, s.b); - printf ("Final cost: %.6d\n", s.cost); + contour (XX, YY, d); + line ([0, 0], [-10, -2]); + line ([0, 0], [2, 10]); + title ("Diffraction"); 8 tests, 8 passed, 0 known failure, 0 skipped -[inst/ls_absolute_geom.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_absolute_geom.m -***** error - ls_absolute_geom (1, 2); -***** error - ls_absolute_geom (1, 2, 3, 4); -***** error - x = [-1, 1]; - [XX, YY, ZZ] = ndgrid (x); - ls_absolute_geom (struct (), XX, YY); -***** error - ls_absolute_geom (struct (), [-1, 0, 1], [0, 0, 0]); -***** error - ls_absolute_geom (struct (), zeros (3, 2), zeros (2, 2)); -5 tests, 5 passed, 0 known failure, 0 skipped [inst/ls_issubset.m] >>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_issubset.m ***** error @@ -5355,7 +4627,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5363,7 +4635,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5371,7 +4643,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5379,7 +4651,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5387,7 +4659,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5395,7 +4667,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5403,7 +4675,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5411,7 +4683,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5419,7 +4691,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5427,7 +4699,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5435,7 +4707,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5443,7 +4715,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5451,7 +4723,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5459,7 +4731,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5467,7 +4739,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5475,7 +4747,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5483,7 +4755,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5491,7 +4763,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5499,7 +4771,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5507,7 +4779,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5515,7 +4787,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5523,7 +4795,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5531,7 +4803,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.088561 to 0.090209 warning: called from @@ -5539,7 +4811,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5547,7 +4819,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5555,7 +4827,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5563,7 +4835,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5571,7 +4843,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5579,7 +4851,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5587,7 +4859,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5595,7 +4867,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5603,7 +4875,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5611,7 +4883,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5619,7 +4891,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5627,7 +4899,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5635,7 +4907,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5643,7 +4915,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5651,7 +4923,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5659,7 +4931,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5667,7 +4939,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5675,7 +4947,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5683,7 +4955,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5691,7 +4963,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5699,7 +4971,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5707,7 +4979,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5715,7 +4987,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5723,7 +4995,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 warning: increased distance in fast marching 0.105699 to 0.105896 warning: called from @@ -5731,7 +5003,7 @@ ls_signed_distance at line 45 column 5 __test__ at line 16 column 7 test at line 682 column 11 - /tmp/tmp.OmGkgeBbE1 at line 254 column 31 + /tmp/tmp.2JzDtJpmdf at line 222 column 31 ***** demo n = 100; @@ -5766,43 +5038,456 @@ phi0 = ls_genbasic (XX, YY, "sphere", [0, 0], 3); ls_animate_evolution (phi0, F, h, linspace (0, 3, 40), 0.01); 8 tests, 8 passed, 0 known failure, 0 skipped -[inst/ls_union.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_union.m +[inst/ls_find_geometry.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_find_geometry.m ***** error - ls_union () -***** error - ls_union (1, -2, [1, 2]) + ls_find_geometry () +***** error + ls_find_geometry (1, 2, 3, 4) +***** error + ls_find_geometry (resize (zeros (8, 1), [2, 2, 2])) +***** error + ls_find_geometry ([1, -1, 1]) +***** error + ls_find_geometry ([0, 1; -1, -1]) +***** error + ls_find_geometry ([-1, NA; -1, -1]) +***** function verifyGeometry (phi, geom) + sz = size (phi); + nNode = prod (sz); + L = sz(1); + M = sz(2); + nElem = (L - 1) * (M - 1); + assert (geom.dim, sz); + + % Basic properties of the elem field. + assert (geom.elem.n, nElem); + assert (size (geom.elem.nodelist), [nElem, 4]); + assert (all (geom.elem.type(geom.elem.index.inner) == -1)); + assert (all ((geom.elem.type(geom.elem.index.bdry) == 0))); + assert (all ((geom.elem.type(geom.elem.index.outer) == 1))); + % Order of the nodes in nodelist. + assert (geom.elem.nodelist(1, :), [L+2, 2, 1, L+1]); + % Correct classification of inner/outer/bdry elements. + assert (all (phi(geom.elem.nodelist(geom.elem.index.inner, :))(:) < 0)); + assert (all (phi(geom.elem.nodelist(geom.elem.index.outer, :))(:) > 0)); + bdryPhis = phi(geom.elem.nodelist(geom.elem.index.bdry, :)); + bdryPhis = sort (bdryPhis, 2); + assert (all (bdryPhis(:, 1) < 0) && all (bdryPhis(:, end) > 0)); + + % Each boundary element should have two or four intersected edges. + % Also verify that the start/endEdge fields of the internal information + % match up to the points in question. + for i = 1 : geom.bdryel.n + empty = length (find (isna (geom.bdryel.edges(i, :)))); + assert (empty == 2 || empty == 0); + for j = 1 : length (geom.internal.bdryelSegments{i}) + s = geom.internal.bdryelSegments{i}{j}; + assert (geom.bdryel.edges(i, s.startEdge) == s.startPt); + assert (geom.bdryel.edges(i, s.endEdge) == s.endPt); + endfor + endfor + + % Run through gamma components and verify that geom.ispts.onedge matches. + for i = 1 : geom.gamma.n + c = geom.gamma.ispts{i}; + c(end + 1) = c(1); + for j = 1 : length (c) - 1 + cur = c(j); + next = c(j + 1); + bdryel = geom.ispts.onedge(cur, 1, 1); + assert (geom.ispts.onedge(next, 2, 1), bdryel); + assert (geom.bdryel.edges(bdryel, geom.ispts.onedge(cur, 1, 2)), cur); + assert (geom.bdryel.edges(bdryel, geom.ispts.onedge(next, 2, 2)), next); + + edgeForward = geom.ispts.onedge(cur, 1, 3); + assert (geom.bedges.ispts(edgeForward, 1), cur); + assert (geom.bedges.ispts(edgeForward, 2), next); + + assert (geom.ispts.gammachain(cur, 1), next); + assert (geom.ispts.gammachain(next, 2), cur); + endfor + endfor + + % Verify that the ordering of points in bedges matches the onedge + % information about start / end points in each boundary element. + for i = 1 : geom.bedges.n + assert (geom.ispts.onedge(geom.bedges.ispts(i, 1), 1, 1), ... + geom.ispts.onedge(geom.bedges.ispts(i, 2), 2, 1)); + assert (geom.ispts.onedge(geom.bedges.ispts(i, 1), 1, 3), i); + assert (geom.ispts.onedge(geom.bedges.ispts(i, 2), 2, 3), i); + endfor +***** endfunction +***** test + phis = ls_get_tests (); + hs = [0.1, 0.5, 1, 1.5]; + for i = 1 : length (phis) + for h = hs + for s = [-1, 1] + cur = phis{i} * s; + phi = ls_normalise (cur, h); + geom = ls_find_geometry (phi, h); + verifyGeometry (phi, geom); + endfor + endfor + endfor +***** test + phi = ones (4, 4); + phi(2 : 3, 2 : 3) = [Inf, -1; -Inf, 2]; + g = ls_find_geometry (phi, 0.1, 0.01); + + ind = find (g.elem.index.bdry == 5); + assert (size (ind), [1, 1]); + edges = g.bdryel.edges(ind, :); + assert (all (~isna (edges))); + + assert (g.ispts.inout(edges, :), [7, 11; 7, 6; 10, 6; 10, 11]); + assert (g.ispts.frac(edges), [0.99; 0.5; 0.01; 1/3], sqrt (eps)); + assert (g.ispts.incoord(edges, :), ... + [0.099, 0; 0, -0.05; -0.001, 0; 0, 1/30], sqrt (eps)); +***** error + phi = [-1, -1; 1, 1]; + ls_find_geometry (phi); +***** test + phi = ones (3, 3); + phi(2, 2) = -1; + geom = ls_find_geometry (phi); + + % Permute the component array such that it starts with the north point + % and then compare coordinates. Note that the "north" point is "south" + % in matrix interpretation and thus has "outindex" of 6. + assert (geom.gamma.n, 1); + c = geom.gamma.ispts{1}'; + while (geom.ispts.inout(c(1), 2) != 6) + c = [c(2 : end), c(1)]; + endwhile + assert (geom.ispts.incoord(c, :), ... + [0, 1/2; -1/2, 0; 0, -1/2; 1/2, 0], sqrt (eps)); +***** function checkBoundaryDirection (pts, dir) + pts(end + 1, :) = pts(1, :); + for i = 1 : length (pts) - 1 + a = [pts(i, :), 0]; + b = [pts(i + 1, :), 0]; + z = cross (a, b); + assert (z(1 : 2), [0, 0]); + assert (sign (z(3)), dir); + endfor +***** endfunction ***** test n = 50; x = linspace (-10, 10, n); + h = x(2) - x(1); [XX, YY] = meshgrid (x, x); - phi1 = (XX - 3).^2 + (YY - 3).^2 - 2^2; - phi2 = (XX + 3).^2 + (YY + 3).^2 - 2^2; - phi3 = XX.^2 + YY.^2 - 2^2; + phi = ls_setdiff (ls_genbasic (XX, YY, "sphere", [0, 0], 8), ... + ls_genbasic (XX, YY, "sphere", [0, 0], 4)); + phi = ls_normalise (phi, h); + geom = ls_find_geometry (phi, h); + geom = ls_absolute_geom (geom, XX, YY); - phi = ls_union (phi1, phi2, phi3); - assert (ls_issubset (phi1, phi)); - assert (ls_issubset (phi2, phi)); - assert (ls_issubset (phi3, phi)); + assert (geom.gamma.n, 2); + len1 = length (geom.gamma.ispts{1}); + len2 = length (geom.gamma.ispts{2}); + if (len1 < len2) + outer = geom.gamma.ispts{2}; + inner = geom.gamma.ispts{1}; + else + assert (len1 > len2); + outer = geom.gamma.ispts{1}; + inner = geom.gamma.ispts{2}; + endif - assert (ls_union (phi3), phi3); + checkBoundaryDirection (geom.ispts.coord(outer, :), 1); + checkBoundaryDirection (geom.ispts.coord(inner, :), -1); +***** test + phi = ones (4, 4); + phi(2, 2) = -1; + phi(3, 3) = -1; + + geom = ls_find_geometry (phi); + assert (geom.gamma.n, 2); + geom = ls_find_geometry (-phi); + assert (geom.gamma.n, 1); + + % Now also try with other "kind" of narrow pair. + phi = phi(:, end : -1 : 1); + geom = ls_find_geometry (phi); + assert (geom.gamma.n, 2); + geom = ls_find_geometry (-phi); + assert (geom.gamma.n, 1); +***** demo + n = 15; + x = linspace (-10, 10, n); + h = x(2) - x(1); + [XX, YY] = meshgrid (x, x); + + r1 = sqrt (2) * 2.9; + r2 = 3; + phi = ls_union (ls_genbasic (XX, YY, "sphere", [-3, -3], r1), ... + ls_genbasic (XX, YY, "sphere", [3, 3], r1), ... + ls_genbasic (XX, YY, "sphere", [-5, 5], r2), ... + ls_genbasic (XX, YY, "sphere", [5, -5], r2)); + + phi = ls_normalise (phi, h); + g = ls_find_geometry (phi, h, 0.2); + g = ls_absolute_geom (g, XX, YY); + + figure (); + hold ("on"); + + for i = 1 : size (g.elem.nodelist, 1) + nodes = g.elem.nodelist(i, :); + switch (g.elem.type(i)) + case -1 + colour = [0.5, 0.5, 1]; + case 0 + colour = [1, 0.5, 0.5]; + case 1 + colour = [0.8, 0.8, 0.8]; + endswitch + patch (XX(nodes), YY(nodes), colour); + endfor + + plot (g.ispts.coord(:, 1), g.ispts.coord(:, 2), "k.", "MarkerSize", 8); + for i = 1 : g.gamma.n + pts = g.gamma.ispts{i}; + pts(end + 1) = pts(1); + plot (g.ispts.coord(pts, 1), g.ispts.coord(pts, 2), "k-", "LineWidth", 2); + endfor + + contour (XX, YY, phi, [0, 0], "g"); + + axis ([min(x), max(x), min(x), max(x)]); + axis ("equal"); + grid ("on"); + set (gca (), "xtick", x, "ytick", x, "xticklabel", "", "yticklabel", ""); + hold ("off"); +12 tests, 12 passed, 0 known failure, 0 skipped +[inst/ls_init_narrowband.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_init_narrowband.m +***** error + ls_init_narrowband () +***** error + ls_init_narrowband (1, 2, 3) +***** test + assert (ls_init_narrowband ([]), []); +***** test + n = 10; + x = linspace (-2, 2, n); + h = x(2) - x(1); + phi = abs (x) - 1; + + d = ls_init_narrowband (phi, h); + where = ~isna (d); + assert (d(where), phi(where), sqrt (eps)); +***** test + n = 50; + x = linspace (-2, 2, n); + h = x(2) - x(1); + [XX, YY, ZZ] = ndgrid (x); + RRsq = XX.^2 + YY.^2 + ZZ.^2; + phi = RRsq - 1; + + d = ls_init_narrowband (phi, h); + where = ~isna (d); + assert (d(where), sqrt (RRsq(where)) - 1, h / 3); +***** test + tol = sqrt (eps); + assert (ls_init_narrowband ([Inf, -Inf, Inf]), [0.5, -0.5, 0.5], tol); + assert (ls_init_narrowband ([Inf, -1, Inf]), [1, 0, 1], tol); + %assert (ls_init_narrowband ([1, -Inf, 1]), [0, 1, 0], tol); +***** function dh = distToSegment (x, a, b) + dir = b - a; + dir /= norm (dir); + proj = dot (x - a, dir); + if (proj < 0) + dh = norm (x - a); + elseif (proj > 1) + dh = norm (x - b); + else + dh = norm (x - (a + proj * dir)); + endif +***** endfunction +***** function dh = distToLine (x, c) + assert (c(1, 1), 0); + dh = Inf; + for i = 2 : size (c, 2) - 1 + dh = min (dh, distToSegment (x, c(:, i), c(:, i + 1))); + endfor +***** endfunction +***** function dh = distOfContoursAsym (c1, c2) + dh = 0; + for i = 2 : size (c1, 2) + dh = max (dh, distToLine (c1(:, i), c2)); + endfor +***** endfunction +***** function dh = distOfContours (c1, c2) + dh = max (distOfContoursAsym (c1, c2), distOfContoursAsym (c2, c1)); +***** endfunction +***** test + phis = ls_get_tests (); + printf ("Comparing contours for %d cases...\n", length (phis)); + for i = 1 : length (phis) + d = ls_init_narrowband (phis{i}); + c1 = contourc (d, [0, 0]); + if (size (c1, 2) > 0) + c2 = contourc (phis{i}, [0, 0]); + dh = distOfContours (c1, c2); + printf ("i = %d: dist = %f\n", i, dh); + if (isfinite (dh)) + assert (dh, 0, 1e-1); + endif + endif + endfor +Comparing contours for 6 cases... +i = 1: dist = 0.060660 +i = 2: dist = Inf +i = 4: dist = 0.039039 +i = 5: dist = 0.085786 +i = 6: dist = 0.085786 +7 tests, 7 passed, 0 known failure, 0 skipped +[inst/ls_check.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_check.m +***** error + ls_check (1, 2) +***** error + ls_check (1, 2, 3, 4) +***** error + ls_check (1, "inside", [1, 2]); +***** error + ls_check (1, "foo", true); +***** error + ls_check (1, NA, false); +***** test + n = 100; + x = linspace (-10, 10, n); + [XX, YY] = meshgrid (x, x); + + circ2 = (XX.^2 + YY.^2 < 2^2); + circ8 = (XX.^2 + YY.^2 < 8^2); + phi = (XX.^2 + YY.^2 - 5^2); + + assert (ls_check (phi, "inside", circ8)); + assert (ls_check (phi, "contain", circ2)); + assert (ls_check (phi, "outside", ~circ8)); + + assert (~ls_check (phi, "inside", circ2)); + assert (~ls_check (phi, "contain", circ8)); + assert (~ls_check (phi, "outside", circ8)); +6 tests, 6 passed, 0 known failure, 0 skipped +[inst/so_run_descent.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/so_run_descent.m +***** shared data, phi0 + data = struct (); + data.p = so_init_params (false); + data.p.vol = 10; + data.p.weight = 50; + + n = 100; + x = linspace (-10, 10, n); + h = x(2) - x(1); + data.g = struct ("x", x, "h", h); + + data = so_example_problem (data); + data.handler = struct (); + + phi0 = ls_genbasic (data.g.x, "box", -3, 5); +***** error + so_run_descent (1, 2); +***** error + so_run_descent (1, 2, 3, 4); +***** error + so_run_descent (0, phi0, data); +***** error + so_run_descent (1.5, phi0, data); +***** error + so_run_descent ([2, 3], phi0, data); +***** error + d = data; + d.p.descent.initialStep = 0; + so_run_descent (1, phi0, d); +***** test + nSteps = 12; + + [s, descentLog] = so_run_descent (nSteps, phi0, data); + assert (s.cost, 0, 1e-3); + assert (length (descentLog.costs), nSteps + 1); + assert (descentLog.costs(end), s.cost); + %semilogy (descentLog.costs, "o"); +***** test + tol = 5e-2; + nSteps = 100; + d = data; + d.cb.check_stop = @(data) (data.cost < tol); + + [s, descentLog] = so_run_descent (nSteps, phi0, d); + assert (s.cost < tol); + printf ("Steps needed: %d\n", descentLog.steps); + assert (descentLog.steps < nSteps); +Steps needed: 8 +***** demo + data = struct (); + data.p = so_init_params (true); + data.p.vol = 10; + data.p.weight = 50; + + n = 100; + x = linspace (-10, 10, n); + h = x(2) - x(1); + data.g = struct ("x", x, "h", h); + + % Look at so_example_problem to see how the callbacks + % and the plotting handler is defined. + data = so_example_problem (data); + + phi0 = ls_genbasic (data.g.x, "box", -3, 7); + [s, descentLog] = so_run_descent (5, phi0, data); + + figure (); + semilogy (0 : descentLog.steps, descentLog.costs, "o"); + title ("Cost Descrease"); + + printf ("\nFinal interval: [%.6d, %.6d]\n", s.a, s.b); + printf ("Final cost: %.6d\n", s.cost); +8 tests, 8 passed, 0 known failure, 0 skipped +[inst/ls_setdiff.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_setdiff.m +***** error + ls_setdiff (1) +***** error + ls_setdiff (1, 2, 3) +***** error + ls_setdiff (1, [1, 2]) +***** test + assert (ls_equal (ls_setdiff ([-1, -1, 1], [1, -1, -1]), [-1, 1, 1])); + n = 50; + x = linspace (-10, 10, n); + h = x(2) - x(1); + [XX, YY] = meshgrid (x, x); + + phi1 = XX.^2 + YY.^2 - 8^2; + phi2 = XX.^2 + YY.^2 - 5^2; + + phi = ls_setdiff (phi1, phi2); + assert (ls_issubset (phi, phi1)); + assert (ls_disjoint (phi, phi2)); + + phi = ls_setdiff (phi2, phi1); + assert (ls_isempty (phi)); ***** demo n = 100; x = linspace (-7, 7, n); [XX, YY] = meshgrid (x, x); - phi1 = (XX - 2 * cos (7/6 * pi)).^2 + (YY - 2 * sin (7/6 * pi)).^2 - 3^2; - phi2 = (XX - 2 * cos (11/6 * pi)).^2 + (YY - 2 * sin (11/6 * pi)).^2 - 3^2; - phi3 = XX.^2 + (YY - 2).^2 - 3^2; - phi = ls_union (phi1, phi2, phi3); + phi1 = (XX - 2).^2 + YY.^2 - 3^2; + phi2 = (XX + 2).^2 + YY.^2 - 3^2; + phi = ls_setdiff (phi1, phi2); figure (); subplot (1, 2, 1); hold ("on"); contour (XX, YY, phi1, [0, 0], "k"); contour (XX, YY, phi2, [0, 0], "k"); - contour (XX, YY, phi3, [0, 0], "k"); hold ("off"); axis ("equal"); @@ -5814,48 +5499,20 @@ contour (XX, YY, phi, [0, 0], "k"); hold ("off"); axis ("equal"); -3 tests, 3 passed, 0 known failure, 0 skipped -[inst/ls_intersect.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_intersect.m -***** error - ls_intersect () -***** error - ls_intersect (1, -2, [1, 2]) -***** test - n = 50; - x = linspace (-10, 10, n); - [XX, YY] = meshgrid (x, x); - - phi1 = (XX - 2).^2 + (YY - 2).^2 - 2^2; - phi2 = (XX + 2).^2 + (YY + 2).^2 - 2^2; - phi3 = XX.^2 + YY.^2 - 2^2; - - assert (ls_isempty (ls_intersect (phi1, phi2))); - assert (ls_intersect (phi3), phi3); - - phi = ls_intersect (phi1, phi3); - assert (~ls_isempty (phi)); - assert (ls_issubset (phi, phi1) && ls_issubset (phi, phi3)); - - phi = ls_intersect (phi2, phi3); - assert (~ls_isempty (phi)); - assert (ls_issubset (phi, phi2) && ls_issubset (phi, phi3)); ***** demo n = 100; x = linspace (-7, 7, n); [XX, YY] = meshgrid (x, x); - phi1 = (XX - 2 * cos (7/6 * pi)).^2 + (YY - 2 * sin (7/6 * pi)).^2 - 3^2; - phi2 = (XX - 2 * cos (11/6 * pi)).^2 + (YY - 2 * sin (11/6 * pi)).^2 - 3^2; - phi3 = XX.^2 + (YY - 2).^2 - 3^2; - phi = ls_intersect (phi1, phi2, phi3); + phi1 = XX.^2 + YY.^2 - 6^2; + phi2 = XX.^2 + YY.^2 - 3^2; + phi = ls_setdiff (phi1, phi2); figure (); subplot (1, 2, 1); hold ("on"); contour (XX, YY, phi1, [0, 0], "k"); contour (XX, YY, phi2, [0, 0], "k"); - contour (XX, YY, phi3, [0, 0], "k"); hold ("off"); axis ("equal"); @@ -5867,7 +5524,117 @@ contour (XX, YY, phi, [0, 0], "k"); hold ("off"); axis ("equal"); -3 tests, 3 passed, 0 known failure, 0 skipped +4 tests, 4 passed, 0 known failure, 0 skipped +[inst/ls_signed_distance.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_signed_distance.m +***** error + ls_signed_distance () +***** error + ls_signed_distance (1, 2, 3) +***** test + assert (ls_signed_distance ([]), []); +***** test + n = 10; + x = linspace (-2, 2, n); + h = x(2) - x(1); + phi = abs (x) - 1; + + d = ls_signed_distance (phi, h); + assert (d, phi, sqrt (eps)); +***** test + n = 50; + x = linspace (-2, 2, n); + h = x(2) - x(1); + [XX, YY, ZZ] = ndgrid (x); + RRsq = XX.^2 + YY.^2 + ZZ.^2; + phi = RRsq - 1; + + d = ls_signed_distance (phi, h); + assert (d, sqrt (RRsq) - 1, h); +***** test + phi = [5e-6, 1.7e-154, -1.3e-2]; + for h = [0.02, 0.01, 0.005] + d = ls_signed_distance (phi, h); + assert (all (isfinite (d))); + assert (d(2), 0); + endfor +***** test + phis = ls_get_tests (); + for i = 1 : length (phis) + phi = ls_normalise (phis{i}); + d = ls_signed_distance (phi); + assert (ls_equal (d, phi)); + endfor +***** test + if (exist ("signbit") == 5) + phi = [-0, 0]; + d = ls_signed_distance (phi); + assert (ls_equal (phi, d)); + else + warning ("'signbit' function not available, skipping test."); + endif +***** demo + n = 100; + x = linspace (-10, 10, n); + h = x(2) - x(1); + [XX, YY] = meshgrid (x, x); + + phi0 = atan (ls_union ((XX.^2 + (YY - 5).^2) - 20, ... + (XX.^2 + (YY + 5).^2) - 20)); + %phi0 = XX.^2 / 1.3^2 + YY.^2 - 1; + d = ls_signed_distance (phi0, h); + + figure (); + subplot (1, 2, 1); + contour (XX, YY, phi0); + title ("Initial"); + colorbar (); + axis ("equal"); + + subplot (1, 2, 2); + contour (XX, YY, d); + title ("Signed Distance"); + colorbar (); + axis ("equal"); +8 tests, 8 passed, 0 known failure, 0 skipped +[inst/ls_enforce.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_enforce.m +***** error + ls_enforce (1, 2) +***** error + ls_enforce (1, 2, 3, 4) +***** error + ls_enforce (1, "inside", [1, 2]); +***** error + ls_enforce (1, "foo", true); +***** error + ls_enforce (1, NA, false); +***** test + n = 100; + x = linspace (-10, 10, n); + [XX, YY] = meshgrid (x, x); + + circ2 = (XX.^2 + YY.^2 < 2^2); + circ8 = (XX.^2 + YY.^2 < 8^2); + phi = (XX.^2 + YY.^2 - 5^2); + + phi2 = ls_enforce (phi, "inside", circ8); + assert (ls_equal (phi2, phi)); + phi2 = ls_enforce (phi, "inside", circ2); + assert (ls_check (phi2, "inside", circ2)); + + phi2 = ls_enforce (phi, "contain", circ2); + assert (ls_equal (phi2, phi)); + phi2 = ls_enforce (phi, "contain", circ8); + assert (ls_check (phi2, "contain", circ8)); + + phi2 = ls_enforce (phi, "outside", ~circ8); + assert (ls_equal (phi2, phi)); + phi2 = ls_enforce (phi, "outside", ~circ2); + ls_check (phi2, "outside", ~circ2); + phi2 = ls_enforce (phi, "outside", circ2); + ls_check (phi2, "outside", circ2); +6 tests, 6 passed, 0 known failure, 0 skipped [inst/ls_isempty.m] >>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_isempty.m ***** error @@ -5886,105 +5653,374 @@ assert (ls_isempty (ls_intersect (phi1, phi2))); assert (~ls_isempty (ls_union (phi1, phi2))); 3 tests, 3 passed, 0 known failure, 0 skipped -[inst/ls_nb_from_geom.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_nb_from_geom.m +[inst/fastmarching.m] +>>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/fastmarching.m ***** error - ls_nb_from_geom (1) -***** error - ls_nb_from_geom (1, 2, 3, 4) + fastmarching () +***** error + fastmarching (1, 2, 3, 4) ***** error - [a, b] = ls_nb_from_geom (1, 2); -***** error - ls_nb_from_geom (1, 2, rand (2, 2)); -***** error - x = linspace (-10, 10, 10); + [a, b] = fastmarching (1, 2) +***** error + fastmarching ([1, 2], [1; 2]) +***** error + fastmarching ([1, 2], [1; 2], [1, 2]) +***** error + fastmarching ([NA, 1], [0, 5]); +***** test + n = 600; + x = linspace (0, 1, n); h = x(2) - x(1); [XX, YY] = meshgrid (x, x); - phi = ls_genbasic (XX, YY, "sphere", [0, 0], 5); - phi = ls_normalise (phi, h); - geom = ls_find_geometry (phi, h); - ls_nb_from_geom (geom, phi); -***** error - x = linspace (-10, 10, 10); + u0 = NA (n, n); + u0(2 : end - 1, 2 : end - 1) = Inf; + u0(1, 1) = 0; + f = 1 + YY; + u = fastmarching (u0, h * f); + + % Length of vertical side: integrate (1 + y, y, 0, x) + vertLength = @(x) x/2 .* (x + 2); + + % Speed difference at top and bottom, gives where the + % paths will meet on the bottom side. + % solve (x * fBot = fTop + (1 - x) * fBot, x) + fTop = mean (f(1, :)); + fBot = mean (f(end, :)); + xMeet = (fTop + fBot) / 2 / fBot; + botRow = vertLength (1) + fBot * x; + where = (x > xMeet); + botRow(where) = vertLength (1) + 1 + fBot * (1 - x(where)); + + assert (u(1, :), x, sqrt (eps)); + assert (u(:, 1), vertLength (x'), 1e-3); + assert (u(:, end), 1 + vertLength (x'), 1e-3); + assert (u(end, :), botRow, 1e-3); +***** test + n = 1100; + x = linspace (0, 1, n); h = x(2) - x(1); - [XX, YY] = meshgrid (x, x); - phi = ls_genbasic (XX, YY, "sphere", [0, 0], 5); - phi = ls_normalise (phi, h); - geom = ls_find_geometry (phi, h); - ls_nb_from_geom (geom, phi, [1, 2, 3]); + + obst1 = round (0.5 / h); + obst2 = round (0.75 / h); + s1 = round (0.2 / h); + s1val = 1; + s2 = round (0.9 / h); + s2val = -1; + + u0 = NA (n, 1); + u0([obst1, obst2]) = Inf; + u0([s1, s2]) = [s1val, s2val]; + f = ones (size (u0)); + g0 = NA (size (u0)); + g0([s1, s2]) = [s1val, s2val]; + + [u, g] = fastmarching (u0, g0, f * h); + + gDesired = NA (size (u0)); + gDesired(1 : obst1 - 1) = s1val; + gDesired(obst2 + 1 : end) = s2val; + assert (g, gDesired, sqrt (eps)); + + uDesired = NA (size (u0)); + uDesired([obst1, obst2]) = Inf; + uDesired(1 : obst1 - 1) = s1val + abs (s1 * h - x(1 : obst1 - 1)); + uDesired(obst2 + 1 : end) = s2val + abs (s2 * h - x(obst2 + 1 : end)); + assert (u, uDesired, 1e-3); ***** test - n = 50; - x = linspace (-10, 10, n); + assert (fastmarching ([], []), []); +***** test + n = 42; + r = 1; + R = 2; + x = linspace (-R, R, n); h = x(2) - x(1); - [XX, YY] = meshgrid (x, x); - phi = ls_setdiff (ls_genbasic (XX, YY, "sphere", [0, 0], 8), ... - ls_genbasic (XX, YY, "sphere", [1, 1], 5)); - phi = ls_normalise (phi, h); - geom = ls_find_geometry (phi, h); - geom = ls_absolute_geom (geom, XX, YY); + [XX, YY, ZZ] = ndgrid (x); + RR = sqrt (XX.^2 + YY.^2 + ZZ.^2); + PPhi = NA (size (XX)); + for i = 1 : numel (PPhi) + pt = [XX(i), YY(i), ZZ(i)]; + PPhi(i) = acos (dot (pt, [0, 0, 1]) / norm (pt)); + endfor - dOld = ls_init_narrowband (phi, h); - dNew = ls_nb_from_geom (geom, phi); + initial = (RR < r); + u0 = NA (size (XX)); + u0(initial) = 0; + g0 = NA (size (XX)); + g0(initial) = PPhi(initial); + f = ones (size (u0)); + [u, g] = fastmarching (u0, g0, h * f); - where = (!isna (dOld)); - assert (all (!isna (dNew(where)))); - assert (dNew(where), dOld(where), h / 4); -***** demo - n = 50; - x = linspace (-10, 10, n); + assert (u(~initial), RR(~initial) - r, 1e-1); + assert (g(~initial), PPhi(~initial), 2e-1); +***** function [dx, dy] = gradient (fcn, h) + ext = NA (size (fcn) + 2); + ext(2 : end - 1, 2 : end - 1) = fcn; + ext(:, 1) = 2 * ext(:, 2) - ext(:, 3); + ext(:, end) = 2 * ext(:, end - 1) - ext(:, end - 2); + ext(1, :) = 2 * ext(2, :) - ext(3, :); + ext(end, :) = 2 * ext(end - 1, :) - ext(end - 2, :); + dx = (ext(2 : end - 1, 3 : end) - ext(2 : end - 1, 1 : end - 2)) / (2 * h); + dy = (ext(3 : end, 2 : end - 1) - ext(1 : end - 2, 2 : end - 1)) / (2 * h); +***** endfunction +***** test + n = 1000; + x = linspace (-2, 2, n); h = x(2) - x(1); [XX, YY] = meshgrid (x, x); - phi = ls_genbasic (XX, YY, "sphere", [0, 0], 3); - phi = ls_normalise (phi, h); - geom = ls_find_geometry (phi, h); - geom = ls_absolute_geom (geom, XX, YY); + phi0 = 2 * XX.^2 + 0.4 * YY.^2 - 1; + initial = (phi0 < 0); + %contour (XX, YY, phi0, [0, 0], "r"); - g0 = NA (1, geom.bedges.n); - for i = 1 : geom.bedges.n - a = geom.ispts.coord(geom.bedges.ispts(i, 1), :); - b = geom.ispts.coord(geom.bedges.ispts(i, 2), :); - m = (a + b) / 2; - angle = abs (atan2 (m(2), m(1))); - g0(i) = min (angle, 2 * pi - angle); - endfor + f = ones (size (XX)); + u0 = NA (size (XX)); + u0(initial) = 0; + g0 = NA (size (XX)); + g0(initial) = sin (atan2 (YY(initial), XX(initial))); - [d, g] = ls_nb_from_geom (geom, phi, g0); - [d, g] = fastmarching (d, g, h * ones (size (phi))); + [u, g] = fastmarching (u0, g0, h * f); - figure (); - hold ("on"); - imagesc (x, x, g); - set (gca (), "ydir", "normal"); - contour (XX, YY, phi, [0, 0], "k"); - hold ("off"); - colorbar (); -7 tests, 7 passed, 0 known failure, 0 skipped -[inst/ls_disjoint.m] ->>>>> /build/reproducible-path/octave-level-set-0.3.1~git.2019.04.13/inst/ls_disjoint.m -***** error - ls_disjoint () -***** error - ls_disjoint (1, -2, [1, 2]) + [dxu, dyu] = gradient (u, h); + [dxg, dyg] = gradient (g, h); + + % We only verify the mean error here, since there tend + % to be lower-dimensional lines on which the error is + % large while it is very low otherwise. + err = abs (dxu .* dxg + dyu .* dyg); + assert (mean (err(initial)), 0, 1e-3); ***** test - assert (ls_disjoint ([-1, 0, 1], [0, 0, 0], [1, 0, -1])); - assert (~ls_disjoint ([Inf, -Inf, 1], [-1, -1, 1])); - assert (~ls_disjoint ([-1, -1, 1], [0, 0, 0], [1, -1, -1])); + u0 = [1.257221, NA, NA; Inf, 0.275128, 0.433001]; + f = [NA, 0.85714, 0.66667; NA, NA, NA]; + u = fastmarching (u0, f); +warning: increased distance in fast marching 1.121446 to 1.131670 +warning: called from + fastmarching at line 110 column 19 + __test__ at line 5 column 5 + test at line 682 column 11 + /tmp/tmp.2JzDtJpmdf at line 294 column 31 + ***** test - n = 50; - x = linspace (-10, 10, n); + u0 = [0, NA; Inf, 2]; + f = ones (size (u0)); + u = fastmarching (u0, f); + assert (u(1, 2), 1, sqrt (eps)); +warning: found too far alive point in fast marching, d = -8.000000 +warning: called from + fastmarching at line 110 column 19 + __test__ at line 5 column 5 + test at line 682 column 11 + /tmp/tmp.2JzDtJpmdf at line 294 column 31 + +warning: found too far alive point in fast marching, d = -8.000000 +warning: called from + fastmarching at line 110 column 19 + __test__ at line 5 column 5 + test at line 682 column 11 + /tmp/tmp.2JzDtJpmdf at line 294 column 31 + +***** test + u0 = [0, NA, NA, NA, 0.1; ... + Inf, Inf, Inf, Inf, Inf; ... + 0.1, NA, NA, NA, 0]; + f = ones (size (u0)); + u = fastmarching (u0, f); + + uExpected = [0, 1, 2, 1.1, 0.1; ... + Inf, Inf, Inf, Inf, Inf; ... + 0.1, 1.1, 2, 1, 0]; + assert (u, uExpected, sqrt (eps)); +***** xtest + ns = [101, 201, 501, 1001, 2001]; + realNs = NA (size (ns)); + times = NA (size (ns)); + for i = 1 : length (ns) + nMid = (ns(i) + 1) / 2; + assert (nMid, round (nMid)); + u0 = NA (ns(i), ns(i)); + u0(nMid, nMid) = 0; + f = ones (size (u0)); + realNs(i) = numel (u0); + + old = cputime (); + u = fastmarching (u0, f); + new = cputime (); + times(i) = new - old; + + printf ("n = %4d: t = %6.3f s\n", ns(i), times(i)); + endfor + + nLogN = realNs .* log (realNs); + p = polyfit (log (realNs), log (times), 1); + pLogN = polyfit (log(nLogN), log (times), 1); + printf ("Exponents:\n O(n): %4.2f\n O(n log n): %4.2f\n", ... + p(1), pLogN(1)); + assert (p(1), 1, 1e-1); + assert (pLogN(1), 1, 1e-1); +n = 101: t = 0.037 s +n = 201: t = 0.149 s +n = 501: t = 0.975 s +n = 1001: t = 4.144 s +n = 2001: t = 17.764 s +Exponents: + O(n): 1.04 + O(n log n): 0.96 +***** test + T = 1.6; + timeSteps = 10000; + L = 2; + gridSteps = 10000; + eps = 1e-4; + floorValue = -1/2; + tol = 7e-2; + + t = linspace (0, T, timeSteps); + dt = t(2) - t(1); + x = linspace (-L/2, L/2, gridSteps); + h = x(2) - x(1); + + F = sqrt (abs (x)); + phi0 = NA (size (x)); + phi0(1 : end/4) = floorValue; + phi0(3*end/4 : end) = floorValue; + phi0 = fastmarching (phi0, h ./ F); + + % Plot the speed field and initial data. + %{ + figure (); + plot (x, F, "r", x, phi0, "k"); + legend ("F", "\\phi_0"); + title ("Speed Field and Initial Data"); + ax = [-L/2, L/2, -1, 1]; + axis (ax); + %} + + % Create the Laplacian as matrix. We assume homogeneous Neumann boundary + % conditions so that the initial data can be chosen as we like. + Delta = spdiags (repmat ([1, -2, 1], gridSteps, 1), [-1, 0, 1], ... + gridSteps, gridSteps); + Delta(1, 1) += Delta(1, 2); + Delta(end, end) += Delta(end - 1, end); + Delta /= h^2; + + % Perform the calculation. The Laplacian is done implicitly, the + % non-linear term explicitly: + % + % phi+ - phi0 = dt (eps Delta phi+ - F |grad phi0|) + % => (I - dt eps Delta) phi+ = phi0 - F |grad phi0| + + %figure (); + phi = phi0'; + M = eye (gridSteps) - dt * eps * Delta; + for tInd = 2 : timeSteps + + % Calculate derivatives as symmetric differences, and zero on the + % boundary. Since the data is flat there, this is correct. + d = NA (size (phi)); + low = 1 : gridSteps - 2; + mid = 2 : gridSteps - 1; + high = 3 : gridSteps; + d(mid) = (phi(high) - phi(low)) / (2 * h); + d([1, end]) = 0; + gradNorm = abs (d); + + % Do the solve. + phi = M \ (phi - dt * F' .* gradNorm); + phiEx = max (phi0 - t(tInd), floorValue); + assert (phi, phiEx', tol); + + % Show solution as animation in real time. + %{ + if (mod (tInd, 100) == 0) + plot (x, phi, "r", x, phiEx, "k"); + legend ("Approximate", "Exact"); + axis (ax); + title (sprintf ("t = %.2f", t(tInd))); + drawnow (); + %pause (0.1); + endif + %} + endfor +***** demo + n = 100; + x = linspace (-1, 1, n); + h = x(2) - x(1); [XX, YY] = meshgrid (x, x); - phi1 = (XX - 2).^2 + (YY - 2).^2 - 2^2; - phi2 = (XX + 2).^2 + (YY + 2).^2 - 2^2; - phi3 = XX.^2 + YY.^2 - 2^2; + u0 = NA (size (XX)); + u0(sqrt (XX.^2 + YY.^2) < 0.5) = Inf; + u0(end, :) = 0; + f = 3 + XX; + g0 = NA (size (XX)); + g0(end, :) = x; - assert (ls_disjoint (phi1, phi2)); - assert (~ls_disjoint (phi1, phi3)); - assert (~ls_disjoint (phi2, phi3)); - assert (~ls_disjoint (phi1, phi2, phi3)); -4 tests, 4 passed, 0 known failure, 0 skipped + [u, g] = fastmarching (u0, g0, h * f); + + figure (); + subplot (2, 2, 1); + imagesc (f); + colorbar (); + title ("Speed Field"); + subplot (2, 2, 2); + imagesc (u0); + colorbar (); + title ("Initial Distances"); + subplot (2, 2, 3); + imagesc (u); + colorbar (); + title ("Distance u"); + subplot (2, 2, 4); + imagesc (g); + colorbar (); + title ("Extended Function g"); +***** demo + pkgs = pkg ("list"); + file = false; + for i = 1 : length (pkgs) + if (strcmp (pkgs{i}.name, "level-set")) + file = fullfile (pkgs{i}.dir, "maze.png"); + endif + endfor + if (!file) + error ("could not locate example image file"); + endif + img = double (imread (file)) / 255; + + % Red is the start area, white (not black) the accessible domain. + start = (img(:, :, 1) > img(:, :, 2) + img(:, :, 3)); + domain = (img(:, :, 2) + img(:, :, 3) > 1.0) | start; + + u0 = NA (size (domain)); + u0(start) = 0; + u0(~domain) = Inf; + f = ones (size (u0)); + + u = fastmarching (u0, f); + u = u / max (u(isfinite (u))); + + % Format result as image. + walls = isinf (u); + notReached = isna (u); + ur = u; + ug = u; + ub = u; + ur(notReached) = 1; + ug(notReached) = 0; + ub(notReached) = 0; + ur(walls) = 0; + ug(walls) = 0; + ub(walls) = 1; + ur(start) = 1; + ug(start) = 1; + ub(start) = 0; + u = NA (size (u, 1), size (u, 2), 3); + u(:, :, 1) = ur; + u(:, :, 2) = ug; + u(:, :, 3) = ub; + figure (); + imshow (u); + title ("Solved Maze. Blue: Walls, Red: Unreachable, Yellow: Start."); +16 tests, 16 passed, 0 known failure, 0 skipped Checking C++ files ... Done running the unit tests. Summary: 258 tests, 254 passed, 4 known failures, 0 skipped @@ -6010,8 +6046,8 @@ dpkg-gencontrol: warning: package octave-level-set: substitution variable ${octave:Upstream-Description} unused, but is defined dh_md5sums -O--buildsystem=octave dh_builddeb -O--buildsystem=octave -dpkg-deb: building package 'octave-level-set-dbgsym' in '../octave-level-set-dbgsym_0.3.1~git.2019.04.13-7_i386.deb'. dpkg-deb: building package 'octave-level-set' in '../octave-level-set_0.3.1~git.2019.04.13-7_i386.deb'. +dpkg-deb: building package 'octave-level-set-dbgsym' in '../octave-level-set-dbgsym_0.3.1~git.2019.04.13-7_i386.deb'. dpkg-genbuildinfo --build=binary -O../octave-level-set_0.3.1~git.2019.04.13-7_i386.buildinfo dpkg-genchanges --build=binary -O../octave-level-set_0.3.1~git.2019.04.13-7_i386.changes dpkg-genchanges: info: binary-only upload (no source code included) @@ -6019,12 +6055,14 @@ dpkg-buildpackage: info: binary-only upload (no source included) dpkg-genchanges: info: not including original source code in upload I: copying local configuration +I: user script /srv/workspace/pbuilder/2523/tmp/hooks/B01_cleanup starting +I: user script /srv/workspace/pbuilder/2523/tmp/hooks/B01_cleanup finished I: unmounting dev/ptmx filesystem I: unmounting dev/pts filesystem I: unmounting dev/shm filesystem I: unmounting proc filesystem I: unmounting sys filesystem I: cleaning the build env -I: removing directory /srv/workspace/pbuilder/23568 and its subdirectories -I: Current time: Sat Jun 15 11:18:12 -12 2024 -I: pbuilder-time-stamp: 1718493492 +I: removing directory /srv/workspace/pbuilder/2523 and its subdirectories +I: Current time: Sat Jul 19 19:44:32 +14 2025 +I: pbuilder-time-stamp: 1752903872