24#ifndef FPPARAMETRICSURFACE_HPP_INCLUDED
25#define FPPARAMETRICSURFACE_HPP_INCLUDED
27#include "fitpack_config.h"
30#include "fxArrays.hpp"
33#include "fitpack_parametric_surface_c.h"
44static_assert(
sizeof(fitpack_parametric_surface_c) ==
sizeof(fitpack_fitter_c),
45 "C descriptor layout mismatch: fitpack_parametric_surface_c vs fitpack_fitter_c");
106 if (
this != &other) {
165 return "fpParametricSurface";
178 const fitpack_parametric_surface_c&
c_handle()
const {
198 return static_cast<fpFitter&
>(*this);
201 return static_cast<const fpFitter&
>(*this);
211 virtual int32_t
fit(int32_t n,
double*
smoothing =
nullptr,
bool* periodic =
nullptr,
bool* keep_knots =
nullptr) {
223 virtual int32_t
least_squares(int32_t n,
double* u_knots =
nullptr,
double* v_knots =
nullptr,
double*
smoothing =
nullptr,
bool* reset_knots =
nullptr) {
231 virtual std::vector<double>
eval(
double u,
double v, int32_t n_result, int32_t* ierr =
nullptr) {
232 std::vector<double> result(n_result);
241 virtual std::vector<double>
eval(std::vector<double>&
u, std::vector<double>&
v, int32_t n_result, int32_t* ierr =
nullptr) {
242 int32_t n =
static_cast<int32_t
>(
u.size());
243 std::vector<double> result(n_result);
256 void comm_pack(std::vector<double>& buffer)
const override {
257 int32_t n =
static_cast<int32_t
>(buffer.size());
266 int32_t n =
static_cast<int32_t
>(buffer.size());
271 double mse()
const override {
283 int32_t n =
static_cast<int32_t
>(buffer.size());
292 int32_t n =
static_cast<int32_t
>(buffer.size());
310 double* raw =
nullptr;
311 int64_t extents[1] = {0};
313 const int64_t total = extents[0];
314 if (raw ==
nullptr || total <= 0)
return {};
315 const double* first =
reinterpret_cast<const double*
>(raw);
316 return std::vector<double>(first, first + total);
332 fxArray<double>
u()
const {
333 double* raw =
nullptr;
334 int64_t extents[1] = {0};
337 for (
int k = 0; k < 1; ++k) {
339 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
341 array_c descr = array_c_null;
342 array_c_from_ptr(&descr,
"u",
static_cast<void*
>(raw),
343 getCFITypeFlag<double>(),
344 static_cast<FX_SIZE
>(
sizeof(
double)),
345 static_cast<FX_RANK
>(1), bounds);
346 return fxArray<double>(descr);
355 double* raw =
nullptr;
356 int64_t extents[1] = {0};
358 const int64_t total = extents[0];
359 if (raw ==
nullptr || total <= 0)
return {};
360 const double* first =
reinterpret_cast<const double*
>(raw);
361 return std::vector<double>(first, first + total);
377 fxArray<double>
v()
const {
378 double* raw =
nullptr;
379 int64_t extents[1] = {0};
382 for (
int k = 0; k < 1; ++k) {
384 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
386 array_c descr = array_c_null;
387 array_c_from_ptr(&descr,
"v",
static_cast<void*
>(raw),
388 getCFITypeFlag<double>(),
389 static_cast<FX_SIZE
>(
sizeof(
double)),
390 static_cast<FX_RANK
>(1), bounds);
391 return fxArray<double>(descr);
404 double* raw =
nullptr;
405 int64_t extents[3] = {0, 0, 0};
407 const int64_t total = extents[0] * extents[1] * extents[2];
408 if (raw ==
nullptr || total <= 0)
return {};
409 const double* first =
reinterpret_cast<const double*
>(raw);
410 return std::vector<double>(first, first + total);
418 double* raw =
nullptr;
419 int64_t extents[3] = {0, 0, 0};
421 return { extents[0], extents[1], extents[2] };
437 fxArray<double>
z()
const {
438 double* raw =
nullptr;
439 int64_t extents[3] = {0, 0, 0};
442 for (
int k = 0; k < 3; ++k) {
444 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
446 array_c descr = array_c_null;
447 array_c_from_ptr(&descr,
"z",
static_cast<void*
>(raw),
448 getCFITypeFlag<double>(),
449 static_cast<FX_SIZE
>(
sizeof(
double)),
450 static_cast<FX_RANK
>(3), bounds);
451 return fxArray<double>(descr);
464 double* raw =
nullptr;
465 int64_t extents[2] = {0, 0};
467 const int64_t total = extents[0] * extents[1];
468 if (raw ==
nullptr || total <= 0)
return {};
469 const double* first =
reinterpret_cast<const double*
>(raw);
470 return std::vector<double>(first, first + total);
478 double* raw =
nullptr;
479 int64_t extents[2] = {0, 0};
481 return { extents[0], extents[1] };
497 fxArray<double>
t()
const {
498 double* raw =
nullptr;
499 int64_t extents[2] = {0, 0};
502 for (
int k = 0; k < 2; ++k) {
504 bounds[2 * k + 1] =
static_cast<FX_SIZE
>(extents[k]);
506 array_c descr = array_c_null;
507 array_c_from_ptr(&descr,
"t",
static_cast<void*
>(raw),
508 getCFITypeFlag<double>(),
509 static_cast<FX_SIZE
>(
sizeof(
double)),
510 static_cast<FX_RANK
>(2), bounds);
511 return fxArray<double>(descr);
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
int32_t & idim()
Definition fpParametricSurface.hpp:519
bool is_allocated() const override
Check if object is allocated.
Definition fpParametricSurface.hpp:142
fxArray< double > v() const
Zero-copy fxArray view of component 'v'.
Definition fpParametricSurface.hpp:377
std::array< int64_t, 3 > z_shape() const
Extents of component 'z', leading dimension first.
Definition fpParametricSurface.hpp:417
std::array< int64_t, 2 > t_shape() const
Extents of component 't', leading dimension first.
Definition fpParametricSurface.hpp:477
std::vector< double > u_vector() const
Deep copy of component 'u' as a std::vector.
Definition fpParametricSurface.hpp:309
const int32_t & nmax() const
Definition fpParametricSurface.hpp:529
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 fpParametricSurface.hpp:164
virtual int32_t interpolate(bool *reset_knots=nullptr)
Definition fpParametricSurface.hpp:216
std::vector< double > z_vector() const
Deep copy of component 'z' as a std::vector.
Definition fpParametricSurface.hpp:403
std::vector< double > t_vector() const
Deep copy of component 't' as a std::vector.
Definition fpParametricSurface.hpp:463
void core_comm_pack(std::vector< double > &buffer) const override
core_comm_pack
Definition fpParametricSurface.hpp:282
fitpack_parametric_surface_c & c_handle()
Get underlying C wrapper (for interop)
Definition fpParametricSurface.hpp:171
fxArray< double > z() const
Zero-copy fxArray view of component 'z'.
Definition fpParametricSurface.hpp:437
void comm_pack(std::vector< double > &buffer) const override
comm_pack
Definition fpParametricSurface.hpp:256
virtual int32_t fit(int32_t n, double *smoothing=nullptr, bool *periodic=nullptr, bool *keep_knots=nullptr)
fit
Definition fpParametricSurface.hpp:211
const char * c_type_name() const override
Return the C wrapper struct name for this class (e.g. "fitpack_parametric_surface_c").
Definition fpParametricSurface.hpp:156
fpParametricSurface(fitpack_parametric_surface_c &c_wrapper, ViewTag)
Non-owning view ctor: bit-copy the C handle, mark is_pointer=true. Used by parent classes' polymorphi...
Definition fpParametricSurface.hpp:130
fpParametricSurface & operator=(fpParametricSurface &&other) noexcept
Move assignment - transfer ownership.
Definition fpParametricSurface.hpp:105
double mse() const override
Definition fpParametricSurface.hpp:271
int32_t core_comm_size() const override
Definition fpParametricSurface.hpp:275
bool is_pointer() const override
Check if this is a non-owning pointer.
Definition fpParametricSurface.hpp:149
virtual std::vector< double > eval(std::vector< double > &u, std::vector< double > &v, int32_t n_result, int32_t *ierr=nullptr)
eval
Definition fpParametricSurface.hpp:241
virtual std::vector< double > eval(double u, double v, int32_t n_result, int32_t *ierr=nullptr)
eval
Definition fpParametricSurface.hpp:231
void destroy_base() override
Definition fpParametricSurface.hpp:297
int32_t & nmax()
Definition fpParametricSurface.hpp:526
const fitpack_parametric_surface_c & c_handle() const
Get underlying C wrapper (const, for interop)
Definition fpParametricSurface.hpp:178
void comm_expand(std::vector< double > &buffer) override
comm_expand
Definition fpParametricSurface.hpp:265
virtual int32_t least_squares(int32_t n, double *u_knots=nullptr, double *v_knots=nullptr, double *smoothing=nullptr, bool *reset_knots=nullptr)
least_squares
Definition fpParametricSurface.hpp:223
const int32_t & idim() const
Definition fpParametricSurface.hpp:522
fpParametricSurface & operator=(const fpParametricSurface &other)
Copy assignment - deep copy.
Definition fpParametricSurface.hpp:86
fpParametricSurface(fpParametricSurface &&other) noexcept
Move constructor - transfer ownership.
Definition fpParametricSurface.hpp:97
const fpFitter & as_parent() const
Definition fpParametricSurface.hpp:200
fxArray< double > u() const
Zero-copy fxArray view of component 'u'.
Definition fpParametricSurface.hpp:332
void core_comm_expand(std::vector< double > &buffer) override
core_comm_expand
Definition fpParametricSurface.hpp:291
fpFitter & as_parent()
Upcast to parent type (reference, no copy)
Definition fpParametricSurface.hpp:197
int32_t comm_size() const override
Definition fpParametricSurface.hpp:249
fxArray< double > t() const
Zero-copy fxArray view of component 't'.
Definition fpParametricSurface.hpp:497
std::vector< double > v_vector() const
Deep copy of component 'v' as a std::vector.
Definition fpParametricSurface.hpp:354
fpParametricSurface(NoAlloc tag)
Definition fpParametricSurface.hpp:534
fpParametricSurface(fitpack_parametric_surface_c &c_wrapper, bool move=false)
Construct from existing C wrapper (takes ownership if move=true)
Definition fpParametricSurface.hpp:116
fpParametricSurface()
Default constructor - allocates new fitpack_parametric_surface.
Definition fpParametricSurface.hpp:64
fpParametricSurface(const fpParametricSurface &other)
Copy constructor - deep copy.
Definition fpParametricSurface.hpp:78
static fpParametricSurface make_view()
Construct an empty (non-owning) wrapper, for use as a view target.
Definition fpParametricSurface.hpp:190
~fpParametricSurface() override
Destructor - deallocates if owned.
Definition fpParametricSurface.hpp:71
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