arithmetic_geometric_mean_fortran Module

Compute arithmetic–geometric mean.



Variables

Type Visibility Attributes Name Initial
integer, private, parameter :: initial_n_iter = -1
integer, private, parameter :: max_n_iter_real128 = digits(0.0_real128)
integer, private, parameter :: max_n_iter_real32 = digits(0.0_real32)
integer, private, parameter :: max_n_iter_real64 = digits(0.0_real64)

Interfaces

public interface arithmetic_geometric_mean

Safe wrapper for the arithmetic-geometric mean (AGM) computation.

This interface performs lightweight AGM computation with input validation, automatic ordering. Unlike the type-bound subroutine instead, this interface does not retain intermediate calculation results, so they cannot be referenced later.

Note

  • If either input was NaN: returns NaN
  • If x and y had opposite signs (x * y .lt. 0): returns NaN
  • If either x or y is zero (x * y .eq. 0): returns 0
  • Otherwise: computes AGM using the iterative kernel
  • private elemental function arithmetic_geometric_mean_real32(x, y) result(agm)

    Safe wrapper for the arithmetic-geometric mean (AGM) computation.

    This function performs lightweight AGM computation with input validation, automatic ordering. Unlike the type-bound subroutine compute_real32 instead, this function does not retain intermediate calculation results, so they cannot be referenced later.

    Note

    • If either input was NaN: returns NaN
    • If x and y had opposite signs (x * y .lt. 0): returns NaN
    • If either x or y is zero (x * y .eq. 0): returns 0
    • Otherwise: computes AGM using the iterative kernel

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real32), intent(in) :: x
    real(kind=real32), intent(in) :: y

    Return Value real(kind=real32)

  • private elemental function arithmetic_geometric_mean_real64(x, y) result(agm)

    Safe wrapper for the arithmetic-geometric mean (AGM) computation.

    This function performs lightweight AGM computation with input validation, automatic ordering. Unlike the type-bound subroutine compute_real64 instead, this function does not retain intermediate calculation results, so they cannot be referenced later.

    Note

    • If either input was NaN: returns NaN
    • If x and y had opposite signs (x * y .lt. 0): returns NaN
    • If either x or y is zero (x * y .eq. 0): returns 0
    • Otherwise: computes AGM using the iterative kernel

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in) :: x
    real(kind=real64), intent(in) :: y

    Return Value real(kind=real64)

  • private elemental function arithmetic_geometric_mean_real128(x, y) result(agm)

    Safe wrapper for the arithmetic-geometric mean (AGM) computation.

    This function performs lightweight AGM computation with input validation, automatic ordering. Unlike the type-bound subroutine compute_real128 instead, this function does not retain intermediate calculation results, so they cannot be referenced later.

    Note

    • If either input was NaN: returns NaN
    • If x and y had opposite signs (x * y .lt. 0): returns NaN
    • If either x or y is zero (x * y .eq. 0): returns 0
    • Otherwise: computes AGM using the iterative kernel

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real128), intent(in) :: x
    real(kind=real128), intent(in) :: y

    Return Value real(kind=real128)

Compute arithmetic–geometric mean (AGM) using the given arithmetic mean a and geometric mean g.

This interface provides a lightweight AGM computation that returns only the final converged value without storing iteration history.
For applications that need to analyze the convergence process, use the type-bound subroutine instead, which preserves the full iteration history.

Warning

  • This interface assumes both inputs are positive.
  • No validation is performed on inputs.

Note

