fitpack
Modern Fortran library for curve and surface fitting with splines
Loading...
Searching...
No Matches
fpGridSpline.hpp
Go to the documentation of this file.
1/***************************************************************************************************
2! ____________________ ___ ________ __
3! / ____/ _/_ __/ __ \/ | / ____/ //_/
4! / /_ / / / / / /_/ / /| |/ / / ,<
5! / __/ _/ / / / / ____/ ___ / /___/ /| |
6! /_/ /___/ /_/ /_/ /_/ |_\____/_/ |_|
7!
8! A Curve Fitting Package
9!
10! fpGridSpline.hpp (class fpGridSpline)
11!> @brief Standalone C++ wrapper for fitpack_gridded_spline (no fortran-arrays dependency)
12!
13! @author Federico Perini
14! @date 2026-08-27
15!
16! References :
17! - C. De Boor, "On calculating with b-splines", J Approx Theory 6 (1972) 50-62
18! - M. G. Cox, "The numerical evaluation of b-splines", J Inst Maths Applics 10 (1972) 134-149
19! - P. Dierckx, "Curve and surface fitting with splines", Monographs on numerical analysis,
20! Oxford university press, 1993.
21!
22! **************************************************************************************************/
23
24#ifndef FPGRIDSPLINE_HPP_INCLUDED
25#define FPGRIDSPLINE_HPP_INCLUDED
26
27#include "fitpack_config.h"
28
29#if HAVE_FXARRAY
30#include "fxArrays.hpp"
31#endif
32
33#include "fitpack_gridded_spline_c.h"
34#include "fpFitter.hpp"
35#include <string>
36#include <vector>
37#include <cstdint>
38#include <memory>
39#include <stdexcept>
40#include <variant>
41#include <optional>
42#include <array>
43#include "fpPoint.hpp"
44
45static_assert(sizeof(fitpack_gridded_spline_c) == sizeof(fitpack_fitter_c),
46 "C descriptor layout mismatch: fitpack_gridded_spline_c vs fitpack_fitter_c");
47
56class fpGridSpline : public fpFitter {
57public:
58 // ===========================================================================================
59 // Constructors and Destructor
60 // ===========================================================================================
61
66 fitpack_gridded_spline_c_allocate(as<fitpack_gridded_spline_c>(), nullptr);
67 }
68
72 ~fpGridSpline() override {
73 fitpack_gridded_spline_c_destroy(as<fitpack_gridded_spline_c>(), nullptr);
74 }
75
80 *as<fitpack_gridded_spline_c>() = fitpack_gridded_spline_c_null;
81 fitpack_gridded_spline_c_copy(as<fitpack_gridded_spline_c>(), other.as<fitpack_gridded_spline_c>(), false, nullptr);
82 }
83
88 if (this != &other) {
89 fitpack_gridded_spline_c_destroy(as<fitpack_gridded_spline_c>(), nullptr);
90 fitpack_gridded_spline_c_copy(as<fitpack_gridded_spline_c>(), other.as<fitpack_gridded_spline_c>(), false, nullptr);
91 }
92 return *this;
93 }
94
98 fpGridSpline(fpGridSpline&& other) noexcept : fpFitter(NoAlloc{}) {
99 *as<fitpack_gridded_spline_c>() = fitpack_gridded_spline_c_null;
100 fitpack_gridded_spline_c_move_alloc(as<fitpack_gridded_spline_c>(), other.as<fitpack_gridded_spline_c>(), nullptr);
101 }
102
107 if (this != &other) {
108 fitpack_gridded_spline_c_destroy(as<fitpack_gridded_spline_c>(), nullptr);
109 fitpack_gridded_spline_c_move_alloc(as<fitpack_gridded_spline_c>(), other.as<fitpack_gridded_spline_c>(), nullptr);
110 }
111 return *this;
112 }
113
117 explicit fpGridSpline(fitpack_gridded_spline_c& c_wrapper, bool move = false) : fpFitter(NoAlloc{}) {
118 if (move) {
119 fitpack_gridded_spline_c_move_alloc(as<fitpack_gridded_spline_c>(), &c_wrapper, nullptr);
120 } else {
121 *as<fitpack_gridded_spline_c>() = fitpack_gridded_spline_c_null;
122 fitpack_gridded_spline_c_copy(as<fitpack_gridded_spline_c>(), &c_wrapper, false, nullptr);
123 }
124 }
125
131 explicit fpGridSpline(fitpack_gridded_spline_c& c_wrapper, ViewTag) : fpFitter(NoAlloc{}) {
132 *as<fitpack_gridded_spline_c>() = c_wrapper;
133 as<fitpack_gridded_spline_c>()->is_pointer = true;
134 }
135
136 // ===========================================================================================
137 // Utility Methods
138 // ===========================================================================================
139
143 bool is_allocated() const override {
144 return as<fitpack_gridded_spline_c>()->cptr != nullptr;
145 }
146
150 bool is_pointer() const override {
151 return as<fitpack_gridded_spline_c>()->is_pointer;
152 }
153
157 const char* c_type_name() const override {
158 return fitpack_gridded_spline_c_c_type_name(*as<fitpack_gridded_spline_c>());
159 }
160
165 const char* cpp_type_name() const override {
166 return "fpGridSpline";
167 }
168
172 fitpack_gridded_spline_c& c_handle() {
174 }
175
179 const fitpack_gridded_spline_c& c_handle() const {
181 }
182
192 return fpGridSpline(NoAlloc{});
193 }
194
199 return static_cast<fpFitter&>(*this);
200 }
201 const fpFitter& as_parent() const {
202 return static_cast<const fpFitter&>(*this);
203 }
204
205 // ===========================================================================================
206 // Method Wrappers (standalone — no fxArray dependency)
207 // ===========================================================================================
208
212 virtual void new_points(int32_t n, int32_t xg_n1, int32_t xg_n2, std::vector<double>& xg, std::vector<double>& z, int32_t* m = nullptr, bool* row_major = nullptr, int32_t* order = nullptr) {
213 fitpack_gridded_spline_c_new_points(as<fitpack_gridded_spline_c>(), xg_n1, xg_n2, xg.data(), static_cast<int32_t>(z.size()), z.data(), n, m, row_major, order);
214 }
215
216
220 virtual int32_t new_fit(int32_t n, int32_t xg_n1, int32_t xg_n2, std::vector<double>& xg, std::vector<double>& z, int32_t* m = nullptr, bool* row_major = nullptr, int32_t* order = nullptr, double* smoothing = nullptr) {
221 return fitpack_gridded_spline_c_new_fit(as<fitpack_gridded_spline_c>(), xg_n1, xg_n2, xg.data(), static_cast<int32_t>(z.size()), z.data(), n, m, row_major, order, smoothing);
222 }
223
224
225 virtual int32_t fit(double* smoothing = nullptr, int32_t* order = nullptr) {
226 return fitpack_gridded_spline_c_fit(as<fitpack_gridded_spline_c>(), smoothing, order);
227 }
228
229 virtual int32_t least_squares(double* smoothing = nullptr, bool* reset_knots = nullptr) {
230 return fitpack_gridded_spline_c_least_squares(as<fitpack_gridded_spline_c>(), smoothing, reset_knots);
231 }
232
233 virtual int32_t interpolate() {
234 return fitpack_gridded_spline_c_interpolate(as<fitpack_gridded_spline_c>());
235 }
236
240 virtual std::vector<double> eval_ongrid(int32_t xg_n1, int32_t xg_n2, std::vector<double>& xg, std::vector<int32_t>& m, int32_t n_result, int32_t* ierr = nullptr) {
241 int32_t n = static_cast<int32_t>(m.size());
242 std::vector<double> result(n_result);
243 fitpack_gridded_spline_c_eval_ongrid(as<fitpack_gridded_spline_c>(), xg_n1, xg_n2, xg.data(), n, m.data(), ierr, result.data(), n_result);
244 return result;
245 }
246
247
251 virtual double eval(std::vector<double>& x, int32_t* ierr = nullptr) const {
252 int32_t n = static_cast<int32_t>(x.size());
253 return fitpack_gridded_spline_c_grid_eval_one(as<fitpack_gridded_spline_c>(), n, x.data(), ierr);
254 }
255
256
260 virtual std::vector<double> eval(int32_t xp_n1, int32_t xp_n2, std::vector<double>& xp, int32_t* ierr = nullptr) {
261 std::vector<double> result(xp_n2);
262 int32_t n_result = 0;
263 fitpack_gridded_spline_c_grid_eval_many(as<fitpack_gridded_spline_c>(), xp_n1, xp_n2, xp.data(), ierr, result.data(), &n_result, xp_n2);
264 result.resize(n_result);
265 return result;
266 }
267
268
272 virtual std::vector<double> dfdx_ongrid(int32_t xg_n1, int32_t xg_n2, std::vector<double>& xg, std::vector<int32_t>& m, std::vector<int32_t>& nu, int32_t n_result, int32_t* ierr = nullptr) {
273 int32_t n = static_cast<int32_t>(m.size());
274 std::vector<double> result(n_result);
275 fitpack_gridded_spline_c_dfdx_ongrid(as<fitpack_gridded_spline_c>(), xg_n1, xg_n2, xg.data(), n, m.data(), nu.data(), ierr, result.data(), n_result);
276 return result;
277 }
278
279
283 virtual double dfdx(std::vector<double>& x, std::vector<int32_t>& nu, int32_t* ierr = nullptr) {
284 int32_t n = static_cast<int32_t>(x.size());
285 return fitpack_gridded_spline_c_grid_derivatives_one(as<fitpack_gridded_spline_c>(), n, x.data(), nu.data(), ierr);
286 }
287
288
292 virtual std::vector<double> dfdx(int32_t xp_n1, int32_t xp_n2, std::vector<double>& xp, std::vector<int32_t>& nu, int32_t* ierr = nullptr) {
293 int32_t n = static_cast<int32_t>(nu.size());
294 std::vector<double> result(xp_n2);
295 int32_t n_result = 0;
296 fitpack_gridded_spline_c_grid_derivatives_many(as<fitpack_gridded_spline_c>(), xp_n1, xp_n2, xp.data(), n, nu.data(), ierr, result.data(), &n_result, xp_n2);
297 result.resize(n_result);
298 return result;
299 }
300
301
305 virtual double integral(std::vector<double>& lower, std::vector<double>& upper) const {
306 int32_t n = static_cast<int32_t>(lower.size());
307 return fitpack_gridded_spline_c_integral(as<fitpack_gridded_spline_c>(), n, lower.data(), upper.data());
308 }
309
310
311 virtual fpGridSpline cross_section(int32_t ax, double u, int32_t* ierr = nullptr) {
312 fitpack_gridded_spline_c result_c;
313 fitpack_gridded_spline_c_cross_section(as<fitpack_gridded_spline_c>(), ax, u, ierr, &result_c);
314 return fpGridSpline(result_c, true);
315 }
316
320 virtual fpGridSpline derivative_spline(std::vector<int32_t>& nu, int32_t* ierr = nullptr) {
321 int32_t n = static_cast<int32_t>(nu.size());
322 fitpack_gridded_spline_c result_c;
323 fitpack_gridded_spline_c_derivative_spline(as<fitpack_gridded_spline_c>(), n, nu.data(), ierr, &result_c);
324 return fpGridSpline(result_c, true);
325 }
326
327
328 int32_t comm_size() const override {
329 return fitpack_gridded_spline_c_comm_size(as<fitpack_gridded_spline_c>());
330 }
331
335 void comm_pack(std::vector<double>& buffer) const override {
336 int32_t n = static_cast<int32_t>(buffer.size());
337 fitpack_gridded_spline_c_comm_pack(as<fitpack_gridded_spline_c>(), n, buffer.data());
338 }
339
340
344 void comm_expand(std::vector<double>& buffer) override {
345 int32_t n = static_cast<int32_t>(buffer.size());
346 fitpack_gridded_spline_c_comm_expand(as<fitpack_gridded_spline_c>(), n, buffer.data());
347 }
348
349
350 double mse() const override {
351 return fitpack_gridded_spline_c_mse(as<fitpack_gridded_spline_c>());
352 }
353
354 int32_t core_comm_size() const override {
355 return fitpack_gridded_spline_c_core_comm_size(as<fitpack_gridded_spline_c>());
356 }
357
361 void core_comm_pack(std::vector<double>& buffer) const override {
362 int32_t n = static_cast<int32_t>(buffer.size());
363 fitpack_gridded_spline_c_core_comm_pack(as<fitpack_gridded_spline_c>(), n, buffer.data());
364 }
365
366
370 void core_comm_expand(std::vector<double>& buffer) override {
371 int32_t n = static_cast<int32_t>(buffer.size());
372 fitpack_gridded_spline_c_core_comm_expand(as<fitpack_gridded_spline_c>(), n, buffer.data());
373 }
374
375
376 void destroy_base() override {
377 fitpack_gridded_spline_c_destroy_base(as<fitpack_gridded_spline_c>());
378 }
379
380 // ===========================================================================================
381 // Component Array Accessors
382 // ===========================================================================================
383
392 std::vector<double> t_vector() const {
393 double* raw = nullptr;
394 int64_t extents[2] = {0, 0};
395 fitpack_gridded_spline_c_getcomp_t(as<fitpack_gridded_spline_c>(), &raw, extents);
396 const int64_t total = extents[0] * extents[1];
397 if (raw == nullptr || total <= 0) return {};
398 const double* first = reinterpret_cast<const double*>(raw);
399 return std::vector<double>(first, first + total);
400 }
401
406 std::array<int64_t, 2> t_shape() const {
407 double* raw = nullptr;
408 int64_t extents[2] = {0, 0};
409 fitpack_gridded_spline_c_getcomp_t(as<fitpack_gridded_spline_c>(), &raw, extents);
410 return { extents[0], extents[1] };
411 }
412
413#if HAVE_FXARRAY
426 fxArray<double> t() const {
427 double* raw = nullptr;
428 int64_t extents[2] = {0, 0};
429 fitpack_gridded_spline_c_getcomp_t(as<fitpack_gridded_spline_c>(), &raw, extents);
430 FX_SIZE bounds[4]; // (lower, upper) per dimension, Fortran lbound 1
431 for (int k = 0; k < 2; ++k) {
432 bounds[2 * k] = 1;
433 bounds[2 * k + 1] = static_cast<FX_SIZE>(extents[k]);
434 }
435 array_c descr = array_c_null;
436 array_c_from_ptr(&descr, "t", static_cast<void*>(raw),
437 getCFITypeFlag<double>(),
438 static_cast<FX_SIZE>(sizeof(double)),
439 static_cast<FX_RANK>(2), bounds);
440 return fxArray<double>(descr);
441 }
442#endif // HAVE_FXARRAY
443
452 std::vector<double> xg_vector() const {
453 double* raw = nullptr;
454 int64_t extents[2] = {0, 0};
455 fitpack_gridded_spline_c_getcomp_xg(as<fitpack_gridded_spline_c>(), &raw, extents);
456 const int64_t total = extents[0] * extents[1];
457 if (raw == nullptr || total <= 0) return {};
458 const double* first = reinterpret_cast<const double*>(raw);
459 return std::vector<double>(first, first + total);
460 }
461
466 std::array<int64_t, 2> xg_shape() const {
467 double* raw = nullptr;
468 int64_t extents[2] = {0, 0};
469 fitpack_gridded_spline_c_getcomp_xg(as<fitpack_gridded_spline_c>(), &raw, extents);
470 return { extents[0], extents[1] };
471 }
472
473#if HAVE_FXARRAY
486 fxArray<double> xg() const {
487 double* raw = nullptr;
488 int64_t extents[2] = {0, 0};
489 fitpack_gridded_spline_c_getcomp_xg(as<fitpack_gridded_spline_c>(), &raw, extents);
490 FX_SIZE bounds[4]; // (lower, upper) per dimension, Fortran lbound 1
491 for (int k = 0; k < 2; ++k) {
492 bounds[2 * k] = 1;
493 bounds[2 * k + 1] = static_cast<FX_SIZE>(extents[k]);
494 }
495 array_c descr = array_c_null;
496 array_c_from_ptr(&descr, "xg", static_cast<void*>(raw),
497 getCFITypeFlag<double>(),
498 static_cast<FX_SIZE>(sizeof(double)),
499 static_cast<FX_RANK>(2), bounds);
500 return fxArray<double>(descr);
501 }
502#endif // HAVE_FXARRAY
503
508 std::vector<double> z_vector() const {
509 double* raw = nullptr;
510 int64_t extents[1] = {0};
511 fitpack_gridded_spline_c_getcomp_z(as<fitpack_gridded_spline_c>(), &raw, extents);
512 const int64_t total = extents[0];
513 if (raw == nullptr || total <= 0) return {};
514 const double* first = reinterpret_cast<const double*>(raw);
515 return std::vector<double>(first, first + total);
516 }
517
518#if HAVE_FXARRAY
531 fxArray<double> z() const {
532 double* raw = nullptr;
533 int64_t extents[1] = {0};
534 fitpack_gridded_spline_c_getcomp_z(as<fitpack_gridded_spline_c>(), &raw, extents);
535 FX_SIZE bounds[2]; // (lower, upper) per dimension, Fortran lbound 1
536 for (int k = 0; k < 1; ++k) {
537 bounds[2 * k] = 1;
538 bounds[2 * k + 1] = static_cast<FX_SIZE>(extents[k]);
539 }
540 array_c descr = array_c_null;
541 array_c_from_ptr(&descr, "z", static_cast<void*>(raw),
542 getCFITypeFlag<double>(),
543 static_cast<FX_SIZE>(sizeof(double)),
544 static_cast<FX_RANK>(1), bounds);
545 return fxArray<double>(descr);
546 }
547#endif // HAVE_FXARRAY
548
549 // ===========================================================================================
550 // Scalar Property Accessors
551 // ===========================================================================================
552
553 int32_t& dims() {
554 return *fitpack_gridded_spline_c_ref_dims(as<fitpack_gridded_spline_c>());
555 }
556 const int32_t& dims() const {
557 return *fitpack_gridded_spline_c_ref_dims(as<fitpack_gridded_spline_c>());
558 }
559
560 // ===========================================================================================
561 // fpPoint<dim> overloads — extra_methods/fpGridSplinePoints.hpp (hand-maintained)
562 //
563 // The N-D analog of the parametric-curve point overloads: a scattered evaluation site of an
564 // N-dimensional gridded spline is a point, and a std::vector<fpPoint<dim>> is bit-identical
565 // to the Fortran xp(dim,np) it feeds. `dim` is deduced from the argument; it is checked
566 // against the spline's own dims() and reports FITPACK_INPUT_ERROR on a mismatch.
567 // ===========================================================================================
568
570 template <FP_SIZE dim>
571 FP_REAL eval(const fpPoint<dim>& x, FP_FLAG* ierr = nullptr) const
572 {
573 if (dims() != dim) { if (ierr) *ierr = FITPACK_INPUT_ERROR; return FP_REAL(0); }
574 std::vector<FP_REAL> xw(x.begin(), x.end());
575 return eval(xw, ierr);
576 }
577
579 template <FP_SIZE dim>
580 std::vector<FP_REAL> eval(const std::vector<fpPoint<dim>>& xp, FP_FLAG* ierr = nullptr)
581 {
582 if (dims() != dim) { if (ierr) *ierr = FITPACK_INPUT_ERROR; return {}; }
583 std::vector<FP_REAL> xw = fpPointFlatten<dim>(xp);
584 return eval(dim, static_cast<FP_SIZE>(xp.size()), xw, ierr);
585 }
586
589 template <FP_SIZE dim>
590 FP_REAL dfdx(const fpPoint<dim>& x, const std::vector<FP_SIZE>& nu, FP_FLAG* ierr = nullptr)
591 {
592 if (dims() != dim) { if (ierr) *ierr = FITPACK_INPUT_ERROR; return FP_REAL(0); }
593 std::vector<FP_REAL> xw(x.begin(), x.end());
594 std::vector<FP_SIZE> nuw(nu);
595 return dfdx(xw, nuw, ierr);
596 }
597
599 template <FP_SIZE dim>
600 std::vector<FP_REAL> dfdx(const std::vector<fpPoint<dim>>& xp, const std::vector<FP_SIZE>& nu,
601 FP_FLAG* ierr = nullptr)
602 {
603 if (dims() != dim) { if (ierr) *ierr = FITPACK_INPUT_ERROR; return {}; }
604 std::vector<FP_REAL> xw = fpPointFlatten<dim>(xp);
605 std::vector<FP_SIZE> nuw(nu);
606 return dfdx(dim, static_cast<FP_SIZE>(xp.size()), xw, nuw, ierr);
607 }
608
610 template <FP_SIZE dim>
611 FP_REAL integral(const fpPoint<dim>& lower, const fpPoint<dim>& upper) const
612 {
613 if (dims() != dim) return FP_REAL(0);
614 std::vector<FP_REAL> lw(lower.begin(), lower.end()), uw(upper.begin(), upper.end());
615 return integral(lw, uw);
616 }
617
618protected:
619 explicit fpGridSpline(NoAlloc tag) : fpFitter(tag) {}
620
621};
622
623#endif /* FPGRIDSPLINE_HPP_INCLUDED */
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
fitpack_gridded_spline_c & c_handle()
Get underlying C wrapper (for interop)
Definition fpGridSpline.hpp:172
fpGridSpline(fpGridSpline &&other) noexcept
Move constructor - transfer ownership.
Definition fpGridSpline.hpp:98
virtual double integral(std::vector< double > &lower, std::vector< double > &upper) const
integral
Definition fpGridSpline.hpp:305
fpGridSpline(fitpack_gridded_spline_c &c_wrapper, ViewTag)
Non-owning view ctor: bit-copy the C handle, mark is_pointer=true. Used by parent classes' polymorphi...
Definition fpGridSpline.hpp:131
std::vector< double > xg_vector() const
Deep copy of component 'xg' as a std::vector.
Definition fpGridSpline.hpp:452
bool is_pointer() const override
Check if this is a non-owning pointer.
Definition fpGridSpline.hpp:150
const fitpack_gridded_spline_c & c_handle() const
Get underlying C wrapper (const, for interop)
Definition fpGridSpline.hpp:179
const fpFitter & as_parent() const
Definition fpGridSpline.hpp:201
int32_t & dims()
Definition fpGridSpline.hpp:553
virtual void new_points(int32_t n, int32_t xg_n1, int32_t xg_n2, std::vector< double > &xg, std::vector< double > &z, int32_t *m=nullptr, bool *row_major=nullptr, int32_t *order=nullptr)
new_points
Definition fpGridSpline.hpp:212
fxArray< double > t() const
Zero-copy fxArray view of component 't'.
Definition fpGridSpline.hpp:426
static fpGridSpline make_view()
Construct an empty (non-owning) wrapper, for use as a view target.
Definition fpGridSpline.hpp:191
std::array< int64_t, 2 > t_shape() const
Extents of component 't', leading dimension first.
Definition fpGridSpline.hpp:406
int32_t comm_size() const override
Definition fpGridSpline.hpp:328
FP_REAL dfdx(const fpPoint< dim > &x, const std::vector< FP_SIZE > &nu, FP_FLAG *ierr=nullptr)
Partial derivative of orders nu(1..dim) at one scattered point.
Definition fpGridSpline.hpp:590
virtual fpGridSpline derivative_spline(std::vector< int32_t > &nu, int32_t *ierr=nullptr)
derivative_spline
Definition fpGridSpline.hpp:320
virtual int32_t fit(double *smoothing=nullptr, int32_t *order=nullptr)
Definition fpGridSpline.hpp:225
fpGridSpline(fitpack_gridded_spline_c &c_wrapper, bool move=false)
Construct from existing C wrapper (takes ownership if move=true)
Definition fpGridSpline.hpp:117
virtual int32_t least_squares(double *smoothing=nullptr, bool *reset_knots=nullptr)
Definition fpGridSpline.hpp:229
int32_t core_comm_size() const override
Definition fpGridSpline.hpp:354
fpGridSpline & operator=(fpGridSpline &&other) noexcept
Move assignment - transfer ownership.
Definition fpGridSpline.hpp:106
fpGridSpline & operator=(const fpGridSpline &other)
Copy assignment - deep copy.
Definition fpGridSpline.hpp:87
std::vector< double > t_vector() const
Deep copy of component 't' as a std::vector.
Definition fpGridSpline.hpp:392
void comm_pack(std::vector< double > &buffer) const override
comm_pack
Definition fpGridSpline.hpp:335
fpGridSpline(const fpGridSpline &other)
Copy constructor - deep copy.
Definition fpGridSpline.hpp:79
fxArray< double > z() const
Zero-copy fxArray view of component 'z'.
Definition fpGridSpline.hpp:531
fpGridSpline()
Default constructor - allocates new fitpack_gridded_spline.
Definition fpGridSpline.hpp:65
virtual std::vector< double > eval_ongrid(int32_t xg_n1, int32_t xg_n2, std::vector< double > &xg, std::vector< int32_t > &m, int32_t n_result, int32_t *ierr=nullptr)
eval_ongrid
Definition fpGridSpline.hpp:240
bool is_allocated() const override
Check if object is allocated.
Definition fpGridSpline.hpp:143
FP_REAL integral(const fpPoint< dim > &lower, const fpPoint< dim > &upper) const
Integral of the spline over the box [lower, upper].
Definition fpGridSpline.hpp:611
fpGridSpline(NoAlloc tag)
Definition fpGridSpline.hpp:619
void core_comm_pack(std::vector< double > &buffer) const override
core_comm_pack
Definition fpGridSpline.hpp:361
void destroy_base() override
Definition fpGridSpline.hpp:376
void core_comm_expand(std::vector< double > &buffer) override
core_comm_expand
Definition fpGridSpline.hpp:370
virtual double eval(std::vector< double > &x, int32_t *ierr=nullptr) const
eval
Definition fpGridSpline.hpp:251
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 fpGridSpline.hpp:165
virtual double dfdx(std::vector< double > &x, std::vector< int32_t > &nu, int32_t *ierr=nullptr)
dfdx
Definition fpGridSpline.hpp:283
virtual std::vector< double > dfdx_ongrid(int32_t xg_n1, int32_t xg_n2, std::vector< double > &xg, std::vector< int32_t > &m, std::vector< int32_t > &nu, int32_t n_result, int32_t *ierr=nullptr)
dfdx_ongrid
Definition fpGridSpline.hpp:272
fpFitter & as_parent()
Upcast to parent type (reference, no copy)
Definition fpGridSpline.hpp:198
void comm_expand(std::vector< double > &buffer) override
comm_expand
Definition fpGridSpline.hpp:344
virtual std::vector< double > dfdx(int32_t xp_n1, int32_t xp_n2, std::vector< double > &xp, std::vector< int32_t > &nu, int32_t *ierr=nullptr)
dfdx
Definition fpGridSpline.hpp:292
virtual fpGridSpline cross_section(int32_t ax, double u, int32_t *ierr=nullptr)
Definition fpGridSpline.hpp:311
fxArray< double > xg() const
Zero-copy fxArray view of component 'xg'.
Definition fpGridSpline.hpp:486
std::vector< double > z_vector() const
Deep copy of component 'z' as a std::vector.
Definition fpGridSpline.hpp:508
virtual int32_t interpolate()
Definition fpGridSpline.hpp:233
const char * c_type_name() const override
Return the C wrapper struct name for this class (e.g. "fitpack_gridded_spline_c").
Definition fpGridSpline.hpp:157
std::array< int64_t, 2 > xg_shape() const
Extents of component 'xg', leading dimension first.
Definition fpGridSpline.hpp:466
virtual std::vector< double > eval(int32_t xp_n1, int32_t xp_n2, std::vector< double > &xp, int32_t *ierr=nullptr)
eval
Definition fpGridSpline.hpp:260
virtual int32_t new_fit(int32_t n, int32_t xg_n1, int32_t xg_n2, std::vector< double > &xg, std::vector< double > &z, int32_t *m=nullptr, bool *row_major=nullptr, int32_t *order=nullptr, double *smoothing=nullptr)
new_fit
Definition fpGridSpline.hpp:220
std::vector< FP_REAL > dfdx(const std::vector< fpPoint< dim > > &xp, const std::vector< FP_SIZE > &nu, FP_FLAG *ierr=nullptr)
Partial derivative of orders nu(1..dim) at every scattered point.
Definition fpGridSpline.hpp:600
~fpGridSpline() override
Destructor - deallocates if owned.
Definition fpGridSpline.hpp:72
double mse() const override
Definition fpGridSpline.hpp:350
const int32_t & dims() const
Definition fpGridSpline.hpp:556
std::vector< FP_REAL > eval(const std::vector< fpPoint< dim > > &xp, FP_FLAG *ierr=nullptr)
Evaluate the spline at every scattered point.
Definition fpGridSpline.hpp:580
FP_REAL eval(const fpPoint< dim > &x, FP_FLAG *ierr=nullptr) const
Evaluate the spline at one scattered point.
Definition fpGridSpline.hpp:571
std::vector< FP_REAL > fpPointFlatten(const std::vector< fpPoint< dims > > &points)
Flatten a vector of points into Fortran x(dims,m) order. One contiguous copy.
Definition fpPoint.hpp:117
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
constexpr FP_REAL * begin()
Definition fpPoint.hpp:62
constexpr FP_REAL * end()
Definition fpPoint.hpp:63