24#ifndef FPCONVEXCURVE_HPP_INCLUDED
25#define FPCONVEXCURVE_HPP_INCLUDED
27#include "fitpack_config.h"
30#include "fxArrays.hpp"
33#include "fitpack_convex_curve_c.h"
43static_assert(
sizeof(fitpack_convex_curve_c) ==
sizeof(fitpack_curve_c),
44 "C descriptor layout mismatch: fitpack_convex_curve_c vs fitpack_curve_c");
105 if (
this != &other) {
164 return "fpConvexCurve";
197 return static_cast<fpCurve&
>(*this);
200 return static_cast<const fpCurve&
>(*this);
210 void new_points(std::vector<double>&
x, std::vector<double>&
y,
double*
w =
nullptr)
override {
211 int32_t n =
static_cast<int32_t
>(
x.size());
216 int32_t
fit(
double*
smoothing =
nullptr, int32_t*
order =
nullptr,
bool* keep_knots =
nullptr)
override {
228 int32_t n =
static_cast<int32_t
>(
v.size());
240 void comm_pack(std::vector<double>& buffer)
const override {
241 int32_t n =
static_cast<int32_t
>(buffer.size());
250 int32_t n =
static_cast<int32_t
>(buffer.size());
255 double mse()
const override {
267 int32_t n =
static_cast<int32_t
>(buffer.size());
276 int32_t n =
static_cast<int32_t
>(buffer.size());
294 double* raw =
nullptr;
295 int64_t extents[1] = {0};
297 const int64_t total = extents[0];
298 if (raw ==
nullptr || total <= 0)
return {};
299 const double* first =
reinterpret_cast<const double*
>(raw);
300 return std::vector<double>(first, first + total);
316 fxArray<double>
v()
const {
317 double* raw =
nullptr;
318 int64_t extents[1] = {0};
321 for (
int k = 0; k < 1; ++k) {
323 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
325 array_c descr = array_c_null;
326 array_c_from_ptr(&descr,
"v",
static_cast<void*
>(raw),
327 getCFITypeFlag<double>(),
328 static_cast<FX_SIZE
>(
sizeof(
double)),
329 static_cast<FX_RANK
>(1), bounds);
330 return fxArray<double>(descr);
339 double* raw =
nullptr;
340 int64_t extents[1] = {0};
342 const int64_t total = extents[0];
343 if (raw ==
nullptr || total <= 0)
return {};
344 const double* first =
reinterpret_cast<const double*
>(raw);
345 return std::vector<double>(first, first + total);
361 fxArray<double>
sx()
const {
362 double* raw =
nullptr;
363 int64_t extents[1] = {0};
366 for (
int k = 0; k < 1; ++k) {
368 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
370 array_c descr = array_c_null;
371 array_c_from_ptr(&descr,
"sx",
static_cast<void*
>(raw),
372 getCFITypeFlag<double>(),
373 static_cast<FX_SIZE
>(
sizeof(
double)),
374 static_cast<FX_RANK
>(1), bounds);
375 return fxArray<double>(descr);
fpConvexCurve(const fpConvexCurve &other)
Copy constructor - deep copy.
Definition fpConvexCurve.hpp:77
void destroy_base() override
Definition fpConvexCurve.hpp:281
void core_comm_pack(std::vector< double > &buffer) const override
core_comm_pack
Definition fpConvexCurve.hpp:266
void comm_expand(std::vector< double > &buffer) override
comm_expand
Definition fpConvexCurve.hpp:249
fpConvexCurve()
Default constructor - allocates new fitpack_convex_curve.
Definition fpConvexCurve.hpp:63
void core_comm_expand(std::vector< double > &buffer) override
core_comm_expand
Definition fpConvexCurve.hpp:275
fpConvexCurve(fitpack_convex_curve_c &c_wrapper, ViewTag)
Non-owning view ctor: bit-copy the C handle, mark is_pointer=true. Used by parent classes' polymorphi...
Definition fpConvexCurve.hpp:129
std::vector< double > sx_vector() const
Deep copy of component 'sx' as a std::vector.
Definition fpConvexCurve.hpp:338
const int32_t & maxtr() const
Definition fpConvexCurve.hpp:386
static fpConvexCurve make_view()
Construct an empty (non-owning) wrapper, for use as a view target.
Definition fpConvexCurve.hpp:189
const int32_t & maxbin() const
Definition fpConvexCurve.hpp:393
fpConvexCurve(NoAlloc tag)
Definition fpConvexCurve.hpp:398
void comm_pack(std::vector< double > &buffer) const override
comm_pack
Definition fpConvexCurve.hpp:240
fpConvexCurve(fitpack_convex_curve_c &c_wrapper, bool move=false)
Construct from existing C wrapper (takes ownership if move=true)
Definition fpConvexCurve.hpp:115
const char * c_type_name() const override
Return the C wrapper struct name for this class (e.g. "fitpack_convex_curve_c").
Definition fpConvexCurve.hpp:155
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 fpConvexCurve.hpp:163
virtual int32_t set_convexity(std::vector< double > &v)
set_convexity
Definition fpConvexCurve.hpp:227
fxArray< double > sx() const
Zero-copy fxArray view of component 'sx'.
Definition fpConvexCurve.hpp:361
fitpack_convex_curve_c & c_handle()
Get underlying C wrapper (for interop)
Definition fpConvexCurve.hpp:170
fxArray< double > v() const
Zero-copy fxArray view of component 'v'.
Definition fpConvexCurve.hpp:316
const fitpack_convex_curve_c & c_handle() const
Get underlying C wrapper (const, for interop)
Definition fpConvexCurve.hpp:177
int32_t core_comm_size() const override
Definition fpConvexCurve.hpp:259
int32_t fit(double *smoothing=nullptr, int32_t *order=nullptr, bool *keep_knots=nullptr) override
Definition fpConvexCurve.hpp:216
bool is_allocated() const override
Check if object is allocated.
Definition fpConvexCurve.hpp:141
int32_t & maxtr()
Definition fpConvexCurve.hpp:383
int32_t least_squares(double *smoothing=nullptr, bool *reset_knots=nullptr) override
Definition fpConvexCurve.hpp:220
void new_points(std::vector< double > &x, std::vector< double > &y, double *w=nullptr) override
new_points
Definition fpConvexCurve.hpp:210
fpConvexCurve(fpConvexCurve &&other) noexcept
Move constructor - transfer ownership.
Definition fpConvexCurve.hpp:96
fpConvexCurve & operator=(const fpConvexCurve &other)
Copy assignment - deep copy.
Definition fpConvexCurve.hpp:85
fpConvexCurve & operator=(fpConvexCurve &&other) noexcept
Move assignment - transfer ownership.
Definition fpConvexCurve.hpp:104
std::vector< double > v_vector() const
Deep copy of component 'v' as a std::vector.
Definition fpConvexCurve.hpp:293
int32_t & maxbin()
Definition fpConvexCurve.hpp:390
~fpConvexCurve() override
Destructor - deallocates if owned.
Definition fpConvexCurve.hpp:70
fpCurve & as_parent()
Upcast to parent type (reference, no copy)
Definition fpConvexCurve.hpp:196
double mse() const override
Definition fpConvexCurve.hpp:255
int32_t comm_size() const override
Definition fpConvexCurve.hpp:233
bool is_pointer() const override
Check if this is a non-owning pointer.
Definition fpConvexCurve.hpp:148
const fpCurve & as_parent() const
Definition fpConvexCurve.hpp:199
fxArray< double > x() const
Zero-copy fxArray view of component 'x'.
Definition fpCurve.hpp:431
int32_t & order()
Definition fpCurve.hpp:700
fxArray< double > y() const
Zero-copy fxArray view of component 'y'.
Definition fpCurve.hpp:476
fpCurve()
Default constructor - allocates new fitpack_curve.
Definition fpCurve.hpp:65
fxArray< double > w() const
Zero-copy fxArray view of component 'w'.
Definition fpCurve.hpp:566
double & smoothing()
Definition fpFitter.hpp:317
T * as()
Definition fpFitter.hpp:360
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