fitpack
Modern Fortran library for curve and surface fitting with splines
Loading...
Searching...
No Matches
fpConstrainedCurve.hpp
Go to the documentation of this file.
1/***************************************************************************************************
2! ____________________ ___ ________ __
3! / ____/ _/_ __/ __ \/ | / ____/ //_/
4! / /_ / / / / / /_/ / /| |/ / / ,<
5! / __/ _/ / / / / ____/ ___ / /___/ /| |
6! /_/ /___/ /_/ /_/ /_/ |_\____/_/ |_|
7!
8! A Curve Fitting Package
9!
10! fpConstrainedCurve.hpp (class fpConstrainedCurve)
11!> @brief Standalone C++ wrapper for fitpack_constrained_curve (no fortran-arrays dependency)
12!
13! @author Federico Perini
14! @date 2026-08-27
15!
16! References :
17! - C. De Boor, "On calculating with b-splines", J Approx Theory 6 (1972) 50-62
18! - M. G. Cox, "The numerical evaluation of b-splines", J Inst Maths Applics 10 (1972) 134-149
19! - P. Dierckx, "Curve and surface fitting with splines", Monographs on numerical analysis,
20! Oxford university press, 1993.
21!
22! **************************************************************************************************/
23
24#ifndef FPCONSTRAINEDCURVE_HPP_INCLUDED
25#define FPCONSTRAINEDCURVE_HPP_INCLUDED
26
27#include "fitpack_config.h"
28
29#if HAVE_FXARRAY
30#include "fxArrays.hpp"
31#endif
32
33#include "fitpack_constrained_curve_c.h"
34#include "fpParametricCurve.hpp"
35#include <string>
36#include <vector>
37#include <cstdint>
38#include <memory>
39#include <stdexcept>
40#include <variant>
41#include <optional>
42#include <array>
43
44static_assert(sizeof(fitpack_constrained_curve_c) == sizeof(fitpack_parametric_curve_c),
45 "C descriptor layout mismatch: fitpack_constrained_curve_c vs fitpack_parametric_curve_c");
46
56public:
57 // ===========================================================================================
58 // Constructors and Destructor
59 // ===========================================================================================
60
65 fitpack_constrained_curve_c_allocate(as<fitpack_constrained_curve_c>(), nullptr);
66 }
67
72 fitpack_constrained_curve_c_destroy(as<fitpack_constrained_curve_c>(), nullptr);
73 }
74
79 *as<fitpack_constrained_curve_c>() = fitpack_constrained_curve_c_null;
80 fitpack_constrained_curve_c_copy(as<fitpack_constrained_curve_c>(), other.as<fitpack_constrained_curve_c>(), false, nullptr);
81 }
82
87 if (this != &other) {
88 fitpack_constrained_curve_c_destroy(as<fitpack_constrained_curve_c>(), nullptr);
89 fitpack_constrained_curve_c_copy(as<fitpack_constrained_curve_c>(), other.as<fitpack_constrained_curve_c>(), false, nullptr);
90 }
91 return *this;
92 }
93
98 *as<fitpack_constrained_curve_c>() = fitpack_constrained_curve_c_null;
99 fitpack_constrained_curve_c_move_alloc(as<fitpack_constrained_curve_c>(), other.as<fitpack_constrained_curve_c>(), nullptr);
100 }
101
106 if (this != &other) {
107 fitpack_constrained_curve_c_destroy(as<fitpack_constrained_curve_c>(), nullptr);
108 fitpack_constrained_curve_c_move_alloc(as<fitpack_constrained_curve_c>(), other.as<fitpack_constrained_curve_c>(), nullptr);
109 }
110 return *this;
111 }
112
116 explicit fpConstrainedCurve(fitpack_constrained_curve_c& c_wrapper, bool move = false) : fpParametricCurve(NoAlloc{}) {
117 if (move) {
118 fitpack_constrained_curve_c_move_alloc(as<fitpack_constrained_curve_c>(), &c_wrapper, nullptr);
119 } else {
120 *as<fitpack_constrained_curve_c>() = fitpack_constrained_curve_c_null;
121 fitpack_constrained_curve_c_copy(as<fitpack_constrained_curve_c>(), &c_wrapper, false, nullptr);
122 }
123 }
124
130 explicit fpConstrainedCurve(fitpack_constrained_curve_c& c_wrapper, ViewTag) : fpParametricCurve(NoAlloc{}) {
131 *as<fitpack_constrained_curve_c>() = c_wrapper;
132 as<fitpack_constrained_curve_c>()->is_pointer = true;
133 }
134
135 // ===========================================================================================
136 // Utility Methods
137 // ===========================================================================================
138
142 bool is_allocated() const override {
143 return as<fitpack_constrained_curve_c>()->cptr != nullptr;
144 }
145
149 bool is_pointer() const override {
150 return as<fitpack_constrained_curve_c>()->is_pointer;
151 }
152
156 const char* c_type_name() const override {
157 return fitpack_constrained_curve_c_c_type_name(*as<fitpack_constrained_curve_c>());
158 }
159
164 const char* cpp_type_name() const override {
165 return "fpConstrainedCurve";
166 }
167
171 fitpack_constrained_curve_c& c_handle() {
173 }
174
178 const fitpack_constrained_curve_c& c_handle() const {
180 }
181
193
198 return static_cast<fpParametricCurve&>(*this);
199 }
201 return static_cast<const fpParametricCurve&>(*this);
202 }
203
204 // ===========================================================================================
205 // Method Wrappers (standalone — no fxArray dependency)
206 // ===========================================================================================
207
208 virtual void clean_constraints() {
209 fitpack_constrained_curve_c_clean_constraints(as<fitpack_constrained_curve_c>());
210 }
211
215 virtual void set_constraints(int32_t ddx_begin_n1, int32_t ddx_begin_n2, int32_t ddx_end_n1, int32_t ddx_end_n2, double* ddx_begin = nullptr, double* ddx_end = nullptr, int32_t* ierr = nullptr) {
216 fitpack_constrained_curve_c_set_constraints(as<fitpack_constrained_curve_c>(), ddx_begin_n1, ddx_begin_n2, ddx_begin, ddx_end_n1, ddx_end_n2, ddx_end, ierr);
217 }
218
219
220 int32_t comm_size() const override {
221 return fitpack_constrained_curve_c_comm_size(as<fitpack_constrained_curve_c>());
222 }
223
227 void comm_pack(std::vector<double>& buffer) const override {
228 int32_t n = static_cast<int32_t>(buffer.size());
229 fitpack_constrained_curve_c_comm_pack(as<fitpack_constrained_curve_c>(), n, buffer.data());
230 }
231
232
236 void comm_expand(std::vector<double>& buffer) override {
237 int32_t n = static_cast<int32_t>(buffer.size());
238 fitpack_constrained_curve_c_comm_expand(as<fitpack_constrained_curve_c>(), n, buffer.data());
239 }
240
241
245 void new_points(int32_t x_n1, int32_t x_n2, std::vector<double>& x, double* u = nullptr, double* w = nullptr) override {
246 fitpack_constrained_curve_c_new_points(as<fitpack_constrained_curve_c>(), x_n1, x_n2, x.data(), u, w);
247 }
248
249
250 void set_default_parameters() override {
251 fitpack_constrained_curve_c_set_default_parameters(as<fitpack_constrained_curve_c>());
252 }
253
257 int32_t new_fit(int32_t x_n1, int32_t x_n2, std::vector<double>& x, double* u = nullptr, double* w = nullptr, double* smoothing = nullptr, int32_t* order = nullptr) override {
258 return fitpack_constrained_curve_c_new_fit(as<fitpack_constrained_curve_c>(), x_n1, x_n2, x.data(), u, w, smoothing, order);
259 }
260
261
262 int32_t fit(double* smoothing = nullptr, int32_t* order = nullptr, bool* keep_knots = nullptr) override {
263 return fitpack_constrained_curve_c_fit(as<fitpack_constrained_curve_c>(), smoothing, order, keep_knots);
264 }
265
266 int32_t interpolate(int32_t* order = nullptr, bool* reset_knots = nullptr) override {
267 return fitpack_constrained_curve_c_interpolate(as<fitpack_constrained_curve_c>(), order, reset_knots);
268 }
269
270 int32_t least_squares(double* smoothing = nullptr, bool* reset_knots = nullptr) override {
271 return fitpack_constrained_curve_c_least_squares(as<fitpack_constrained_curve_c>(), smoothing, reset_knots);
272 }
273
277 std::vector<double> eval_one(double u, int32_t n_result, int32_t* ierr = nullptr) override {
278 std::vector<double> result(n_result);
279 fitpack_constrained_curve_c_eval_one(as<fitpack_constrained_curve_c>(), u, ierr, result.data(), n_result);
280 return result;
281 }
282
283
287 std::vector<double> eval_many(std::vector<double>& u, int32_t n_result, int32_t* ierr = nullptr) override {
288 int32_t n = static_cast<int32_t>(u.size());
289 std::vector<double> result(n_result);
290 fitpack_constrained_curve_c_eval_many(as<fitpack_constrained_curve_c>(), n, u.data(), ierr, result.data(), n_result);
291 return result;
292 }
293
294
298 std::vector<double> dfdx(double u, int32_t order, int32_t n_result, int32_t* ierr = nullptr) override {
299 std::vector<double> result(n_result);
300 fitpack_constrained_curve_c_curve_derivative(as<fitpack_constrained_curve_c>(), u, order, ierr, result.data(), n_result);
301 return result;
302 }
303
304
308 std::vector<double> dfdx(std::vector<double>& u, int32_t order, int32_t n_result, int32_t* ierr = nullptr) override {
309 int32_t n = static_cast<int32_t>(u.size());
310 std::vector<double> result(n_result);
311 fitpack_constrained_curve_c_curve_derivatives(as<fitpack_constrained_curve_c>(), n, u.data(), order, ierr, result.data(), n_result);
312 return result;
313 }
314
315
319 std::vector<double> dfdx_all(double u, int32_t n_result, int32_t* ierr = nullptr) override {
320 std::vector<double> result(n_result);
321 fitpack_constrained_curve_c_curve_all_derivatives(as<fitpack_constrained_curve_c>(), u, ierr, result.data(), n_result);
322 return result;
323 }
324
325
326 double mse() const override {
327 return fitpack_constrained_curve_c_mse(as<fitpack_constrained_curve_c>());
328 }
329
330 int32_t core_comm_size() const override {
331 return fitpack_constrained_curve_c_core_comm_size(as<fitpack_constrained_curve_c>());
332 }
333
337 void core_comm_pack(std::vector<double>& buffer) const override {
338 int32_t n = static_cast<int32_t>(buffer.size());
339 fitpack_constrained_curve_c_core_comm_pack(as<fitpack_constrained_curve_c>(), n, buffer.data());
340 }
341
342
346 void core_comm_expand(std::vector<double>& buffer) override {
347 int32_t n = static_cast<int32_t>(buffer.size());
348 fitpack_constrained_curve_c_core_comm_expand(as<fitpack_constrained_curve_c>(), n, buffer.data());
349 }
350
351
352 void destroy_base() override {
353 fitpack_constrained_curve_c_destroy_base(as<fitpack_constrained_curve_c>());
354 }
355
356 // ===========================================================================================
357 // Component Array Accessors
358 // ===========================================================================================
359
368 std::vector<double> deriv_begin_vector() const {
369 double* raw = nullptr;
370 int64_t extents[2] = {0, 0};
371 fitpack_constrained_curve_c_getcomp_deriv_begin(as<fitpack_constrained_curve_c>(), &raw, extents);
372 const int64_t total = extents[0] * extents[1];
373 if (raw == nullptr || total <= 0) return {};
374 const double* first = reinterpret_cast<const double*>(raw);
375 return std::vector<double>(first, first + total);
376 }
377
382 std::array<int64_t, 2> deriv_begin_shape() const {
383 double* raw = nullptr;
384 int64_t extents[2] = {0, 0};
385 fitpack_constrained_curve_c_getcomp_deriv_begin(as<fitpack_constrained_curve_c>(), &raw, extents);
386 return { extents[0], extents[1] };
387 }
388
389#if HAVE_FXARRAY
402 fxArray<double> deriv_begin() const {
403 double* raw = nullptr;
404 int64_t extents[2] = {0, 0};
405 fitpack_constrained_curve_c_getcomp_deriv_begin(as<fitpack_constrained_curve_c>(), &raw, extents);
406 FX_SIZE bounds[4]; // (lower, upper) per dimension, Fortran lbound 1
407 for (int k = 0; k < 2; ++k) {
408 bounds[2 * k] = 1;
409 bounds[2 * k + 1] = static_cast<FX_SIZE>(extents[k]);
410 }
411 array_c descr = array_c_null;
412 array_c_from_ptr(&descr, "deriv_begin", static_cast<void*>(raw),
413 getCFITypeFlag<double>(),
414 static_cast<FX_SIZE>(sizeof(double)),
415 static_cast<FX_RANK>(2), bounds);
416 return fxArray<double>(descr);
417 }
418#endif // HAVE_FXARRAY
419
428 std::vector<double> deriv_end_vector() const {
429 double* raw = nullptr;
430 int64_t extents[2] = {0, 0};
431 fitpack_constrained_curve_c_getcomp_deriv_end(as<fitpack_constrained_curve_c>(), &raw, extents);
432 const int64_t total = extents[0] * extents[1];
433 if (raw == nullptr || total <= 0) return {};
434 const double* first = reinterpret_cast<const double*>(raw);
435 return std::vector<double>(first, first + total);
436 }
437
442 std::array<int64_t, 2> deriv_end_shape() const {
443 double* raw = nullptr;
444 int64_t extents[2] = {0, 0};
445 fitpack_constrained_curve_c_getcomp_deriv_end(as<fitpack_constrained_curve_c>(), &raw, extents);
446 return { extents[0], extents[1] };
447 }
448
449#if HAVE_FXARRAY
462 fxArray<double> deriv_end() const {
463 double* raw = nullptr;
464 int64_t extents[2] = {0, 0};
465 fitpack_constrained_curve_c_getcomp_deriv_end(as<fitpack_constrained_curve_c>(), &raw, extents);
466 FX_SIZE bounds[4]; // (lower, upper) per dimension, Fortran lbound 1
467 for (int k = 0; k < 2; ++k) {
468 bounds[2 * k] = 1;
469 bounds[2 * k + 1] = static_cast<FX_SIZE>(extents[k]);
470 }
471 array_c descr = array_c_null;
472 array_c_from_ptr(&descr, "deriv_end", static_cast<void*>(raw),
473 getCFITypeFlag<double>(),
474 static_cast<FX_SIZE>(sizeof(double)),
475 static_cast<FX_RANK>(2), bounds);
476 return fxArray<double>(descr);
477 }
478#endif // HAVE_FXARRAY
479
488 std::vector<double> xx_vector() const {
489 double* raw = nullptr;
490 int64_t extents[2] = {0, 0};
491 fitpack_constrained_curve_c_getcomp_xx(as<fitpack_constrained_curve_c>(), &raw, extents);
492 const int64_t total = extents[0] * extents[1];
493 if (raw == nullptr || total <= 0) return {};
494 const double* first = reinterpret_cast<const double*>(raw);
495 return std::vector<double>(first, first + total);
496 }
497
502 std::array<int64_t, 2> xx_shape() const {
503 double* raw = nullptr;
504 int64_t extents[2] = {0, 0};
505 fitpack_constrained_curve_c_getcomp_xx(as<fitpack_constrained_curve_c>(), &raw, extents);
506 return { extents[0], extents[1] };
507 }
508
509#if HAVE_FXARRAY
522 fxArray<double> xx() const {
523 double* raw = nullptr;
524 int64_t extents[2] = {0, 0};
525 fitpack_constrained_curve_c_getcomp_xx(as<fitpack_constrained_curve_c>(), &raw, extents);
526 FX_SIZE bounds[4]; // (lower, upper) per dimension, Fortran lbound 1
527 for (int k = 0; k < 2; ++k) {
528 bounds[2 * k] = 1;
529 bounds[2 * k + 1] = static_cast<FX_SIZE>(extents[k]);
530 }
531 array_c descr = array_c_null;
532 array_c_from_ptr(&descr, "xx", static_cast<void*>(raw),
533 getCFITypeFlag<double>(),
534 static_cast<FX_SIZE>(sizeof(double)),
535 static_cast<FX_RANK>(2), bounds);
536 return fxArray<double>(descr);
537 }
538#endif // HAVE_FXARRAY
539
548 std::vector<double> cp_vector() const {
549 double* raw = nullptr;
550 int64_t extents[2] = {0, 0};
551 fitpack_constrained_curve_c_getcomp_cp(as<fitpack_constrained_curve_c>(), &raw, extents);
552 const int64_t total = extents[0] * extents[1];
553 if (raw == nullptr || total <= 0) return {};
554 const double* first = reinterpret_cast<const double*>(raw);
555 return std::vector<double>(first, first + total);
556 }
557
562 std::array<int64_t, 2> cp_shape() const {
563 double* raw = nullptr;
564 int64_t extents[2] = {0, 0};
565 fitpack_constrained_curve_c_getcomp_cp(as<fitpack_constrained_curve_c>(), &raw, extents);
566 return { extents[0], extents[1] };
567 }
568
569#if HAVE_FXARRAY
582 fxArray<double> cp() const {
583 double* raw = nullptr;
584 int64_t extents[2] = {0, 0};
585 fitpack_constrained_curve_c_getcomp_cp(as<fitpack_constrained_curve_c>(), &raw, extents);
586 FX_SIZE bounds[4]; // (lower, upper) per dimension, Fortran lbound 1
587 for (int k = 0; k < 2; ++k) {
588 bounds[2 * k] = 1;
589 bounds[2 * k + 1] = static_cast<FX_SIZE>(extents[k]);
590 }
591 array_c descr = array_c_null;
592 array_c_from_ptr(&descr, "cp", static_cast<void*>(raw),
593 getCFITypeFlag<double>(),
594 static_cast<FX_SIZE>(sizeof(double)),
595 static_cast<FX_RANK>(2), bounds);
596 return fxArray<double>(descr);
597 }
598#endif // HAVE_FXARRAY
599
600 // ===========================================================================================
601 // Scalar Property Accessors
602 // ===========================================================================================
603
604 int32_t& ib() {
605 return *fitpack_constrained_curve_c_ref_ib(as<fitpack_constrained_curve_c>());
606 }
607 const int32_t& ib() const {
608 return *fitpack_constrained_curve_c_ref_ib(as<fitpack_constrained_curve_c>());
609 }
610
611 int32_t& ie() {
612 return *fitpack_constrained_curve_c_ref_ie(as<fitpack_constrained_curve_c>());
613 }
614 const int32_t& ie() const {
615 return *fitpack_constrained_curve_c_ref_ie(as<fitpack_constrained_curve_c>());
616 }
617
618 // ===========================================================================================
619 // extra_methods/fpParametricInherit.hpp (hand-maintained)
620 //
621 // This class overrides the raw new_fit / fit, which hides the fpPoint<dim> overloads
622 // spliced into fpParametricCurve. Re-expose them; the overrides above still win for their
623 // own signatures, and every fpPoint<dim> overload dispatches back through them.
624 // ===========================================================================================
625
628
629 // ===========================================================================================
630 // Endpoint constraints — extra_methods/fpConstrainedPoints.hpp (hand-maintained)
631 //
632 // Each list holds the position and the successive derivatives to pin at that endpoint:
633 // entry j is the j-th derivative, so a single entry fixes the point only.
634 //
635 // The const_cast is safe: the Fortran dummy is `optional, intent(in)`. The generated
636 // wrapper takes a non-const pointer only because an OPTIONAL argument is passed by
637 // address, and nullptr is how a C caller says "absent".
638 // ===========================================================================================
639
641 template <FP_SIZE dim>
642 FP_FLAG constrain_begin(const std::vector<fpPoint<dim>>& ddx_begin)
643 {
644 FP_FLAG ierr = FITPACK_OK;
645 set_constraints(dim, static_cast<FP_SIZE>(ddx_begin.size()), dim, 0,
646 const_cast<FP_REAL*>(fpPointData<dim>(ddx_begin)), nullptr, &ierr);
647 return ierr;
648 }
649
651 template <FP_SIZE dim>
652 FP_FLAG constrain_both(const std::vector<fpPoint<dim>>& ddx_begin,
653 const std::vector<fpPoint<dim>>& ddx_end)
654 {
655 FP_FLAG ierr = FITPACK_OK;
656 set_constraints(dim, static_cast<FP_SIZE>(ddx_begin.size()),
657 dim, static_cast<FP_SIZE>(ddx_end.size()),
658 const_cast<FP_REAL*>(fpPointData<dim>(ddx_begin)),
659 const_cast<FP_REAL*>(fpPointData<dim>(ddx_end)), &ierr);
660 return ierr;
661 }
662
664 template <FP_SIZE dim>
665 FP_FLAG constrain_end(const std::vector<fpPoint<dim>>& ddx_end)
666 {
667 FP_FLAG ierr = FITPACK_OK;
668 set_constraints(dim, 0, dim, static_cast<FP_SIZE>(ddx_end.size()),
669 nullptr, const_cast<FP_REAL*>(fpPointData<dim>(ddx_end)), &ierr);
670 return ierr;
671 }
672
673protected:
675
676};
677
678#endif /* FPCONSTRAINEDCURVE_HPP_INCLUDED */
void core_comm_expand(std::vector< double > &buffer) override
core_comm_expand
Definition fpConstrainedCurve.hpp:346
int32_t comm_size() const override
Definition fpConstrainedCurve.hpp:220
fpConstrainedCurve(NoAlloc tag)
Definition fpConstrainedCurve.hpp:674
int32_t new_fit(int32_t x_n1, int32_t x_n2, std::vector< double > &x, double *u=nullptr, double *w=nullptr, double *smoothing=nullptr, int32_t *order=nullptr) override
new_fit
Definition fpConstrainedCurve.hpp:257
double mse() const override
Definition fpConstrainedCurve.hpp:326
int32_t core_comm_size() const override
Definition fpConstrainedCurve.hpp:330
std::vector< double > deriv_begin_vector() const
Deep copy of component 'deriv_begin' as a std::vector.
Definition fpConstrainedCurve.hpp:368
std::vector< double > eval_many(std::vector< double > &u, int32_t n_result, int32_t *ierr=nullptr) override
eval_many
Definition fpConstrainedCurve.hpp:287
fpConstrainedCurve & operator=(fpConstrainedCurve &&other) noexcept
Move assignment - transfer ownership.
Definition fpConstrainedCurve.hpp:105
std::array< int64_t, 2 > deriv_end_shape() const
Extents of component 'deriv_end', leading dimension first.
Definition fpConstrainedCurve.hpp:442
std::array< int64_t, 2 > cp_shape() const
Extents of component 'cp', leading dimension first.
Definition fpConstrainedCurve.hpp:562
bool is_allocated() const override
Check if object is allocated.
Definition fpConstrainedCurve.hpp:142
const fpParametricCurve & as_parent() const
Definition fpConstrainedCurve.hpp:200
std::vector< double > deriv_end_vector() const
Deep copy of component 'deriv_end' as a std::vector.
Definition fpConstrainedCurve.hpp:428
int32_t interpolate(int32_t *order=nullptr, bool *reset_knots=nullptr) override
Definition fpConstrainedCurve.hpp:266
virtual void clean_constraints()
Definition fpConstrainedCurve.hpp:208
fpConstrainedCurve(fitpack_constrained_curve_c &c_wrapper, ViewTag)
Non-owning view ctor: bit-copy the C handle, mark is_pointer=true. Used by parent classes' polymorphi...
Definition fpConstrainedCurve.hpp:130
FP_FLAG constrain_both(const std::vector< fpPoint< dim > > &ddx_begin, const std::vector< fpPoint< dim > > &ddx_end)
Pin both endpoints.
Definition fpConstrainedCurve.hpp:652
fpConstrainedCurve()
Default constructor - allocates new fitpack_constrained_curve.
Definition fpConstrainedCurve.hpp:64
static fpConstrainedCurve make_view()
Construct an empty (non-owning) wrapper, for use as a view target.
Definition fpConstrainedCurve.hpp:190
fxArray< double > deriv_begin() const
Zero-copy fxArray view of component 'deriv_begin'.
Definition fpConstrainedCurve.hpp:402
std::vector< double > xx_vector() const
Deep copy of component 'xx' as a std::vector.
Definition fpConstrainedCurve.hpp:488
std::array< int64_t, 2 > xx_shape() const
Extents of component 'xx', leading dimension first.
Definition fpConstrainedCurve.hpp:502
std::vector< double > dfdx(double u, int32_t order, int32_t n_result, int32_t *ierr=nullptr) override
dfdx
Definition fpConstrainedCurve.hpp:298
fpConstrainedCurve(const fpConstrainedCurve &other)
Copy constructor - deep copy.
Definition fpConstrainedCurve.hpp:78
FP_FLAG constrain_end(const std::vector< fpPoint< dim > > &ddx_end)
Pin the end endpoint; leave the begin endpoint free.
Definition fpConstrainedCurve.hpp:665
fxArray< double > deriv_end() const
Zero-copy fxArray view of component 'deriv_end'.
Definition fpConstrainedCurve.hpp:462
int32_t least_squares(double *smoothing=nullptr, bool *reset_knots=nullptr) override
Definition fpConstrainedCurve.hpp:270
const char * c_type_name() const override
Return the C wrapper struct name for this class (e.g. "fitpack_constrained_curve_c").
Definition fpConstrainedCurve.hpp:156
FP_FLAG constrain_begin(const std::vector< fpPoint< dim > > &ddx_begin)
Pin the begin endpoint; leave the end endpoint free.
Definition fpConstrainedCurve.hpp:642
const int32_t & ie() const
Definition fpConstrainedCurve.hpp:614
std::vector< double > dfdx(std::vector< double > &u, int32_t order, int32_t n_result, int32_t *ierr=nullptr) override
dfdx
Definition fpConstrainedCurve.hpp:308
virtual void set_constraints(int32_t ddx_begin_n1, int32_t ddx_begin_n2, int32_t ddx_end_n1, int32_t ddx_end_n2, double *ddx_begin=nullptr, double *ddx_end=nullptr, int32_t *ierr=nullptr)
set_constraints
Definition fpConstrainedCurve.hpp:215
std::vector< double > cp_vector() const
Deep copy of component 'cp' as a std::vector.
Definition fpConstrainedCurve.hpp:548
std::vector< double > dfdx_all(double u, int32_t n_result, int32_t *ierr=nullptr) override
dfdx_all
Definition fpConstrainedCurve.hpp:319
int32_t & ie()
Definition fpConstrainedCurve.hpp:611
const fitpack_constrained_curve_c & c_handle() const
Get underlying C wrapper (const, for interop)
Definition fpConstrainedCurve.hpp:178
void new_points(int32_t x_n1, int32_t x_n2, std::vector< double > &x, double *u=nullptr, double *w=nullptr) override
new_points
Definition fpConstrainedCurve.hpp:245
fpConstrainedCurve & operator=(const fpConstrainedCurve &other)
Copy assignment - deep copy.
Definition fpConstrainedCurve.hpp:86
bool is_pointer() const override
Check if this is a non-owning pointer.
Definition fpConstrainedCurve.hpp:149
fpParametricCurve & as_parent()
Upcast to parent type (reference, no copy)
Definition fpConstrainedCurve.hpp:197
void comm_pack(std::vector< double > &buffer) const override
comm_pack
Definition fpConstrainedCurve.hpp:227
fxArray< double > cp() const
Zero-copy fxArray view of component 'cp'.
Definition fpConstrainedCurve.hpp:582
fpConstrainedCurve(fitpack_constrained_curve_c &c_wrapper, bool move=false)
Construct from existing C wrapper (takes ownership if move=true)
Definition fpConstrainedCurve.hpp:116
std::array< int64_t, 2 > deriv_begin_shape() const
Extents of component 'deriv_begin', leading dimension first.
Definition fpConstrainedCurve.hpp:382
const int32_t & ib() const
Definition fpConstrainedCurve.hpp:607
void destroy_base() override
Definition fpConstrainedCurve.hpp:352
int32_t fit(double *smoothing=nullptr, int32_t *order=nullptr, bool *keep_knots=nullptr) override
Definition fpConstrainedCurve.hpp:262
fpConstrainedCurve(fpConstrainedCurve &&other) noexcept
Move constructor - transfer ownership.
Definition fpConstrainedCurve.hpp:97
~fpConstrainedCurve() override
Destructor - deallocates if owned.
Definition fpConstrainedCurve.hpp:71
fxArray< double > xx() const
Zero-copy fxArray view of component 'xx'.
Definition fpConstrainedCurve.hpp:522
void core_comm_pack(std::vector< double > &buffer) const override
core_comm_pack
Definition fpConstrainedCurve.hpp:337
void comm_expand(std::vector< double > &buffer) override
comm_expand
Definition fpConstrainedCurve.hpp:236
void set_default_parameters() override
Definition fpConstrainedCurve.hpp:250
fitpack_constrained_curve_c & c_handle()
Get underlying C wrapper (for interop)
Definition fpConstrainedCurve.hpp:171
std::vector< double > eval_one(double u, int32_t n_result, int32_t *ierr=nullptr) override
eval_one
Definition fpConstrainedCurve.hpp:277
const char * cpp_type_name() const override
Return the fully-qualified C++ class name for this class. Owned by the C++ layer — does not round-tri...
Definition fpConstrainedCurve.hpp:164
int32_t & ib()
Definition fpConstrainedCurve.hpp:604
double & smoothing()
Definition fpFitter.hpp:317
T * as()
Definition fpFitter.hpp:360
fpParametricCurve()
Default constructor - allocates new fitpack_parametric_curve.
Definition fpParametricCurve.hpp:65
virtual int32_t fit(double *smoothing=nullptr, int32_t *order=nullptr, bool *keep_knots=nullptr)
Definition fpParametricCurve.hpp:229
fxArray< double > u() const
Zero-copy fxArray view of component 'u'.
Definition fpParametricCurve.hpp:436
fxArray< double > x() const
Zero-copy fxArray view of component 'x'.
Definition fpParametricCurve.hpp:391
virtual int32_t new_fit(int32_t x_n1, int32_t x_n2, std::vector< double > &x, double *u=nullptr, double *w=nullptr, double *smoothing=nullptr, int32_t *order=nullptr)
new_fit
Definition fpParametricCurve.hpp:224
fxArray< double > w() const
Zero-copy fxArray view of component 'w'.
Definition fpParametricCurve.hpp:526
int32_t & order()
Definition fpParametricCurve.hpp:674
const FP_REAL * fpPointData(const std::vector< fpPoint< dims > > &points)
Borrow a vector of points as a Fortran x(dims,m) buffer. No copy, no allocation.
Definition fpPoint.hpp:107
Tag type for derived class constructors (no allocation)
Definition fpFitter.hpp:349
Tag type for non-owning view constructors of polymorphic concrete subtypes. Declared on roots and abs...
Definition fpFitter.hpp:103
A point in dims-dimensional space.
Definition fpPoint.hpp:45