fitpack
Modern Fortran library for curve and surface fitting with splines
Loading...
Searching...
No Matches
fpGridSpline Class Reference

Standalone C++ RAII wrapper for Fortran fitpack_gridded_spline. More...

#include <fpGridSpline.hpp>

Inheritance diagram for fpGridSpline:
Collaboration diagram for fpGridSpline:

Public Member Functions

 fpGridSpline ()
 Default constructor - allocates new fitpack_gridded_spline.
 
 ~fpGridSpline () override
 Destructor - deallocates if owned.
 
 fpGridSpline (const fpGridSpline &other)
 Copy constructor - deep copy.
 
fpGridSplineoperator= (const fpGridSpline &other)
 Copy assignment - deep copy.
 
 fpGridSpline (fpGridSpline &&other) noexcept
 Move constructor - transfer ownership.
 
fpGridSplineoperator= (fpGridSpline &&other) noexcept
 Move assignment - transfer ownership.
 
 fpGridSpline (fitpack_gridded_spline_c &c_wrapper, bool move=false)
 Construct from existing C wrapper (takes ownership if move=true)
 
 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' polymorphic accessors to wrap a base-class handle as the correct concrete subtype.
 
bool is_allocated () const override
 Check if object is allocated.
 
bool is_pointer () const override
 Check if this is a non-owning pointer.
 
const char * c_type_name () const override
 Return the C wrapper struct name for this class (e.g. "fitpack_gridded_spline_c").
 
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-trip through Fortran.
 
fitpack_gridded_spline_c & c_handle ()
 Get underlying C wrapper (for interop)
 
const fitpack_gridded_spline_c & c_handle () const
 Get underlying C wrapper (const, for interop)
 
fpFitteras_parent ()
 Upcast to parent type (reference, no copy)
 
const fpFitteras_parent () const
 
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
 
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
 
virtual int32_t fit (double *smoothing=nullptr, int32_t *order=nullptr)
 
virtual int32_t least_squares (double *smoothing=nullptr, bool *reset_knots=nullptr)
 
virtual int32_t interpolate ()
 
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
 
virtual double eval (std::vector< double > &x, int32_t *ierr=nullptr) const
 eval
 
virtual std::vector< double > eval (int32_t xp_n1, int32_t xp_n2, std::vector< double > &xp, int32_t *ierr=nullptr)
 eval
 
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
 
virtual double dfdx (std::vector< double > &x, std::vector< int32_t > &nu, int32_t *ierr=nullptr)
 dfdx
 
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
 
virtual double integral (std::vector< double > &lower, std::vector< double > &upper) const
 integral
 
virtual fpGridSpline cross_section (int32_t ax, double u, int32_t *ierr=nullptr)
 
virtual fpGridSpline derivative_spline (std::vector< int32_t > &nu, int32_t *ierr=nullptr)
 derivative_spline
 
int32_t comm_size () const override
 
void comm_pack (std::vector< double > &buffer) const override
 comm_pack
 
void comm_expand (std::vector< double > &buffer) override
 comm_expand
 
double mse () const override
 
int32_t core_comm_size () const override
 
void core_comm_pack (std::vector< double > &buffer) const override
 core_comm_pack
 
void core_comm_expand (std::vector< double > &buffer) override
 core_comm_expand
 
void destroy_base () override
 
std::vector< double > t_vector () const
 Deep copy of component 't' as a std::vector.
 
std::array< int64_t, 2 > t_shape () const
 Extents of component 't', leading dimension first.
 
fxArray< double > t () const
 Zero-copy fxArray view of component 't'.
 
std::vector< double > xg_vector () const
 Deep copy of component 'xg' as a std::vector.
 
std::array< int64_t, 2 > xg_shape () const
 Extents of component 'xg', leading dimension first.
 
fxArray< double > xg () const
 Zero-copy fxArray view of component 'xg'.
 
std::vector< double > z_vector () const
 Deep copy of component 'z' as a std::vector.
 
fxArray< double > z () const
 Zero-copy fxArray view of component 'z'.
 
int32_t & dims ()
 
