[vspline] 62/72: added vspline::bspline::brace() This method simply applies the brace using either coefficients already present in the spline's core or 'pulling in' a coefficient array first. This way, externally generated coefficients can easily be used to set up a bspline object for evaluation with vspline's evaluation code.

Kay F. Jahnke kfj-guest at moszumanska.debian.org
Sun Jul 2 09:02:43 UTC 2017


This is an automated email from the git hooks/post-receive script.

kfj-guest pushed a commit to branch master
in repository vspline.

commit b258fa42054528985b98f054b5b5b8b2009f18ff
Author: Kay F. Jahnke <kfjahnke at gmail.com>
Date:   Sun May 14 08:28:41 2017 +0200

    added vspline::bspline::brace()
    This method simply applies the brace using either coefficients already
    present in the spline's core or 'pulling in' a coefficient array first.
    This way, externally generated coefficients can easily be used to set up
    a bspline object for evaluation with vspline's evaluation code.
---
 bspline.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 46 insertions(+), 8 deletions(-)

diff --git a/bspline.h b/bspline.h
index dfc58ac..61bd18e 100644
--- a/bspline.h
+++ b/bspline.h
@@ -510,7 +510,7 @@ public:
     {
       // if the user has passed in data, they have to have precisely the shape
       // we have set up in core (_core_shape passed into the constructor).
-      // This can have surpising effects if the container array isn't owned by the
+      // This can have surprising effects if the container array isn't owned by the
       // spline but constitutes a view to data kept elsewhere (by passing _space to the
       // constructor).
       if ( data.shape() != core_shape )
@@ -549,7 +549,9 @@ public:
     switch ( strategy )
     {
       case UNBRACED:
-        // only call the solver, don't do any bracing
+        // only call the solver, don't do any bracing. If necessary, bracing can be
+        // aplied later by a call to brace() - provided the bspline object has space
+        // for the brace.
         solve < view_type , view_type , math_type >
               ( data ,
                 core ,
@@ -561,7 +563,9 @@ public:
         break ;
       case BRACED:
         // solve first, passing in BC codes to pick out the appropriate functions to
-        // calculate the initial causal and anticausal coefficient, then brace result
+        // calculate the initial causal and anticausal coefficient, then brace result.
+        // note how, just as in brace(), the whole frame is filled, which may be more
+        // than is strictly needed by the evaluator.
         solve < view_type , view_type , math_type >
               ( data ,
                 core ,
@@ -575,19 +579,17 @@ public:
         // for additional headroom
         for ( int d = 0 ; d < dimension ; d++ )
           br.apply ( container , bcv[d] , left_frame[d] , right_frame[d] , d ) ;
-// was:
-//         for ( int d = 0 ; d < dimension ; d++ )
-//           br ( coeffs , bcv[d] , spline_degree , d ) ;
         break ;
       case EXPLICIT:
-        // first create frame with BC codes passed in, then solve with BC code GUESS
+        // first fill frame using BC codes passed in, then solve with BC code GUESS
         // this automatically fills the brace as well, since it's part of the frame.
         // TODO: the values in the frame will not come out precisely the same as they
         // would by filling the brace after the coefficients have been calculated.
         // The difference will be larger towards the margin of the frame, and we assume
         // that due to the small support of the evaluation the differences near the
         // margin of the core data will be negligible, having picked a sufficiently
-        // large frame size. This is debatable.
+        // large frame size. This is debatable. If it's a problem, a call to brace()
+        // after prefilter() will brace again, now with coefficients from the core.
         for ( int d = 0 ; d < dimension ; d++ )
           br.apply ( container , bcv[d] , left_frame[d] , right_frame[d] , d ) ;
         solve < view_type , view_type , math_type >
@@ -618,6 +620,42 @@ public:
     }
   }
 
+  /// if the spline coefficients are already known, they obviously don't need to be
+  /// prefiltered. But in order to be used by vspline's evaluation code, they need to
+  /// be 'braced' - the 'core' coefficients have to be surrounded by more coeffcients
+  /// covering the support the evaluator needs to operate without bounds checking
+  /// inside the spline's defined range. brace() performs this operation. brace()
+  /// assumes the bspline object has been set up with the desired initial parameters,
+  /// so that the boundary conditions and metrics are already known and storage is
+  /// available. If brace() is called with an empty view (or without parameters),
+  /// it assumes the coefficients are in the spline's core already and simply
+  /// fills in the 'empty' space around them. If data are passed to brace(), they
+  /// have to be the same size as the spline's core and are copied into the core
+  /// before the bracing is applied.
+
+  void brace ( view_type data = view_type() ) ///< view to knot point data to use instead of 'core'
+  {
+    if ( data.hasData() )
+    {
+      // if the user has passed in data, they have to have precisely the shape
+      // we have set up in core
+
+      if ( data.shape() != core_shape )
+        throw shape_mismatch
+         ( "when passing data to prefilter, they have to have precisely the core's shape" ) ;
+      
+      // we copy the data into the core
+      core = data ;
+    }
+
+    // we use class bracer to do the work, creating the brace for all axes in turn
+
+    bracer<view_type> br ;
+
+    for ( int d = 0 ; d < dimension ; d++ )
+      br.apply ( container , bcv[d] , left_frame[d] , right_frame[d] , d ) ;
+  }
+
   /// overloaded constructor for 1D splines. This is useful because if we don't
   /// provide it, the caller would have to pass TinyVector < T , 1 > instead of T
   /// for the shape and the boundary condition.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/vspline.git



More information about the debian-science-commits mailing list