V3FIT
Functions/Subroutines
line_segment Module Reference

Module is part of the LIBSTELL. This module contains code to create a profile constructed of line sigments. These line segments are assumed to be specified such that xx(i) < xx(i + 1) More...

Functions/Subroutines

subroutine, public line_seg (x, y, xx, yy, n)
 Interpolate a point on a line. More...
 
subroutine, public line_seg_int (x, y, xx, yy, n)
 Integrate to a point on a line. More...
 
pure recursive subroutine, private get_indices (x, xx, lBound, uBound, ilow, ihigh)
 Find the bounding indicies of the array. More...
 
pure real(rprec) function, private slope (yy, xx, ilow, ihigh)
 Find the slope of the line. More...
 
pure real(rprec) function, private offset (yy, xx, ilow, ihigh)
 Find the y intercept of the line. More...
 
pure real(rprec) function, private y_value (x, yy, xx, ilow, ihigh)
 Evaluate the line. More...
 
pure real(rprec) function, private y_value_int (x0, x1, yy, xx, ilow, ihigh)
 Integrate the line. More...
 
logical function, public line_seg_test ()
 Line segment unit test function. More...
 
logical function, private check (expected, received, testNum, name)
 Check a real value. More...
 

Detailed Description

Module is part of the LIBSTELL. This module contains code to create a profile constructed of line sigments. These line segments are assumed to be specified such that xx(i) < xx(i + 1)

Function/Subroutine Documentation

◆ check()

logical function, private line_segment::check ( real(rprec), intent(in)  expected,
real(rprec), intent(in)  received,
integer, intent(in)  testNum,
character (len=*), intent(in)  name 
)
private

Check a real value.

Checks that the expected value matches the recieved. Otherwise report an error.

Parameters
[in]expectedThe known value.
[in]receivedThe known test value.
[in]testNumThe number of the test.
[in]nameThe name of the test.
Returns
True if the check passes and false otherwise.

Definition at line 589 of file line_segment.f.

◆ get_indices()

pure recursive subroutine, private line_segment::get_indices ( real(rprec), intent(in)  x,
real(rprec), dimension(:), intent(in)  xx,
integer, intent(in)  lBound,
integer, intent(in)  uBound,
integer, intent(out)  ilow,
integer, intent(out)  ihigh 
)
private

Find the bounding indicies of the array.

This performs a recursive search to find the upper and lower indices of the that bound a point x. This is performed by splitting the array in half and recursively calling the subroutine on the half that still bounda the point. Once the array is down to two elements, the bounding indicies have been found.

Parameters
[in]xX point to find the bounds at.
[in]xxX positions defining the line segments.
[in]lBoundLower bound value of the array.
[in]uBoundUpper bound value of the array.
[out]ilowIndex of the lower bound.
[out]ihighIndex of the upper bound.

Definition at line 165 of file line_segment.f.

◆ line_seg()

subroutine, public line_segment::line_seg ( real (rprec), intent(in)  x,
real (rprec), intent(out)  y,
real (rprec), dimension(:), intent(in)  xx,
real (rprec), dimension(:), intent(in)  yy,
integer, intent(in)  n 
)

Interpolate a point on a line.

Find the linearly interpolated value of y at position x from line sigments specified by yy(xx).

Parameters
[in]xX point to interpolate the line at.
[out]yThe value of the interpolated point.
[in]xxX positions defining the line segments.
[in]yyY positions defining the line segments.
[in]nNumber of points defining the line.

Definition at line 41 of file line_segment.f.

◆ line_seg_int()

subroutine, public line_segment::line_seg_int ( real (rprec), intent(in)  x,
real (rprec), intent(out)  y,
real (rprec), dimension(:), intent(in)  xx,
real (rprec), dimension(:), intent(in)  yy,
integer, intent(in)  n 
)

Integrate to a point on a line.

Find the linearly integrated value of y at position x from line sigments specified by yy(xx).

Parameters
[in]xX point to interpolate the line at.
[out]yThe value of the interpolated point.
[in]xxX positions defining the line segments.
[in]yyY positions defining the line segments.
[in]nNumber of points defining the line.

Definition at line 88 of file line_segment.f.

◆ line_seg_test()

logical function, public line_segment::line_seg_test

Line segment unit test function.

This runs the associated unit tests and returns the result.

Returns
True if the tests pass and false otherwise.

Definition at line 344 of file line_segment.f.

◆ offset()

pure real(rprec) function, private line_segment::offset ( real(rprec), dimension(:), intent(in)  yy,
real(rprec), dimension(:), intent(in)  xx,
integer, intent(in)  ilow,
integer, intent(in)  ihigh 
)
private

Find the y intercept of the line.

This finds the b of y = m*x + b where x is defined as xx and y is defined as yy. b is defined as (x2y1 - x1y2)/(x2 - x1).

Parameters
[in]xxX positions defining the line segments.
[in]yyY positions defining the line segments.
[in]ilowIndex of the lower bound.
[in]ihighIndex of the upper bound.
Returns
The y intercept of the line between the indicies.

Definition at line 239 of file line_segment.f.

◆ slope()

pure real(rprec) function, private line_segment::slope ( real(rprec), dimension(:), intent(in)  yy,
real(rprec), dimension(:), intent(in)  xx,
integer, intent(in)  ilow,
integer, intent(in)  ihigh 
)
private

Find the slope of the line.

This find the m of y = m*x + b where x is defined as xx and y is defined as yy. m is defined as dy/dx.

Parameters
[in]xxX positions defining the line segments.
[in]yyY positions defining the line segments.
[in]ilowIndex of the lower bound.
[in]ihighIndex of the upper bound.
Returns
The slope of the line between the indicies.

Definition at line 211 of file line_segment.f.

◆ y_value()

pure real(rprec) function, private line_segment::y_value ( real(rprec), intent(in)  x,
real(rprec), dimension(:), intent(in)  yy,
real(rprec), dimension(:), intent(in)  xx,
integer, intent(in)  ilow,
integer, intent(in)  ihigh 
)
private

Evaluate the line.

Evaluates the line defined by the x and y at the indicies. Avoid a possible divide by zero when two xx indices have the same value. Handel this by taking the high index of yy.

Parameters
[in]xX point to evaluate the line at.
[in]xxX positions defining the line segments.
[in]yyY positions defining the line segments.
[in]ilowIndex of the lower bound.
[in]ihighIndex of the upper bound.
Returns
y(x).

Definition at line 270 of file line_segment.f.

◆ y_value_int()

pure real(rprec) function, private line_segment::y_value_int ( real(rprec), intent(in)  x0,
real(rprec), intent(in)  x1,
real(rprec), dimension(:), intent(in)  yy,
real(rprec), dimension(:), intent(in)  xx,
integer, intent(in)  ilow,
integer, intent(in)  ihigh 
)
private

Integrate the line.

Evaluates the integral of line defined by the x and y at the indicies. Avoid a potential divide by zero error when two xx indices have the same value. In this case, the integral is zero.

Parameters
[in]x0Starting point of the integration.
[in]x1Ending point of the integration.
[in]xxX positions defining the line segments.
[in]yyY positions defining the line segments.
[in]ilowIndex of the lower bound.
[in]ihighIndex of the upper bound.
Returns
Int[y(x),x].

Definition at line 307 of file line_segment.f.