Convergence criterion
See is_not_converged

  • private elemental function arithmetic_geometric_mean_kernel_real32(a, g) result(agm)

    Compute arithmetic–geometric mean (AGM) using the given arithmetic mean a and geometric mean g.

    This function provides a lightweight AGM computation that returns only the final converged value without storing iteration history.
    For applications that need to analyze the convergence process, use the type-bound subroutine compute_kernel_real32 instead, which preserves the full iteration history.

    Warning

    • This function assumes both inputs are positive.
    • No validation is performed on inputs.

    Note

    Convergence criterion
    See is_not_converged

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real32), intent(in) :: a

    arithmetic mean

    real(kind=real32), intent(in) :: g

    geometric mean

    Return Value real(kind=real32)

  • private elemental function arithmetic_geometric_mean_kernel_real64(a, g) result(agm)

    Compute arithmetic–geometric mean (AGM) using the given arithmetic mean a and geometric mean g.

    This function provides a lightweight AGM computation that returns only the final converged value without storing iteration history.
    For applications that need to analyze the convergence process, use the type-bound subroutine compute_kernel_real64 instead, which preserves the full iteration history.

    Warning

    • This function assumes both inputs are positive.
    • No validation is performed on inputs.

    Note

    Convergence criterion
    See is_not_converged

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in) :: a

    arithmetic mean

    real(kind=real64), intent(in) :: g

    geometric mean

    Return Value real(kind=real64)

  • private elemental function arithmetic_geometric_mean_kernel_real128(a, g) result(agm)

    Compute arithmetic–geometric mean (AGM) using the given arithmetic mean a and geometric mean g.

    This function provides a lightweight AGM computation that returns only the final converged value without storing iteration history.
    For applications that need to analyze the convergence process, use the type-bound subroutine compute_kernel_real128 instead, which preserves the full iteration history.

    Warning

    • This function assumes both inputs are positive.
    • No validation is performed on inputs.

    Note

    Convergence criterion
    See is_not_converged

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real128), intent(in) :: a

    arithmetic mean

    real(kind=real128), intent(in) :: g

    geometric mean

    Return Value real(kind=real128)

private interface compute_step

Compute arithmetic and geometric mean using the given prev_a and prev_g.

Warning

  • This interface assumes both inputs are positive.
  • No validation is performed on inputs.
  • private elemental subroutine compute_step_real32(prev_a, prev_g, next_a, next_g)

    Compute arithmetic and geometric mean using the given prev_a and prev_g.

    Warning

    • This subroutine assumes both inputs are positive.
    • No validation is performed on inputs.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real32), intent(in) :: prev_a

    previous arithmetic mean

    real(kind=real32), intent(in) :: prev_g

    previous geometric mean

    real(kind=real32), intent(out) :: next_a

    next arithmetic mean

    real(kind=real32), intent(out) :: next_g

    next geometric mean

  • private elemental subroutine compute_step_real64(prev_a, prev_g, next_a, next_g)

    Compute arithmetic and geometric mean using the given prev_a and prev_g.

    Warning

    • This subroutine assumes both inputs are positive.
    • No validation is performed on inputs.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in) :: prev_a

    previous arithmetic mean

    real(kind=real64), intent(in) :: prev_g

    previous geometric mean

    real(kind=real64), intent(out) :: next_a

    next arithmetic mean

    real(kind=real64), intent(out) :: next_g

    next geometric mean

  • private elemental subroutine compute_step_real128(prev_a, prev_g, next_a, next_g)

    Compute arithmetic and geometric mean using the given prev_a and prev_g.

    Warning

    • This subroutine assumes both inputs are positive.
    • No validation is performed on inputs.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real128), intent(in) :: prev_a

    previous arithmetic mean

    real(kind=real128), intent(in) :: prev_g

    previous geometric mean

    real(kind=real128), intent(out) :: next_a

    next arithmetic mean

    real(kind=real128), intent(out) :: next_g

    next geometric mean

