A monte carlo pin cell spectral code for nuclear engineering applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
interpolate.h File Reference

Utility functions for linear interpolation of 1D functions. More...

Go to the source code of this file.

Functions

template<typename T , typename U >
int findUpperIndex (T *x, int upper_bound, int lower_bound, U pt)
 This function finds the index of the first element in an array that is greater than the given parameter value. This is a recursive function and it uses the binary search algorithm to find the upper bound index. More...
 
template<typename T , typename U , typename P >
linearInterp (T *x, T *y, int length, U pt)
 This function takes in the x and y values of a 1D function and returns the linearly interpolated y value at a particular x-coordinate (pt). It assumes that the values given in x are ordered from least to greatest. More...
 

Detailed Description

Utility functions for linear interpolation of 1D functions.

Author
William Boyd (wboyd.nosp@m.@mit.nosp@m..edu)
Date
March 13, 2012

Function Documentation

template<typename T , typename U >
int findUpperIndex ( T *  x,
int  upper_bound,
int  lower_bound,
pt 
)

This function finds the index of the first element in an array that is greater than the given parameter value. This is a recursive function and it uses the binary search algorithm to find the upper bound index.

Parameters
xarray of values to search
upper_boundthe current upper bound at this level of recursion
lower_boundthe current lower bound at this level of recursion
ptthe value to search for
Returns
the index of the first element in x which is greater than pt
template<typename T , typename U , typename P >
P linearInterp ( T *  x,
T *  y,
int  length,
pt 
)

This function takes in the x and y values of a 1D function and returns the linearly interpolated y value at a particular x-coordinate (pt). It assumes that the values given in x are ordered from least to greatest.

Parameters
xvector of x values
yvector of y values
lengththe number of x and y
ptx-coordinate we wish to interpolate