Hello community,
here is the log from the commit of package octave-forge-splines for
openSUSE:Factory checked in at 2015-12-03 13:32:52
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/octave-forge-splines (Old)
and /work/SRC/openSUSE:Factory/.octave-forge-splines.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "octave-forge-splines"
Changes:
--------
---
/work/SRC/openSUSE:Factory/octave-forge-splines/octave-forge-splines.changes
2015-06-16 15:13:55.000000000 +0200
+++
/work/SRC/openSUSE:Factory/.octave-forge-splines.new/octave-forge-splines.changes
2015-12-03 13:32:54.000000000 +0100
@@ -1,0 +2,7 @@
+Wed Dec 2 17:01:15 UTC 2015 - [email protected]
+
+- Update to version 1.2.9
+ * new function tps_val_der
+ * vectorization option for speedup of tps_val
+
+-------------------------------------------------------------------
Old:
----
splines-1.2.8.tar.gz
New:
----
splines-1.2.9.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ octave-forge-splines.spec ++++++
--- /var/tmp/diff_new_pack.pMXYDG/_old 2015-12-03 13:32:54.000000000 +0100
+++ /var/tmp/diff_new_pack.pMXYDG/_new 2015-12-03 13:32:54.000000000 +0100
@@ -18,7 +18,7 @@
%define octpkg splines
Name: octave-forge-%{octpkg}
-Version: 1.2.8
+Version: 1.2.9
Release: 0
Summary: Additional spline functions for Octave
License: GPL-2.0+ and GPL-3.0+ and SUSE-Public-Domain
++++++ splines-1.2.8.tar.gz -> splines-1.2.9.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/splines-1.2.8/CITATION new/splines/CITATION
--- old/splines-1.2.8/CITATION 1970-01-01 01:00:00.000000000 +0100
+++ new/splines/CITATION 2015-11-30 14:50:57.000000000 +0100
@@ -0,0 +1,7 @@
+@software{splines,
+ author = {Krakauer, Nir Y. and others},
+ title = {Splines Package for GNU Octave},
+ url = {http://octave.sourceforge.net/splines},
+ version = {1.2.9},
+ date = {2015-11-28},
+ }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/splines-1.2.8/DESCRIPTION new/splines/DESCRIPTION
--- old/splines-1.2.8/DESCRIPTION 2015-05-06 18:17:32.000000000 +0200
+++ new/splines/DESCRIPTION 2015-11-30 14:50:57.000000000 +0100
@@ -1,6 +1,6 @@
Name: splines
-Version: 1.2.8
-Date: 2015-05-05
+Version: 1.2.9
+Date: 2015-11-28
Author: various authors
Maintainer: Nir Krakauer <[email protected]>
Title: Splines.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/splines-1.2.8/INDEX new/splines/INDEX
--- old/splines-1.2.8/INDEX 2015-05-06 18:17:32.000000000 +0200
+++ new/splines/INDEX 2015-11-30 14:50:57.000000000 +0100
@@ -1,14 +1,15 @@
analysis >> Data analysis
Spline functions
bin_values
+ catmullrom
csapi
csape
csaps
csaps_sel
dedup
+ fnder
fnplt
- fnder
fnval
- catmullrom
tpaps
tps_val
+ tps_val_der
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/splines-1.2.8/Makefile new/splines/Makefile
--- old/splines-1.2.8/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ new/splines/Makefile 2015-11-30 14:50:57.000000000 +0100
@@ -0,0 +1,90 @@
+## Makefile to simplify Octave Forge package maintenance tasks
+
+PACKAGE = $(shell $(SED) -n -e 's/^Name: *\(\w\+\)/\1/p' DESCRIPTION |
$(TOLOWER))
+VERSION = $(shell $(SED) -n -e 's/^Version: *\(\w\+\)/\1/p' DESCRIPTION |
$(TOLOWER))
+#DEPENDS = $(shell $(SED) -n -e 's/^Depends[^,]*, \(.*\)/\1/p' DESCRIPTION |
$(SED) 's/ *([^()]*),*/ /g')
+
+RELEASE_DIR = $(PACKAGE)-$(VERSION)
+RELEASE_TARBALL = $(PACKAGE)-$(VERSION).tar.gz
+HTML_DIR = $(PACKAGE)-html
+HTML_TARBALL = $(PACKAGE)-html.tar.gz
+
+MD5SUM ?= md5sum
+MKOCTFILE ?= mkoctfile
+OCTAVE ?= octave
+SED ?= sed
+TAR ?= tar
+
+TOLOWER = $(SED) -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'
+
+.PHONY: help dist html release install all check run doc clean maintainer-clean
+
+help:
+ @echo "Targets:"
+ @echo " dist - Create $(RELEASE_TARBALL) for release"
+ @echo " html - Create $(HTML_TARBALL) for release"
+ @echo " release - Create both of the above and show md5sums"
+ @echo
+ @echo " install - Install the package in GNU Octave"
+ @echo " all - Build all oct files"
+ @echo " check - Execute package tests (w/o install)"
+ @echo " run - Run Octave with development in PATH (no
install)"
+ @echo " doc - Build Texinfo package manual"
+ @echo
+ @echo " clean - Remove releases, html documentation, and
oct files"
+ @echo " maintainer-clean - Additionally remove all generated files"
+
+$(RELEASE_DIR): .hg/dirstate
+ @echo "Creating package version $(VERSION) release ..."
+ -rm -rf $@
+ hg archive --exclude ".hg*" --exclude Makefile --type files $@
+ chmod -R a+rX,u+w,go-w $@
+
+$(RELEASE_TARBALL): $(RELEASE_DIR)
+ $(TAR) cf - --posix $< | gzip -9n > $@
+ -rm -rf $<
+
+$(HTML_DIR): install
+ @echo "Generating HTML documentation. This may take a while ..."
+ -rm -rf $@
+ $(OCTAVE) --silent \
+ --eval 'graphics_toolkit ("gnuplot");' \
+ --eval 'pkg load generate_html $(PACKAGE);' \
+ --eval 'generate_package_html ("$(PACKAGE)", "$@", "octave-forge");'
+ chmod -R a+rX,u+w,go-w $@
+
+$(HTML_TARBALL): $(HTML_DIR)
+ $(TAR) cf - --posix $< | gzip -9n > $@
+ -rm -rf $<
+
+dist: $(RELEASE_TARBALL)
+
+html: $(HTML_TARBALL)
+
+release: dist html
+ @$(MD5SUM) $(RELEASE_TARBALL) $(HTML_TARBALL)
+ @echo "Upload @ https://sourceforge.net/p/octave/package-releases/new/"
+ @echo "Execute: hg tag \"$(VERSION)\""
+
+install: $(RELEASE_TARBALL)
+ @echo "Installing package locally ..."
+ $(OCTAVE) --silent --eval 'pkg install $(RELEASE_TARBALL);'
+
+all:
+
+check: all
+ $(OCTAVE) --silent \
+ --eval 'addpath (fullfile ([pwd filesep "inst"]));' \
+ --eval 'runtests ("inst");'
+
+run: all
+ $(OCTAVE) --silent --persist \
+ --eval 'addpath (fullfile ([pwd filesep "inst"]));'
+
+doc:
+
+clean:
+ -rm -rf $(RELEASE_DIR) $(RELEASE_TARBALL) $(HTML_TARBALL) $(HTML_DIR)
+
+maintainer-clean: clean
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/splines-1.2.8/NEWS new/splines/NEWS
--- old/splines-1.2.8/NEWS 2015-05-06 18:17:32.000000000 +0200
+++ new/splines/NEWS 2015-11-30 14:50:57.000000000 +0100
@@ -1,3 +1,9 @@
+Summary of important user-visible changes for splines 1.2.9:
+-------------------------------------------------------------------
+
+ ** new function tps_val_der
+ ** vectorization option for speedup of tps_val
+
Summary of important user-visible changes for splines 1.2.8:
-------------------------------------------------------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/splines-1.2.8/inst/bin_values.m
new/splines/inst/bin_values.m
--- old/splines-1.2.8/inst/bin_values.m 2015-05-06 18:17:32.000000000 +0200
+++ new/splines/inst/bin_values.m 2015-11-30 14:50:57.000000000 +0100
@@ -31,7 +31,7 @@
##
## Outputs:@*
## @var{x_bin}, @var{y_bin}: Mean values by bin (ordered by increasing
@var{x}) @*
-## @var{w_bin}: Weights (inverse standard error of each element in
@var{y_bin}; note: will be infinite where @var{n_bin} = 1)@*
+## @var{w_bin}: Weights (inverse standard error of each element in
@var{y_bin}; note: will be NaN or Inf where @var{n_bin} = 1)@*
## @var{n_bin}: Number of elements of @var{x} per bin
## @end deftypefn
## @seealso{csaps, dedup}
@@ -88,7 +88,8 @@
%! [x_bin y_bin w_bin n_bin] = bin_values(x, y);
%!assert (x_bin, [1; 7/3]);
%!assert (y_bin, [0 0; 2 2]);
-%!assert (w_bin, [NaN NaN; 3 1]);
+%!assert (!any(isfinite(w_bin(1, :))));
+%!assert (w_bin(2, :), [3 1]);
%!assert (n_bin, [1; 3]);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/splines-1.2.8/inst/csaps_sel.m
new/splines/inst/csaps_sel.m
--- old/splines-1.2.8/inst/csaps_sel.m 2015-05-06 18:17:32.000000000 +0200
+++ new/splines/inst/csaps_sel.m 2015-11-30 14:50:57.000000000 +0100
@@ -28,7 +28,7 @@
##
## @var{x} and @var{w} should be @var{n} by 1 in size; @var{y} should be
@var{n} by @var{m}; @var{xi} should be @var{k} by 1; the values in @var{x}
should be distinct and in ascending order; the values in @var{w} should be
nonzero.
##
-## Returns the smoothing spline @var{pp} or its values @var{yi} at the desired
@var{xi}; the selected @var{p}; the estimated data scatter (variance from the
smooth trend) @var{sigma2}; and the estimated uncertainty (SD) of the smoothing
spline fit at each @var{x} value, @var{unc_y}.
+## Returns the smoothing spline @var{pp} or its values @var{yi} at the desired
@var{xi}; the selected @var{p}; the estimated data scatter (variance from the
smooth trend) @var{sigma2}; the estimated uncertainty (SD) of the smoothing
spline fit at each @var{x} value, @var{unc_y}; and the estimated number of
degrees of freedom @var{df} (out of @var{n}) used in the fit.
##
## For small @var{n}, the optimization uses singular value decomposition of an
@var{n} by @var{n} matrix in order to quickly compute the residual size and
model degrees of freedom for many @var{p} values for the optimization (Craven
and Wahba 1979). For large @var{n} (currently >300), an asymptotically more
computation and storage efficient method that takes advantage of the sparsity
of the problem's coefficient matrices is used (Hutchinson and de Hoog 1985).
##
@@ -51,7 +51,7 @@
## Author: Nir Krakauer <[email protected]>
-function [ret,p,sigma2,unc_y]=csaps_sel(x,y,xi,w,crit)
+function [ret,p,sigma2,unc_y,df]=csaps_sel(x,y,xi,w,crit)
if (nargin < 5)
crit = [];
@@ -128,14 +128,14 @@
endif
## estimate the trend uncertainty
- if isargout (3) || isargout (4)
+ if isargout (3) || isargout (4) || isargout (5)
if chol_method
- [MSR, Ht] = penalty_terms_chol(p, QT, R, y, w, n);
+ [MSR, df] = penalty_terms_chol(p, QT, R, y, w, n);
else
H = influence_matrix(p, U, D, n, w);
- [MSR, Ht] = penalty_terms(H, y, w);
+ [MSR, df] = penalty_terms(H, y, w);
end
- sigma2 = mean(MSR(:)) * (n / (n-Ht)); #estimated data error variance
(wahba83)
+ sigma2 = mean(MSR(:)) * (n / (n-df)); #estimated data error variance
(wahba83)
if isargout (4)
if chol_method
Hd = influence_matrix_diag_chol(p, QT, R, y, w, n);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/splines-1.2.8/inst/tpaps.m new/splines/inst/tpaps.m
--- old/splines-1.2.8/inst/tpaps.m 2015-05-06 18:17:32.000000000 +0200
+++ new/splines/inst/tpaps.m 2015-11-30 14:50:57.000000000 +0100
@@ -60,7 +60,7 @@
## Bouhamidi, A. (2005) Weighted thin plate splines, Analysis and
Applications, 3: 297-324
##
## @end deftypefn
-## @seealso{csaps, tps_val}
+## @seealso{csaps, tps_val, tps_val_der}
## Author: Nir Krakauer <[email protected]>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/splines-1.2.8/inst/tps_val.m
new/splines/inst/tps_val.m
--- old/splines-1.2.8/inst/tps_val.m 2015-05-06 18:17:32.000000000 +0200
+++ new/splines/inst/tps_val.m 2015-11-30 14:50:57.000000000 +0100
@@ -14,7 +14,7 @@
## along with this program; If not, see <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
-## @deftypefn{Function File}{[@var{yi}] =} tps_val(@var{x}, @var{coefs},
@var{xi})
+## @deftypefn{Function File}{[@var{yi}] =} tps_val(@var{x}, @var{coefs},
@var{xi}, @var{vectorize}=true)
##
## Evaluates a thin plate spline at given points @*
## @var{xi}
@@ -23,20 +23,22 @@
##
## @var{x} should be @var{n} by @var{d} in size, where @var{n} is the number
of points and @var{d} the number of dimensions; @var{coefs} should be @var{n} +
@var{d} + 1 by 1; @var{xi} should be @var{k} by @var{d}
##
+## The logical argument @var{vectorize} controls whether an @var{k} by @var{n}
by @var{d} intermediate array is formed to speed up computation (the default)
or whether looping is used to economize on memory
+##
+## The returned @var{yi} will be @var{k} by 1
+##
## See the documentation to @code{tpaps} for more information
##
## @end deftypefn
-## @seealso{tpaps}
+## @seealso{tpaps, tps_val_der}
## Author: Nir Krakauer <[email protected]>
-function [yi]=tps_val(x,coefs,xi)
+function [yi]=tps_val(x,coefs,xi,vectorize=true)
- [n d] = size(x); #d: number of dimensions; n: number of points [y should be
n*1]
+ [n d] = size(x); #d: number of dimensions; n: number of points
k = size(xi, 1); #number of points for which to find the spline function
value
-
- dist = @(x1, x2) norm(x2 - x1, 2, "rows"); #Euclidian distance between
points in d-dimensional space
#form of the Green's function for solutions
G = @(r) merge(r == 0, 0, r .^ 2 .* log(r));
@@ -46,7 +48,14 @@
yi = [ones(k, 1) xi] * b;
-
+ if vectorize
+ if d == 1
+ yi = yi + G(abs(x' - xi)) * a;
+ else
+ yi = yi + G(sqrt(sumsq((reshape(x, 1, n, d) - reshape(xi, k, 1, d)), 3)))
* a;
+ endif
+ else
+ dist = @(x1, x2) norm(x2 - x1, 2, "rows"); #Euclidian distance between
points in d-dimensional space
warn_state = warning ("query", "Octave:broadcast").state;
warning ("off", "Octave:broadcast"); #turn off warning message for
automatic broadcasting when dist is called
unwind_protect
@@ -62,16 +71,18 @@
unwind_protect_cleanup
warning (warn_state, "Octave:broadcast");
end_unwind_protect
-
+ endif
endfunction
-%!shared x,y,c
+%!shared x,y,c,xi
%! x = ([1:10 10.5 11.3])'; y = sin(x);
%! c = tpaps(x,y,1);
%!assert (tpaps(x,y,1,x), tps_val(x,c,x));
%! x = rand(100, 2)*2 - 1;
%! y = x(:, 1) .^ 2 + x(:, 2) .^ 2;
%! c = tpaps(x,y,1);
-%!assert (tpaps(x,y,1,x), tps_val(x,c,x));
+%!assert (tpaps(x,y,1,x), tps_val(x,c,x), 100*eps);
+%! xi = rand(30, 2);
+%!assert (tps_val(x,c,x,true), tps_val(x,c,x,false), 100*eps);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/splines-1.2.8/inst/tps_val_der.m
new/splines/inst/tps_val_der.m
--- old/splines-1.2.8/inst/tps_val_der.m 1970-01-01 01:00:00.000000000
+0100
+++ new/splines/inst/tps_val_der.m 2015-11-30 14:50:57.000000000 +0100
@@ -0,0 +1,116 @@
+## Copyright (C) 2015 Nir Krakauer
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; If not, see <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn{Function File}{[@var{dyi}] =} tps_val_der(@var{x}, @var{coefs},
@var{xi}, @var{vectorize}=true )
+##
+## Evaluates the first derivative of a thin plate spline at given points @*
+## @var{xi}
+##
+## @var{coefs} should be the vector of fitted coefficients returned from
@code{tpaps(x, y, [p])}
+##
+## @var{x} should be @var{n} by @var{d} in size, where @var{n} is the number
of points and @var{d} the number of dimensions; @var{coefs} should be (@var{n}
+ @var{d} + 1) by 1; @var{xi} should be @var{k} by @var{d}
+##
+## The logical argument @var{vectorize} controls whether @var{k} by @var{n} by
@var{d} intermediate arrays are formed to speed up computation (the default) or
whether looping is used to economize on memory
+##
+## The returned @var{dyi} will be @var{k} by @var{d}, containing the first
partial derivatives of the thin plate spline at @var{xi}
+##
+##
+## Example usages:
+## @example
+## x = ([1:10 10.5 11.3])'; y = sin(x); dy = cos(x); xi = (0:0.1:12)';
+## coefs = tpaps(x, y, 0.5);
+## [dyi] = tps_val_der(x,coefs,xi);
+## subplot(1, 1, 1)
+## plot(x, dy, 's', xi, dyi)
+## legend('original', 'tps')
+## @end example
+##
+## @example
+## x = rand(100, 2)*2 - 1;
+## y = x(:, 1) .^ 2 + x(:, 2) .^ 2;
+## [x1 y1] = meshgrid((-1:0.2:1)', (-1:0.2:1)');
+## xi = [x1(:) y1(:)];
+## coefs = tpaps(x, y, 1);
+## dyio = [2*x1(:) 2*y1(:)];
+## [dyi] = tps_val_der(x,coefs,xi);
+## subplot(2, 2, 1)
+## contourf(x1, y1, reshape(dyio(:, 1), 11, 11)); colorbar
+## title('original x1 partial derivative')
+## subplot(2, 2, 2)
+## contourf(x1, y1, reshape(dyi(:, 1), 11, 11)); colorbar
+## title('tps x1 partial derivative')
+## subplot(2, 2, 3)
+## contourf(x1, y1, reshape(dyio(:, 2), 11, 11)); colorbar
+## title('original x2 partial derivative')
+## subplot(2, 2, 4)
+## contourf(x1, y1, reshape(dyi(:, 2), 11, 11)); colorbar
+## title('tps x2 partial derivative')
+## @end example
+##
+## See the documentation to @code{tpaps} for more information
+##
+## @end deftypefn
+## @seealso{tpaps, tpaps_val, tps_val_der}
+
+## Author: Nir Krakauer <[email protected]>
+
+function [dyi]=tps_val_der(x,coefs,xi,vectorize=true)
+
+
+ [n d] = size(x); #d: number of dimensions; n: number of points
+ k = size(xi, 1); #number of points for which to find the spline derivative
value
+
+ #derivative of the spline Green's function, divided by radial distance
+ dG_scaled = @(r) merge(r == 0, 0, 1 + 2 .* log(r));
+
+ a = coefs(1:n);
+ b = coefs((n+1):end);
+
+ dyi = ones(k, 1) * b(2:end)'; #derivatives of linear part
+
+ if vectorize
+ dists = reshape(xi, k, 1, d) - reshape(x, 1, n, d);
+ dist = sqrt(sumsq(dists, 3)); #Euclidian distance between points in
d-dimensional space
+ dyi += squeeze(sum(reshape(a, 1, n) .* dG_scaled(dist) .* dists, 2));
+ else
+ for i = 1:k
+ for l = 1:n
+ dists = xi(i, :) - x(l, :);
+ dist = sqrt(sumsq(dists));
+ dyi(i, :) += a(l) * dG_scaled(dist) * dists;
+ endfor
+ endfor
+ endif
+
+endfunction
+
+
+
+
+
+#check with linear functions (derivatives should be constant)
+%!shared a,b,x,y,x1,x2,y1,c,dy,dy0
+%! a = 2; b = -3; x = ([1:2:10 10.5 11.3])'; y = a*x;
+%! c = tpaps(x,y,1);
+%!assert (a*ones(size(x)), tps_val_der(x,c,x), 1E3*eps);
+%! [x1 x2] = meshgrid(x, x);
+%! y1 = a*x1+b*x2;
+%! c = tpaps([x1(:) x2(:)],y1(:),0.5);
+%! dy = tps_val_der([x1(:) x2(:)],c,[x1(:) x2(:)]);
+%! dy0 = tps_val_der([x1(:) x2(:)],c,[x1(:) x2(:)],false);
+%!assert (a*ones(size(x1(:))), dy(:, 1), 1E3*eps);
+%!assert (b*ones(size(x2(:))), dy(:, 2), 1E3*eps);
+%!assert (dy0, dy, 1E3*eps);