piecewise1D Derived Type

type, public, extends(piecewise) :: piecewise1D

1D piecewise type. Used for the spectral type


Components

Type Visibility Attributes Name Initial
real(kind=wp), public, allocatable :: array(:,:)

Input array to sample from. Should be size(n, 2). 1st column is x-axis, 2nd column is y-axis

real(kind=wp), public, allocatable :: cdf(:)

cumulative distribution function (CDF) of array.


Constructor

public interface piecewise1D

  • public function init_piecewise1D(array) result(res)

    initalise the piecewise1D type with an array size (n, 2). Calculates the CDF of this array. Input array

    Arguments

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

    Return Value type(piecewise1D)


Type-Bound Procedures

procedure, public :: sample => sample1D

Overloaded sampling function

  • public subroutine sample1D(this, x, y, value)

    Randomly sample from 1D array

    Arguments

    Type IntentOptional Attributes Name
    class(piecewise1D), intent(in) :: this
    real(kind=wp), intent(out) :: x

    Return value

    real(kind=wp), intent(out) :: y

    Not used, but here so we can have same interface as 2D sample routine.

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

    Optional x value. If not present we generate a random one in the range [0., 1.]

Source Code

    type, extends(piecewise) :: piecewise1D
        !> Input array to sample from. Should be size(n, 2). 1st column is x-axis, 2nd column is y-axis
        real(kind=wp), allocatable :: array(:, :)
        !> cumulative distribution function (CDF) of array.
        real(kind=wp), allocatable :: cdf(:)
        contains
            !> Overloaded sampling function
            procedure :: sample => sample1D
    end type piecewise1D