const int32_t & dims () const
 
template<FP_SIZE dim>
FP_REAL eval (const fpPoint< dim > &x, FP_FLAG *ierr=nullptr) const
 Evaluate the spline at one scattered point.
 
template<FP_SIZE dim>
std::vector< FP_REAL > eval (const std::vector< fpPoint< dim > > &xp, FP_FLAG *ierr=nullptr)
 Evaluate the spline at every scattered point.
 
template<FP_SIZE dim>
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.
 
template<FP_SIZE dim>
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.
 
template<FP_SIZE dim>
FP_REAL integral (const fpPoint< dim > &lower, const fpPoint< dim > &upper) const
 Integral of the spline over the box [lower, upper].
 
- Public Member Functions inherited from fpFitter
virtual ~fpFitter ()=default
 
const char * fortran_type_name () const
 Return the dynamic Fortran type name of the underlying object.
 
fitpack_fitter_c & c_handle ()
 Get underlying C wrapper (for interop)
 
const fitpack_fitter_c & c_handle () const
 Get underlying C wrapper (const, for interop)
 
std::vector< double > c_vector () const
 Deep copy of component 'c' as a std::vector.
 
fxArray< double > c () const
 Zero-copy fxArray view of component 'c'.
 
std::vector< double > wrk_vector () const
 Deep copy of component 'wrk' as a std::vector.
 
fxArray< double > wrk () const
 Zero-copy fxArray view of component 'wrk'.
 
std::vector< int32_t > iwrk_vector () const
 Deep copy of component 'iwrk' as a std::vector.
 
fxArray< int32_t > iwrk () const
 Zero-copy fxArray view of component 'iwrk'.
 
int32_t & iopt ()
 
const int32_t & iopt () const
 
double & smoothing ()
 
const double & smoothing () const
 
double & fp ()
 
const double & fp () const
 
int32_t & lwrk ()
 
const int32_t & lwrk () const
 
int32_t & liwrk ()
 
const int32_t & liwrk () const
 

Static Public Member Functions

static fpGridSpline make_view ()
 Construct an empty (non-owning) wrapper, for use as a view target.
 

Protected Member Functions

 fpGridSpline (NoAlloc tag)
 
- Protected Member Functions inherited from fpFitter
 fpFitter (NoAlloc)
 Protected constructor for derived classes (does not allocate)
 
template<typename T>
T * as ()
 
template<typename T>
const T * as () const
 

Additional Inherited Members

- Protected Attributes inherited from fpFitter
fitpack_fitter_c cobj = fitpack_fitter_c_null
 

Detailed Description

Standalone C++ RAII wrapper for Fortran fitpack_gridded_spline.

This class provides automatic memory management (RAII) and a natural C++ API for the underlying Fortran fitpack_gridded_spline, without requiring the fortran-arrays library. Array arguments use std::vector<T> for standalone operation. Extends fpFitter (Fortran: extends(fitpack_fitter))

Constructor & Destructor Documentation

◆ fpGridSpline() [1/6]

fpGridSpline::fpGridSpline ( )
inline

Default constructor - allocates new fitpack_gridded_spline.

Here is the call graph for this function:

◆ ~fpGridSpline()

fpGridSpline::~fpGridSpline ( )
inlineoverride

Destructor - deallocates if owned.

Here is the call graph for this function:

◆ fpGridSpline() [2/6]

fpGridSpline::fpGridSpline ( const fpGridSpline & other)
inline

Copy constructor - deep copy.

Here is the call graph for this function:

◆ fpGridSpline() [3/6]

fpGridSpline::fpGridSpline ( fpGridSpline && other)
inlinenoexcept

Move constructor - transfer ownership.

Here is the call graph for this function:

◆ fpGridSpline() [4/6]

fpGridSpline::fpGridSpline ( fitpack_gridded_spline_c & c_wrapper,
bool move = false )
inlineexplicit

Construct from existing C wrapper (takes ownership if move=true)

Here is the call graph for this function:

◆ fpGridSpline() [5/6]

