numdiff_utilities_module Module

Utility routines.


Uses

  • module~~numdiff_utilities_module~~UsesGraph module~numdiff_utilities_module numdiff_utilities_module module~numdiff_kinds_module numdiff_kinds_module module~numdiff_utilities_module->module~numdiff_kinds_module iso_fortran_env iso_fortran_env module~numdiff_kinds_module->iso_fortran_env

Used by

  • module~~numdiff_utilities_module~~UsedByGraph module~numdiff_utilities_module numdiff_utilities_module module~numdiff_cache_module numdiff_cache_module module~numdiff_cache_module->module~numdiff_utilities_module module~numerical_differentiation_module numerical_differentiation_module module~numerical_differentiation_module->module~numdiff_utilities_module module~numerical_differentiation_module->module~numdiff_cache_module

Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: max_size_for_insertion_sort = 20

max size for using insertion sort.


Interfaces

public interface expand_vector

  • private pure subroutine expand_vector_int(vec, n, chunk_size, val, finished)

    Add elements to the integer vector in chunks.

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(inout), dimension(:), allocatable :: vec
    integer, intent(inout) :: n

    counter for last element added to vec. must be initialized to size(vec) (or 0 if not allocated) before first call

    integer, intent(in) :: chunk_size

    allocate vec in blocks of this size (>0)

    integer, intent(in), optional :: val

    the value to add to vec

    logical, intent(in), optional :: finished

    set to true to return vec as its correct size (n)

  • private pure subroutine expand_vector_real(vec, n, chunk_size, val, finished)

    Add elements to the real vector in chunks.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=wp), intent(inout), dimension(:), allocatable :: vec
    integer, intent(inout) :: n

    counter for last element added to vec. must be initialized to size(vec) (or 0 if not allocated) before first call

    integer, intent(in) :: chunk_size

    allocate vec in blocks of this size (>0)

    real(kind=wp), intent(in), optional :: val

    the value to add to vec

    logical, intent(in), optional :: finished

    set to true to return vec as its correct size (n)

public interface unique

  • private function unique_int(vec, chunk_size) result(ivec_unique)

    Returns only the unique elements of the vector (sorted in ascending order).

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in), dimension(:) :: vec

    a vector of integers

    integer, intent(in) :: chunk_size

    chunk size for adding to arrays

    Return Value integer, dimension(:), allocatable

    unique elements of ivec

  • private function unique_real(vec, chunk_size) result(ivec_unique)

    Returns only the unique elements of the vector (sorted in ascending order).

    Arguments

    Type IntentOptional Attributes Name
    real(kind=wp), intent(in), dimension(:) :: vec

    a vector of integers

    integer, intent(in) :: chunk_size

    chunk size for adding to arrays

    Return Value real(kind=wp), dimension(:), allocatable

    unique elements of ivec

public interface sort_ascending

  • private subroutine sort_ascending_int(ivec)

    Sorts an integer array ivec in increasing order. Uses a basic recursive quicksort (with insertion sort for partitions with 20 elements).

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(inout), dimension(:) :: ivec
  • private subroutine sort_ascending_real(ivec)

    Sorts a real array ivec in increasing order. Uses a basic recursive quicksort (with insertion sort for partitions with 20 elements).

    Arguments

    Type IntentOptional Attributes Name
    real(kind=wp), intent(inout), dimension(:) :: ivec

private interface swap

  • private pure elemental subroutine swap_int(i1, i2)

    Swap two integer values.

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(inout) :: i1
    integer, intent(inout) :: i2
  • private pure elemental subroutine swap_real(i1, i2)

    Swap two integer values.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=wp), intent(inout) :: i1
    real(kind=wp), intent(inout) :: i2

Functions

private function unique_int(vec, chunk_size) result(ivec_unique)

Returns only the unique elements of the vector (sorted in ascending order).

Arguments

Type IntentOptional Attributes Name
integer, intent(in), dimension(:) :: vec

a vector of integers

integer, intent(in) :: chunk_size

chunk size for adding to arrays

Return Value integer, dimension(:), allocatable

unique elements of ivec

private function unique_real(vec, chunk_size) result(ivec_unique)

Returns only the unique elements of the vector (sorted in ascending order).

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in), dimension(:) :: vec

a vector of integers

integer, intent(in) :: chunk_size

chunk size for adding to arrays

Return Value real(kind=wp), dimension(:), allocatable

unique elements of ivec

public pure function equal_within_tol(vals, tol) result(equal)

Returns true if the values in the array are the same (to within the specified absolute tolerance).

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in), dimension(:) :: vals

a set of values

real(kind=wp), intent(in) :: tol

a positive tolerance value

Return Value logical

true if they are equal within the tolerance

public function divide_interval(num_points) result(points)

Returns a set of slightly randomized equally-spaced points that divide an interval.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: num_points

the number of points in the interval

Return Value real(kind=wp), dimension(:), allocatable

the resultant vector


Subroutines

private pure subroutine expand_vector_int(vec, n, chunk_size, val, finished)

Add elements to the integer vector in chunks.

Arguments

Type IntentOptional Attributes Name
integer, intent(inout), dimension(:), allocatable :: vec
integer, intent(inout) :: n

counter for last element added to vec. must be initialized to size(vec) (or 0 if not allocated) before first call

integer, intent(in) :: chunk_size

allocate vec in blocks of this size (>0)

integer, intent(in), optional :: val

the value to add to vec

logical, intent(in), optional :: finished

set to true to return vec as its correct size (n)

private pure subroutine expand_vector_real(vec, n, chunk_size, val, finished)

Add elements to the real vector in chunks.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(inout), dimension(:), allocatable :: vec
integer, intent(inout) :: n

counter for last element added to vec. must be initialized to size(vec) (or 0 if not allocated) before first call

integer, intent(in) :: chunk_size

allocate vec in blocks of this size (>0)

real(kind=wp), intent(in), optional :: val

the value to add to vec

logical, intent(in), optional :: finished

set to true to return vec as its correct size (n)

private subroutine sort_ascending_int(ivec)

Sorts an integer array ivec in increasing order. Uses a basic recursive quicksort (with insertion sort for partitions with 20 elements).

Arguments

Type IntentOptional Attributes Name
integer, intent(inout), dimension(:) :: ivec

private subroutine sort_ascending_real(ivec)

Sorts a real array ivec in increasing order. Uses a basic recursive quicksort (with insertion sort for partitions with 20 elements).

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(inout), dimension(:) :: ivec

private pure elemental subroutine swap_int(i1, i2)

Swap two integer values.

Arguments

Type IntentOptional Attributes Name
integer, intent(inout) :: i1
integer, intent(inout) :: i2

private pure elemental subroutine swap_real(i1, i2)

Swap two integer values.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(inout) :: i1
real(kind=wp), intent(inout) :: i2