Shape Parametrisation Utilities for the Optimisation Shell INVERSE
(for Version 3.11)
Igor Grešovnik
Ljubljana, 27 September, 2005
Contents:
9. Shape Parametrisation
Utilities
9.1 Cubis Splines with Prescribed Endpoint Derivatives
9.2 Shell Built-in Splines Utilities
9.3 File Interpreter Functions for Manipulating Splines
9.3.1 setnewcubspl
{ x y k1 kn idvar }
9.3.2 setcubsplid
{ id x y k1 kn }
9.3.3 setcubsplglob
{ x y k1 kn }
9.3.5 fprintcubspldata
{ <id> }
9.3.6 printcubspldata
{ <id> }
9.4 Expression Evaluator Functions for Manipulating Splines
9.4.1 setnewcubspl [
k1, kn, x1, y1, x2, y2, … ].
9.4.2 setcubspl [
<id>, k1, kn, x1, y1, x2, y2, … ]
9.4.4 cubspl
[ <id>, x ] , cubsplval
9.4.5 cubsplsensy
[ <id>, i, x ]
9.4.6 cubsplsensx
[ <id>, i, x ]
9.4.7 cubsplsensk1
[ <id>, x ]
9.4.8 cubsplsenskn
[ <id>, x ]
Spline interpolation is a piecewise polynomial interpolation (Figure 9.1). An interval on which we want to interpolate the function by a spline is subdivided into subintervals with common endpoints called nodes:
We require that functions f and g match on nodes, i.e.
We require that function is a polynomial of a certain degree on each subinterval, i.e.
We also require certain continuity conditions to be fulfilled in nodes (e.g. continuity of the first and second derivatives) and appropriate boundary conditions to be fulfilled in the endpoints a and b (e.g. we specify values of the first derivatives in these points). Points , where is the i-th node and is the prescribed value of the spline in this node, are called control points.
Figure 9.1: Cubic spline with 6 control points.
A cubic spline is a function of the form (9.3), which is represented in each subinterval of the subdivision (9.1) by a polynomial of the third or lesser degree, and is a continuous function with continuous first and second derivatives in the interval .
A cubic polynomial in any interval of the subdivision (9.1) is uniquely determined by endpoint values and derivatives:
, (9.4)
where
and
and must be prescribed while other derivatives are determined by evaluation of the linear system of equations which is obtained by taking into account the continuity and boundary conditions, namely
where
Since computation of spline values involves solution of the system (9.8) (which can be solved only once prior to any evaluation of or , respectively), derivatives with respect to any parameter involve implicit terms :
These terms are obtained by derivation of (9.8) with respect to the parameter :
can be any parameter that defines the spline, i.e. x or y coordinate of any node (i.e. or ) or the prescribed derivative in the first or the last node (i.e. or ). The derivative of the vector of derivatives of the spline in internal nodes () can be evaluated prior to evaluation of in any point . Moreover, the linear system for evaluation of has the same system matrix as the system for evaluation of u itself, therefore the factorized matrix that was calculated to solve the system for can be reused.
The optimisation shell Inverse includes a set of basic utilities for doing spline calculation. User can define splines by specifying control points and endpoint derivatives, calculate values on defined splines and derivatives of these values with respect to any parameter of a spline (x or y coordinate of individual control points or endpoint derivatives). Calculator functions enable both defining splines and performing calculations on them, but it is better to use file interpreter functions for defining splines because in this case x and y coordinates of all control points defining the splines are gathered in vectors.
More than one spline can be defined at once. Different splines are referred to by identification numbers. There is however one spline, referred to in this text as the “global spline”, which needs not to be referred by an identification number. When using functions that require the spline identification number, this spline can be referred to by the identification number 0. The global spline is introduced for the sake of simplicity; the user is in this way not forced to use and keep trace of spline identification numbers if it is sufficient for a specific problem that only one spline is defined at once.
File interpreter functions enable definition of splines and their destruction.
Sets a new cubic spline defined by x coordinates of control points x, y coordinates of control points y (both vector arguments) and prescribed derivatives in the first and the last control points, k1 and kn (value arguments), respectively. The function assigns the identification number of the newly defined spline to a calculator variable named idvar. The identification number of the newly defined spline is determined by the spline system and must be specified any time when this spline is referred after its definition.
Defines a cubic spline that has identification number id (value argument). If the spline with identification number id is already defined, its definition is overridden by the new one. If it does not exist yet, a new spline is created in the spline system and identification number id is assigned to it. In this case id should not be too large because spline identification numbers are internally stored in a table that has as many elements as is the largest currently existing identification number. id must in any case evaluate to an integer greater than or equal to 0. If id is 0, the definition affects the global spline.
The spline gets defined by x coordinates of control points x, y coordinates of control points y (both vector arguments) and prescribed derivatives in the first and the last control points, k1 and kn (value arguments), respectively.
Defines the global cubic spline by x coordinates of control points x, y coordinates of control points y (both vector arguments) and prescribed derivatives in the first and the last control points, k1 and kn (value arguments), respectively.
Deletes the definition of the cubic spline identified by id (value argument) togerher with associated internal auxiliary data structures. Identification numver id is available for new splines (e.g. defined by the setnewcubspl interpreter function) after this function is executed. If id is not specified, the function deletes the global cubic spline.
Prints the data about splines defined in the cubic spline system to the output file of the programme (i.e. the file outfile) . If id is specified, only the data about the cubic spline with identification number id is printed.
Prints the data about splines defined in the cubic spline system to the standard output of the programme. If id is specified, only the data about the cubic spline with identification number id is printed.
Defines a new cubic spline and returns its identification number. Arguments k1 and kn are the prescribed derivatives in the first and the last control points, x1 and y1 are x and y coordinates of the first control point, x2 and y2 are coordinates of the second control point, etc. There must be at least two control points (at minimum 6 arguments) and the number of arguments must be even.
Remark:
It is more common to use the interpreter function with the same name instead of this calculator function. x and y coordinates of control points are specified by vector arguments when using the interpreter function.
Defines the cubic spline identified by id. If the spline with this identification number already exists, its definition is overridden. If it does not exist, it is created anew, in which case id should not be too large because spline identification numbers are internally stored in a table that has as many elements as is the largest currently existing identification number. id must evaluate to an integer greater than or equal to 0. If id is 0 or it is not specified, the global cubic spline is defined.
Arguments k1 and kn are the prescribed derivatives in the first and the last control points, x1 and y1 are x and y coordinates of the first control point, x2 and y2 are coordinates of the second control point, etc. There must be at least two control points (at minimum 6 arguments).
Remark:
It is more common to use the interpreter function setcubsplid or setcubsplglob instead of this calculator function. x and y coordinates of control points are specified by vector arguments when using the interpreter function.
Deletes the definition of the cubic spline identified by id. If id is not specified, this affects the global cubic spline.
Remark:
It is more common to use the interpreter function with the same name instead of this calculator function.
Evaluates to the value of the cubic spline with identification number id at x. If id is not specified or it is zero, the value of the global cubic spline is calculated.
Evaluates to sensitivity of the value of the cubic spline with identification number id at x with respect to the y coordinate of the i-th control point that defines the spline. If id is not specified or it is zero, the function refers to the global spline.
Evaluates to the sensitivity of the value of the cubic spline with identification number id at x with respect to the x coordinate of the i-th control point that defines the spline. If id is not specified or it is zero, the function refers to the global spline.
Evaluates to the sensitivity of the value of the cubic spline with identification number id at x with respect to the prescribed derivative in the first node. If id is not specified or it evaluates to zero, the function refers to the global spline.
Evaluates to the sensitivity of the value of the cubic spline with identification number id at x with respect to the prescribed derivative in the last node. If id is not specified or it evaluates to zero, the function refers to the global spline.