public interface gap

  • private elemental function gap_final_real32(agm) result(gap_final)

    Extract the final gap (arithmetic mean - geometric mean).

    Warning

    This function assumes the AGM computation has been performed via the compute method.
    If called on an uninitialized or improperly computed AGM object, the result may be NaN or undefined.

    Arguments

    Type IntentOptional Attributes Name
    type(arithmetic_geometric_mean_real32_type), intent(in) :: agm

    Return Value real(kind=real32)

  • private elemental function gap_final_real64(agm) result(gap_final)

    Extract the final gap (arithmetic mean - geometric mean).

    Warning

    This function assumes the AGM computation has been performed via the compute method.
    If called on an uninitialized or improperly computed AGM object, the result may be NaN or undefined.

    Arguments

    Type IntentOptional Attributes Name
    type(arithmetic_geometric_mean_real64_type), intent(in) :: agm

    Return Value real(kind=real64)

  • private elemental function gap_final_real128(agm) result(gap_final)

    Extract the final gap (arithmetic mean - geometric mean).

    Warning

    This function assumes the AGM computation has been performed via the compute method.
    If called on an uninitialized or improperly computed AGM object, the result may be NaN or undefined.

    Arguments

    Type IntentOptional Attributes Name
    type(arithmetic_geometric_mean_real128_type), intent(in) :: agm

    Return Value real(kind=real128)

  • private elemental function gap_selectable_real32(agm, i) result(gap_selectable)

    Extract the gap (arithmetic mean - geometric mean) at a specific iteration.

    Warning

    This function assumes the AGM computation has been performed via the compute method.
    If called on an uninitialized or improperly computed AGM object, the result may be NaN or undefined.

    The iteration index i must be valid: 0 <= i <= n_iter.
    No bounds checking is performed; invalid indices may cause undefined behavior.

    Arguments

    Type IntentOptional Attributes Name
    type(arithmetic_geometric_mean_real32_type), intent(in) :: agm
    integer, intent(in) :: i

    Return Value real(kind=real32)

  • private elemental function gap_selectable_real64(agm, i) result(gap_selectable)

    Extract the gap (arithmetic mean - geometric mean) at a specific iteration.

    Warning

    This function assumes the AGM computation has been performed via the compute method.
    If called on an uninitialized or improperly computed AGM object, the result may be NaN or undefined.

    The iteration index i must be valid: 0 <= i <= n_iter.
    No bounds checking is performed; invalid indices may cause undefined behavior.

    Arguments

    Type IntentOptional Attributes Name
    type(arithmetic_geometric_mean_real64_type), intent(in) :: agm
    integer, intent(in) :: i

    Return Value real(kind=real64)

  • private elemental function gap_selectable_real128(agm, i) result(gap_selectable)

    Extract the gap (arithmetic mean - geometric mean) at a specific iteration.

    Warning

    This function assumes the AGM computation has been performed via the compute method.
    If called on an uninitialized or improperly computed AGM object, the result may be NaN or undefined.

    The iteration index i must be valid: 0 <= i <= n_iter.
    No bounds checking is performed; invalid indices may cause undefined behavior.

    Arguments

    Type IntentOptional Attributes Name
    type(arithmetic_geometric_mean_real128_type), intent(in) :: agm
    integer, intent(in) :: i

    Return Value real(kind=real128)

private interface initialize

Initialize components: n_iter, list_a and list_g

private interface is_not_converged

Check if the arithmetic-geometric mean iteration has not yet converged.

Note

Convergence criterion
Returns .true. if the absolute difference between the arithmetic mean a and geometric mean g exceeds the machine epsilon relative to the smaller value, as determined by spacing(min(a, g)).

Mathematically: |a - g| > spacing(min(a, g))

Appendix
This interface is designed for internal use within the AGM iteration where both values are guaranteed to be positive and converging.

  • private elemental function is_not_converged_real32(a, g) result(stat)

    Check if the arithmetic-geometric mean iteration has not yet converged.

    Note

    Convergence criterion
    Returns .true. if the absolute difference between the arithmetic mean a and geometric mean g exceeds the machine epsilon relative to the smaller value, as determined by spacing(min(a, g)).

    Mathematically: |a - g| > spacing(min(a, g))

    Appendix
    This function is designed for internal use within the AGM iteration where both values are guaranteed to be positive and converging.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real32), intent(in) :: a

    arithmetic mean

    real(kind=real32), intent(in) :: g

    geometric mean

    Return Value logical

  • private elemental function is_not_converged_real64(a, g) result(stat)

    Check if the arithmetic-geometric mean iteration has not yet converged.

    Note

    Convergence criterion
    Returns .true. if the absolute difference between the arithmetic mean a and geometric mean g exceeds the machine epsilon relative to the smaller value, as determined by spacing(min(a, g)).

    Mathematically: |a - g| > spacing(min(a, g))

    Appendix
    This function is designed for internal use within the AGM iteration where both values are guaranteed to be positive and converging.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in) :: a

    arithmetic mean

    real(kind=real64), intent(in) :: g

    geometric mean

    Return Value logical

  • private elemental function is_not_converged_real128(a, g) result(stat)

    Check if the arithmetic-geometric mean iteration has not yet converged.

    Note

    Convergence criterion
    Returns .true. if the absolute difference between the arithmetic mean a and geometric mean g exceeds the machine epsilon relative to the smaller value, as determined by spacing(min(a, g)).

    Mathematically: |a - g| > spacing(min(a, g))

    Appendix
    This function is designed for internal use within the AGM iteration where both values are guaranteed to be positive and converging.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real128), intent(in) :: a

    arithmetic mean

    real(kind=real128), intent(in) :: g

    geometric mean

    Return Value logical