fpGridSpline::fpGridSpline ( fitpack_gridded_spline_c & c_wrapper,
ViewTag  )
inlineexplicit

Non-owning view ctor: bit-copy the C handle, mark is_pointer=true. Used by parent classes' polymorphic accessors to wrap a base-class handle as the correct concrete subtype.

Here is the call graph for this function:

◆ fpGridSpline() [6/6]

fpGridSpline::fpGridSpline ( NoAlloc tag)
inlineexplicitprotected
Here is the call graph for this function:

Member Function Documentation

◆ as_parent() [1/2]

fpFitter & fpGridSpline::as_parent ( )
inline

Upcast to parent type (reference, no copy)

Here is the call graph for this function:

◆ as_parent() [2/2]

const fpFitter & fpGridSpline::as_parent ( ) const
inline
Here is the call graph for this function:

◆ c_handle() [1/2]

fitpack_gridded_spline_c & fpGridSpline::c_handle ( )
inline

Get underlying C wrapper (for interop)

Here is the call graph for this function:

◆ c_handle() [2/2]

const fitpack_gridded_spline_c & fpGridSpline::c_handle ( ) const
inline

Get underlying C wrapper (const, for interop)

Here is the call graph for this function:

◆ c_type_name()

const char * fpGridSpline::c_type_name ( ) const
inlineoverridevirtual

Return the C wrapper struct name for this class (e.g. "fitpack_gridded_spline_c").

Reimplemented from fpFitter.

Here is the call graph for this function:

◆ comm_expand()

void fpGridSpline::comm_expand ( std::vector< double > & buffer)
inlineoverridevirtual

comm_expand

Implements fpFitter.

Here is the call graph for this function:

◆ comm_pack()

void fpGridSpline::comm_pack ( std::vector< double > & buffer) const
inlineoverridevirtual

comm_pack

Implements fpFitter.

Here is the call graph for this function:

◆ comm_size()

int32_t fpGridSpline::comm_size ( ) const
inlineoverridevirtual

Implements fpFitter.

Here is the call graph for this function:

◆ core_comm_expand()

void fpGridSpline::core_comm_expand ( std::vector< double > & buffer)
inlineoverridevirtual

core_comm_expand

Reimplemented from fpFitter.

Here is the call graph for this function:

◆ core_comm_pack()

void fpGridSpline::core_comm_pack ( std::vector< double > & buffer) const
inlineoverridevirtual

core_comm_pack

Reimplemented from fpFitter.

Here is the call graph for this function:

◆ core_comm_size()

int32_t fpGridSpline::core_comm_size ( ) const
inlineoverridevirtual

Reimplemented from fpFitter.

Here is the call graph for this function:

◆ cpp_type_name()

const char * fpGridSpline::cpp_type_name ( ) const
inlineoverridevirtual

Return the fully-qualified C++ class name for this class. Owned by the C++ layer — does not round-trip through Fortran.

Reimplemented from fpFitter.

◆ cross_section()

virtual fpGridSpline fpGridSpline::cross_section ( int32_t ax,
double u,
int32_t * ierr = nullptr )
inlinevirtual
Here is the call graph for this function:

◆ derivative_spline()

virtual fpGridSpline fpGridSpline::derivative_spline ( std::vector< int32_t > & nu,
int32_t * ierr = nullptr )
inlinevirtual

derivative_spline

Here is the call graph for this function:

◆ destroy_base()

void fpGridSpline::destroy_base ( )
inlineoverridevirtual

Reimplemented from fpFitter.

Here is the call graph for this function:

◆ dfdx() [1/4]

template<FP_SIZE dim>
FP_REAL fpGridSpline::dfdx ( const fpPoint< dim > & x,
const std::vector< FP_SIZE > & nu,
FP_FLAG * ierr = nullptr )
inline

Partial derivative of orders nu(1..dim) at one scattered point.

Note
Not const: the Fortran receiver of the raw dfdx is intent(inout).
Here is the call graph for this function:

◆ dfdx() [2/4]

