24#ifndef FPCONSTRAINEDCURVE_HPP_INCLUDED
25#define FPCONSTRAINEDCURVE_HPP_INCLUDED
27#include "fitpack_config.h"
30#include "fxArrays.hpp"
33#include "fitpack_constrained_curve_c.h"
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");
106 if (
this != &other) {
165 return "fpConstrainedCurve";
178 const fitpack_constrained_curve_c&
c_handle()
const {
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);
227 void comm_pack(std::vector<double>& buffer)
const override {
228 int32_t n =
static_cast<int32_t
>(buffer.size());
237 int32_t n =
static_cast<int32_t
>(buffer.size());
245 void new_points(int32_t x_n1, int32_t x_n2, std::vector<double>&
x,
double*
u =
nullptr,
double*
w =
nullptr)
override {
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 {
262 int32_t
fit(
double*
smoothing =
nullptr, int32_t*
order =
nullptr,
bool* keep_knots =
nullptr)
override {
277 std::vector<double>
eval_one(
double u, int32_t n_result, int32_t* ierr =
nullptr)
override {
278 std::vector<double> result(n_result);
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);
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);
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);
319 std::vector<double>
dfdx_all(
double u, int32_t n_result, int32_t* ierr =
nullptr)
override {
320 std::vector<double> result(n_result);
326 double mse()
const override {
338 int32_t n =
static_cast<int32_t
>(buffer.size());
347 int32_t n =
static_cast<int32_t
>(buffer.size());
369 double* raw =
nullptr;
370 int64_t extents[2] = {0, 0};
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);
383 double* raw =
nullptr;
384 int64_t extents[2] = {0, 0};
386 return { extents[0], extents[1] };
403 double* raw =
nullptr;
404 int64_t extents[2] = {0, 0};
407 for (
int k = 0; k < 2; ++k) {
409 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
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);
429 double* raw =
nullptr;
430 int64_t extents[2] = {0, 0};
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);
443 double* raw =
nullptr;
444 int64_t extents[2] = {0, 0};
446 return { extents[0], extents[1] };
463 double* raw =
nullptr;
464 int64_t extents[2] = {0, 0};
467 for (
int k = 0; k < 2; ++k) {
469 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
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);
489 double* raw =
nullptr;
490 int64_t extents[2] = {0, 0};
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);
503 double* raw =
nullptr;
504 int64_t extents[2] = {0, 0};
506 return { extents[0], extents[1] };
522 fxArray<double>
xx()
const {
523 double* raw =
nullptr;
524 int64_t extents[2] = {0, 0};
527 for (
int k = 0; k < 2; ++k) {
529 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
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);
549 double* raw =
nullptr;
550 int64_t extents[2] = {0, 0};
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);
563 double* raw =
nullptr;
564 int64_t extents[2] = {0, 0};
566 return { extents[0], extents[1] };
582 fxArray<double>
cp()
const {
583 double* raw =
nullptr;
584 int64_t extents[2] = {0, 0};
587 for (
int k = 0; k < 2; ++k) {
589 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
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);
607 const int32_t&
ib()
const {
614 const int32_t&
ie()
const {
641 template <FP_SIZE dim>
644 FP_FLAG ierr = FITPACK_OK;
651 template <FP_SIZE dim>
655 FP_FLAG ierr = FITPACK_OK;
657 dim,
static_cast<FP_SIZE
>(ddx_end.size()),
664 template <FP_SIZE dim>
667 FP_FLAG ierr = FITPACK_OK;
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