Hex  2.2
Hydrogen-electron collision solver
Public Member Functions | Static Public Member Functions
Bspline Class Reference

B-spline environment. More...

#include <bspline.h>

Public Member Functions

 Bspline (int order, Real th, rArrayView cknots1, rArrayView rknots, rArrayView cknots2)
 Constructor. More...
 
Complex bspline (int i, int iknot, int k, Complex r) const
 Evaluate B-spline. More...
 
Complex dspline (int i, int iknot, int k, Complex r) const
 Evaluate derivative of a B-spline. More...
 
void B (int i, int iknot, int n, const Complex *x, Complex *y) const
 B-spline. More...
 
void dB (int i, int iknot, int n, const Complex *x, Complex *y) const
 Derivative of a B-spline. More...
 
Complex rotate (Real r) const
 Apply the ECS transformation. More...
 
Real unrotate (Complex z) const
 Apply the inverse ECS transformation. More...
 
Complex clamp (Complex z, Real a, Real b) const
 Restrict value into a given range. More...
 
cArray zip (const cArrayView coeff, const rArrayView grid) const
 Zip 1D expansion. More...
 
cArray zip (const cArrayView coeff, const rArrayView xgrid, const rArrayView ygrid) const
 Zip 2D expansion. More...
 
int knot (Complex x) const
 Get knot index for coordinate. More...
 
Complex eval (const cArrayView coeff, Real x) const
 Evaluate 1D B-spline expansion. More...
 
Complex eval (const cArrayView coeff, Real x, Real y) const
 Evaluate 2D B-spline expansion. More...
 
cArrayView t () const
 B-spline knot sequence. More...
 
Complex const & t (int i) const
 B-spline knot sequence. More...
 
int Nspline () const
 Number of B-splines. More...
 
int Nknot () const
 Number of knots. More...
 
int Nreknot () const
 Number of real knots. More...
 
int order () const
 B-spline order. More...
 
int iR1 () const
 Index of knot between leading complex grid and real grid. More...
 
int iR2 () const
 Index of knot between real grid and trailing complex grid. More...
 
Real R1 () const
 Beginning of the real grid. More...
 
Real R2 () const
 End of the real grid. More...
 
Real Rmin () const
 Beginning of the grid (unrotated). More...
 
Real Rmax () const
 End of the grid (unrotated). More...
 
Real ECStheta () const
 ECS rotation angle. More...
 
rArray const & rknots () const
 real knots More...
 
rArray const & cknots1 () const
 complex knots More...
 
rArray const & cknots2 () const
 
std::size_t hash () const
 Return (almost) unique identification for this B-spline object. More...
 

Static Public Member Functions

static cArray zip (Bspline const &bx, Bspline const &by, const cArrayView coeff, const rArrayView xgrid, const rArrayView ygrid, Complex(Bspline::*evalXBSpline)(int, int, int, Complex) const =&Bspline::bspline, Complex(Bspline::*evalYBSpline)(int, int, int, Complex) const =&Bspline::bspline)
 

Detailed Description

This class is used to manage B-spline computations within the context of the exterior complex scaling. That is, it allows (upon construction) specification of the real and complex knot sequences

\[ t_1^{R}, t_2^{R}, ..., t_{\mathrm{Nreknot}}^{R} \ , \]

\[ t_{\mathrm{Nreknot}+1}^{C}, ..., t_{\mathrm{Nknot}}^{C} \ , \]

which then serve as the knot data of the B-spline set. See bspline and dspline on the definition formulae.

Constructor & Destructor Documentation

◆ Bspline()

Bspline::Bspline ( int  order,
Real  th,
rArrayView  cknots1,
rArrayView  rknots,
rArrayView  cknots2 
)

Setup the knot sequence, which will consist of two parts.

Parameters
orderB-spline order.
thECS angle in radians.
cknots1Leading complex-rotated knots.
rknotsReal knot array.
cknots2Trailing complex-rotated knots.

Member Function Documentation

◆ B()

void Bspline::B ( int  i,
int  iknot,
int  n,
const Complex *  x,
Complex *  y 
) const

Evaluates single B-spline at several points at once. This results in increased speed, because some data need to be computed only once. Also, some operation have been reorganized to a form that allows SIMD auto-vectorization.

Note that all evaluation points must be in the interval bounded by 'iknot'-th and 'iknot+1'-th knot.

For parameters description see bspline.

◆ bspline()

Complex Bspline::bspline ( int  i,
int  iknot,
int  k,
Complex  r 
) const

Function evaluates a B-spline in one point. The recursive Cox de Boor formula is used:

\[ B_i^{(0)}(x) = \cases { 1 & t_i \le x \le t_{i+1} \cr 0 & \mbox{otherwise} }\ , \]

\[ B_i^{(k)}(x) = \frac{x - t_i}{t_{i+k-1} - t_i} B_i^{(k-1)}(x) + \frac{t_{i+k} - x}{t_{i+k} - t_{i+1}} B_{i+1}^{(k-1)}(x) \ . \]

