24#ifndef FPGRIDPOLAR_HPP_INCLUDED
25#define FPGRIDPOLAR_HPP_INCLUDED
27#include "fitpack_config.h"
30#include "fxArrays.hpp"
33#include "fitpack_grid_polar_c.h"
44static_assert(
sizeof(fitpack_grid_polar_c) ==
sizeof(fitpack_fitter_c),
45 "C descriptor layout mismatch: fitpack_grid_polar_c vs fitpack_fitter_c");
106 if (
this != &other) {
165 return "fpGridPolar";
198 return static_cast<fpFitter&
>(*this);
201 return static_cast<const fpFitter&
>(*this);
211 virtual void new_points(std::vector<double>&
u, std::vector<double>&
v,
double r, int32_t z_n1, int32_t z_n2, std::vector<double>&
z,
double*
z0 =
nullptr) {
212 int32_t n =
static_cast<int32_t
>(
u.size());
220 virtual int32_t
new_fit(std::vector<double>&
u, std::vector<double>&
v,
double r, int32_t z_n1, int32_t z_n2, std::vector<double>&
z,
double*
z0 =
nullptr,
double*
smoothing =
nullptr) {
221 int32_t n =
static_cast<int32_t
>(
u.size());
226 virtual void set_origin_BC(
double*
z0 =
nullptr,
bool* exact =
nullptr,
bool* differentiable =
nullptr) {
230 virtual int32_t
fit(
double*
smoothing =
nullptr,
bool* keep_knots =
nullptr) {
242 virtual double eval(
double u,
double v, int32_t* ierr =
nullptr) {
249 virtual std::vector<double>
eval(std::vector<double>&
u, std::vector<double>&
v, int32_t* ierr =
nullptr) {
250 int32_t n =
static_cast<int32_t
>(
u.size());
251 std::vector<double> result(n * n);
252 int32_t n_result = 0;
253 fitpack_grid_polar_c_gridded_eval_many(
as<fitpack_grid_polar_c>(), n,
u.data(),
v.data(), ierr, result.data(), &n_result, n * n);
254 result.resize(n_result);
266 void comm_pack(std::vector<double>& buffer)
const override {
267 int32_t n =
static_cast<int32_t
>(buffer.size());
276 int32_t n =
static_cast<int32_t
>(buffer.size());
281 virtual void write(
const char* filename) {
285 double mse()
const override {
297 int32_t n =
static_cast<int32_t
>(buffer.size());
306 int32_t n =
static_cast<int32_t
>(buffer.size());
324 double* raw =
nullptr;
325 int64_t extents[1] = {0};
327 const int64_t total = extents[0];
328 if (raw ==
nullptr || total <= 0)
return {};
329 const double* first =
reinterpret_cast<const double*
>(raw);
330 return std::vector<double>(first, first + total);
346 fxArray<double>
u()
const {
347 double* raw =
nullptr;
348 int64_t extents[1] = {0};
351 for (
int k = 0; k < 1; ++k) {
353 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
355 array_c descr = array_c_null;
356 array_c_from_ptr(&descr,
"u",
static_cast<void*
>(raw),
357 getCFITypeFlag<double>(),
358 static_cast<FX_SIZE
>(
sizeof(
double)),
359 static_cast<FX_RANK
>(1), bounds);
360 return fxArray<double>(descr);
369 double* raw =
nullptr;
370 int64_t extents[1] = {0};
372 const int64_t total = extents[0];
373 if (raw ==
nullptr || total <= 0)
return {};
374 const double* first =
reinterpret_cast<const double*
>(raw);
375 return std::vector<double>(first, first + total);
391 fxArray<double>
v()
const {
392 double* raw =
nullptr;
393 int64_t extents[1] = {0};
396 for (
int k = 0; k < 1; ++k) {
398 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
400 array_c descr = array_c_null;
401 array_c_from_ptr(&descr,
"v",
static_cast<void*
>(raw),
402 getCFITypeFlag<double>(),
403 static_cast<FX_SIZE
>(
sizeof(
double)),
404 static_cast<FX_RANK
>(1), bounds);
405 return fxArray<double>(descr);
418 double* raw =
nullptr;
419 int64_t extents[2] = {0, 0};
421 const int64_t total = extents[0] * extents[1];
422 if (raw ==
nullptr || total <= 0)
return {};
423 const double* first =
reinterpret_cast<const double*
>(raw);
424 return std::vector<double>(first, first + total);
432 double* raw =
nullptr;
433 int64_t extents[2] = {0, 0};
435 return { extents[0], extents[1] };
451 fxArray<double>
z()
const {
452 double* raw =
nullptr;
453 int64_t extents[2] = {0, 0};
456 for (
int k = 0; k < 2; ++k) {
458 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
460 array_c descr = array_c_null;
461 array_c_from_ptr(&descr,
"z",
static_cast<void*
>(raw),
462 getCFITypeFlag<double>(),
463 static_cast<FX_SIZE
>(
sizeof(
double)),
464 static_cast<FX_RANK
>(2), bounds);
465 return fxArray<double>(descr);
478 double* raw =
nullptr;
479 int64_t extents[2] = {0, 0};
481 const int64_t total = extents[0] * extents[1];
482 if (raw ==
nullptr || total <= 0)
return {};
483 const double* first =
reinterpret_cast<const double*
>(raw);
484 return std::vector<double>(first, first + total);
492 double* raw =
nullptr;
493 int64_t extents[2] = {0, 0};
495 return { extents[0], extents[1] };
511 fxArray<double>
t()
const {
512 double* raw =
nullptr;
513 int64_t extents[2] = {0, 0};
516 for (
int k = 0; k < 2; ++k) {
518 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
520 array_c descr = array_c_null;
521 array_c_from_ptr(&descr,
"t",
static_cast<void*
>(raw),
522 getCFITypeFlag<double>(),
523 static_cast<FX_SIZE
>(
sizeof(
double)),
524 static_cast<FX_RANK
>(2), bounds);
525 return fxArray<double>(descr);
536 const double&
r()
const {
543 const double&
z0()
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
fpGridPolar(fitpack_grid_polar_c &c_wrapper, ViewTag)
Non-owning view ctor: bit-copy the C handle, mark is_pointer=true. Used by parent classes' polymorphi...
Definition fpGridPolar.hpp:130
fxArray< double > z() const
Zero-copy fxArray view of component 'z'.
Definition fpGridPolar.hpp:451
fpGridPolar & operator=(const fpGridPolar &other)
Copy assignment - deep copy.
Definition fpGridPolar.hpp:86
double & r()
Definition fpGridPolar.hpp:533
int32_t & bc_continuity_origin()
Definition fpGridPolar.hpp:575
int32_t & bc_boundary()
Definition fpGridPolar.hpp:582
void set_z0_present(bool value)
Definition fpGridPolar.hpp:550
std::vector< double > v_vector() const
Deep copy of component 'v' as a std::vector.
Definition fpGridPolar.hpp:368
void comm_expand(std::vector< double > &buffer) override
comm_expand
Definition fpGridPolar.hpp:275
fpFitter & as_parent()
Upcast to parent type (reference, no copy)
Definition fpGridPolar.hpp:197
double mse() const override
Definition fpGridPolar.hpp:285
virtual double eval(double u, double v, int32_t *ierr=nullptr)
Definition fpGridPolar.hpp:242
const int32_t & nmax() const
Definition fpGridPolar.hpp:571
const int32_t & bc_boundary() const
Definition fpGridPolar.hpp:585
fxArray< double > t() const
Zero-copy fxArray view of component 't'.
Definition fpGridPolar.hpp:511
void set_z0_zero_gradient(bool value)
Definition fpGridPolar.hpp:564
virtual int32_t least_squares(double *smoothing=nullptr, bool *reset_knots=nullptr)
Definition fpGridPolar.hpp:234
virtual int32_t interpolate(bool *reset_knots=nullptr)
Definition fpGridPolar.hpp:238
virtual int32_t new_fit(std::vector< double > &u, std::vector< double > &v, double r, int32_t z_n1, int32_t z_n2, std::vector< double > &z, double *z0=nullptr, double *smoothing=nullptr)
new_fit
Definition fpGridPolar.hpp:220
std::array< int64_t, 2 > z_shape() const
Extents of component 'z', leading dimension first.
Definition fpGridPolar.hpp:431
virtual int32_t fit(double *smoothing=nullptr, bool *keep_knots=nullptr)
Definition fpGridPolar.hpp:230
static fpGridPolar make_view()
Construct an empty (non-owning) wrapper, for use as a view target.
Definition fpGridPolar.hpp:190
double & z0()
Definition fpGridPolar.hpp:540
fpGridPolar()
Default constructor - allocates new fitpack_grid_polar.
Definition fpGridPolar.hpp:64
fpGridPolar(fpGridPolar &&other) noexcept
Move constructor - transfer ownership.
Definition fpGridPolar.hpp:97
int32_t & nmax()
Definition fpGridPolar.hpp:568
bool is_allocated() const override
Check if object is allocated.
Definition fpGridPolar.hpp:142
virtual void write(const char *filename)
Definition fpGridPolar.hpp:281
void destroy_base() override
Definition fpGridPolar.hpp:311
virtual std::vector< double > eval(std::vector< double > &u, std::vector< double > &v, int32_t *ierr=nullptr)
eval
Definition fpGridPolar.hpp:249
fxArray< double > u() const
Zero-copy fxArray view of component 'u'.
Definition fpGridPolar.hpp:346
void core_comm_pack(std::vector< double > &buffer) const override
core_comm_pack
Definition fpGridPolar.hpp:296
const fpFitter & as_parent() const
Definition fpGridPolar.hpp:200
fpGridPolar(NoAlloc tag)
Definition fpGridPolar.hpp:590
virtual void set_origin_BC(double *z0=nullptr, bool *exact=nullptr, bool *differentiable=nullptr)
Definition fpGridPolar.hpp:226
const fitpack_grid_polar_c & c_handle() const
Get underlying C wrapper (const, for interop)
Definition fpGridPolar.hpp:178
const char * c_type_name() const override
Return the C wrapper struct name for this class (e.g. "fitpack_grid_polar_c").
Definition fpGridPolar.hpp:156
std::array< int64_t, 2 > t_shape() const
Extents of component 't', leading dimension first.
Definition fpGridPolar.hpp:491
bool is_pointer() const override
Check if this is a non-owning pointer.
Definition fpGridPolar.hpp:149
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 fpGridPolar.hpp:164
std::vector< double > t_vector() const
Deep copy of component 't' as a std::vector.
Definition fpGridPolar.hpp:477
fitpack_grid_polar_c & c_handle()
Get underlying C wrapper (for interop)
Definition fpGridPolar.hpp:171
fpGridPolar(fitpack_grid_polar_c &c_wrapper, bool move=false)
Construct from existing C wrapper (takes ownership if move=true)
Definition fpGridPolar.hpp:116
fpGridPolar & operator=(fpGridPolar &&other) noexcept
Move assignment - transfer ownership.
Definition fpGridPolar.hpp:105
void set_z0_exact(bool value)
Definition fpGridPolar.hpp:557
bool z0_exact() const
Definition fpGridPolar.hpp:554
void comm_pack(std::vector< double > &buffer) const override
comm_pack
Definition fpGridPolar.hpp:266
std::vector< double > z_vector() const
Deep copy of component 'z' as a std::vector.
Definition fpGridPolar.hpp:417
std::vector< double > u_vector() const
Deep copy of component 'u' as a std::vector.
Definition fpGridPolar.hpp:323
int32_t comm_size() const override
Definition fpGridPolar.hpp:259
void core_comm_expand(std::vector< double > &buffer) override
core_comm_expand
Definition fpGridPolar.hpp:305
const double & r() const
Definition fpGridPolar.hpp:536
const double & z0() const
Definition fpGridPolar.hpp:543
const int32_t & bc_continuity_origin() const
Definition fpGridPolar.hpp:578
bool z0_present() const
Definition fpGridPolar.hpp:547
int32_t core_comm_size() const override
Definition fpGridPolar.hpp:289
virtual void new_points(std::vector< double > &u, std::vector< double > &v, double r, int32_t z_n1, int32_t z_n2, std::vector< double > &z, double *z0=nullptr)
new_points
Definition fpGridPolar.hpp:211
bool z0_zero_gradient() const
Definition fpGridPolar.hpp:561
fxArray< double > v() const
Zero-copy fxArray view of component 'v'.
Definition fpGridPolar.hpp:391
~fpGridPolar() override
Destructor - deallocates if owned.
Definition fpGridPolar.hpp:71
fpGridPolar(const fpGridPolar &other)
Copy constructor - deep copy.
Definition fpGridPolar.hpp:78
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