public interface max

  • private elemental function max_final_real32(agm) result(max_final)

    Extract the final arithmetic-geometric mean from completed AGM calculations.
    Specifically, this function returns the larger of the two final values.

    Warning

    This function assumes the AGM computation has been performed via the compute method.
    If called on an uninitialized or improperly computed AGM object, the result may be NaN or undefined.

    Arguments

    Type IntentOptional Attributes Name
    type(arithmetic_geometric_mean_real32_type), intent(in) :: agm

    Return Value real(kind=real32)

  • private elemental function max_final_real64(agm) result(max_final)

    Extract the final arithmetic-geometric mean from completed AGM calculations.
    Specifically, this function returns the larger of the two final values.

    Warning

    This function assumes the AGM computation has been performed via the compute method.
    If called on an uninitialized or improperly computed AGM object, the result may be NaN or undefined.

    Arguments

    Type IntentOptional Attributes Name
    type(arithmetic_geometric_mean_real64_type), intent(in) :: agm

    Return Value real(kind=real64)

  • private elemental function max_final_real128(agm) result(max_final)

    Extract the final arithmetic-geometric mean from completed AGM calculations.
    Specifically, this function returns the larger of the two final values.

    Warning

    This function assumes the AGM computation has been performed via the compute method.
    If called on an uninitialized or improperly computed AGM object, the result may be NaN or undefined.

    Arguments

    Type IntentOptional Attributes Name
    type(arithmetic_geometric_mean_real128_type), intent(in) :: agm

    Return Value real(kind=real128)

  • private elemental function max_selectable_real32(agm, i) result(max_selectable)

    Extract the arithmetic-geometric mean value at a specific iteration.
    Specifically, this function returns the larger of the two values.

    Warning

    This function assumes the AGM computation has been performed via the compute method.
    If called on an uninitialized or improperly computed AGM object, the result may be NaN or undefined.

    The iteration index i must be valid: 0 <= i <= n_iter.
    No bounds checking is performed; invalid indices may cause undefined behavior.

    Arguments

    Type IntentOptional Attributes Name
    type(arithmetic_geometric_mean_real32_type), intent(in) :: agm
    integer, intent(in) :: i

    Return Value real(kind=real32)

  • private elemental function max_selectable_real64(agm, i) result(max_selectable)

    Extract the arithmetic-geometric mean value at a specific iteration.
    Specifically, this function returns the larger of the two values.

    Warning

    This function assumes the AGM computation has been performed via the compute method.
    If called on an uninitialized or improperly computed AGM object, the result may be NaN or undefined.

    The iteration index i must be valid: 0 <= i <= n_iter.
    No bounds checking is performed; invalid indices may cause undefined behavior.

    Arguments

    Type IntentOptional Attributes Name
    type(arithmetic_geometric_mean_real64_type), intent(in) :: agm
    integer, intent(in) :: i

    Return Value real(kind=real64)

  • private elemental function max_selectable_real128(agm, i) result(max_selectable)

    Extract the arithmetic-geometric mean value at a specific iteration.
    Specifically, this function returns the larger of the two values.

    Warning

    This function assumes the AGM computation has been performed via the compute method.
    If called on an uninitialized or improperly computed AGM object, the result may be NaN or undefined.

    The iteration index i must be valid: 0 <= i <= n_iter.
    No bounds checking is performed; invalid indices may cause undefined behavior.

    Arguments

    Type IntentOptional Attributes Name
    type(arithmetic_geometric_mean_real128_type), intent(in) :: agm
    integer, intent(in) :: i

    Return Value real(kind=real128)

