24#ifndef FPPOLAR_HPP_INCLUDED
25#define FPPOLAR_HPP_INCLUDED
27#include "fitpack_config.h"
30#include "fxArrays.hpp"
33#include "fitpack_polar_c.h"
44static_assert(
sizeof(fitpack_polar_c) ==
sizeof(fitpack_fitter_c),
45 "C descriptor layout mismatch: fitpack_polar_c vs fitpack_fitter_c");
106 if (
this != &other) {
198 return static_cast<fpFitter&
>(*this);
201 return static_cast<const fpFitter&
>(*this);
211 virtual void new_points(std::vector<double>&
x, std::vector<double>&
y, std::vector<double>&
z, fitpack_polar_boundary_fn boundary,
double*
w =
nullptr, int32_t* boundary_bc =
nullptr) {
212 int32_t n =
static_cast<int32_t
>(
x.size());
220 virtual int32_t
new_fit(std::vector<double>&
x, std::vector<double>&
y, std::vector<double>&
z, fitpack_polar_boundary_fn boundary,
double*
w =
nullptr, int32_t* boundary_bc =
nullptr,
double*
smoothing =
nullptr) {
221 int32_t n =
static_cast<int32_t
>(
x.size());
226 virtual int32_t
fit(
double*
smoothing =
nullptr,
bool* keep_knots =
nullptr) {
238 virtual double eval(
double x,
double y, int32_t* ierr =
nullptr) {
245 virtual std::vector<double>
eval(std::vector<double>&
x, std::vector<double>&
y, int32_t* ierr =
nullptr) {
246 int32_t n =
static_cast<int32_t
>(
x.size());
247 std::vector<double> result(n);
248 int32_t n_result = 0;
249 fitpack_polar_c_polr_eval_many(
as<fitpack_polar_c>(), n,
x.data(),
y.data(), ierr, result.data(), &n_result, n);
250 result.resize(n_result);
262 void comm_pack(std::vector<double>& buffer)
const override {
263 int32_t n =
static_cast<int32_t
>(buffer.size());
272 int32_t n =
static_cast<int32_t
>(buffer.size());
277 double mse()
const override {
289 int32_t n =
static_cast<int32_t
>(buffer.size());
298 int32_t n =
static_cast<int32_t
>(buffer.size());
316 double* raw =
nullptr;
317 int64_t extents[1] = {0};
319 const int64_t total = extents[0];
320 if (raw ==
nullptr || total <= 0)
return {};
321 const double* first =
reinterpret_cast<const double*
>(raw);
322 return std::vector<double>(first, first + total);
338 fxArray<double>
x()
const {
339 double* raw =
nullptr;
340 int64_t extents[1] = {0};
343 for (
int k = 0; k < 1; ++k) {
345 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
347 array_c descr = array_c_null;
348 array_c_from_ptr(&descr,
"x",
static_cast<void*
>(raw),
349 getCFITypeFlag<double>(),
350 static_cast<FX_SIZE
>(
sizeof(
double)),
351 static_cast<FX_RANK
>(1), bounds);
352 return fxArray<double>(descr);
361 double* raw =
nullptr;
362 int64_t extents[1] = {0};
364 const int64_t total = extents[0];
365 if (raw ==
nullptr || total <= 0)
return {};
366 const double* first =
reinterpret_cast<const double*
>(raw);
367 return std::vector<double>(first, first + total);
383 fxArray<double>
y()
const {
384 double* raw =
nullptr;
385 int64_t extents[1] = {0};
388 for (
int k = 0; k < 1; ++k) {
390 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
392 array_c descr = array_c_null;
393 array_c_from_ptr(&descr,
"y",
static_cast<void*
>(raw),
394 getCFITypeFlag<double>(),
395 static_cast<FX_SIZE
>(
sizeof(
double)),
396 static_cast<FX_RANK
>(1), bounds);
397 return fxArray<double>(descr);
406 double* raw =
nullptr;
407 int64_t extents[1] = {0};
409 const int64_t total = extents[0];
410 if (raw ==
nullptr || total <= 0)
return {};
411 const double* first =
reinterpret_cast<const double*
>(raw);
412 return std::vector<double>(first, first + total);
428 fxArray<double>
z()
const {
429 double* raw =
nullptr;
430 int64_t extents[1] = {0};
433 for (
int k = 0; k < 1; ++k) {
435 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
437 array_c descr = array_c_null;
438 array_c_from_ptr(&descr,
"z",
static_cast<void*
>(raw),
439 getCFITypeFlag<double>(),
440 static_cast<FX_SIZE
>(
sizeof(
double)),
441 static_cast<FX_RANK
>(1), bounds);
442 return fxArray<double>(descr);
451 double* raw =
nullptr;
452 int64_t extents[1] = {0};
454 const int64_t total = extents[0];
455 if (raw ==
nullptr || total <= 0)
return {};
456 const double* first =
reinterpret_cast<const double*
>(raw);
457 return std::vector<double>(first, first + total);
473 fxArray<double>
u()
const {
474 double* raw =
nullptr;
475 int64_t extents[1] = {0};
478 for (
int k = 0; k < 1; ++k) {
480 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
482 array_c descr = array_c_null;
483 array_c_from_ptr(&descr,
"u",
static_cast<void*
>(raw),
484 getCFITypeFlag<double>(),
485 static_cast<FX_SIZE
>(
sizeof(
double)),
486 static_cast<FX_RANK
>(1), bounds);
487 return fxArray<double>(descr);
496 double* raw =
nullptr;
497 int64_t extents[1] = {0};
499 const int64_t total = extents[0];
500 if (raw ==
nullptr || total <= 0)
return {};
501 const double* first =
reinterpret_cast<const double*
>(raw);
502 return std::vector<double>(first, first + total);
518 fxArray<double>
v()
const {
519 double* raw =
nullptr;
520 int64_t extents[1] = {0};
523 for (
int k = 0; k < 1; ++k) {
525 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
527 array_c descr = array_c_null;
528 array_c_from_ptr(&descr,
"v",
static_cast<void*
>(raw),
529 getCFITypeFlag<double>(),
530 static_cast<FX_SIZE
>(
sizeof(
double)),
531 static_cast<FX_RANK
>(1), bounds);
532 return fxArray<double>(descr);
541 double* raw =
nullptr;
542 int64_t extents[1] = {0};
544 const int64_t total = extents[0];
545 if (raw ==
nullptr || total <= 0)
return {};
546 const double* first =
reinterpret_cast<const double*
>(raw);
547 return std::vector<double>(first, first + total);
563 fxArray<double>
w()
const {
564 double* raw =
nullptr;
565 int64_t extents[1] = {0};
568 for (
int k = 0; k < 1; ++k) {
570 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
572 array_c descr = array_c_null;
573 array_c_from_ptr(&descr,
"w",
static_cast<void*
>(raw),
574 getCFITypeFlag<double>(),
575 static_cast<FX_SIZE
>(
sizeof(
double)),
576 static_cast<FX_RANK
>(1), bounds);
577 return fxArray<double>(descr);
586 double* raw =
nullptr;
587 int64_t extents[1] = {0};
589 const int64_t total = extents[0];
590 if (raw ==
nullptr || total <= 0)
return {};
591 const double* first =
reinterpret_cast<const double*
>(raw);
592 return std::vector<double>(first, first + total);
609 double* raw =
nullptr;
610 int64_t extents[1] = {0};
613 for (
int k = 0; k < 1; ++k) {
615 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
617 array_c descr = array_c_null;
618 array_c_from_ptr(&descr,
"wrk2",
static_cast<void*
>(raw),
619 getCFITypeFlag<double>(),
620 static_cast<FX_SIZE
>(
sizeof(
double)),
621 static_cast<FX_RANK
>(1), bounds);
622 return fxArray<double>(descr);
635 double* raw =
nullptr;
636 int64_t extents[2] = {0, 0};
638 const int64_t total = extents[0] * extents[1];
639 if (raw ==
nullptr || total <= 0)
return {};
640 const double* first =
reinterpret_cast<const double*
>(raw);
641 return std::vector<double>(first, first + total);
649 double* raw =
nullptr;
650 int64_t extents[2] = {0, 0};
652 return { extents[0], extents[1] };
668 fxArray<double>
t()
const {
669 double* raw =
nullptr;
670 int64_t extents[2] = {0, 0};
673 for (
int k = 0; k < 2; ++k) {
675 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
677 array_c descr = array_c_null;
678 array_c_from_ptr(&descr,
"t",
static_cast<void*
>(raw),
679 getCFITypeFlag<double>(),
680 static_cast<FX_SIZE
>(
sizeof(
double)),
681 static_cast<FX_RANK
>(2), bounds);
682 return fxArray<double>(descr);
693 const int32_t&
m()
const {
double & smoothing()
Definition fpFitter.hpp:317
fpFitter(NoAlloc)
Protected constructor for derived classes (does not allocate)
Definition fpFitter.hpp:354
T * as()
Definition fpFitter.hpp:360
fxArray< double > v() const
Zero-copy fxArray view of component 'v'.
Definition fpPolar.hpp:518
void destroy_base() override
Definition fpPolar.hpp:303
int32_t & bc_boundary()
Definition fpPolar.hpp:711
fxArray< double > z() const
Zero-copy fxArray view of component 'z'.
Definition fpPolar.hpp:428
const fpFitter & as_parent() const
Definition fpPolar.hpp:200
virtual double eval(double x, double y, int32_t *ierr=nullptr)
Definition fpPolar.hpp:238
fitpack_polar_c & c_handle()
Get underlying C wrapper (for interop)
Definition fpPolar.hpp:171
int32_t & bc_continuity_origin()
Definition fpPolar.hpp:704
void core_comm_pack(std::vector< double > &buffer) const override
core_comm_pack
Definition fpPolar.hpp:288
fpPolar()
Default constructor - allocates new fitpack_polar.
Definition fpPolar.hpp:64
fxArray< double > wrk2() const
Zero-copy fxArray view of component 'wrk2'.
Definition fpPolar.hpp:608
void core_comm_expand(std::vector< double > &buffer) override
core_comm_expand
Definition fpPolar.hpp:297
fpPolar & operator=(const fpPolar &other)
Copy assignment - deep copy.
Definition fpPolar.hpp:86
static fpPolar make_view()
Construct an empty (non-owning) wrapper, for use as a view target.
Definition fpPolar.hpp:190
const int32_t & lwrk2() const
Definition fpPolar.hpp:700
const char * c_type_name() const override
Return the C wrapper struct name for this class (e.g. "fitpack_polar_c").
Definition fpPolar.hpp:156
virtual std::vector< double > eval(std::vector< double > &x, std::vector< double > &y, int32_t *ierr=nullptr)
eval
Definition fpPolar.hpp:245
std::vector< double > u_vector() const
Deep copy of component 'u' as a std::vector.
Definition fpPolar.hpp:450
fxArray< double > u() const
Zero-copy fxArray view of component 'u'.
Definition fpPolar.hpp:473
std::vector< double > y_vector() const
Deep copy of component 'y' as a std::vector.
Definition fpPolar.hpp:360
std::array< int64_t, 2 > t_shape() const
Extents of component 't', leading dimension first.
Definition fpPolar.hpp:648
fxArray< double > w() const
Zero-copy fxArray view of component 'w'.
Definition fpPolar.hpp:563
virtual void new_points(std::vector< double > &x, std::vector< double > &y, std::vector< double > &z, fitpack_polar_boundary_fn boundary, double *w=nullptr, int32_t *boundary_bc=nullptr)
new_points
Definition fpPolar.hpp:211
int32_t comm_size() const override
Definition fpPolar.hpp:255
virtual int32_t least_squares(double *smoothing=nullptr, bool *reset_knots=nullptr)
Definition fpPolar.hpp:230
virtual int32_t fit(double *smoothing=nullptr, bool *keep_knots=nullptr)
Definition fpPolar.hpp:226
const int32_t & m() const
Definition fpPolar.hpp:693
double mse() const override
Definition fpPolar.hpp:277
fpFitter & as_parent()
Upcast to parent type (reference, no copy)
Definition fpPolar.hpp:197
int32_t & m()
Definition fpPolar.hpp:690
const int32_t & nmax() const
Definition fpPolar.hpp:721
fxArray< double > t() const
Zero-copy fxArray view of component 't'.
Definition fpPolar.hpp:668
~fpPolar() override
Destructor - deallocates if owned.
Definition fpPolar.hpp:71
fpPolar & operator=(fpPolar &&other) noexcept
Move assignment - transfer ownership.
Definition fpPolar.hpp:105
int32_t & lwrk2()
Definition fpPolar.hpp:697
bool is_allocated() const override
Check if object is allocated.
Definition fpPolar.hpp:142
fxArray< double > y() const
Zero-copy fxArray view of component 'y'.
Definition fpPolar.hpp:383
void comm_pack(std::vector< double > &buffer) const override
comm_pack
Definition fpPolar.hpp:262
virtual int32_t new_fit(std::vector< double > &x, std::vector< double > &y, std::vector< double > &z, fitpack_polar_boundary_fn boundary, double *w=nullptr, int32_t *boundary_bc=nullptr, double *smoothing=nullptr)
new_fit
Definition fpPolar.hpp:220
const int32_t & bc_continuity_origin() const
Definition fpPolar.hpp:707
void comm_expand(std::vector< double > &buffer) override
comm_expand
Definition fpPolar.hpp:271
int32_t & nmax()
Definition fpPolar.hpp:718
const fitpack_polar_c & c_handle() const
Get underlying C wrapper (const, for interop)
Definition fpPolar.hpp:178
virtual int32_t interpolate(bool *reset_knots=nullptr)
Definition fpPolar.hpp:234
std::vector< double > z_vector() const
Deep copy of component 'z' as a std::vector.
Definition fpPolar.hpp:405
int32_t core_comm_size() const override
Definition fpPolar.hpp:281
fpPolar(fitpack_polar_c &c_wrapper, ViewTag)
Non-owning view ctor: bit-copy the C handle, mark is_pointer=true. Used by parent classes' polymorphi...
Definition fpPolar.hpp:130
std::vector< double > w_vector() const
Deep copy of component 'w' as a std::vector.
Definition fpPolar.hpp:540
std::vector< double > t_vector() const
Deep copy of component 't' as a std::vector.
Definition fpPolar.hpp:634
std::vector< double > x_vector() const
Deep copy of component 'x' as a std::vector.
Definition fpPolar.hpp:315
fpPolar(const fpPolar &other)
Copy constructor - deep copy.
Definition fpPolar.hpp:78
fpPolar(fpPolar &&other) noexcept
Move constructor - transfer ownership.
Definition fpPolar.hpp:97
fpPolar(fitpack_polar_c &c_wrapper, bool move=false)
Construct from existing C wrapper (takes ownership if move=true)
Definition fpPolar.hpp:116
const int32_t & bc_boundary() const
Definition fpPolar.hpp:714
fpPolar(NoAlloc tag)
Definition fpPolar.hpp:726
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 fpPolar.hpp:164
fxArray< double > x() const
Zero-copy fxArray view of component 'x'.
Definition fpPolar.hpp:338
std::vector< double > v_vector() const
Deep copy of component 'v' as a std::vector.
Definition fpPolar.hpp:495
bool is_pointer() const override
Check if this is a non-owning pointer.
Definition fpPolar.hpp:149
std::vector< double > wrk2_vector() const
Deep copy of component 'wrk2' as a std::vector.
Definition fpPolar.hpp:585
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