Parameters
iIndex of the B-spline.
iknotIndex of the left knot.
kB-spline order.
rCoordinate (independent variable).

◆ cknots1()

rArray const& Bspline::cknots1 ( ) const
inline

◆ cknots2()

rArray const& Bspline::cknots2 ( ) const
inline

◆ clamp()

Complex Bspline::clamp ( Complex  z,
Real  a,
Real  b 
) const

Returns the value unchanged if it fits into the given range, or one of the bounds (the nearer one) if it doesn't. The bounds a and b are (unrotated) coordinates along the contour.

◆ dB()

void Bspline::dB ( int  i,
int  iknot,
int  n,
const Complex *  x,
Complex *  y 
) const

For parameters description see dspline.

This routine simply calls dspline for every evaluation point.

◆ dspline()

Complex Bspline::dspline ( int  i,
int  iknot,
int  k,
Complex  r 
) const

This function evaluated the derivative of a B-spline, using the formula

Parameters
iIndex of the B-spline.
iknotIndex of the left knot.
kB-spline order.
rCoordinate (independent variable).

◆ ECStheta()

Real Bspline::ECStheta ( ) const
inline

◆ eval() [1/2]

Complex Bspline::eval ( const cArrayView  coeff,
Real  x 
) const

Evaluates a B-spline expansion in a single point x. This function is faster than calling

Complex z = zip (coeff, rArray({x}));

though the results are the same.

◆ eval() [2/2]

Complex Bspline::eval ( const cArrayView  coeff,
Real  x,
Real  y 
) const

Evaluates a double B-spline expansion in a single point (x,y). This function is faster than calling

Complex z = zip (coeff, rArray({x}), rArray({y}));

though the results are the same.

◆ hash()

std::size_t Bspline::hash ( ) const

The identifier is calculated as a simple hash of the data contained in the object.

◆ iR1()

int Bspline::iR1 ( ) const
inline

This is also the index of the first possibly purely real B-spline.

◆ iR2()

int Bspline::iR2 ( ) const
inline

This is the index of the trailing knot of the last possibly purely real B-spline. The index of that B-spline is iR2 - order - 1.

◆ knot()

int Bspline::knot ( Complex  x) const

Finds knot (interval \( \langle t_i,t_{i+1} \rangle \)) for 'x'.

Parameters
xComplex coordinate.

◆ Nknot()

int Bspline::Nknot ( ) const
inline

◆ Nreknot()

int Bspline::Nreknot ( ) const
inline

◆ Nspline()

int Bspline::Nspline ( ) const
inline

◆ order()

int Bspline::order ( ) const
inline

◆ R1()

Real Bspline::R1 ( ) const
inline

◆ R2()

Real Bspline::R2 ( ) const
inline

◆ rknots()

rArray const& Bspline::rknots ( ) const
inline

◆ Rmax()

Real Bspline::Rmax ( ) const
inline

◆ Rmin()

Real Bspline::Rmin ( ) const
inline

◆ rotate()

Complex Bspline::rotate ( Real  r) const
inline
Parameters
rReal coordinate.

◆ t() [1/2]

cArrayView Bspline::t ( ) const
inline

◆ t() [2/2]

Complex const& Bspline::t ( int  i) const
inline

◆ unrotate()

Real Bspline::unrotate ( Complex  z) const
inline
Parameters
zComplex coordinate.

◆ zip() [1/3]

cArray Bspline::zip ( const cArrayView  coeff,
const rArrayView  grid 
) const

Evaluate 1D function given as a B-spline expansion over a grid.

Parameters
coeffExpansion coefficients.
gridEvaluation points (unrotated). They are assumed to be sorted. The length of coeff must be at least equal to the spline count and it is these first Nspline coefficients that are used in evaluation.

◆ zip() [2/3]

cArray Bspline::zip ( const cArrayView  coeff,
const rArrayView  xgrid,
const rArrayView  ygrid 
) const

Evaluate 2D function given as a B-spline expansion over a carthesian product of two 1D grids.

Parameters
coeffExpansion coefficients.
xgridEvaluation points at x-axis (unrotated). They are assumed to be sorted.
ygridEvaluation points at y-axis (unrotated). They are assumed to be sorted. The length of coeff must be at least equal to the spline count squared and it is these first Nspline**2 coefficients that are used in evaluation.

◆ zip() [3/3]

cArray Bspline::zip ( Bspline const &  bx,
Bspline const &  by,
const cArrayView  coeff,
const rArrayView  xgrid,
const rArrayView  ygrid,
Complex(Bspline::*)(int, int, int, Complex) const  evalXBSpline = &Bspline::bspline,
Complex(Bspline::*)(int, int, int, Complex) const  evalYBSpline = &Bspline::bspline 
)
static

Zip 2D expansion.

Evaluate 2D function given as a B-spline expansion over a carthesian product of two 1D grids. The user may supply the B-spline evaluation functions for the individual axes, thus allowing evaluation of partial derivatives besides the plain B-spline expansion.


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