public interface min

  • private elemental function min_final_real32(agm) result(min_final)

    Extract the final arithmetic-geometric mean from completed AGM calculations.
    Specifically, this function returns the smaller of the two final values.

    Warning

    This function assumes the AGM computation has been performed via the compute method.
    If called on an uninitialized or improperly computed AGM object, the result may be NaN or undefined.

    Arguments

    Type IntentOptional Attributes Name
    type(arithmetic_geometric_mean_real32_type), intent(in) :: agm

    Return Value real(kind=real32)

  • private elemental function min_final_real64(agm) result(min_final)

    Extract the final arithmetic-geometric mean from completed AGM calculations.
    Specifically, this function returns the smaller of the two final values.

    Warning

    This function assumes the AGM computation has been performed via the compute method.
    If called on an uninitialized or improperly computed AGM object, the result may be NaN or undefined.

    Arguments

    Type IntentOptional Attributes Name
    type(arithmetic_geometric_mean_real64_type), intent(in) :: agm

    Return Value real(kind=real64)

  • private elemental function min_final_real128(agm) result(min_final)

    Extract the final arithmetic-geometric mean from completed AGM calculations.
    Specifically, this function returns the smaller of the two final values.

    Warning

    This function assumes the AGM computation has been performed via the compute method.
    If called on an uninitialized or improperly computed AGM object, the result may be NaN or undefined.

    Arguments

    Type IntentOptional Attributes Name
    type(arithmetic_geometric_mean_real128_type), intent(in) :: agm

    Return Value real(kind=real128)

  • private elemental function min_selectable_real32(agm, i) result(min_selectable)

    Extract the arithmetic-geometric mean value at a specific iteration.
    Specifically, this function returns the smaller of the two values.

    Warning

    This function assumes the AGM computation has been performed via the compute method.
    If called on an uninitialized or improperly computed AGM object, the result may be NaN or undefined.

    The iteration index i must be valid: 0 <= i <= n_iter.
    No bounds checking is performed; invalid indices may cause undefined behavior.

    Arguments

    Type IntentOptional Attributes Name
    type(arithmetic_geometric_mean_real32_type), intent(in) :: agm
    integer, intent(in) :: i

    Return Value real(kind=real32)

  • private elemental function min_selectable_real64(agm, i) result(min_selectable)

    Extract the arithmetic-geometric mean value at a specific iteration.
    Specifically, this function returns the smaller of the two values.

    Warning

    This function assumes the AGM computation has been performed via the compute method.
    If called on an uninitialized or improperly computed AGM object, the result may be NaN or undefined.

    The iteration index i must be valid: 0 <= i <= n_iter.
    No bounds checking is performed; invalid indices may cause undefined behavior.

    Arguments

    Type IntentOptional Attributes Name
    type(arithmetic_geometric_mean_real64_type), intent(in) :: agm
    integer, intent(in) :: i

    Return Value real(kind=real64)

  • private elemental function min_selectable_real128(agm, i) result(min_selectable)

    Extract the arithmetic-geometric mean value at a specific iteration.
    Specifically, this function returns the smaller of the two values.

    Warning

    This function assumes the AGM computation has been performed via the compute method.
    If called on an uninitialized or improperly computed AGM object, the result may be NaN or undefined.

    The iteration index i must be valid: 0 <= i <= n_iter.
    No bounds checking is performed; invalid indices may cause undefined behavior.

    Arguments

    Type IntentOptional Attributes Name
    type(arithmetic_geometric_mean_real128_type), intent(in) :: agm
    integer, intent(in) :: i

    Return Value real(kind=real128)


Derived Types

type, private, abstract ::  arithmetic_geometric_mean_base_type

Components

Type Visibility Attributes Name Initial
integer, private :: n_iter_ = initial_n_iter

the number of iterations performed during AGM calculation

Type-Bound Procedures

procedure, public, pass :: n_iter

Components

Type Visibility Attributes Name Initial
real(kind=real128), private :: list_a(0:max_n_iter_real128)

history of the arithmetic mean

real(kind=real128), private :: list_g(0:max_n_iter_real128)

history of the geometric mean

Type-Bound Procedures

generic, public :: compute => compute_real128
generic, private :: compute_kernel => compute_kernel_real128
procedure, private, pass :: compute_kernel_real128
procedure, private, pass :: compute_real128
procedure, public, pass :: n_iter

Components

