/Users/enrico/Ricerca/develop/PINS/pins-mechatronix/LibSources/submodules/Splines/src/Splines/Splines1D.hxx Source FileΒΆ

Splines: /Users/enrico/Ricerca/develop/PINS/pins-mechatronix/LibSources/submodules/Splines/src/Splines/Splines1D.hxx Source File
Splines
Splines1D.hxx
1/*--------------------------------------------------------------------------*\
2 | |
3 | Copyright (C) 2016 |
4 | |
5 | , __ , __ |
6 | /|/ \ /|/ \ |
7 | | __/ _ ,_ | __/ _ ,_ |
8 | | \|/ / | | | | \|/ / | | | |
9 | |(__/|__/ |_/ \_/|/|(__/|__/ |_/ \_/|/ |
10 | /| /| |
11 | \| \| |
12 | |
13 | Enrico Bertolazzi |
14 | Dipartimento di Ingegneria Industriale |
15 | Universita` degli Studi di Trento |
16 | email: enrico.bertolazzi@unitn.it |
17 | |
18\*--------------------------------------------------------------------------*/
19
20/*\
21 | ____ _ _ _ ____
22 | / ___| _ __ | (_)_ __ ___/ | _ \
23 | \___ \| '_ \| | | '_ \ / _ \ | | | |
24 | ___) | |_) | | | | | | __/ | |_| |
25 | |____/| .__/|_|_|_| |_|\___|_|____/
26 | |_|
27\*/
28
29namespace Splines {
30
32 class Spline1D {
33 protected:
34
35 #ifndef DOXYGEN_SHOULD_SKIP_THIS
36
37 std::string m_name;
38 Spline * m_pSpline{nullptr};
39
40 #endif
41
42 public:
43
44 Spline1D( Spline1D const & ) = delete;
45 Spline1D const & operator = ( Spline1D const & ) = delete;
46
49
55 Spline1D( std::string const & n )
56 : m_name(n)
57 {}
58
63 {}
64
66
67
72
76 string const & name() const { return m_pSpline->name(); }
77
79 bool is_closed() const { return m_pSpline->is_closed(); }
80
86 void make_closed() { m_pSpline->make_closed(); }
87
93 void make_opened() { m_pSpline->make_opened(); }
94
98 bool is_bounded() const { return m_pSpline->is_bounded(); }
99
105 void make_unbounded() { m_pSpline->make_unbounded(); }
111 void make_bounded() { m_pSpline->make_bounded(); }
112
116 bool is_extended_constant() const { return m_pSpline->is_extended_constant(); }
122 void make_extended_constant() { m_pSpline->make_extended_constant(); }
128 void make_extended_not_constant() { m_pSpline->make_extended_not_constant(); }
129
131
132
136 integer num_points() const { return m_pSpline->num_points(); }
137
141 real_type x_node( integer i ) const { return m_pSpline->x_node(i); }
142
146 real_type y_node( integer i ) const { return m_pSpline->y_node(i); }
147
151 real_type x_begin() const { return m_pSpline->x_begin(); }
152
156 real_type y_begin() const { return m_pSpline->y_begin(); }
157
161 real_type x_end() const { return m_pSpline->x_end(); }
162
166 real_type y_end() const { return m_pSpline->y_end(); }
167
171 void reserve( integer npts ) { return m_pSpline->reserve( npts ); }
172
176 void push_back( real_type x, real_type y ) { return m_pSpline->push_back( x, y ); }
180 void drop_back() { m_pSpline->drop_back(); }
181
185 // must be defined in derived classes
186 void build() { m_pSpline->build(); }
187
191 void setup( GenericContainer const & gc );
195 void build( GenericContainer const & gc ) { setup(gc); }
196
207 // must be defined in derived classes
208 void
210 SplineType1D tp,
211 real_type const x[], integer incx,
212 real_type const y[], integer incy,
213 integer n
214 );
215
224 void
226 SplineType1D tp,
227 real_type const x[],
228 real_type const y[],
229 integer n
230 ) {
231 this->build( tp, x, 1, y, 1, n );
232 }
233
241 void
243 SplineType1D tp,
244 vector<real_type> const & x,
245 vector<real_type> const & y
246 ) {
247 integer n{integer(x.size())};
248 this->build( tp, &x.front(), &y.front(), n );
249 }
250
254 void clear() { m_pSpline->clear(); }
255
259 real_type x_min() const { return m_pSpline->x_min(); }
260
264 real_type x_max() const { return m_pSpline->x_max(); }
265
269 real_type y_min() const { return m_pSpline->y_min(); }
270
274 real_type y_max() const { return m_pSpline->y_max(); }
275
280 void set_origin( real_type x0 ) { return m_pSpline->set_origin( x0 ); }
281
285 void set_range( real_type xmin, real_type xmax ) { return m_pSpline->set_range( xmin, xmax ); }
286
291 void
293 ostream_type & s,
294 integer nintervals,
295 char const header[] = "x\ty"
296 ) const {
297 m_pSpline->dump( s, nintervals, header );
298 }
299
303 void
305 char const fname[],
306 integer nintervals,
307 char const header[] = "x\ty"
308 ) const {
309 m_pSpline->dump( fname, nintervals, header );
310 }
311
315
319 real_type eval( real_type x ) const { return m_pSpline->eval(x); }
320
324 real_type D( real_type x ) const { return m_pSpline->D(x); }
325
329 real_type DD( real_type x ) const { return m_pSpline->DD(x); }
330
334 real_type DDD( real_type x ) const { return m_pSpline->DDD(x); }
335
339 real_type DDDD( real_type x ) const { return m_pSpline->DDDD(x); }
340
344 real_type DDDDD( real_type x ) const { return m_pSpline->DDDDD(x); }
345
347
353 real_type operator () ( real_type x ) const { return m_pSpline->eval(x); }
354
356 real_type eval_D( real_type x ) const { return m_pSpline->D(x); }
357
359 real_type eval_DD( real_type x ) const { return m_pSpline->DD(x); }
360
362 real_type eval_DDD( real_type x ) const { return m_pSpline->DDD(x); }
363
365 real_type eval_DDDD( real_type x ) const { return m_pSpline->DDDD(x); }
366
368 real_type eval_DDDDD( real_type x ) const { return m_pSpline->DDDDD(x); }
370
381 id_eval( integer ni, real_type x ) const { return m_pSpline->id_eval(ni,x); }
382
389 id_D( integer ni, real_type x ) const { return m_pSpline->id_D(ni,x); }
390
397 id_DD( integer ni, real_type x ) const { return m_pSpline->id_DD(ni,x); }
398
405 id_DDD( integer ni, real_type x ) const { return m_pSpline->id_DDD(ni,x); }
406
413 id_DDDD( integer ni, real_type x ) const { return m_pSpline->id_DDDD(ni,x); }
414
421 id_DDDDD( integer ni, real_type x ) const { return m_pSpline->id_DDDDD(ni,x); }
422
424
428 integer // order
430 real_type cfs[],
431 real_type nodes[],
432 bool transpose = false
433 ) const {
434 return m_pSpline->coeffs( cfs, nodes, transpose );
435 }
436
440 integer order() const { return m_pSpline->order(); }
441
445 void
446 write_to_stream( ostream_type & s ) const
447 { return m_pSpline->write_to_stream( s ); }
448
452 char const *
453 type_name() const
454 { return m_pSpline->type_name(); }
455
460 type() const
461 { return m_pSpline->type(); }
462
466 string
467 info() const
468 { return m_pSpline->info(); }
469
473 void
474 info( ostream_type & stream ) const
475 { m_pSpline->info( stream ); }
476
477 #ifdef SPLINES_BACK_COMPATIBILITY
478 integer numPoints() const { return m_pSpline->num_points(); }
479 real_type xNode( integer i ) const { return this->x_node(i); }
480 real_type yNode( integer i ) const { return this->y_node(i); }
481 real_type xBegin() const { return this->x_begin(); }
482 real_type yBegin() const { return this->y_begin(); }
483 real_type xEnd() const { return this->x_end(); }
484 real_type yEnd() const { return this->y_end(); }
485 void pushBack( real_type x, real_type y ) { return this->push_back( x, y ); }
486 void dropBack() { this->drop_back(); }
487 real_type xMin() const { return this->x_min(); }
488 real_type xMax() const { return this->x_max(); }
489 real_type yMin() const { return this->y_min(); }
490 real_type yMax() const { return this->y_max(); }
491 void setOrigin( real_type x0 ) { return this->set_origin( x0 ); }
492 void setRange( real_type xmin, real_type xmax ) { return this->set_range( xmin, xmax ); }
493 #endif
494
495 };
496
497}
498
499// EOF: Spline1D.hxx
Spline Management Class.
Definition Splines1D.hxx:32
void build(SplineType1D tp, vector< real_type > const &x, vector< real_type > const &y)
Definition Splines1D.hxx:242
SplineType1D type() const
Definition Splines1D.hxx:460
void make_extended_constant()
Definition Splines1D.hxx:122
real_type DDDD(real_type x) const
Definition Splines1D.hxx:339
real_type y_begin() const
Definition Splines1D.hxx:156
real_type eval_DDD(real_type x) const
the value of the third derivative of the spline at x
Definition Splines1D.hxx:362
bool is_bounded() const
Definition Splines1D.hxx:98
void clear()
Definition Splines1D.hxx:254
real_type id_DDDDD(integer ni, real_type x) const
Definition Splines1D.hxx:421
void make_closed()
Definition Splines1D.hxx:86
real_type x_begin() const
Definition Splines1D.hxx:151
void dump(char const fname[], integer nintervals, char const header[]="x\ty") const
Definition Splines1D.hxx:304
Spline1D(std::string const &n)
Definition Splines1D.hxx:55
string info() const
Definition Splines1D.hxx:467
bool is_closed() const
Definition Splines1D.hxx:79
real_type id_DDDD(integer ni, real_type x) const
Definition Splines1D.hxx:413
real_type D(real_type x) const
Definition Splines1D.hxx:324
real_type y_min() const
Definition Splines1D.hxx:269
real_type x_min() const
Definition Splines1D.hxx:259
void drop_back()
Definition Splines1D.hxx:180
void make_extended_not_constant()
Definition Splines1D.hxx:128
void build()
Definition Splines1D.hxx:186
integer num_points() const
Definition Splines1D.hxx:136
real_type DD(real_type x) const
Definition Splines1D.hxx:329
real_type DDD(real_type x) const
Definition Splines1D.hxx:334
void set_range(real_type xmin, real_type xmax)
Definition Splines1D.hxx:285
real_type id_eval(integer ni, real_type x) const
Definition Splines1D.hxx:381
void make_bounded()
Definition Splines1D.hxx:111
void build(SplineType1D tp, real_type const x[], real_type const y[], integer n)
Definition Splines1D.hxx:225
real_type operator()(real_type x) const
Definition Splines1D.hxx:353
real_type eval(real_type x) const
Definition Splines1D.hxx:319
real_type y_node(integer i) const
Definition Splines1D.hxx:146
real_type id_D(integer ni, real_type x) const
Definition Splines1D.hxx:389
void reserve(integer npts)
Definition Splines1D.hxx:171
void dump(ostream_type &s, integer nintervals, char const header[]="x\ty") const
Definition Splines1D.hxx:292
real_type x_max() const
Definition Splines1D.hxx:264
void push_back(real_type x, real_type y)
Definition Splines1D.hxx:176
bool is_extended_constant() const
Definition Splines1D.hxx:116
real_type id_DDD(integer ni, real_type x) const
Definition Splines1D.hxx:405
real_type eval_DDDDD(real_type x) const
the value of the 5-th derivative of the spline at x
Definition Splines1D.hxx:368
void write_to_stream(ostream_type &s) const
Definition Splines1D.hxx:446
real_type y_end() const
Definition Splines1D.hxx:166
~Spline1D()
Definition Splines1D.hxx:62
integer coeffs(real_type cfs[], real_type nodes[], bool transpose=false) const
Definition Splines1D.hxx:429
void info(ostream_type &stream) const
Definition Splines1D.hxx:474
real_type eval_DDDD(real_type x) const
the value of the 4-th derivative of the spline at x
Definition Splines1D.hxx:365
real_type eval_DD(real_type x) const
the value of the second derivative of the spline at x
Definition Splines1D.hxx:359
void make_opened()
Definition Splines1D.hxx:93
string const & name() const
Definition Splines1D.hxx:76
real_type eval_D(real_type x) const
the value of the first derivative of the spline at x
Definition Splines1D.hxx:356
void setup(GenericContainer const &gc)
Definition Splines1D.cc:94
void make_unbounded()
Definition Splines1D.hxx:105
char const * type_name() const
Definition Splines1D.hxx:453
integer order() const
Definition Splines1D.hxx:440
real_type DDDDD(real_type x) const
Definition Splines1D.hxx:344
void set_origin(real_type x0)
Definition Splines1D.hxx:280
void build(GenericContainer const &gc)
Definition Splines1D.hxx:195
real_type y_max() const
Definition Splines1D.hxx:274
void build(SplineType1D tp, real_type const x[], integer incx, real_type const y[], integer incy, integer n)
real_type x_node(integer i) const
Definition Splines1D.hxx:141
real_type x_end() const
Definition Splines1D.hxx:161
real_type id_DD(integer ni, real_type x) const
Definition Splines1D.hxx:397
Definition Splines.hh:372
Definition SplineAkima.cc:50
int integer
Signed integer type for splines.
Definition Splines.hh:58
enum class SplineType1D :integer { CONSTANT=0, LINEAR=1, CUBIC=2, AKIMA=3, BESSEL=4, PCHIP=5, QUINTIC=6, HERMITE=7, SPLINE_SET=8, SPLINE_VEC=9 } SplineType1D
Associate a number for each type of splines implemented.
Definition Splines.hh:71
double real_type
Floating point type for splines.
Definition Splines.hh:57