template<FP_SIZE dim>
std::vector< FP_REAL > fpGridSpline::dfdx ( const std::vector< fpPoint< dim > > & xp,
const std::vector< FP_SIZE > & nu,
FP_FLAG * ierr = nullptr )
inline

Partial derivative of orders nu(1..dim) at every scattered point.

Here is the call graph for this function:

◆ dfdx() [3/4]

virtual std::vector< double > fpGridSpline::dfdx ( int32_t xp_n1,
int32_t xp_n2,
std::vector< double > & xp,
std::vector< int32_t > & nu,
int32_t * ierr = nullptr )
inlinevirtual

dfdx

Here is the call graph for this function:

◆ dfdx() [4/4]

virtual double fpGridSpline::dfdx ( std::vector< double > & x,
std::vector< int32_t > & nu,
int32_t * ierr = nullptr )
inlinevirtual

dfdx

Here is the call graph for this function:

◆ dfdx_ongrid()

virtual std::vector< double > fpGridSpline::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 )
inlinevirtual

dfdx_ongrid

Here is the call graph for this function:

◆ dims() [1/2]

int32_t & fpGridSpline::dims ( )
inline
Here is the call graph for this function:

◆ dims() [2/2]

const int32_t & fpGridSpline::dims ( ) const
inline
Here is the call graph for this function:

◆ eval() [1/4]

template<FP_SIZE dim>
FP_REAL fpGridSpline::eval ( const fpPoint< dim > & x,
FP_FLAG * ierr = nullptr ) const
inline

Evaluate the spline at one scattered point.

Here is the call graph for this function:

◆ eval() [2/4]

template<FP_SIZE dim>
std::vector< FP_REAL > fpGridSpline::eval ( const std::vector< fpPoint< dim > > & xp,
FP_FLAG * ierr = nullptr )
inline

Evaluate the spline at every scattered point.

Here is the call graph for this function:

◆ eval() [3/4]

virtual std::vector< double > fpGridSpline::eval ( int32_t xp_n1,
int32_t xp_n2,
std::vector< double > & xp,
int32_t * ierr = nullptr )
inlinevirtual

eval

Here is the call graph for this function:

◆ eval() [4/4]

virtual double fpGridSpline::eval ( std::vector< double > & x,
int32_t * ierr = nullptr ) const
inlinevirtual

eval

Here is the call graph for this function:

◆ eval_ongrid()

virtual std::vector< double > fpGridSpline::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 )
inlinevirtual

eval_ongrid

Here is the call graph for this function:

◆ fit()

virtual int32_t fpGridSpline::fit ( double * smoothing = nullptr,
int32_t * order = nullptr )
inlinevirtual
Here is the call graph for this function:

◆ integral() [1/2]

template<FP_SIZE dim>
FP_REAL fpGridSpline::integral ( const fpPoint< dim > & lower,
const fpPoint< dim > & upper ) const
inline

Integral of the spline over the box [lower, upper].

Here is the call graph for this function:

◆ integral() [2/2]

virtual double fpGridSpline::integral ( std::vector< double > & lower,
std::vector< double > & upper ) const
inlinevirtual

integral

Here is the call graph for this function:

◆ interpolate()

virtual int32_t fpGridSpline::interpolate ( )
inlinevirtual
Here is the call graph for this function:

◆ is_allocated()

bool fpGridSpline::is_allocated ( ) const
inlineoverridevirtual

Check if object is allocated.

Reimplemented from fpFitter.

Here is the call graph for this function:

◆ is_pointer()

bool fpGridSpline::is_pointer ( ) const
inlineoverridevirtual

Check if this is a non-owning pointer.

Reimplemented from fpFitter.

Here is the call graph for this function:

◆ least_squares()

virtual int32_t fpGridSpline::least_squares ( double * smoothing = nullptr,
bool * reset_knots = nullptr )
inlinevirtual
Here is the call graph for this function:

◆ make_view()

static fpGridSpline fpGridSpline::make_view ( )
inlinestatic

Construct an empty (non-owning) wrapper, for use as a view target.

The returned object has a null handle (cptr==nullptr, is_pointer==false) and does NOT allocate a Fortran object. Intended as a fill target for member-view accessors emitted on parent types — the parent populates the handle with c_loc() into its own storage and sets is_pointer=true.