Type Visibility Attributes Name Initial
real(kind=real32), private :: list_a(0:max_n_iter_real32)

history of the arithmetic mean

real(kind=real32), private :: list_g(0:max_n_iter_real32)

history of the geometric mean

Type-Bound Procedures

generic, public :: compute => compute_real32
generic, private :: compute_kernel => compute_kernel_real32
procedure, private, pass :: compute_kernel_real32
procedure, private, pass :: compute_real32
procedure, public, pass :: n_iter

Components

Type Visibility Attributes Name Initial
real(kind=real64), private :: list_a(0:max_n_iter_real64)

history of the arithmetic mean

real(kind=real64), private :: list_g(0:max_n_iter_real64)

history of the geometric mean

Type-Bound Procedures

generic, public :: compute => compute_real64
generic, private :: compute_kernel => compute_kernel_real64
procedure, private, pass :: compute_kernel_real64
procedure, private, pass :: compute_real64
procedure, public, pass :: n_iter

Functions

public elemental function n_iter(agm)

return the number of iterations performed during AGM calculation

Arguments

Type IntentOptional Attributes Name
class(arithmetic_geometric_mean_base_type), intent(in) :: agm

Return Value integer

private elemental function is_not_converged_real128(a, g) result(stat)

Check if the arithmetic-geometric mean iteration has not yet converged.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real128), intent(in) :: a

arithmetic mean

real(kind=real128), intent(in) :: g

geometric mean

Return Value logical

private elemental function is_not_converged_real32(a, g) result(stat)

Check if the arithmetic-geometric mean iteration has not yet converged.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(in) :: a

arithmetic mean

real(kind=real32), intent(in) :: g

geometric mean

Return Value logical

private elemental function is_not_converged_real64(a, g) result(stat)

Check if the arithmetic-geometric mean iteration has not yet converged.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: a

arithmetic mean

real(kind=real64), intent(in) :: g

geometric mean

Return Value logical

private elemental function arithmetic_geometric_mean_kernel_real128(a, g) result(agm)

Compute arithmetic–geometric mean (AGM) using the given arithmetic mean a and geometric mean g.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real128), intent(in) :: a

arithmetic mean

real(kind=real128), intent(in) :: g

geometric mean

Return Value real(kind=real128)

private elemental function arithmetic_geometric_mean_real128(x, y) result(agm)

Safe wrapper for the arithmetic-geometric mean (AGM) computation.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real128), intent(in) :: x
real(kind=real128), intent(in) :: y

Return Value real(kind=real128)

private elemental function gap_final_real128(agm) result(gap_final)

Extract the final gap (arithmetic mean - geometric mean).

Read more…

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real128_type), intent(in) :: agm

Return Value real(kind=real128)

private elemental function gap_selectable_real128(agm, i) result(gap_selectable)

Extract the gap (arithmetic mean - geometric mean) at a specific iteration.

Read more…

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real128_type), intent(in) :: agm
integer, intent(in) :: i

Return Value real(kind=real128)

private elemental function max_final_real128(agm) result(max_final)

Extract the final arithmetic-geometric mean from completed AGM calculations.
Specifically, this function returns the larger of the two final values.

Read more…

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real128_type), intent(in) :: agm

Return Value real(kind=real128)

private elemental function max_selectable_real128(agm, i) result(max_selectable)

Extract the arithmetic-geometric mean value at a specific iteration.
Specifically, this function returns the larger of the two values.

Read more…

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real128_type), intent(in) :: agm
integer, intent(in) :: i

Return Value real(kind=real128)

private elemental function min_final_real128(agm) result(min_final)

Extract the final arithmetic-geometric mean from completed AGM calculations.
Specifically, this function returns the smaller of the two final values.

Read more…

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real128_type), intent(in) :: agm

Return Value real(kind=real128)

private elemental function min_selectable_real128(agm, i) result(min_selectable)

Extract the arithmetic-geometric mean value at a specific iteration.
Specifically, this function returns the smaller of the two values.

Read more…

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real128_type), intent(in) :: agm
integer, intent(in) :: i

Return Value real(kind=real128)

private elemental function arithmetic_geometric_mean_kernel_real32(a, g) result(agm)

