libSUFR
a LIBrary of Some Useful Fortran Routines
Loading...
Searching...
No Matches
sufr_interpolate Module Reference

Procedures to do interpolation (and fitting?) More...

Functions/Subroutines

pure real(double) function linear_interpolation (x1, x2, y1, y2, x)
 Do linear interpolation using the data points x1,x2, and y1,y2 to find the value y corresponding to x.
 
pure real function linear_interpolation_sp (x1, x2, y1, y2, x)
 Do linear interpolation using the data points x1,x2, and y1,y2 to find the value y corresponding to x, using single-precision variables.
 
real(double) function linear_interpolate_array (xarr, yarr, xval)
 Do linear interpolation using the data arrays xArr,yArr to find the value y corresponding to x.
 
pure subroutine perfect_parabolic_fit (x1, x2, x3, y1, y2, y3, a, b, c)
 Fit a parabola perfectly to three sets of data points x1,y1, x2,y2 and x3,y3.
 
pure real(double) function parabola (x, a, b, c)
 Compute a parabola a*x^2 + b*x + c.
 
pure integer function locate_value_in_array (xval, xarray)
 Locate the index in a monotonic array, such that a given value lies between array(index) and array(index+1). 0 or nArr+1 is returned if the value lies outside the array.
 

Detailed Description

Procedures to do interpolation (and fitting?)

Function/Subroutine Documentation

◆ linear_interpolate_array()

real(double) function sufr_interpolate::linear_interpolate_array ( real(double), dimension(:), intent(in) xarr,
real(double), dimension(:), intent(in) yarr,
real(double), intent(in) xval )

Do linear interpolation using the data arrays xArr,yArr to find the value y corresponding to x.

Parameters
xArrX-array, sorted to increasing value
yArrY-array
xValX value to find y value for
Return values
linear_interpolate_arrayY value found

Definition at line 91 of file interpolate.f90.

References sufr_kinds::double, linear_interpolate_array(), linear_interpolation(), locate_value_in_array(), and sufr_system::warn().

Referenced by linear_interpolate_array().

Here is the call graph for this function:

◆ linear_interpolation()

pure real(double) function sufr_interpolate::linear_interpolation ( real(double), intent(in) x1,
real(double), intent(in) x2,
real(double), intent(in) y1,
real(double), intent(in) y2,
real(double), intent(in) x )

Do linear interpolation using the data points x1,x2, and y1,y2 to find the value y corresponding to x.

Parameters
x1X value 1
x2X value 2
y1Y value 1, belonging to x1
y2Y value 2, belonging to x2
xX value to find y value for
Return values
linear_interpolationY value found

Definition at line 41 of file interpolate.f90.

References sufr_kinds::double, and linear_interpolation().

Referenced by linear_interpolate_array(), linear_interpolation(), and linear_interpolation_sp().

Here is the call graph for this function:

◆ linear_interpolation_sp()

pure real function sufr_interpolate::linear_interpolation_sp ( real, intent(in) x1,
real, intent(in) x2,
real, intent(in) y1,
real, intent(in) y2,
real, intent(in) x )

Do linear interpolation using the data points x1,x2, and y1,y2 to find the value y corresponding to x, using single-precision variables.

Parameters
x1X value 1
x2X value 2
y1Y value 1, belonging to x1
y2Y value 2, belonging to x2
xX value to find y value for
Return values
linear_interpolation_spY value found

Definition at line 70 of file interpolate.f90.

References linear_interpolation(), and linear_interpolation_sp().

Referenced by linear_interpolation_sp().

Here is the call graph for this function:

◆ locate_value_in_array()

pure integer function sufr_interpolate::locate_value_in_array ( real(double), intent(in) xval,
real(double), dimension(:), intent(in) xarray )

Locate the index in a monotonic array, such that a given value lies between array(index) and array(index+1). 0 or nArr+1 is returned if the value lies outside the array.

Parameters
xValValue to locate
xArrayArray to locate value in. xArray must be monotonic, either ascending or descending
Return values
locate_value_in_arrayIndex such that the value lies between array(index) and array(index+1).
See also
Numerical Recipes in Fortran, Sect.3.4

Definition at line 181 of file interpolate.f90.

References sufr_numerics::deq(), sufr_kinds::double, and locate_value_in_array().

Referenced by linear_interpolate_array(), and locate_value_in_array().

Here is the call graph for this function:

◆ parabola()

pure real(double) function sufr_interpolate::parabola ( real(double), intent(in) x,
real(double), intent(in) a,
real(double), intent(in) b,
real(double), intent(in) c )

Compute a parabola a*x^2 + b*x + c.

Parameters
xX value
aCoefficient a in y = a*x^2 +b*x + c
bCoefficient b in y = a*x^2 +b*x + c
cCoefficient c in y = a*x^2 +b*x + c
Return values
parabolaThe value of the parabola at x.

Definition at line 158 of file interpolate.f90.

References sufr_kinds::double, and parabola().

Referenced by parabola().

Here is the call graph for this function:

◆ perfect_parabolic_fit()

pure subroutine sufr_interpolate::perfect_parabolic_fit ( real(double), intent(in) x1,
real(double), intent(in) x2,
real(double), intent(in) x3,
real(double), intent(in) y1,
real(double), intent(in) y2,
real(double), intent(in) y3,
real(double), intent(out) a,
real(double), intent(out) b,
real(double), intent(out) c )

Fit a parabola perfectly to three sets of data points x1,y1, x2,y2 and x3,y3.

Parameters
x1X value 1
x2X value 2
x3X value 3
y1Y value 1, belonging to x1
y2Y value 2, belonging to x2
y3Y value 3, belonging to x3
aCoefficient a in y = a*x^2 + b*x + c (output)
bCoefficient b in y = a*x^2 + b*x + c (output)
cCoefficient c in y = a*x^2 + b*x + c (output)

Definition at line 127 of file interpolate.f90.

References sufr_kinds::double.