MOM6
polynomial_functions Module Reference

Detailed Description

Polynomial functions.

Date of creation: 2008.06.12 L. White

This module contains routines that handle polynomials.

Functions/Subroutines

real function, public evaluation_polynomial (coeff, ncoef, x)
 Pointwise evaluation of a polynomial at x. More...
 
real function, public first_derivative_polynomial (coeff, ncoef, x)
 Calculates the first derivative of a polynomial evaluated at a point x. More...
 
real function, public integration_polynomial (xi0, xi1, Coeff, npoly)
 Exact integration of polynomial of degree npoly. More...
 

Function/Subroutine Documentation

◆ evaluation_polynomial()

real function, public polynomial_functions::evaluation_polynomial ( real, dimension(:), intent(in)  coeff,
integer, intent(in)  ncoef,
real, intent(in)  x 
)

Pointwise evaluation of a polynomial at x.

The polynomial is defined by the coefficients contained in the array of the same name, as follows: C(1) + C(2)x + C(3)x^2 + C(4)x^3 + ... where C refers to the array 'coeff'. The number of coefficients is given by ncoef and x is the coordinate where the polynomial is to be evaluated.

Parameters
[in]coeffThe coefficients of the polynomial
[in]ncoefThe number of polynomial coefficients
[in]xThe position at which to evaluate the polynomial

Definition at line 20 of file polynomial_functions.F90.

20  real, dimension(:), intent(in) :: coeff !< The coefficients of the polynomial
21  integer, intent(in) :: ncoef !< The number of polynomial coefficients
22  real, intent(in) :: x !< The position at which to evaluate the polynomial
23  ! Local variables
24  integer :: k
25  real :: f ! value of polynomial at x
26 
27  f = 0.0
28  do k = 1,ncoef
29  f = f + coeff(k) * ( x**(k-1) )
30  enddo
31 
32  evaluation_polynomial = f
33 

Referenced by regrid_edge_slopes::edge_slopes_implicit_h3(), regrid_edge_slopes::edge_slopes_implicit_h5(), regrid_edge_values::edge_values_explicit_h4(), regrid_edge_values::edge_values_implicit_h4(), regrid_edge_values::edge_values_implicit_h6(), mom_neutral_diffusion::find_neutral_pos_full(), mom_neutral_diffusion::find_neutral_pos_linear(), mom_neutral_diffusion::neutral_diffusion_calc_coeffs(), and mom_neutral_diffusion::neutral_surface_t_eval().

Here is the caller graph for this function:

◆ first_derivative_polynomial()

real function, public polynomial_functions::first_derivative_polynomial ( real, dimension(:), intent(in)  coeff,
integer, intent(in)  ncoef,
real, intent(in)  x 
)

Calculates the first derivative of a polynomial evaluated at a point x.

The polynomial is defined by the coefficients contained in the array of the same name, as follows: C(1) + C(2)x + C(3)x^2 + C(4)x^3 + ... where C refers to the array 'coeff'. The number of coefficients is given by ncoef and x is the coordinate where the polynomial's derivative is to be evaluated.

Parameters
[in]coeffThe coefficients of the polynomial
[in]ncoefThe number of polynomial coefficients
[in]xThe position at which to evaluate the derivative

Definition at line 44 of file polynomial_functions.F90.

44  real, dimension(:), intent(in) :: coeff !< The coefficients of the polynomial
45  integer, intent(in) :: ncoef !< The number of polynomial coefficients
46  real, intent(in) :: x !< The position at which to evaluate the derivative
47  ! Local variables
48  integer :: k
49  real :: f ! value of polynomial at x
50 
51  f = 0.0
52  do k = 2,ncoef
53  f = f + real(k-1)*coeff(k) * ( x**(k-2) )
54  enddo
55 
56  first_derivative_polynomial = f
57 

Referenced by mom_neutral_diffusion::find_neutral_pos_linear().

Here is the caller graph for this function:

◆ integration_polynomial()

real function, public polynomial_functions::integration_polynomial ( real, intent(in)  xi0,
real, intent(in)  xi1,
real, dimension(:), intent(in)  Coeff,
integer, intent(in)  npoly 
)

Exact integration of polynomial of degree npoly.

The array of coefficients (Coeff) must be of size npoly+1.

Parameters
[in]xi0The lower bound of the integral
[in]xi1The lower bound of the integral
[in]coeffThe coefficients of the polynomial
[in]npolyThe degree of the polynomial

Definition at line 64 of file polynomial_functions.F90.

64  real, intent(in) :: xi0 !< The lower bound of the integral
65  real, intent(in) :: xi1 !< The lower bound of the integral
66  real, dimension(:), intent(in) :: Coeff !< The coefficients of the polynomial
67  integer, intent(in) :: npoly !< The degree of the polynomial
68  ! Local variables
69  integer :: k
70  real :: integral
71 
72  integral = 0.0
73 
74  do k = 1,npoly+1
75  integral = integral + coeff(k) * (xi1**k - xi0**k) / real(k)
76  enddo
77 !
78 !One non-answer-changing way of unrolling the above is:
79 ! k=1
80 ! integral = integral + Coeff(k) * (xi1**k - xi0**k) / real(k)
81 ! if (npoly>=1) then
82 ! k=2
83 ! integral = integral + Coeff(k) * (xi1**k - xi0**k) / real(k)
84 ! endif
85 ! if (npoly>=2) then
86 ! k=3
87 ! integral = integral + Coeff(k) * (xi1**k - xi0**k) / real(k)
88 ! endif
89 ! if (npoly>=3) then
90 ! k=4
91 ! integral = integral + Coeff(k) * (xi1**k - xi0**k) / real(k)
92 ! endif
93 ! if (npoly>=4) then
94 ! k=5
95 ! integral = integral + Coeff(k) * (xi1**k - xi0**k) / real(k)
96 ! endif
97 !
98  integration_polynomial = integral
99