Compute arithmetic–geometric mean (AGM) using the given arithmetic mean a and geometric mean g.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(in) :: a

arithmetic mean

real(kind=real32), intent(in) :: g

geometric mean

Return Value real(kind=real32)

private elemental function arithmetic_geometric_mean_real32(x, y) result(agm)

Safe wrapper for the arithmetic-geometric mean (AGM) computation.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(in) :: x
real(kind=real32), intent(in) :: y

Return Value real(kind=real32)

private elemental function gap_final_real32(agm) result(gap_final)

Extract the final gap (arithmetic mean - geometric mean).

Read more…

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real32_type), intent(in) :: agm

Return Value real(kind=real32)

private elemental function gap_selectable_real32(agm, i) result(gap_selectable)

Extract the gap (arithmetic mean - geometric mean) at a specific iteration.

Read more…

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real32_type), intent(in) :: agm
integer, intent(in) :: i

Return Value real(kind=real32)

private elemental function max_final_real32(agm) result(max_final)

Extract the final arithmetic-geometric mean from completed AGM calculations.
Specifically, this function returns the larger of the two final values.

Read more…

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real32_type), intent(in) :: agm

Return Value real(kind=real32)

private elemental function max_selectable_real32(agm, i) result(max_selectable)

Extract the arithmetic-geometric mean value at a specific iteration.
Specifically, this function returns the larger of the two values.

Read more…

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real32_type), intent(in) :: agm
integer, intent(in) :: i

Return Value real(kind=real32)

private elemental function min_final_real32(agm) result(min_final)

Extract the final arithmetic-geometric mean from completed AGM calculations.
Specifically, this function returns the smaller of the two final values.

Read more…

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real32_type), intent(in) :: agm

Return Value real(kind=real32)

private elemental function min_selectable_real32(agm, i) result(min_selectable)

Extract the arithmetic-geometric mean value at a specific iteration.
Specifically, this function returns the smaller of the two values.

Read more…

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real32_type), intent(in) :: agm
integer, intent(in) :: i

Return Value real(kind=real32)

private elemental function arithmetic_geometric_mean_kernel_real64(a, g) result(agm)

Compute arithmetic–geometric mean (AGM) using the given arithmetic mean a and geometric mean g.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: a

arithmetic mean

real(kind=real64), intent(in) :: g

geometric mean

Return Value real(kind=real64)

private elemental function arithmetic_geometric_mean_real64(x, y) result(agm)

Safe wrapper for the arithmetic-geometric mean (AGM) computation.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: x
real(kind=real64), intent(in) :: y

Return Value real(kind=real64)

private elemental function gap_final_real64(agm) result(gap_final)

Extract the final gap (arithmetic mean - geometric mean).

Read more…

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real64_type), intent(in) :: agm

Return Value real(kind=real64)

private elemental function gap_selectable_real64(agm, i) result(gap_selectable)

Extract the gap (arithmetic mean - geometric mean) at a specific iteration.

Read more…

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real64_type), intent(in) :: agm
integer, intent(in) :: i

Return Value real(kind=real64)

private elemental function max_final_real64(agm) result(max_final)

Extract the final arithmetic-geometric mean from completed AGM calculations.
Specifically, this function returns the larger of the two final values.

Read more…

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real64_type), intent(in) :: agm

Return Value real(kind=real64)

private elemental function max_selectable_real64(agm, i) result(max_selectable)

Extract the arithmetic-geometric mean value at a specific iteration.
Specifically, this function returns the larger of the two values.

Read more…

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real64_type), intent(in) :: agm
integer, intent(in) :: i

Return Value real(kind=real64)

private elemental function min_final_real64(agm) result(min_final)

Extract the final arithmetic-geometric mean from completed AGM calculations.
Specifically, this function returns the smaller of the two final values.

Read more…

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real64_type), intent(in) :: agm

Return Value real(kind=real64)

private elemental function min_selectable_real64(agm, i) result(min_selectable)

Extract the arithmetic-geometric mean value at a specific iteration.
Specifically, this function returns the smaller of the two values.

Read more…

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real64_type), intent(in) :: agm
integer, intent(in) :: i

Return Value real(kind=real64)


Subroutines

private elemental subroutine compute_kernel_real128(agm, init_a, init_g)