Here is the call graph for this function:

◆ mse()

double fpGridSpline::mse ( ) const
inlineoverridevirtual

Reimplemented from fpFitter.

Here is the call graph for this function:

◆ new_fit()

virtual int32_t fpGridSpline::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 )
inlinevirtual

new_fit

Here is the call graph for this function:

◆ new_points()

virtual void fpGridSpline::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 )
inlinevirtual

new_points

Here is the call graph for this function:

◆ operator=() [1/2]

fpGridSpline & fpGridSpline::operator= ( const fpGridSpline & other)
inline

Copy assignment - deep copy.

Here is the call graph for this function:

◆ operator=() [2/2]

fpGridSpline & fpGridSpline::operator= ( fpGridSpline && other)
inlinenoexcept

Move assignment - transfer ownership.

Here is the call graph for this function:

◆ t()

fxArray< double > fpGridSpline::t ( ) const
inline

Zero-copy fxArray view of component 't'.

array_c_from_ptr builds the descriptor from the borrowed pointer and bounds, so the view aliases the Fortran storage directly — nothing is copied and writes through t()(i, j) land in the object.

Note
Only available when the Fortran-Arrays library is present and enabled (HAVE_FXARRAY).
Warning
The view is invalidated by any refit, assignment or destroy call on this object; re-read it rather than retaining it.
Here is the call graph for this function:

◆ t_shape()

std::array< int64_t, 2 > fpGridSpline::t_shape ( ) const
inline

Extents of component 't', leading dimension first.

Returns
All zeros when the component is unallocated.
Here is the call graph for this function:

◆ t_vector()

std::vector< double > fpGridSpline::t_vector ( ) const
inline

Deep copy of component 't' as a std::vector.

The rank-2 component is flattened COLUMN-MAJOR (Fortran order): element (i, j, ...) — zero-based — is at index i + j * extents[0] + ... Query the extents with t_shape().

Returns
An owning copy, empty when the component is unallocated.
Here is the call graph for this function:

◆ xg()

fxArray< double > fpGridSpline::xg ( ) const
inline

Zero-copy fxArray view of component 'xg'.

array_c_from_ptr builds the descriptor from the borrowed pointer and bounds, so the view aliases the Fortran storage directly — nothing is copied and writes through xg()(i, j) land in the object.

Note
Only available when the Fortran-Arrays library is present and enabled (HAVE_FXARRAY).
Warning
The view is invalidated by any refit, assignment or destroy call on this object; re-read it rather than retaining it.
Here is the call graph for this function:

◆ xg_shape()

std::array< int64_t, 2 > fpGridSpline::xg_shape ( ) const
inline

Extents of component 'xg', leading dimension first.

Returns
All zeros when the component is unallocated.
Here is the call graph for this function:

◆ xg_vector()

std::vector< double > fpGridSpline::xg_vector ( ) const
inline

Deep copy of component 'xg' as a std::vector.

The rank-2 component is flattened COLUMN-MAJOR (Fortran order): element (i, j, ...) — zero-based — is at index i + j * extents[0] + ... Query the extents with xg_shape().

Returns
An owning copy, empty when the component is unallocated.
Here is the call graph for this function:

◆ z()

fxArray< double > fpGridSpline::z ( ) const
inline

Zero-copy fxArray view of component 'z'.

array_c_from_ptr builds the descriptor from the borrowed pointer and bounds, so the view aliases the Fortran storage directly — nothing is copied and writes through z()(i) land in the object.

Note
Only available when the Fortran-Arrays library is present and enabled (HAVE_FXARRAY).
Warning
The view is invalidated by any refit, assignment or destroy call on this object; re-read it rather than retaining it.
Here is the call graph for this function:

◆ z_vector()

std::vector< double > fpGridSpline::z_vector ( ) const
inline

Deep copy of component 'z' as a std::vector.

Returns
An owning copy, empty when the component is unallocated.
Here is the call graph for this function:

The documentation for this class was generated from the following file: