Loading...
Searching...
No Matches
gpr::ski::UniformGrid Class Reference

#include <gpr/ml/gp/DerivativeSKI.h>

Public Member Functions

 UniformGrid (double lo, double hi, Eigen::Index m)
Eigen::Index size () const noexcept
double spacing () const noexcept
double at (Eigen::Index i) const noexcept
double indexOf (double x) const noexcept
 Grid coordinate of x in index units.

Detailed Description

Uniform grid of m points spanning [lo, hi] with two cells of padding, so every interior input keeps its full four-point stencil.

Definition at line 54 of file DerivativeSKI.h.

Constructor & Destructor Documentation

◆ UniformGrid()

gpr::ski::UniformGrid::UniformGrid ( double lo,
double hi,
Eigen::Index m )

Definition at line 54 of file DerivativeSKI.cpp.

55{
56 if (m < 4) throw std::invalid_argument("SKI grid needs at least 4 points");
57 if (!(hi >= lo)) throw std::invalid_argument("SKI grid bounds inverted");
58 m_ = m;
59 // Two cells of padding at each end so an interior input keeps four
60 // neighbours; a degenerate span still yields a usable unit spacing.
61 // Those cells leave m - 5 steps between the endpoints. Zero steps cannot
62 // cover a positive span: the quotient is Inf and indexOf is NaN.
63 const double span = hi - lo;
64 const Eigen::Index steps = m - 5;
65 if (span > 0.0 && steps == 0) {
66 throw std::invalid_argument(
67 "SKI grid needs an interior interval to span a positive range");
68 }
69 h_ = (span > 0.0) ? span / static_cast<double>(steps) : 1.0;
70 origin_ = lo - 2.0 * h_;
71}

Member Function Documentation

◆ at()

double gpr::ski::UniformGrid::at ( Eigen::Index i) const
inlinenodiscardnoexcept

Definition at line 66 of file DerivativeSKI.h.

67 {
68 return origin_ + static_cast<double>(i) * h_;
69 }

◆ indexOf()

double gpr::ski::UniformGrid::indexOf ( double x) const
inlinenodiscardnoexcept

Grid coordinate of x in index units.

Definition at line 71 of file DerivativeSKI.h.

72 {
73 return (x - origin_) / h_;
74 }
@ x
Definition Enums.h:28

◆ size()

Eigen::Index gpr::ski::UniformGrid::size ( ) const
inlinenodiscardnoexcept

Definition at line 58 of file DerivativeSKI.h.

59 {
60 return m_;
61 }

◆ spacing()

double gpr::ski::UniformGrid::spacing ( ) const
inlinenodiscardnoexcept

Definition at line 62 of file DerivativeSKI.h.

63 {
64 return h_;
65 }

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