Compute arithmetic–geometric mean (AGM) using the given arithmetic mean init_a and geometric mean init_g and store the complete iteration history.

Read more…

Arguments

Type IntentOptional Attributes Name
class(arithmetic_geometric_mean_real128_type), intent(inout) :: agm
real(kind=real128), intent(in) :: init_a

initial value: arithmetic mean

real(kind=real128), intent(in) :: init_g

initial value: geometric mean

private elemental subroutine compute_kernel_real32(agm, init_a, init_g)

Compute arithmetic–geometric mean (AGM) using the given arithmetic mean init_a and geometric mean init_g and store the complete iteration history.

Read more…

Arguments

Type IntentOptional Attributes Name
class(arithmetic_geometric_mean_real32_type), intent(inout) :: agm
real(kind=real32), intent(in) :: init_a

initial value: arithmetic mean

real(kind=real32), intent(in) :: init_g

initial value: geometric mean

private elemental subroutine compute_kernel_real64(agm, init_a, init_g)

Compute arithmetic–geometric mean (AGM) using the given arithmetic mean init_a and geometric mean init_g and store the complete iteration history.

Read more…

Arguments

Type IntentOptional Attributes Name
class(arithmetic_geometric_mean_real64_type), intent(inout) :: agm
real(kind=real64), intent(in) :: init_a

initial value: arithmetic mean

real(kind=real64), intent(in) :: init_g

initial value: geometric mean

private elemental subroutine compute_real128(agm, x, y)

Safe wrapper for the arithmetic-geometric mean (AGM) computation.

Read more…

Arguments

Type IntentOptional Attributes Name
class(arithmetic_geometric_mean_real128_type), intent(inout) :: agm
real(kind=real128), intent(in) :: x
real(kind=real128), intent(in) :: y

private elemental subroutine compute_real32(agm, x, y)

Safe wrapper for the arithmetic-geometric mean (AGM) computation.

Read more…

Arguments

Type IntentOptional Attributes Name
class(arithmetic_geometric_mean_real32_type), intent(inout) :: agm
real(kind=real32), intent(in) :: x
real(kind=real32), intent(in) :: y

private elemental subroutine compute_real64(agm, x, y)

Safe wrapper for the arithmetic-geometric mean (AGM) computation.

Read more…

Arguments

Type IntentOptional Attributes Name
class(arithmetic_geometric_mean_real64_type), intent(inout) :: agm
real(kind=real64), intent(in) :: x
real(kind=real64), intent(in) :: y

private elemental subroutine compute_step_real128(prev_a, prev_g, next_a, next_g)

Compute arithmetic and geometric mean using the given prev_a and prev_g.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real128), intent(in) :: prev_a

previous arithmetic mean

real(kind=real128), intent(in) :: prev_g

previous geometric mean

real(kind=real128), intent(out) :: next_a

next arithmetic mean

real(kind=real128), intent(out) :: next_g

next geometric mean

private elemental subroutine compute_step_real32(prev_a, prev_g, next_a, next_g)

Compute arithmetic and geometric mean using the given prev_a and prev_g.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(in) :: prev_a

previous arithmetic mean

real(kind=real32), intent(in) :: prev_g

previous geometric mean

real(kind=real32), intent(out) :: next_a

next arithmetic mean

real(kind=real32), intent(out) :: next_g

next geometric mean

private elemental subroutine compute_step_real64(prev_a, prev_g, next_a, next_g)

Compute arithmetic and geometric mean using the given prev_a and prev_g.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: prev_a

previous arithmetic mean

real(kind=real64), intent(in) :: prev_g

previous geometric mean

real(kind=real64), intent(out) :: next_a

next arithmetic mean

real(kind=real64), intent(out) :: next_g

next geometric mean

private elemental subroutine initialize_real128(agm)

Initialize components: n_iter, list_a and list_g

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real128_type), intent(inout) :: agm

private elemental subroutine initialize_real32(agm)

Initialize components: n_iter, list_a and list_g

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real32_type), intent(inout) :: agm

private elemental subroutine initialize_real64(agm)

Initialize components: n_iter, list_a and list_g

Arguments

Type IntentOptional Attributes Name
type(arithmetic_geometric_mean_real64_type), intent(inout) :: agm