dierckx_sys/lib.rs
1
2#![doc = include_str!("../README.md")]
3
4use libc::{c_double,c_int, };
5
6/*
7 Copyright 2021, Harbers Bik LLC
8
9 Licensed under the Apache License, Version 2.0 (the "License");
10 you may not use this file except in compliance with the License.
11 You may obtain a copy of the License at
12
13 http://www.apache.org/licenses/LICENSE-2.0
14
15 Unless required by applicable law or agreed to in writing, software
16 distributed under the License is distributed on an "AS IS" BASIS,
17 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 See the License for the specific language governing permissions and
19 limitations under the License.
20*/
21
22extern "C" {
23
24 #[doc = include_str!("curfit.md")]
25 pub fn curfit_(
26 iopt: *const c_int, // iopt -1: Least-squares spline fixed knots, 0,1: smoothing spline. iopt=0 and s=0: interpolating spline
27 m: *const c_int, // Number of data points supplied
28 x: *const c_double, // Array of x coordinates (at least m values)
29 y: *const c_double, // Array of y coordinates (at least m values)
30 w: *const c_double, // Array weights (at least m values)
31 xb: *const c_double, // Bounderies of the approximation interval. xb<=x(1), xe<=x(m)
32 xe: *const c_double,
33 k: *const c_int, // Degree of the spline, Linear = 1, Cubic = 3, Quintic = 5
34 s: *const c_double, // Smoothing factor to be used if iopt >= 0
35 nest: *const c_int, // nest = m + k + 1
36 n: *mut c_int, // Number of knots returned. For iopt=-1 value needs to be specified on entry
37 t: *mut c_double, // Array of dimension of at least nest. For iopt=-1 array of knots to be used for least-squares spline
38 c: *mut c_double, // Double array of at least nest. Will contain the coefficients of the b-spline representation
39 fp: *mut c_double, // Weighted sum of the squared residuals of the spline approximation.
40 wrk: *mut c_double, // Double array of dimension at least (m(k+1)+nest(7+3k)).
41 lwrk: *const c_int, // Size of 'wrk'
42 iwrk: *mut c_int, // int Array of at least nest (m + k + 1)
43 ier: *mut c_int // Error flag.
44 );
45
46
47 pub fn concur_(
48 iopt: *const c_int, // iopt -1: Least-squares spline fixed knots, 0,1: smoothing spline. iopt=0 and s=0: interpolating spline
49 idim: *const c_int, // dimension of the curve 0 < idim < 11; e.g. 3: trajectory of a fly flying in your office
50 m: *const c_int, // Number of data points supplied
51 u: *const c_double, // Array of parameter values (e.g. pathlength)
52 mx: *const c_int, // Array size of data points, idim * m
53 x: *const c_double, // Datapoints eg [x0, y0, z0, ... x1, y1.., z1, ..]
54 xx: *mut c_double, // mx sized array, used as working space.
55 w: *const c_double, // Array weights (at least m values)
56 ib: *const c_int, // number of derivative constraints for the curve at the begin point: 0<=ib<=(k+1)/2
57 // choose 0 for only endpoint value (x) , 1 to add first derivative [x, dx/du], 2: to add second [x, dx/du, d2x/du2]
58 db: *const c_double, // Array with the actural derivative begin point constraints
59 nb: *const c_int, // Size of db: idim*ib
60 ie: *const c_int, // number of derivative constraints for the curve at the end point: 0<=ib<=(k+1)/2
61 // choose 0 for only endpoint value (x) , 1 to add first derivative [x, dx/du], 2: to add second [x, dx/du, d2x/du2]
62 de: *const c_double, // Array with the actural derivative begin point constraints
63 ne: *const c_int, // Size of db: idim*ib
64 k: *const c_int, // Degree of the spline, cubic = 3
65 s: *const c_double, // Smoothing factor to be used if iopt >= 0
66 nest: *const c_int, // nest=m+k+1+max(0,ib-1)+max(0,ie-1),
67 n: *mut c_int, // Number of knots returned. For iopt=-1 value needs to pe specified on entry
68 t: *mut c_double, // Array of dimension of at least nest. For iopt=-1 array of knots to be used for lsq spline
69 nc: *const c_int, // actual size of array c: nest * idim
70 c: *mut c_double, // coefficients of the b-spline representation, with size nc = nest * idim
71 np: *const c_int, // size of cp: 2 * (k+1) * idim
72 cp:*mut c_double, // array at least 2 * (k+1) * idim; spline representation of end points, mainly for internal use
73 fp: *mut c_double, // Weighted sum of the squared residuals of the spline approximation.
74 wrk: *mut c_double, // Float working array
75 lwrk: *const c_int, // m*(k+1)+nest*(6+idim+3*k)
76 iwrk: *mut c_int, // Integer working array
77 ier: *mut c_int // Error flag.
78 );
79
80 pub fn splev_(
81 t: *const c_double, // array,length n, which contains the position of the knots
82 n: *const c_int, // integer, giving the total number of knots of s(x).
83 c: *const c_double, // array,length n, which contains the b-spline coefficients
84 k: *const c_int, // integer, giving the degree of s(x)
85 x: *const c_double, // array,length m, which contains the points where s(x) must be evaluated
86 y: *mut c_double, // array,length m, giving the value of s(x) at the different points
87 m: *const c_int, // length of x and y
88 ier: *mut c_int, // ier = 0 : normal return; ier =10 : invalid input data : restrictions: m >= 1, t(k+1) <= x(i) <= x(i+1) <= t(n-k) , i=1,2,...,m-1
89 );
90
91 pub fn curev_(
92 idim: *const c_int, // integer, spline curve dimension
93 t: *const c_double, // array, length n, knot positions
94 n: *const c_int, // integer, total number of knots of s(x).
95 c: *const c_double, // array, length n, b-spline coefficients
96 nc: *const c_int, // integer, number of b-spline coefficients
97 k: *const c_int, // integer, spline degree
98 u: *const c_double, // array,length m, which contains the points where spline s(u) must be evaluated
99 m: *const c_int, // number of points where s(u) mut be evaluated
100 xy: *mut c_double, // array,length mxy; xy[idim*i+j] will contain the j-th coordinate of the i-th point on the curve
101 mxy: *const c_int, // length of xy; mxy>=m*idim
102 ier: *mut c_int, // ier = 0 : normal return; ier =10 : invalid input data : restrictions: m >= 1, t(k+1) <= x(i) <= x(i+1) <= t(n-k) , i=1,2,...,m-1
103 );
104
105 // all derivatives for a single point
106 pub fn spalde_(
107 t: *const c_double, // array,length n, which contains the position of the knots
108 n: *const c_int, // integer, giving the total number of knots of s(x).
109 c: *const c_double, // array,length n, which contains the b-spline coefficients
110 k1: *const c_int, // integer, giving the order of s(x), k+1, with k polynomial degree
111 x: *const c_double, // (single) f64 value which contains the point where the derivatives must be evaluated
112 d: *mut c_double, // array,length k+1, containing the derivative values of s(x)
113 ier: *mut c_int, // ier = 0 : normal return; ier =10 : invalid input data
114 );
115
116 // all derivatives for a single point
117 pub fn cualde_(
118 idim: *const c_int, // integer, giving the dimension of the spline curve
119 t: *const c_double, // array,length n, which contains the position of the knots
120 n: *const c_int, // integer, giving the total number of knots of s(x).
121 c: *const c_double, // array,length n, which contains the b-spline coefficients
122 k1: *const c_int, // integer, giving the order of s(x), k+1, with k polynomial degree
123 u: *const c_double, // (single) f64 value which contains the point where the derivatives must be evaluated
124 d: *mut c_double, // array,length nd, giving the different curve derivatives. d(idim*l+j) will contain the j-th coordinate of the l-th derivative of the curve at the point u
125 nd: *const c_int, // integer, giving the dimension of array d: `nd >=(k+1)*idim`
126 ier: *mut c_int, // ier = 0 : normal return; ier =10 : invalid input data
127 );
128
129 // a single derivative for an array of points
130 pub fn spalder_(
131 t: *const c_double, // array,length n, which contains the position of the knots
132 n: *const c_int, // integer, giving the total number of knots of s(x).
133 c: *const c_double, // array,length n, which contains the b-spline coefficients
134 k: *const c_int, // integer, degree of s(x)
135 nu: *const c_int, // integer, specifying the order of the derivative. 0<=nu<=k
136 x: *const c_double, // array,length m, which contains the points where the derivative of s(x) must be evaluated
137 y: *mut c_double, // array,length m, giving the value of the derivative of s(x) at the different points
138 m: *const c_int, // length of x
139 wrk: *mut c_double, // Float working array of dimension n
140 ier: *mut c_int, // ier = 0 : normal return; ier =10 : invalid input data
141 );
142
143
144}